From: Michael Tremer Date: Thu, 13 May 2021 12:14:28 +0000 (+0000) Subject: cli: Add execute command X-Git-Tag: 0.9.28~1285^2~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d86a58fb6e1a7a4e81c2fa6abea5b512953c2fc;p=pakfire.git cli: Add execute command Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index f33c0bfd8..cb2ad6ec9 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -91,6 +91,14 @@ class Cli(object): help=_("Disallow changing the architecture of packages")) downgrade.set_defaults(func=self.handle_downgrade) + # execute + execute = subparsers.add_parser("execute", + help=_("Executes a command in the pakfire environment (useful for development)")) + execute.add_argument("--bind", nargs="*", default=[], dest="binds", + help=_("Bind-mounts the given directory")) + execute.add_argument("command", nargs=argparse.REMAINDER) + execute.set_defaults(func=self.handle_execute) + # extract extract = subparsers.add_parser("extract", help=_("Extract a package to a directory")) @@ -207,6 +215,15 @@ class Cli(object): return p + def handle_execute(self, ns): + pakfire = self.pakfire(ns) + + # Bind-mount everything + for bind in ns.binds: + pakfire.bind(bind) + + return pakfire.execute(ns.command) + def run(self): args = self.parse_cli() assert args.func, "Argument function not defined"