Skip to content

Commit 651b79e

Browse files
committed
cmd-import: generate the oci manifest from ociarchive
Operate on the ociarchive directly rather than args.srcimg because otherwise the manifest we fetch with skopeo *could* be a manifest list. Fixes #4310
1 parent c0d3310 commit 651b79e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/cmd-import

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ def main():
4343
sys.exit(1)
4444

4545
with tempfile.TemporaryDirectory(prefix='cosa-import-', dir='tmp') as tmpd:
46-
# create the OCI archive and manifest
46+
# create the OCI archive
4747
tmp_oci_archive = generate_oci_archive(args, tmpd)
48-
tmp_oci_manifest = generate_oci_manifest(args, tmpd)
48+
# extract the OCI manifest from it. Note here that we operate
49+
# on the ociarchive directly rather than args.srcimg because
50+
# otherwise the manifest we fetch with skopeo *could* be a
51+
# manifest list.
52+
tmp_oci_manifest = generate_oci_manifest(tmp_oci_archive, tmpd)
4953

5054
# import into the tmp/repo to get the ostree-commit but also so it's cached
5155
ostree_commit = import_oci_archive(tmpd, tmp_oci_archive, buildid)
@@ -87,10 +91,10 @@ def generate_oci_archive(args, tmpd):
8791
return tmpf
8892

8993

90-
def generate_oci_manifest(args, tmpd):
94+
def generate_oci_manifest(ociarchive, tmpd):
9195
tmpf = os.path.join(tmpd, 'oci-manifest.json')
9296
with open(tmpf, 'wb') as f:
93-
f.write(subprocess.check_output(["skopeo", "inspect", "--raw", args.srcimg]))
97+
f.write(subprocess.check_output(["skopeo", "inspect", "--raw", f"oci-archive:{ociarchive}"]))
9498
os.fchmod(f.fileno(), S_IREAD | S_IRGRP | S_IROTH)
9599
return tmpf
96100

0 commit comments

Comments
 (0)