From 351e333731a1c7803736a2338bf00e9c828303f051ab85e8555383cf06f18c6a Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Wed, 25 Sep 2024 09:03:48 +0000 Subject: [PATCH] - Small cleanups: * Pass --quiet to cpio * Use consistent variable name for REGISTRY_DIGEST * Mention %BASE_*% behaviour for multi-stage builds explicitly OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-kiwi_metainfo_helper?expand=0&rev=41 --- README | 38 ++++++++++++------------ kiwi_metainfo_helper | 7 +++-- obs-service-kiwi_metainfo_helper.changes | 8 +++++ 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/README b/README index 464d8ed..5027516 100644 --- a/README +++ b/README @@ -5,22 +5,22 @@ This service can be enabled to run during buildtime, when it will edit the build recipe (.kiwi, Dockerfile, Chart.yaml) to replace placeholders with build-specific metainfo. -| Placeholder | Value | Example | -|--------------------------------------|-------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------| -| %DISTURL% | The OBS dist url | obs://build.opensuse.org/openSUSE:Factory/images/0f40c57dd619e1dff9e512949b6bca09-opensuse-tumbleweed-image | -| %SOURCEURL% | Source url for container recipe (OBS) | https://build.opensuse.org/package/show/openSUSE:Factory/opensuse-tumbleweed-image?rev=0f40c57dd619e1dff9e512949b6bca09 | -| %SOURCEURL% | Source url for container recipe (IBS) | https://sources.suse.com/SUSE:SLE-15:Update:CR/sles15-image/2951b67133dd6384cacb28203174e030/ | -| %RELEASE% | The OBS release number (.) | 4.2 | -| %BUILDTIME% | $(date --utc +%FT%T.%NZ) | 2018-10-30T09:19:02.074934628Z | -| %ARCH% | The architecture of the image | aarch64 | -| %OS_VERSION% | VERSION in the os-release file | 15-SP3 | -| %OS_VERSION_NO_DASH% | VERSION in the os-release file, with space (SLE only) | 15 SP3 | -| %OS_VERSION_ID% | VERSION_ID in the os-release file | 15 | -| %OS_VERSION_ID_SP% | Like VERSION_ID, but with SP (SLE only) | 15.3 | -| %OS_PRETTY_NAME% | PRETTY_NAME in the os-release file | SUSE Linux Enterprise Server 15 SP3 (Snapshot16) | -| %OS_VENDOR% | PRETTY_NAME up to first space character | SUSE | -| %OS_PRETTY_NAME_DASHED% | PRETTY_NAME with dashes in place of spaces | SUSE-Linux-Enterprise-Server-15-SP3-Snapshot-16 | -| %OS_PRETTY_NAME_BEFORE_PAREN% | PRETTY_NAME up to the first open parentheses | SUSE Linux Enterprise Server 15 SP3 | -| %OS_PRETTY_NAME_BEFORE_PAREN_DASHED% | PRETTY_NAME up to first open paren with dashes | SUSE-Linux-Enterprise-Server-15-SP3 | -| %BASE_REFNAME% | The tag of the base container from registry | registry.suse.com/bci/bci-base:15.6 | -| %BASE_DIGEST% | The dist digest of the base container from registry | sha256:eb34a30c66b6e1df129bc42d413749466f62e81101c1f8ef04c8fa248e2fe482 | +| Placeholder | Value | Example | +|--------------------------------------|--------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------| +| %DISTURL% | The OBS dist url | obs://build.opensuse.org/openSUSE:Factory/images/0f40c57dd619e1dff9e512949b6bca09-opensuse-tumbleweed-image | +| %SOURCEURL% | Source url for container recipe (OBS) | https://build.opensuse.org/package/show/openSUSE:Factory/opensuse-tumbleweed-image?rev=0f40c57dd619e1dff9e512949b6bca09 | +| %SOURCEURL% | Source url for container recipe (IBS) | https://sources.suse.com/SUSE:SLE-15:Update:CR/sles15-image/2951b67133dd6384cacb28203174e030/ | +| %RELEASE% | The OBS release number (.) | 4.2 | +| %BUILDTIME% | $(date --utc +%FT%T.%NZ) | 2018-10-30T09:19:02.074934628Z | +| %ARCH% | The architecture of the image | aarch64 | +| %OS_VERSION% | VERSION in the os-release file | 15-SP3 | +| %OS_VERSION_NO_DASH% | VERSION in the os-release file, with space (SLE only) | 15 SP3 | +| %OS_VERSION_ID% | VERSION_ID in the os-release file | 15 | +| %OS_VERSION_ID_SP% | Like VERSION_ID, but with SP (SLE only) | 15.3 | +| %OS_PRETTY_NAME% | PRETTY_NAME in the os-release file | SUSE Linux Enterprise Server 15 SP3 (Snapshot16) | +| %OS_VENDOR% | PRETTY_NAME up to first space character | SUSE | +| %OS_PRETTY_NAME_DASHED% | PRETTY_NAME with dashes in place of spaces | SUSE-Linux-Enterprise-Server-15-SP3-Snapshot-16 | +| %OS_PRETTY_NAME_BEFORE_PAREN% | PRETTY_NAME up to the first open parentheses | SUSE Linux Enterprise Server 15 SP3 | +| %OS_PRETTY_NAME_BEFORE_PAREN_DASHED% | PRETTY_NAME up to first open paren with dashes | SUSE-Linux-Enterprise-Server-15-SP3 | +| %BASE_REFNAME% | The tag of the base container (FROM line for the last stage) on the registry | registry.suse.com/bci/bci-base:15.6 | +| %BASE_DIGEST% | The dist digest of the base container (FROM line for the last stage) on the registry | sha256:eb34a30c66b6e1df129bc42d413749466f62e81101c1f8ef04c8fa248e2fe482 | diff --git a/kiwi_metainfo_helper b/kiwi_metainfo_helper index c734f58..06101d2 100644 --- a/kiwi_metainfo_helper +++ b/kiwi_metainfo_helper @@ -73,7 +73,7 @@ if grep -q "%OS_" ${files[@]}; then # Extract the content tempdir=$(mktemp -d) trap "rm -r ${tempdir}" EXIT - rpm2cpio "${relpkgs[0]}" | (cd "${tempdir}" && cpio -id) + rpm2cpio "${relpkgs[0]}" | (cd "${tempdir}" && cpio -id --quiet) # And source it [ -f "${tempdir}/usr/lib/os-release" ] && . "${tempdir}/usr/lib/os-release" @@ -128,12 +128,13 @@ if grep -q "%OS_" ${files[@]}; then fi # Export base container REFNAME and DIGEST +# This XML file was generated by OBS and filled with exactly the data we need. if [ -f containers/annotation ]; then REGISTRY_REFNAME="$(sed -n 's/.*\([^<]*\)<.*/\1/p' < containers/annotation)" - REGISTRY_REFDIGEST="$(sed -n 's/.*\(.*\)<.*/\1/p' < containers/annotation)" + REGISTRY_DIGEST="$(sed -n 's/.*\(.*\)<.*/\1/p' < containers/annotation)" sed -i"" \ -e "s#%BASE_REFNAME%#${REGISTRY_REFNAME}#g" \ - -e "s#%BASE_DIGEST%#${REGISTRY_REFDIGEST}#g" \ + -e "s#%BASE_DIGEST%#${REGISTRY_DIGEST}#g" \ "${files[@]}" fi diff --git a/obs-service-kiwi_metainfo_helper.changes b/obs-service-kiwi_metainfo_helper.changes index 8630fd2..f56fa9d 100644 --- a/obs-service-kiwi_metainfo_helper.changes +++ b/obs-service-kiwi_metainfo_helper.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Sep 25 09:01:19 UTC 2024 - Fabian Vogt + +- Small cleanups: + * Pass --quiet to cpio + * Use consistent variable name for REGISTRY_DIGEST + * Mention %BASE_*% behaviour for multi-stage builds explicitly + ------------------------------------------------------------------- Thu Aug 8 09:23:21 UTC 2024 - Dirk Müller