From fad49ca13ac262c9773cbb2e1ea65158d78f68f8 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 28 2018 13:36:00 +0000 Subject: Allow t use new/old-chroot in runroot Fixes: https://pagure.io/koji/issue/772 --- diff --git a/plugins/builder/runroot.py b/plugins/builder/runroot.py index 373e880..b9dd659 100644 --- a/plugins/builder/runroot.py +++ b/plugins/builder/runroot.py @@ -90,7 +90,7 @@ class RunRootTask(koji.tasks.BaseTaskHandler): if not path.startswith('/'): raise koji.GenericError("bad config: all paths (default_mounts, safe_roots, path_subs) needs to be absolute: %s" % path) - def handler(self, root, arch, command, keep=False, packages=[], mounts=[], repo_id=None, skip_setarch=False, weight=None, upload_logs=None, new_chroot=False): + def handler(self, root, arch, command, keep=False, packages=[], mounts=[], repo_id=None, skip_setarch=False, weight=None, upload_logs=None, new_chroot=None): """Create a buildroot and run a command (as root) inside of it Command may be a string or a list. @@ -185,6 +185,8 @@ class RunRootTask(koji.tasks.BaseTaskHandler): mock_cmd = ['chroot'] if new_chroot: mock_cmd.append('--new-chroot') + elif new_chroot is False: # None -> no option added + mock_cmd.append('--old-chroot') if skip_setarch: #we can't really skip it, but we can set it to the current one instead of of the chroot one myarch = platform.uname()[5] diff --git a/plugins/cli/runroot.py b/plugins/cli/runroot.py index 8e8e660..ee6493f 100644 --- a/plugins/cli/runroot.py +++ b/plugins/cli/runroot.py @@ -23,8 +23,10 @@ def handle_runroot(options, session, args): help=_("Print the ID of the runroot task")) parser.add_option("--use-shell", action="store_true", default=False, help=_("Run command through a shell, otherwise uses exec")) - parser.add_option("--new-chroot", action="store_true", default=False, + parser.add_option("--new-chroot", action="store_true", default=None, help=_("Run command with the --new-chroot (systemd-nspawn) option to mock")) + parser.add_option("--old-chroot", action="store_false", default=None, dest='new_chroot', + help=_("Run command with the --old-chroot (systemd-nspawn) option to mock")) parser.add_option("--repo-id", type="int", help=_("ID of the repo to use")) parser.add_option("--nowait", action="store_false", dest="wait", default=True, help=_("Do not wait on task")) @@ -55,8 +57,8 @@ def handle_runroot(options, session, args): 'weight': opts.weight } # Only pass this kwarg if it is true - this prevents confusing older # builders with a different function signature - if opts.new_chroot: - kwargs['new_chroot'] = True + if opts.new_chroot is not None: + kwargs['new_chroot'] = opts.new_chroot task_id = session.runroot(tag, arch, command, **kwargs) except koji.GenericError as e: