|
| 1 | +#!/usr/bin/bash |
| 2 | +# |
| 3 | +# Generates mock manifests (i.e. without real resolved content) |
| 4 | +# XXX: copied from the images library, this is temporary until |
| 5 | +# all image manifest generation for bib moves into "images" itself. |
| 6 | + |
| 7 | +set -euo pipefail |
| 8 | + |
| 9 | +tmpdir="$(mktemp -d)" |
| 10 | +cleanup() { |
| 11 | + rm -r "${tmpdir}" |
| 12 | +} |
| 13 | +trap cleanup EXIT |
| 14 | + |
| 15 | +manifests_dir="${1:-}" |
| 16 | +if [ "$manifests_dir" = "" ]; then |
| 17 | + echo "need a manifests dir as first argument" |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | +mkdir -p "$manifests_dir" |
| 21 | + |
| 22 | +export OSBUILD_TESTING_RNG_SEED=0 |
| 23 | +export IMAGE_BUILDER_EXPERIMENTAL=bib-mock-resolvers |
| 24 | + |
| 25 | +echo "Checking if bib compiles" |
| 26 | +if ! (cd bib && go build -v -o "${tmpdir}/bin/" ./cmd/bootc-image-builder); then |
| 27 | + echo "Failed to compile bootc-image-builder. Skipping..." |
| 28 | + exit 0 |
| 29 | +fi |
| 30 | + |
| 31 | +echo "Generating mock manifests" |
| 32 | +# XXX: we look into the image so we need a real bootc container available, |
| 33 | +# this is not ideal and may invalidate the whole approach |
| 34 | +BOOTC_REF="quay.io/centos-bootc/centos-bootc:stream9" |
| 35 | +podman pull "$BOOTC_REF" |
| 36 | +# XXX: more arches? |
| 37 | +for arch in x86_64 aarch64; do |
| 38 | + # XXX: add anaconda-iso once we can mock it too |
| 39 | + for imgtype in ami qcow2 vmdk raw vhd gce; do |
| 40 | + if ! "${tmpdir}/bin/bootc-image-builder" \ |
| 41 | + manifest -v "$BOOTC_REF" \ |
| 42 | + --target-arch "$arch" \ |
| 43 | + --type "$imgtype" \ |
| 44 | + 2> "${tmpdir}/stderr" \ |
| 45 | + | jq > "$manifests_dir/manifest-$arch-$imgtype.json"; then |
| 46 | + cat "${tmpdir}/stderr" |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + done |
| 50 | +done |
| 51 | + |
| 52 | +echo "Manifests saved to ${manifests_dir}" |
0 commit comments