diff --git a/mock/py/mockbuild/buildroot.py b/mock/py/mockbuild/buildroot.py index 385b48455..6633d0b8c 100644 --- a/mock/py/mockbuild/buildroot.py +++ b/mock/py/mockbuild/buildroot.py @@ -110,8 +110,12 @@ def __init__(self, config, uid_manager, state, plugins, bootstrap_buildroot=None self.env.update(proxy_env) os.environ.update(proxy_env) - self.use_chroot_image = self.config['use_bootstrap_image'] - self.chroot_image = self.config['bootstrap_image'] + image = 'bootstrap' if is_bootstrap else 'buildroot' + self.use_chroot_image = self.config[f"use_{image}_image"] + self.chroot_image = self.config[f"{image}_image"] + self.image_skip_pull = self.config[f"{image}_image_skip_pull"] + self.image_assert_digest = self.config.get(f"{image}_image_assert_digest", None) + self.image_keep_getting = self.config[f"{image}_image_keep_getting"] self.pkg_manager = None self.mounts = mounts.Mounts(self) @@ -239,7 +243,7 @@ def _init_locked(self): @traceLog() def _load_from_container_image(self): - if not self.uses_bootstrap_image or self.chroot_was_initialized: + if not self.use_chroot_image or self.chroot_was_initialized: return if util.mock_host_environment_type() == "docker": @@ -269,15 +273,15 @@ def _fallback(message): podman = Podman(self, self.chroot_image) with _fallback("Can't initialize from container image"): - if not self.config["image_skip_pull"]: - podman.retry_image_pull(self.config["image_keep_getting"]) + if not self.image_skip_pull: + podman.retry_image_pull(self.image_keep_getting) else: podman.read_image_id() getLog().info("Using local image %s (%s)", self.chroot_image, podman.image_id) podman.tag_image() - digest_expected = self.config.get("image_assert_digest", None) + digest_expected = self.image_assert_digest if digest_expected: getLog().info("Checking image digest: %s", digest_expected) diff --git a/mock/py/mockbuild/config.py b/mock/py/mockbuild/config.py index 56b4827d5..03d2380ff 100644 --- a/mock/py/mockbuild/config.py +++ b/mock/py/mockbuild/config.py @@ -105,6 +105,14 @@ def setup_default_config_opts(): config_opts['bootstrap_image_keep_getting'] = 120 config_opts['bootstrap_image_assert_digest'] = None + config_opts['use_buildroot_image'] = False + config_opts['buildroot_image'] = None + config_opts['buildroot_image_skip_pull'] = True + config_opts['buildroot_image_ready'] = False + config_opts['buildroot_image_fallback'] = True + config_opts['buildroot_image_keep_getting'] = 120 + config_opts['buildroot_image_assert_digest'] = None + config_opts['internal_dev_setup'] = True # cleanup_on_* only take effect for separate --resultdir @@ -235,7 +243,7 @@ def setup_default_config_opts(): 'process-distgit', ] }, - 'oci_as_buildroot_enable': True, + 'oci_as_buildroot_enable': False, 'oci_as_buildroot_opts': {}, } @@ -676,6 +684,9 @@ def set_config_opts_per_cmdline(config_opts, options, args): if config_opts["calculatedeps"]: config_opts["plugin_conf"]["buildroot_lock_enable"] = True + if config_opts["buildroot_image"]: + config_opts["use_buildroot_image"] = True + def check_config(config_opts): if 'root' not in config_opts: raise exception.ConfigError("Error in configuration " diff --git a/releng/release-notes-next/oci-image-as-buildroot.bugfix b/releng/release-notes-next/oci-image-as-buildroot.bugfix new file mode 100644 index 000000000..851fe9518 --- /dev/null +++ b/releng/release-notes-next/oci-image-as-buildroot.bugfix @@ -0,0 +1,2 @@ +New feature was added to a) generate an OCI image from Mock-generated buildroot, +and b) for using such an image as a base buildroot for the next build.