Overview

Request 1192635 superseded

- add substitutions for base image references and digests


Fabian Vogt's avatar
14+for base_image_path in $(find containers -regextype egrep -regex "containers/.*\.(tgz|tar|tar\.xz|tar\.gz)$" -print); do

Isn't that just `for base_image_path in containers/*.{tgz,tar,tar.xz,tar.gz}; do`?

15+    echo "Loading base image ${base_image_path##*/}"
16+    if tar -tf $base_image_path | grep -q "^manifest.json"; then

Quoting please. Can there ever be a container tarball without manifest?

17+        CONFIG_BLOB=$(tar -xOf $base_image_path manifest.json | paste -s | sed -n -e 's/^.*"Config"\s*:\s*"\([^"]*\)".*$/\1/p')

What does paste do here? For json, please use jq...

18+        if [ -n "$CONFIG_BLOB" ]; then

Can this ever be empty?

19+            CONFIG_JSON=$(tar -xOf $base_image_path "$CONFIG_BLOB" | paste -s)

Quoting.

20+            CONTAINER_REFERENCE=$(echo "$CONFIG_JSON" | sed -n -e 's/^.*"org.opensuse.reference"\s*:\s*"\([^"]*\)".*$/\1/p')
21+            CONTAINER_NAME=$(echo "$CONFIG_JSON" | sed -n -e 's/^.*"org.opensuse.reference"\s*:\s*".*\/\([^:/]*\):.*".*$/\1/p' | tr '[:lower:]-' '[:upper:]_')
22+            sed -i"" \
23+                -e "s#%BASE_${CONTAINER_NAME}_REFERENCE%#${CONTAINER_REFERENCE}#g" \
24+                -e "s#%BASE_${CONTAINER_NAME}_DIGEST%#${CONFIG_BLOB}#g" \

The digest here needs to be the sha256 of the manifest, not the config blob.

25+                "${files[@]}"
26+        fi
27+    fi
28+done

Dirk Mueller's avatar
author source maintainer target maintainer

Isn't that just for base_image_path in containers/*.{tgz,tar,tar.xz,tar.gz}; do?

no, there's subdirectories involved. we could do containers/*/.{....} instead with globstar set


Fabian Vogt's avatar

Constant level of subdirs? If not, yes, globstar is needed


Dirk Mueller's avatar
author source maintainer target maintainer

Can there ever be a container tarball without manifest?

yes, manifest is legacy docker stuff, oci doesn't have it.


Fabian Vogt's avatar

Hm, do we need oci support as well?


Dirk Mueller's avatar
author source maintainer target maintainer

The digest here needs to be the sha256 of the manifest, not the config blob.

no. both docker and podman use the sha256 of the config blob as image digest. the oci spec is a bit unclear on that.


Fabian Vogt's avatar

The registry uses content addressed storage, so the sha256 of the manifest is the entry point, which then refers to the layers and config blob. FWICT the _DIGEST needs to refer to what you can pull from the registry.

Request History
Dirk Mueller's avatar

dirkmueller created request

- add substitutions for base image references and digests


Dirk Mueller's avatar

dirkmueller superseded request

superseded by 1192925

openSUSE Build Service is sponsored by