Skip to content

Commit de628bc

Browse files
committed
sign: Use replace-detached-metadata if available
Part of actually shipping chunked format, see coreos/fedora-coreos-config#1698 Not tested.
1 parent 4db0e09 commit de628bc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/cmd-sign

+9-1
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,19 @@ def robosign_ostree(args, s3, build, gpgkey):
178178
# We've validated the commit, now re-export the repo
179179
ostree_image = build['images']['ostree']
180180
exported_ostree_path = os.path.join(builddir, ostree_image['path'])
181+
exported_ostree_ref = f'oci-archive:{exported_ostree_path}:latest'
181182
# Files stored in the build directory are mode 0600 to prevent
182183
# accidental mutation. Remove the existing one because otherwise
183184
# we'll try to `open(O_TRUNC)` it and fail.
184185
os.unlink(exported_ostree_path)
185-
subprocess.check_call(['ostree', 'container', 'export', '--repo=tmp/repo', checksum, f'oci-archive:{exported_ostree_path}:latest'])
186+
# Detect and use the replace-detached-metadata API only if available
187+
verb = "replace-detached-metadata"
188+
tmp_image = 'tmp.ociarchive'
189+
if subprocess.check_output(['ostree', 'container', 'image', '--help']).find(verb) >= 0:
190+
subprocess.check_call(['ostree', 'container', 'image', verb, f'--src={exported_ostree_ref}', f'--dest=oci-archive:{tmp_image}:latest', metapath])
191+
os.rename(tmp_image, exported_ostree_path)
192+
else:
193+
subprocess.check_call(['ostree', 'container', 'export', '--repo=tmp/repo', checksum, exported_ostree_ref])
186194
# Finalize the export by making it not writable.
187195
os.chmod(exported_ostree_path, 0o400)
188196
ostree_image['size'] = os.path.getsize(exported_ostree_path)

0 commit comments

Comments
 (0)