Skip to content

Commit eeb59fe

Browse files
committed
Use skopeo for hermetic bootstrap images
1 parent 3a77f8c commit eeb59fe

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

mock/mock.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Suggests: qemu-user-static
9696
Suggests: procenv
9797
Recommends: buildah
9898
Recommends: podman
99+
Recommends: skopeo
99100
Recommends: fuse-overlayfs
100101

101102
%if %{with tests}

mock/py/mock-hermetic-repo.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,14 @@ def prepare_image(image_specification, bootstrap_data, outputdir):
127127
"""
128128
Store the tarball into the same directory where the RPMs are
129129
"""
130-
pull_cmd = ["podman", "pull"]
130+
pull_cmd = ["skopeo", "sync", "--scoped", "--src", "docker", "--dest", "dir"]
131+
if "architecture" in bootstrap_data:
132+
pull_cmd += ["--override-arch", bootstrap_data["architecture"]]
131133
if "pull_digest" in bootstrap_data:
132134
image_specification += "@" + bootstrap_data["pull_digest"]
133-
if "architecture" in bootstrap_data:
134-
pull_cmd += ["--arch", bootstrap_data["architecture"]]
135-
pull_cmd += [image_specification]
135+
pull_cmd += [image_specification, outputdir]
136136
log.info("Pulling like: %s", ' '.join(pull_cmd))
137137
subprocess.check_output(pull_cmd)
138-
subprocess.check_output(["podman", "save", "--format=oci-archive", "--quiet",
139-
"-o", os.path.join(outputdir, "bootstrap.tar"),
140-
image_specification])
141138

142139

143140
def _main():

mock/py/mockbuild/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,9 @@ def process_hermetic_build_config(cmdline_opts, config_opts):
806806
"offline RPM repository (RPM metadata not found)")
807807

808808
# Use the offline image for bootstrapping.
809-
bootstrap_tarball = os.path.join(final_offline_repo, "bootstrap.tar")
810-
config_opts["bootstrap_image"] = f"oci-archive:{bootstrap_tarball}"
809+
image_pullspec = f"{data['config']['bootstrap_image']}@{data['bootstrap']['pull_digest']}"
810+
bootstrap_dir = os.path.join(final_offline_repo, image_pullspec)
811+
config_opts["bootstrap_image"] = f"dir:{bootstrap_dir}"
811812

812813
config_opts["offline_local_repository"] = final_offline_repo
813814

mock/py/mockbuild/podman.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def get_oci_digest(self):
192192
as the check that we've loaded same image.
193193
"""
194194
the_image = self.image
195-
if the_image.startswith("oci-archive:"):
195+
if the_image.startswith("oci-archive:") or the_image.startswith("dir:"):
196196
# We can't query digest from tarball directly, but note
197197
# the image needs to be tagged first!
198198
the_image = self._tagged_id
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Bootstrap image caching for hermetic builds now use
2+
[skopeo](https://github.com/containers/skopeo) sync instead of ``podman
3+
pull|save`` commands. Skopeo better handles digests, so we can always be sure
4+
that we're using correct image.

0 commit comments

Comments
 (0)