From 0e214541cb5fa636b91da44751359161ab3bde38d599e2dc29bad089acde34d5 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Wed, 16 Mar 2022 09:26:39 +0000 Subject: [PATCH] Accepting request 962099 from home:fcrozat:branches:openSUSE:Tools - Generate OS_VERSION_NO_DASH based on os-release VERSION, as workaround to replace dash with space in OS name (bsc#1195061). - Bump version to 0.6 OBS-URL: https://build.opensuse.org/request/show/962099 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-kiwi_metainfo_helper?expand=0&rev=30 --- README | 31 ++++++++++++------------ kiwi_metainfo_helper | 2 ++ obs-service-kiwi_metainfo_helper.changes | 8 ++++++ obs-service-kiwi_metainfo_helper.spec | 2 +- test.sh | 2 ++ 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/README b/README index 376838c..58b3a23 100644 --- a/README +++ b/README @@ -5,18 +5,19 @@ 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 | -| %OS_VERSION% | VERSION in the os-release file | 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 (.) | 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 | diff --git a/kiwi_metainfo_helper b/kiwi_metainfo_helper index ff2be81..95aee5e 100644 --- a/kiwi_metainfo_helper +++ b/kiwi_metainfo_helper @@ -78,6 +78,7 @@ if grep -q "%OS_" ${files[@]}; then [ -f "${tempdir}/etc/os-release" ] && . "${tempdir}/etc/os-release" VERSION="${VERSION:-}" + VERSION_NO_DASH="${VERSION/-/ }" # Special case for SLE X "SP 0", make sure it has .0 VERSION_ID_SP="${VERSION_ID}" [[ "${VERSION_ID_SP%}" == *"."* ]] || VERSION_ID_SP="${VERSION_ID}.0" @@ -120,6 +121,7 @@ if grep -q "%OS_" ${files[@]}; then -e "s/%OS_PRETTY_NAME_BEFORE_PAREN%/${PRETTY_NAME_BEFORE_PAREN}/g" \ -e "s/%OS_PRETTY_NAME_BEFORE_PAREN_DASHED%/${PRETTY_NAME_BEFORE_PAREN_DASHED}/g" \ -e "s/%OS_VERSION%/${VERSION}/g" \ + -e "s/%OS_VERSION_NO_DASH%/${VERSION_NO_DASH}/g" \ -e "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}" fi diff --git a/obs-service-kiwi_metainfo_helper.changes b/obs-service-kiwi_metainfo_helper.changes index 2dc55bb..2d96931 100644 --- a/obs-service-kiwi_metainfo_helper.changes +++ b/obs-service-kiwi_metainfo_helper.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Feb 15 11:03:50 UTC 2022 - Frederic Crozat + +- Generate OS_VERSION_NO_DASH based on os-release VERSION, + as workaround to replace dash with space in OS name + (bsc#1195061). +- Bump version to 0.6 + ------------------------------------------------------------------- Tue Feb 8 16:10:01 UTC 2022 - Frederic Crozat diff --git a/obs-service-kiwi_metainfo_helper.spec b/obs-service-kiwi_metainfo_helper.spec index b7f72e2..bafa6d5 100644 --- a/obs-service-kiwi_metainfo_helper.spec +++ b/obs-service-kiwi_metainfo_helper.spec @@ -17,7 +17,7 @@ Name: obs-service-kiwi_metainfo_helper -Version: 0.5 +Version: 0.6 Release: 0 Summary: Service for substituting various variables in build recipes License: GPL-2.0-or-later diff --git a/test.sh b/test.sh index 98aa3b1..9249713 100644 --- a/test.sh +++ b/test.sh @@ -34,6 +34,7 @@ SOURCEURL=%SOURCEURL% RELEASE=%RELEASE% BUILDTIME=%BUILDTIME% OS_VERSION=%OS_VERSION% +OS_VERSION_NO_DASH=%OS_VERSION_NO_DASH% OS_VERSION_ID=%OS_VERSION_ID% OS_VERSION_ID_SP=%OS_VERSION_ID_SP% OS_PRETTY_NAME=%OS_PRETTY_NAME% @@ -51,6 +52,7 @@ SOURCEURL=https://build.opensuse.org/package/show/openSUSE:Factory/opensuse-tumb RELEASE=4.2 BUILDTIME=2018-10-30T09:19:02.074934628Z OS_VERSION=15-SP4 +OS_VERSION_NO_DASH=15 SP4 OS_VERSION_ID=15.4 OS_VERSION_ID_SP=15.4 OS_PRETTY_NAME=SUSE Linux Enterprise Server 15 SP4