Skip to content

Commit dadf28e

Browse files
committed
Fix signature handling with additionalimagestore
Copy images to local storage without signatures before bootc install to avoid signature invalidation errors. Falls back to original behavior if copy fails.
1 parent b664ecb commit dadf28e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

crates/kit/src/to_disk.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,34 @@ impl ToDiskOpts {
247247
tty=--tty
248248
fi
249249
250+
# Workaround for issue #126: Copy image from additionalimagestore to local storage
251+
# without signatures, since bootc install requires changing layer representation.
252+
export STORAGE_OPTS=additionalimagestore=${AIS}
253+
SOURCE_REF={SOURCE_IMGREF}
254+
LOCAL_IMGREF="containers-storage:bcvk-temp-install:latest"
255+
SIG_POLICY=$(mktemp)
256+
cat > ${SIG_POLICY} <<'EOF'
257+
{"default":[{"type":"insecureAcceptAnything"}],"transports":{"containers-storage":{"":[{"type":"insecureAcceptAnything"}]}}}
258+
EOF
259+
if skopeo copy --signature-policy ${SIG_POLICY} --remove-signatures \
260+
--storage-opt additionalimagestore=${AIS} \
261+
${SOURCE_REF} ${LOCAL_IMGREF}; then
262+
unset STORAGE_OPTS
263+
PODMAN_ENV=""
264+
else
265+
LOCAL_IMGREF=${SOURCE_REF}
266+
PODMAN_ENV="--env=STORAGE_OPTS"
267+
fi
268+
rm -f ${SIG_POLICY}
269+
250270
# Execute bootc installation, having the outer podman pull from
251271
# the virtiofs store on the host, as well as the inner bootc.
252272
# Mount /var/tmp into inner container to avoid cross-device link errors (issue #125)
253-
export STORAGE_OPTS=additionalimagestore=${AIS}
254273
podman run --rm -i ${tty} --privileged --pid=host --net=none -v /sys:/sys:ro \
255274
-v /var/lib/containers:/var/lib/containers -v /var/tmp:/var/tmp -v /dev:/dev -v ${AIS}:${AIS} --security-opt label=type:unconfined_t \
256-
--env=STORAGE_OPTS \
275+
${PODMAN_ENV} \
257276
{INSTALL_LOG} \
258-
{SOURCE_IMGREF} \
277+
${LOCAL_IMGREF} \
259278
bootc install to-disk \
260279
--generic-image \
261280
--skip-fetch-check \

0 commit comments

Comments
 (0)