Skip to content

Commit

Permalink
Use buildroot from container image
Browse files Browse the repository at this point in the history
For now as:
--config-opts buildroot_image=registry.fedoraproject.org/fedora:41

Fixes: #1159
  • Loading branch information
praiskup committed Dec 11, 2024
1 parent eedee1a commit b29e1da
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
16 changes: 10 additions & 6 deletions mock/py/mockbuild/buildroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion mock/py/mockbuild/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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': {},
}

Expand Down Expand Up @@ -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 "
Expand Down
2 changes: 2 additions & 0 deletions releng/release-notes-next/oci-image-as-buildroot.bugfix
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit b29e1da

Please sign in to comment.