From eff162ed62024e0e09f7960733acce6b0ae206f4 Mon Sep 17 00:00:00 2001 From: Igor Raits Date: Nov 13 2022 10:00:17 +0000 Subject: [PATCH 1/2] Revert "PR#3568: kiwi: don't bind builders's /dev" This reverts commit 56cea9adc25216bbb162d65a359013ef81267652, reversing changes made to e9b5ec215d1f1e40ef177b9146a90508f0b9126f. --- diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py index bc216c2..f536d78 100644 --- a/plugins/builder/kiwi.py +++ b/plugins/builder/kiwi.py @@ -304,10 +304,6 @@ class KiwiCreateImageTask(BaseBuildTask): desc_url, desc_path, opts=None): self.opts = opts build_tag = target_info['build_tag'] - if opts.get('bind_dev'): - bind_opts = {'dirs': {'/dev': '/dev'}} - else: - bind_opts = None broot = BuildRoot(self.session, self.options, tag=build_tag, arch=arch, @@ -315,7 +311,7 @@ class KiwiCreateImageTask(BaseBuildTask): repo_id=repo_info['id'], install_group='kiwi-build', setup_dns=True, - bind_opts=bind_opts) + bind_opts={'dirs': {'/dev': '/dev', }}) broot.workdir = self.workdir # create the mock chroot diff --git a/plugins/cli/kiwi.py b/plugins/cli/kiwi.py index 61764ef..6e965c0 100644 --- a/plugins/cli/kiwi.py +++ b/plugins/cli/kiwi.py @@ -30,9 +30,6 @@ def handle_kiwi_build(goptions, session, args): parser.add_option("--type", help="Override default build type from description") parser.add_option("--make-prep", action="store_true", default=False, help="Run 'make prep' in checkout before starting the build") - parser.add_option("--bind-dev", action="store_true", default=False, - help="e.g. images using device-mapper needs /dev mounted in kiwi env, " - "while others can fail in such env.") parser.add_option("--can-fail", action="store", dest="optional_arches", metavar="ARCH1,ARCH2,...", default="", help="List of archs which are not blocking for build " @@ -55,7 +52,6 @@ def handle_kiwi_build(goptions, session, args): 'target': target, 'desc_url': scm, 'desc_path': path, - 'bind_dev': options.bind_dev, } if options.scratch: kwargs['scratch'] = True diff --git a/plugins/hub/kiwi.py b/plugins/hub/kiwi.py index f83b209..7b0c2f0 100644 --- a/plugins/hub/kiwi.py +++ b/plugins/hub/kiwi.py @@ -17,7 +17,7 @@ koji.tasks.LEGACY_SIGNATURES['createKiwiImage'] = [ @export def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile=None, scratch=False, priority=None, make_prep=False, repos=None, release=None, - type=None, bind_dev=False): + type=None): context.session.assertPerm('image') for i in [desc_url, desc_path, profile, release]: if i is not None: @@ -52,8 +52,6 @@ def kiwiBuild(target, arches, desc_url, desc_path, optional_arches=None, profile opts['release'] = release if optional_arches: opts['optional_arches'] = optional_arches - if bind_dev: - opts['bind_dev'] = bind_dev if repos: opts['repos'] = repos if make_prep: From b07e817d90c0edbab0caee5bdcfd545f7cd555ff Mon Sep 17 00:00:00 2001 From: Igor Raits Date: Nov 13 2022 10:00:33 +0000 Subject: [PATCH 2/2] kiwi: Bind-mount /dev into the buildroot for old-chroot The OEM images can't be build with nspawn as they require mocking with device-mapper which is near to impossible to properly to set up in the container so those ones have to be built in old chroot where /dev can and must be bind-mounted. In opposite for nspawn, bind-mounting /dev breaks build completely. Let's just dynamically decide based on the chroot type what to do. --- diff --git a/plugins/builder/kiwi.py b/plugins/builder/kiwi.py index f536d78..eb3b086 100644 --- a/plugins/builder/kiwi.py +++ b/plugins/builder/kiwi.py @@ -65,6 +65,8 @@ class KiwiBuildTask(BuildImageTask): opts['scratch'] = False if not opts.get('optional_arches'): opts['optional_arches'] = [] + if not buildconfig['extra'].get('mock.new_chroot', True): + opts['mount_dev'] = True self.opts = opts # get configuration @@ -304,6 +306,9 @@ class KiwiCreateImageTask(BaseBuildTask): desc_url, desc_path, opts=None): self.opts = opts build_tag = target_info['build_tag'] + bind_opts = {'dirs': {}} + if self.opts.get('mount_dev'): + bind_opts['dirs']['/dev'] = '/dev' broot = BuildRoot(self.session, self.options, tag=build_tag, arch=arch, @@ -311,7 +316,7 @@ class KiwiCreateImageTask(BaseBuildTask): repo_id=repo_info['id'], install_group='kiwi-build', setup_dns=True, - bind_opts={'dirs': {'/dev': '/dev', }}) + bind_opts=bind_opts) broot.workdir = self.workdir # create the mock chroot