- 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
This commit is contained in:
Fabian Vogt 2024-09-25 09:03:48 +00:00 committed by Git OBS Bridge
parent 8e4bb88238
commit 351e333731
3 changed files with 31 additions and 22 deletions

38
README
View File

@ -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 (<cicnt\>.<bldcnt\>) | 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 (<cicnt\>.<bldcnt\>) | 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 |

View File

@ -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/.*<registry_refname>\([^<]*\)<.*/\1/p' < containers/annotation)"
REGISTRY_REFDIGEST="$(sed -n 's/.*<registry_digest>\(.*\)<.*/\1/p' < containers/annotation)"
REGISTRY_DIGEST="$(sed -n 's/.*<registry_digest>\(.*\)<.*/\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

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Wed Sep 25 09:01:19 UTC 2024 - Fabian Vogt <fvogt@suse.com>
- 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 <dmueller@suse.com>