Sync from SUSE:SLFO:Main obs-service-kiwi_metainfo_helper revision 2fbf7815e250776964a921911ea9de44
This commit is contained in:
parent
b7f52975d9
commit
a9433af072
35
README
35
README
@ -5,19 +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 |
|
||||
| %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 |
|
||||
|
@ -11,12 +11,13 @@ fi
|
||||
BUILD_DATA="${BUILD_DIST/.dist/.data}"
|
||||
if [ -e "${BUILD_DATA}" ]; then
|
||||
. "${BUILD_DATA}"
|
||||
BUILD_ARCH="${BUILD_ARCH%%:*}"
|
||||
|
||||
# The build script renames the recipe (to strip _service:foo:), but doesn't update .data
|
||||
RECIPEFILE="${RECIPEFILE##*:}"
|
||||
|
||||
if [ "${RECIPEFILE##*.}" != "kiwi" ] && [ "${RECIPEFILE}" != "Dockerfile" ] && [ "${RECIPEFILE}" != "Chart.yaml" ]; then
|
||||
echo "Recipe is neither Dockerfile, kiwi recipe nor helm chart - exiting"
|
||||
if [ "${RECIPEFILE##*.}" != "kiwi" ] && [[ ! "${RECIPEFILE}" =~ ^Dockerfile.* ]] && [ "${RECIPEFILE}" != "Chart.yaml" ]; then
|
||||
echo "Recipe ${RECIPEFILE} is neither Dockerfile, kiwi recipe nor helm chart - exiting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -25,6 +26,7 @@ else
|
||||
echo "Warning: No build data found - chroot build?"
|
||||
DISTURL="local"
|
||||
RELEASE=0
|
||||
BUILD_ARCH="noarch"
|
||||
|
||||
# Guess the build recipe
|
||||
files=(*.kiwi Dockerfile* Chart.yaml*)
|
||||
@ -39,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}"
|
||||
@ -71,7 +73,7 @@ if grep -q "%OS_" ${files[@]}; then
|
||||
# Extract the content
|
||||
tempdir=$(mktemp -d)
|
||||
trap "rm -r ${tempdir}" EXIT
|
||||
rpm2cpio "${relpkgs[0]}" | cpio -idD "${tempdir}"
|
||||
rpm2cpio "${relpkgs[0]}" | (cd "${tempdir}" && cpio -id --quiet)
|
||||
|
||||
# And source it
|
||||
[ -f "${tempdir}/usr/lib/os-release" ] && . "${tempdir}/usr/lib/os-release"
|
||||
@ -125,8 +127,20 @@ 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" \
|
||||
-e "s/%RELEASE%/${RELEASE}/g" \
|
||||
-e "s/%ARCH%/${BUILD_ARCH}/g" \
|
||||
-e "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" "${files[@]}"
|
||||
|
@ -1,3 +1,33 @@
|
||||
-------------------------------------------------------------------
|
||||
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>
|
||||
|
||||
- Support Docker.FLAVOR in _multibuild (boo#1226010)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 1 15:54:12 UTC 2024 - Marina Latini <marina.latini@suse.com>
|
||||
|
||||
- Replace %ARCH% with the architecture in images for supporting
|
||||
subscriptions in SCC based on architectures
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 15 13:08:03 UTC 2023 - Michal Suchanek <msuchanek@suse.com>
|
||||
|
||||
- cpio on SLE12 does not support -D option, emulate it.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 6 17:10:20 UTC 2022 - Dominique Leuenberger <dimstar@opensuse.org>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package obs-service-kiwi_metainfo_helper
|
||||
#
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
|
75
test.sh
75
test.sh
@ -25,6 +25,7 @@ cat >.data <<EOF
|
||||
DISTURL="obs://build.opensuse.org/openSUSE:Factory/images/0f40c57dd619e1dff9e512949b6bca09-opensuse-tumbleweed-image:docker"
|
||||
RELEASE=4.2
|
||||
RECIPEFILE=_service:foobar:Dockerfile
|
||||
BUILD_ARCH=aarch64:aarch64_ilp32:armv8l
|
||||
EOF
|
||||
export BUILD_DIST=.dist
|
||||
|
||||
@ -33,6 +34,7 @@ DISTURL=%DISTURL%
|
||||
SOURCEURL=%SOURCEURL%
|
||||
RELEASE=%RELEASE%
|
||||
BUILDTIME=%BUILDTIME%
|
||||
ARCH=%ARCH%
|
||||
OS_VERSION=%OS_VERSION%
|
||||
OS_VERSION_NO_DASH=%OS_VERSION_NO_DASH%
|
||||
OS_VERSION_ID=%OS_VERSION_ID%
|
||||
@ -51,6 +53,7 @@ DISTURL=obs://build.opensuse.org/openSUSE:Factory/images/0f40c57dd619e1dff9e5129
|
||||
SOURCEURL=https://build.opensuse.org/package/show/openSUSE:Factory/opensuse-tumbleweed-image?rev=0f40c57dd619e1dff9e512949b6bca09
|
||||
RELEASE=4.2
|
||||
BUILDTIME=2018-10-30T09:19:02.074934628Z
|
||||
ARCH=aarch64
|
||||
OS_VERSION=15-SP4
|
||||
OS_VERSION_NO_DASH=15 SP4
|
||||
OS_VERSION_ID=15.4
|
||||
@ -67,6 +70,7 @@ cat >.data <<EOF
|
||||
DISTURL="obs://build.suse.de/SUSE:SLE-15-SP3:Update:CR/images/5f0a221b7877396cbf977205e64690d2-sles15-image"
|
||||
RELEASE=4.2
|
||||
RECIPEFILE=_service:foobar:Dockerfile
|
||||
BUILD_ARCH=aarch64:aarch64_ilp32:armv8l
|
||||
EOF
|
||||
|
||||
cat >Dockerfile <<EOF
|
||||
@ -81,6 +85,46 @@ DISTURL=obs://build.suse.de/SUSE:SLE-15-SP3:Update:CR/images/5f0a221b7877396cbf9
|
||||
SOURCEURL=https://sources.suse.com/SUSE:SLE-15-SP3:Update:CR/sles15-image/5f0a221b7877396cbf977205e64690d2/
|
||||
EOF
|
||||
|
||||
# Test _multibuild
|
||||
cat >.data <<EOF
|
||||
DISTURL="obs://build.opensuse.org/openSUSE:Factory/images/0f40c57dd619e1dff9e512949b6bca09-opensuse-tumbleweed-image:docker"
|
||||
RELEASE=4.2
|
||||
RELEASE=4.2
|
||||
RECIPEFILE=_service:foobar:Dockerfile.FLAVOR
|
||||
BUILD_ARCH=aarch64:aarch64_ilp32:armv8l
|
||||
EOF
|
||||
export BUILD_DIST=.dist
|
||||
|
||||
cat >Dockerfile.FLAVOR <<EOF
|
||||
RELEASE=%RELEASE%
|
||||
EOF
|
||||
|
||||
bash "${script}"
|
||||
|
||||
diff -u Dockerfile.FLAVOR - <<EOF
|
||||
RELEASE=4.2
|
||||
EOF
|
||||
|
||||
# Test _multibuild when not a Dockerfile
|
||||
cat >.data <<EOF
|
||||
DISTURL="obs://build.opensuse.org/openSUSE:Factory/images/0f40c57dd619e1dff9e512949b6bca09-opensuse-tumbleweed-image:docker"
|
||||
RELEASE=4.2
|
||||
RELEASE=4.2
|
||||
RECIPEFILE=_service:foobar:NotADockerfile
|
||||
BUILD_ARCH=aarch64:aarch64_ilp32:armv8l
|
||||
EOF
|
||||
export BUILD_DIST=.dist
|
||||
|
||||
cat >NotADockerfile <<EOF
|
||||
RELEASE=%RELEASE%
|
||||
EOF
|
||||
|
||||
bash "${script}"
|
||||
|
||||
diff -u NotADockerfile - <<EOF
|
||||
RELEASE=%RELEASE%
|
||||
EOF
|
||||
|
||||
# Now test without build data (osc chroot build) and that without %OS_*% it doesn't need a release RPM
|
||||
rm -r ./.data ./repos/
|
||||
|
||||
@ -89,6 +133,7 @@ DISTURL=%DISTURL%
|
||||
SOURCEURL=%SOURCEURL%
|
||||
RELEASE=%RELEASE%
|
||||
BUILDTIME=%BUILDTIME%
|
||||
ARCH=%ARCH%
|
||||
EOF
|
||||
|
||||
bash "${script}"
|
||||
@ -98,4 +143,34 @@ DISTURL=local
|
||||
SOURCEURL=https://local/package/show/local/local?rev=local
|
||||
RELEASE=0
|
||||
BUILDTIME=2018-10-30T09:19:02.074934628Z
|
||||
ARCH=noarch
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user