github.com/quay/claircore@v1.5.28/etc/extract-layers (about) 1 #!/bin/sh 2 if [ "$#" -lt 2 ]; then 3 printf 'missing "image name" and "tar pattern(s)" arguments\n' >&2 4 exit 99 5 fi 6 for cmd in jq skopeo; do 7 command -v "$cmd" >/dev/null 2>/dev/null || { 8 printf 'missing "%s"\n' "$cmd" >&2 9 exit 99 10 } 11 done 12 13 src=$1; shift 14 local=$(basename "$src" | sed 's/:.\+$//') 15 set -e 16 17 skopeo copy --remove-signatures "${src}" "oci:${local}" 18 ( 19 cd "${local}" 20 n=0 21 jq -r '.manifests|.[]|.digest' index.json | 22 sed 's,:,/,' | 23 while read -r m; do 24 jq -r '.layers|.[]|.digest' "blobs/$m" | 25 sed 's,:,/,' 26 done | 27 while read -r l; do 28 d=$((n++)) 29 mkdir -p "layer/$d" 30 echo ": $l" 31 tar --no-same-permissions -x -z -f "blobs/$l" -C "layer/$d" "$@" ||: 32 done 33 ) 34 command -v tree >/dev/null 2>/dev/null && tree -a "${local}/layer"