diff --git a/README b/README index fc92660..40268e0 100644 --- a/README +++ b/README @@ -5,10 +5,15 @@ 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.suse.de/SUSE:SLE-15:Update:CR/images/2951b67133dd6384cacb28203174e030-sles15-image| -| %RELEASE% | The OBS release number (.)| 4.2 | -| %BUILDTIME% | $(date --utc +%FT%T.%NZ) | 2018-10-30T09:19:02.074934628Z | -| %OS_VERSION_ID% | VERSION_ID in the os-release file | 15 | -| %OS_VERSION_ID_SP% | Like VERSION_ID, but with SP (SLE only) | 15.0 | +| Placeholder | Value | Example | +|--------------------------------------|----------------------------------------------- |------------------------------------------------------------------------------------------------| +| %DISTURL% | The OBS dist url | obs://build.suse.de/SUSE:SLE-15:Update:CR/images/2951b67133dd6384cacb28203174e030-sles15-image | +| %RELEASE% | The OBS release number (.) | 4.2 | +| %BUILDTIME% | $(date --utc +%FT%T.%NZ) | 2018-10-30T09:19:02.074934628Z | +| %OS_VERSION_ID% | VERSION_ID in the os-release file | 15 | +| %OS_VERSION_ID_SP% | Like VERSION_ID, but with SP (SLE only) | 15.0 | +| %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 3242ae1..a608e58 100644 --- a/kiwi_metainfo_helper +++ b/kiwi_metainfo_helper @@ -70,9 +70,43 @@ if grep -q "%OS_" ${files[@]}; then VERSION_ID_SP="${VERSION_ID}" [[ "${VERSION_ID_SP%}" == *"."* ]] || VERSION_ID_SP="${VERSION_ID}.0" + # Provide various modified spellings of PRETTY_NAME useful for writing + # KIWI image definitions with reduced diff between SLE, Leap and Tumbleweed: + # + # VENDOR: openSUSE + # PRETTY_NAME_DASHED: openSUSE-Leap-15.3 + # PRETTY_NAME_BEFORE_PAREN: openSUSE Leap 15.3 + # PRETTY_NAME_BEFORE_PAREN_DASHED: openSUSE-Leap-15.3 + # + # VENDOR: SUSE + # PRETTY_NAME_DASHED: SUSE-Linux-Enterprise-Server-15-SP3-Snapshot-16 + # PRETTY_NAME_BEFORE_PAREN: SUSE Linux Enterprise Server 15 SP3 + # PRETTY_NAME_BEFORE_PAREN_DASHED: SUSE-Linux-Enterprise-Server-15-SP3 + + # First word of PRETTY_NAME, typically used as vendor name e.g. SUSE or openSUSE. + VENDOR="${PRETTY_NAME%% *}" + + # KIWI image name attribute must not contain spaces, replace with dash + PRETTY_NAME_DASHED="${PRETTY_NAME//[^[:alnum:].]/-}" + # Remove repeated dashes from parentheses surrounding SLE release labels + PRETTY_NAME_DASHED="${PRETTY_NAME_DASHED//--/-}" + # Remove dash at end from parentheses surrounding SLE release labels + PRETTY_NAME_DASHED="${PRETTY_NAME_DASHED%%-}" + + # Special case for SLE release labels e.g. RC1. Keep only up to (space) open paren. + # Provides a stable project name for third-party integrations e.g. app store submissions + PRETTY_NAME_BEFORE_PAREN="${PRETTY_NAME// (*/}" + + # KIWI image name attribute must not contain spaces, replace with dash + PRETTY_NAME_BEFORE_PAREN_DASHED="${PRETTY_NAME_BEFORE_PAREN//[^[:alnum:].]/-}" + sed -i"" \ -e "s/%OS_VERSION_ID%/${VERSION_ID}/g" \ -e "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/g" \ + -e "s/%OS_VENDOR%/${VENDOR}/g" \ + -e "s/%OS_PRETTY_NAME_DASHED%/${PRETTY_NAME_DASHED}/g" \ + -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_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}" fi diff --git a/kiwi_metainfo_helper.service b/kiwi_metainfo_helper.service index 81c4d96..c158d03 100644 --- a/kiwi_metainfo_helper.service +++ b/kiwi_metainfo_helper.service @@ -1,4 +1,4 @@ Substitute various variables in build recipes - Substitutes %DISTURL%, %RELEASE% and %BUILDTIME% in build recipes. + Substitutes variables in build recipes. See README for variable listing. diff --git a/obs-service-kiwi_metainfo_helper.changes b/obs-service-kiwi_metainfo_helper.changes index 387e2e7..d8d0605 100644 --- a/obs-service-kiwi_metainfo_helper.changes +++ b/obs-service-kiwi_metainfo_helper.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Wed Jun 2 14:23:53 UTC 2021 - Jeff Kowalczyk + +- Provide various modified spellings of PRETTY_NAME useful for + writing KIWI image definitions with reduced diff between SLE, + Leap and Tumbleweed. DASHED satisfies the requirement that kiwi + image names must not have spaces. The BEFORE_PAREN variations + drop the release label in parentheses (SLE only) and can be used + as a stable name for image registries and WSL app store + submissions. + * VENDOR + * PRETTY_NAME_DASHED + * PRETTY_NAME_BEFORE_PAREN + * PRETTY_NAME_BEFORE_PAREN_DASHED +- Update README and service definition XML to reflect all variables +- Bump version to 0.3 + ------------------------------------------------------------------- Mon Feb 1 10:29:08 UTC 2021 - Fabian Vogt @@ -9,6 +26,7 @@ Wed Jan 27 11:25:26 UTC 2021 - Fabian Vogt - Read os-release from the to be installed RPMs. This avoids pulling in distribution-release when not necessary (boo#1180263) +- Bump version to 0.2 ------------------------------------------------------------------- Tue Sep 1 08:42:45 UTC 2020 - Fabian Vogt @@ -60,4 +78,3 @@ Thu Jan 10 08:06:05 UTC 2019 - Fabian Vogt Wed Oct 17 14:56:38 UTC 2018 - Fabian Vogt - Initial commit (fate#326856, bsc#1118103) - diff --git a/obs-service-kiwi_metainfo_helper.spec b/obs-service-kiwi_metainfo_helper.spec index e59ee28..9c245f9 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.2 +Version: 0.3 Release: 0 Summary: Service for substituting various variables in build recipes License: GPL-2.0-or-later