Accepting request 1203385 from openSUSE:Tools
- Small cleanups: * Pass --quiet to cpio * Use consistent variable name for REGISTRY_DIGEST * Mention %BASE_*% behaviour for multi-stage builds explicitly - add substitutions for base image references and digests (jsc#PED-8543) OBS-URL: https://build.opensuse.org/request/show/1203385 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/obs-service-kiwi_metainfo_helper?expand=0&rev=18
This commit is contained in:
36
README
36
README
@@ -5,20 +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 |
|
||||
| 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 |
|
||||
|
@@ -41,7 +41,7 @@ prj=$(echo ${DISTURL} | cut -d/ -f4)
|
||||
localpath=$(echo ${DISTURL} | cut -d/ -f6-)
|
||||
rev=$(echo ${localpath} | cut -d- -f1)
|
||||
packagename=$(echo ${localpath} | cut -d- -f2- | cut -d: -f1)
|
||||
if [[ "${DISTURL}" == obs://build.suse.de/* ]]; then
|
||||
if [[ "${DISTURL}" == obs://build.suse.de/* ]]; then
|
||||
SOURCEURL="https://sources.suse.com/${prj}/${packagename}/${rev}/"
|
||||
else
|
||||
SOURCEURL="https://$(echo ${DISTURL} | cut -d/ -f3)/package/show/${prj}/${packagename}?rev=${rev}"
|
||||
@@ -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"
|
||||
@@ -127,6 +127,17 @@ if grep -q "%OS_" ${files[@]}; then
|
||||
-e "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}"
|
||||
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_DIGEST="$(sed -n 's/.*<registry_digest>\(.*\)<.*/\1/p' < containers/annotation)"
|
||||
sed -i"" \
|
||||
-e "s#%BASE_REFNAME%#${REGISTRY_REFNAME}#g" \
|
||||
-e "s#%BASE_DIGEST%#${REGISTRY_DIGEST}#g" \
|
||||
"${files[@]}"
|
||||
fi
|
||||
|
||||
sed -i"" \
|
||||
-e "s#%DISTURL%#${DISTURL}#g" \
|
||||
-e "s#%SOURCEURL%#${SOURCEURL}#g" \
|
||||
|
@@ -1,3 +1,17 @@
|
||||
-------------------------------------------------------------------
|
||||
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>
|
||||
|
||||
- add substitutions for base image references and digests
|
||||
(jsc#PED-8543)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 7 08:35:33 UTC 2024 - Andrea Mazzotti <andrea.mazzotti@suse.com>
|
||||
|
||||
|
31
test.sh
31
test.sh
@@ -144,4 +144,33 @@ SOURCEURL=https://local/package/show/local/local?rev=local
|
||||
RELEASE=0
|
||||
BUILDTIME=2018-10-30T09:19:02.074934628Z
|
||||
ARCH=noarch
|
||||
EOF
|
||||
EOF
|
||||
|
||||
# test base container annotations
|
||||
cat >Dockerfile - <<EOF
|
||||
BASE_REFNAME=%BASE_REFNAME%
|
||||
BASE_DIGEST=%BASE_DIGEST%
|
||||
EOF
|
||||
|
||||
mkdir -p containers
|
||||
cat >containers/annotation - <<EOF
|
||||
<annotation>
|
||||
<repo url="obsrepositories:/"/>
|
||||
<binaryid>491e4873e01f1a58464ea33970a08a3219062ec1bb9a4c5a1bd014d0d596beab</binaryid>
|
||||
<registry_refname>registry.suse.com/bci/bci-base:15.6</registry_refname>
|
||||
<registry_digest>sha256:cee5bd9e5a186dc1cca01e523f588f4c19c6c45abaa47139f7c021c289cb4c04</registry_digest>
|
||||
<registry_fatdigest>sha256:887c83266ee8ae4a83c215974a814abbb2007f0a445a67fac7079e922e846133</registry_fatdigest>
|
||||
<version>cee5bd9e5a186dc1cca01e523f588f4c19c6c45abaa47139f7c021c289cb4c04</version>
|
||||
<release>0</release>
|
||||
<binaryarch>noarch</binaryarch>
|
||||
<hdrmd5>05cb99d4617ee49ed6419f72cc8fcf6e</hdrmd5>
|
||||
</annotation>
|
||||
EOF
|
||||
|
||||
bash "${script}"
|
||||
|
||||
diff -u Dockerfile - <<EOF
|
||||
BASE_REFNAME=registry.suse.com/bci/bci-base:15.6
|
||||
BASE_DIGEST=sha256:cee5bd9e5a186dc1cca01e523f588f4c19c6c45abaa47139f7c021c289cb4c04
|
||||
EOF
|
||||
rm -r containers/annotation
|
||||
|
Reference in New Issue
Block a user