diff --git a/mock/py/mock-isolated-repo.py b/mock/py/mock-isolated-repo.py index f873eee6e..98393e687 100755 --- a/mock/py/mock-isolated-repo.py +++ b/mock/py/mock-isolated-repo.py @@ -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]) diff --git a/mock/py/mockbuild/buildroot.py b/mock/py/mockbuild/buildroot.py index 704f89e13..566236d8f 100644 --- a/mock/py/mockbuild/buildroot.py +++ b/mock/py/mockbuild/buildroot.py @@ -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")) diff --git a/mock/py/mockbuild/config.py b/mock/py/mockbuild/config.py index 8d91019af..13daf7697 100644 --- a/mock/py/mockbuild/config.py +++ b/mock/py/mockbuild/config.py @@ -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 @@ -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) diff --git a/mock/py/mockbuild/podman.py b/mock/py/mockbuild/podman.py index 9ece97502..e46d3d670 100644 --- a/mock/py/mockbuild/podman.py +++ b/mock/py/mockbuild/podman.py @@ -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,