Skip to content

Commit a710bde

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. Signed-off-by: gursewak1997 <[email protected]>
1 parent b664ecb commit a710bde

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+
trap 'rm -f -- "${SIG_POLICY}"' EXIT
257+
cat > "${SIG_POLICY}" <<'EOF'
258+
{"default":[{"type":"insecureAcceptAnything"}],"transports":{"containers-storage":[{"type":"insecureAcceptAnything"}]}}
259+
EOF
260+
if skopeo copy --signature-policy "${SIG_POLICY}" --remove-signatures \
261+
--storage-opt "additionalimagestore=${AIS}" \
262+
"${SOURCE_REF}" "${LOCAL_IMGREF}"; then
263+
unset STORAGE_OPTS
264+
PODMAN_ENV=""
265+
else
266+
LOCAL_IMGREF=${SOURCE_REF}
267+
PODMAN_ENV="--env=STORAGE_OPTS"
268+
fi
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)