@@ -202,6 +202,11 @@ impl ToDiskOpts {
202202 . map_err ( |e| eyre ! ( "Failed to quote source imgref '{}': {}" , source_imgref, e) ) ?
203203 . to_string ( ) ;
204204
205+ // Quote the source image name for local storage operations
206+ let quoted_source_image = shlex:: try_quote ( & self . source_image )
207+ . map_err ( |e| eyre ! ( "Failed to quote source image '{}': {}" , self . source_image, e) ) ?
208+ . to_string ( ) ;
209+
205210 let install_log = self
206211 . additional
207212 . install_log
@@ -247,15 +252,38 @@ impl ToDiskOpts {
247252 tty=--tty
248253 fi
249254
250- # Execute bootc installation, having the outer podman pull from
251- # the virtiofs store on the host, as well as the inner bootc.
252- # Mount /var/tmp into inner container to avoid cross-device link errors (issue #125)
255+ # Workaround for issue #126:
256+ # Copy image to local storage without signatures. This is unfortunately necessary
257+ # because policy.json alone doesn't prevent the signature validation error when
258+ # bootc changes layer representation during install.
259+ # Note: containers/container-libs#144 would make this copy faster via reflinks,
260+ # but we'd still need to copy to remove signatures. See also bootc-dev/bootc#1601.
261+ # Write permissive policy to VM's /etc/containers/policy.json for the copy operation.
253262 export STORAGE_OPTS=additionalimagestore=${AIS}
263+ mkdir -p /etc/containers
264+ cat > /etc/containers/policy.json <<'EOF'
265+ {
266+ "default": [{"type": "insecureAcceptAnything"}],
267+ "transports": {
268+ "containers-storage": {"": [{"type": "insecureAcceptAnything"}]},
269+ "docker": {"": [{"type": "insecureAcceptAnything"}]}
270+ }
271+ }
272+ EOF
273+
274+ # Copy image without signatures to avoid "Would invalidate signatures" error
275+ skopeo copy --remove-signatures {SOURCE_IMGREF} containers-storage:{SOURCE_IMAGE}
276+
277+ # Execute bootc installation using the unsigned local copy
278+ # Mount /var/tmp into inner container to avoid cross-device link errors (issue #125)
279+ # Bind mount the permissive policy so bootc install's internal operations also work
254280 podman run --rm -i ${tty} --privileged --pid=host --net=none -v /sys:/sys:ro \
255- -v /var/lib/containers:/var/lib/containers -v /var/tmp:/var/tmp -v /dev:/dev -v ${AIS}:${AIS} --security-opt label=type:unconfined_t \
281+ -v /var/lib/containers:/var/lib/containers -v /var/tmp:/var/tmp -v /dev:/dev -v "${AIS}:${AIS}" \
282+ --mount type=bind,source=/etc/containers/policy.json,target=/etc/containers/policy.json,readonly \
283+ --security-opt label=type:unconfined_t \
256284 --env=STORAGE_OPTS \
257285 {INSTALL_LOG} \
258- {SOURCE_IMGREF } \
286+ containers-storage:{SOURCE_IMAGE } \
259287 bootc install to-disk \
260288 --generic-image \
261289 --skip-fetch-check \
@@ -266,6 +294,7 @@ impl ToDiskOpts {
266294 "# }
267295 . replace ( "{TMPFS_SIZE}" , & tmpfs_size_quoted)
268296 . replace ( "{SOURCE_IMGREF}" , & quoted_source_imgref)
297+ . replace ( "{SOURCE_IMAGE}" , & quoted_source_image)
269298 . replace ( "{INSTALL_LOG}" , & install_log)
270299 . replace ( "{BOOTC_ARGS}" , & bootc_args) ;
271300
0 commit comments