cmds.posix.CmdCopy: Support platform macros

Expand platform macros (as in %{codename}) in the src and dst command
arguments. Expansion can be turned off by -F --fixed-strings.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-16 13:34:59 +02:00
commit b72c417510

View file

@ -22,6 +22,13 @@ class CmdCopy(Cmd): # export
parser.add_argument('-o', '--owner', default=None, help='Destination file owner') parser.add_argument('-o', '--owner', default=None, help='Destination file owner')
parser.add_argument('-g', '--group', default=None, help='Destination file group') parser.add_argument('-g', '--group', default=None, help='Destination file group')
parser.add_argument('-m', '--mode', default=None, help='Destination file mode') parser.add_argument('-m', '--mode', default=None, help='Destination file mode')
parser.add_argument('-F', '--fixed-strings', action='store_true',
help='Don\'t expand platform info macros in <src> and <dst>')
async def _run(self, args: Namespace) -> None: async def _run(self, args: Namespace) -> None:
await copy(args.src, args.dst, owner=args.owner, group=args.group, mode=args.mode) def __expand(url: str) -> str:
if args.fixed_strings:
return url
return self.app.distro_info(url)
await copy(__expand(args.src), __expand(args.dst),
owner=args.owner, group=args.group, mode=args.mode)