From 18f23a904c6cc11051e4b45a9eb6a1d5aaec2479 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mar 07 2017 20:20:29 +0000 Subject: runroot: Support nspawn_args For rpm-ostree we need ``` config_opts['nspawn_args'] = ['--capability=CAP_NET_ADMIN', '--as-pid2'] ``` Which is now exposed via https://github.com/rpm-software-management/mock/pull/35 --- diff --git a/builder/kojid b/builder/kojid index 714d032..9b4a8c2 100755 --- a/builder/kojid +++ b/builder/kojid @@ -176,7 +176,8 @@ class BuildRoot(object): self.config = self.session.getBuildConfig(self.tag_id, event=self.event_id) def _new(self, tag, arch, task_id, repo_id=None, install_group='build', - setup_dns=False, bind_opts=None, maven_opts=None, maven_envs=None, deps=None): + setup_dns=False, bind_opts=None, maven_opts=None, maven_envs=None, deps=None, + nspawn_args=[]): """Create a brand new repo""" if not repo_id: raise koji.BuildrootError("A repo id must be provided") @@ -215,6 +216,7 @@ class BuildRoot(object): self.install_group = install_group self.setup_dns = setup_dns self.bind_opts = bind_opts + self.nspawn_args = nspawn_args self.maven_opts = maven_opts self.maven_envs = maven_envs self.deps = deps @@ -239,6 +241,7 @@ class BuildRoot(object): opts['maven_opts'] = self.maven_opts opts['maven_envs'] = self.maven_envs opts['bind_opts'] = self.bind_opts + opts['nspawn_args'] = self.nspawn_args opts['target_arch'] = self.target_arch if 'mock.package_manager' in self.config['extra']: opts['package_manager'] = self.config['extra']['mock.package_manager'] diff --git a/cli/koji b/cli/koji index 21ba190..f624a1e 100755 --- a/cli/koji +++ b/cli/koji @@ -7111,6 +7111,8 @@ def handle_runroot(options, session, args): help=_("Run command through a shell, otherwise uses exec")) parser.add_option("--new-chroot", action="store_true", default=False, help=_("Run command with the --new-chroot (systemd-nspawn) option to mock")) + parser.add_option("--nspawn-arg", action="append", dest="nspawn_args", default=[], + help=_("Configure nspawn arguments for mock")) parser.add_option("--repo-id", type="int", help=_("ID of the repo to use")) (opts, args) = parser.parse_args(args) @@ -7136,6 +7138,8 @@ def handle_runroot(options, session, args): # builders with a different function signature if opts.new_chroot: kwargs['new_chroot'] = True + if opts.nspawn_args: + kwargs['nspawn_args'] = opts.nspawn_args task_id = session.runroot(tag, arch, command, **kwargs) except koji.GenericError, e: diff --git a/plugins/builder/runroot.py b/plugins/builder/runroot.py index 37fabbe..faf599c 100644 --- a/plugins/builder/runroot.py +++ b/plugins/builder/runroot.py @@ -92,7 +92,7 @@ class RunRootTask(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=False, nspawn_args=[]): """Create a buildroot and run a command (as root) inside of it Command may be a string or a list. @@ -154,7 +154,8 @@ class RunRootTask(tasks.BaseTaskHandler): if compat_mode: broot = BuildRoot(root, br_arch, self.id, repo_id=repo_info['id'], setup_dns=True) else: - broot = BuildRoot(self.session, self.options, root, br_arch, self.id, repo_id=repo_info['id'], setup_dns=True) + broot = BuildRoot(self.session, self.options, root, br_arch, self.id, repo_id=repo_info['id'], setup_dns=True, + nspawn_args=opts.nspawn_args) broot.workdir = self.workdir broot.init() rootdir = broot.rootdir()