From ca5266f3ba301845f59bb0d7c97ad686ff05101e Mon Sep 17 00:00:00 2001 From: RishabhSaini Date: Tue, 2 May 2023 11:41:53 -0400 Subject: [PATCH] cmd-build: Conditionally change the packing structure of container-image When the previous build exists, use its packing structure otherwise container-encapsulate generates a new one --- src/cmd-build | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cmd-build b/src/cmd-build index fd375997c6..fa15de5abf 100755 --- a/src/cmd-build +++ b/src/cmd-build @@ -452,6 +452,15 @@ else "--label=io.openshift.build.versions=machine-os=${buildid}" ) fi + + last_build_manifest=() + #Use the last stable release if buildfetch used + if [ -n "${PARENT_BUILD}" ]; then + last_build_manifest+=("--previous_build_manifest=${parent_builddir}/${name}-${PARENT_BUILD}-ostree.${basearch}-manifest.json") + #Use the previous local build + elif [ -n "${previous_build}" ]; then + last_build_manifest+=("--previous_build_manifest=${previous_builddir}/${name}-${previous_build}-ostree.${basearch}-manifest.json") + fi runv rpm-ostree compose container-encapsulate --max-layers="$MAX_OSTREECONTAINER_LAYERS" --format-version=1 \ --repo="${tmprepo}" \ --label="coreos-assembler.image-config-checksum=${image_config_checksum}" \ @@ -459,11 +468,15 @@ else --label="org.opencontainers.image.source=${gitsrc}" \ --label="org.opencontainers.image.revision=${config_gitrev}" \ --copymeta-opt=fedora-coreos.stream \ + "${last_build_manifest[@]}" \ "${labels[@]}" \ "${buildid}" \ oci-archive:"${ostree_tarfile_path}".tmp:latest /usr/lib/coreos-assembler/finalize-artifact "${ostree_tarfile_path}"{.tmp,} ostree_tarfile_sha256=$(sha256sum "${ostree_tarfile_path}" | awk '{print$1}') + ostree_oci_manifest_path="${name}-${buildid}-ostree.${basearch}-manifest.json" + skopeo inspect --raw oci-archive:"${ostree_tarfile_path}" > tmp/manifest.json + /usr/lib/coreos-assembler/finalize-artifact tmp/manifest.json "${ostree_oci_manifest_path}" fi # The base metadata, plus locations for code sources.