Skip to content

Commit

Permalink
Import the bootstrap image from the exported tarball
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup committed Jul 3, 2024
1 parent d39e498 commit 5fc17c5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mock/py/mock-isolated-repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def prepare_image(image_specification, outputdir):
Store the tarball into the same directory where the RPMs are
"""
subprocess.check_output(["podman", "pull", image_specification])
subprocess.check_output(["podman", "save", "--quiet", "-o",
os.path.join(outputdir, "bootstrap.tar"),
subprocess.check_output(["podman", "save", "--format=oci-archive" "--quiet",
"-o", os.path.join(outputdir, "bootstrap.tar"),
image_specification])


Expand Down
6 changes: 6 additions & 0 deletions mock/py/mockbuild/buildroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ def _fallback(message):
with _fallback("Can't initialize from bootstrap image"):
if not self.config["image_skip_pull"]:
podman.retry_image_pull(self.config["image_keep_getting"])

if self.config["isolated_build"]:
tarball = os.path.join(self.config["local_directory"],
"bootstrap.tar")
podman.import_tarball(tarball)

podman.cp(self.make_chroot_path(), self.config["tar_binary"])
file_util.unlink_if_exists(os.path.join(self.make_chroot_path(),
"etc/rpm/macros.image-language-conf"))
Expand Down
3 changes: 3 additions & 0 deletions mock/py/mockbuild/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ def setup_default_config_opts():
config_opts["recursion_limit"] = 5000

config_opts["calculatedeps"] = None
config_opts["isolated_build"] = False

return config_opts

Expand All @@ -411,6 +412,8 @@ def process_isolated_build_config(cmdline_opts, config_opts):
if not cmdline_opts.isolated_build_config:
return

config_opts["isolated_build"] = True

json_conf, local_repo = cmdline_opts.isolated_build_config
with open(json_conf, "r", encoding="utf-8") as fd:
data = json.load(fd)
Expand Down
8 changes: 8 additions & 0 deletions mock/py/mockbuild/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ def pull_image(self):
logger.error(out)
return not exit_status

def import_tarball(self, tarball):
"""
Import tarball using podman into the local database.
"""
getLog().info("Loading bootstrap image from %s", tarball)
cmd = [self.podman_binary, "load", "-i", tarball]
util.do_with_status(cmd, env=self.buildroot.env)

def retry_image_pull(self, max_time):
""" Try pulling the image multiple times """
@backoff.on_predicate(backoff.expo, lambda x: not x,
Expand Down

0 comments on commit 5fc17c5

Please sign in to comment.