@@ -247,15 +247,56 @@ impl ToDiskOpts {
247247 tty=--tty
248248 fi
249249
250+ # Workaround for issue #126: If image has signatures, copy from additionalimagestore
251+ # to local storage without signatures, since bootc install requires changing layer
252+ # representation which invalidates signatures.
253+ export STORAGE_OPTS=additionalimagestore=${AIS}
254+ SOURCE_REF={SOURCE_IMGREF}
255+ LOCAL_IMGREF="containers-storage:bcvk-temp-install:latest"
256+
257+ # Check if image has signatures - only do copy if signatures are present
258+ # Note: If skopeo inspect fails, we assume no signatures to avoid false positives
259+ # but this means we might miss signatures if inspect fails for other reasons
260+ HAS_SIGNATURES=0
261+ if skopeo inspect --storage-opt "additionalimagestore=${AIS}" "${SOURCE_REF}" 2>/dev/null | \
262+ grep -q '"Signatures"'; then
263+ HAS_SIGNATURES=1
264+ fi
265+
266+ if [ ${HAS_SIGNATURES} -eq 1 ]; then
267+ # Image has signatures - must copy to local storage without signatures
268+ # If copy fails, we cannot proceed as bootc install will fail with signature error
269+ SIG_POLICY=$(mktemp)
270+ trap 'rm -f -- "${SIG_POLICY}"' EXIT
271+ cat > "${SIG_POLICY}" <<'EOF'
272+ {"default":[{"type":"insecureAcceptAnything"}],"transports":{"containers-storage":[{"type":"insecureAcceptAnything"}]}}
273+ EOF
274+ if ! skopeo copy --signature-policy "${SIG_POLICY}" --remove-signatures \
275+ --storage-opt "additionalimagestore=${AIS}" \
276+ "${SOURCE_REF}" "${LOCAL_IMGREF}"; then
277+ echo "Error: Failed to copy signed image to local storage. This is required to proceed."
278+ rm -f "${SIG_POLICY}"
279+ trap - EXIT
280+ exit 1
281+ fi
282+ unset STORAGE_OPTS
283+ PODMAN_ENV=""
284+ rm -f "${SIG_POLICY}"
285+ trap - EXIT
286+ else
287+ # No signatures, use original reference directly
288+ LOCAL_IMGREF=${SOURCE_REF}
289+ PODMAN_ENV="--env=STORAGE_OPTS"
290+ fi
291+
250292 # Execute bootc installation, having the outer podman pull from
251293 # the virtiofs store on the host, as well as the inner bootc.
252294 # Mount /var/tmp into inner container to avoid cross-device link errors (issue #125)
253- export STORAGE_OPTS=additionalimagestore=${AIS}
254295 podman run --rm -i ${tty} --privileged --pid=host --net=none -v /sys:/sys:ro \
255296 -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 \
297+ ${PODMAN_ENV} \
257298 {INSTALL_LOG} \
258- {SOURCE_IMGREF } \
299+ ${LOCAL_IMGREF } \
259300 bootc install to-disk \
260301 --generic-image \
261302 --skip-fetch-check \
0 commit comments