1
0

Accepting request 900211 from home:jfkw:branches:Virtualization:WSL

- 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

- Bump version to 0.2

OBS-URL: https://build.opensuse.org/request/show/900211
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-kiwi_metainfo_helper?expand=0&rev=22
This commit is contained in:
Fabian Vogt 2021-06-21 11:24:12 +00:00 committed by Git OBS Bridge
parent 83e53be8ef
commit 2e05118d34
5 changed files with 66 additions and 10 deletions

19
README
View File

@ -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 recipe (.kiwi, Dockerfile, Chart.yaml) to replace placeholders with
build-specific metainfo. build-specific metainfo.
| Placeholder | Value | Example | | Placeholder | Value | Example |
|--------------------|--------------------------------------------|-----------------------------------------------------------------------------------------------| |--------------------------------------|----------------------------------------------- |------------------------------------------------------------------------------------------------|
| %DISTURL% | The OBS dist url | obs://build.suse.de/SUSE:SLE-15:Update:CR/images/2951b67133dd6384cacb28203174e030-sles15-image| | %DISTURL% | The OBS dist url | obs://build.suse.de/SUSE:SLE-15:Update:CR/images/2951b67133dd6384cacb28203174e030-sles15-image |
| %RELEASE% | The OBS release number (<cicnt\>.<bldcnt\>)| 4.2 | | %RELEASE% | The OBS release number (<cicnt\>.<bldcnt\>) | 4.2 |
| %BUILDTIME% | $(date --utc +%FT%T.%NZ) | 2018-10-30T09:19:02.074934628Z | | %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% | VERSION_ID in the os-release file | 15 |
| %OS_VERSION_ID_SP% | Like VERSION_ID, but with SP (SLE only) | 15.0 | | %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 |

View File

@ -70,9 +70,43 @@ if grep -q "%OS_" ${files[@]}; then
VERSION_ID_SP="${VERSION_ID}" VERSION_ID_SP="${VERSION_ID}"
[[ "${VERSION_ID_SP%}" == *"."* ]] || VERSION_ID_SP="${VERSION_ID}.0" [[ "${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"" \ sed -i"" \
-e "s/%OS_VERSION_ID%/${VERSION_ID}/g" \ -e "s/%OS_VERSION_ID%/${VERSION_ID}/g" \
-e "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/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[@]}" -e "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}"
fi fi

View File

@ -1,4 +1,4 @@
<service name="kiwi_metainfo_helper"> <service name="kiwi_metainfo_helper">
<summary>Substitute various variables in build recipes</summary> <summary>Substitute various variables in build recipes</summary>
<description>Substitutes %DISTURL%, %RELEASE% and %BUILDTIME% in build recipes.</description> <description>Substitutes variables in build recipes. See README for variable listing.</description>
</service> </service>

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Wed Jun 2 14:23:53 UTC 2021 - Jeff Kowalczyk <jkowalczyk@suse.com>
- 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 <fvogt@suse.com> Mon Feb 1 10:29:08 UTC 2021 - Fabian Vogt <fvogt@suse.com>
@ -9,6 +26,7 @@ Wed Jan 27 11:25:26 UTC 2021 - Fabian Vogt <fvogt@suse.com>
- Read os-release from the to be installed RPMs. This avoids pulling - Read os-release from the to be installed RPMs. This avoids pulling
in distribution-release when not necessary (boo#1180263) in distribution-release when not necessary (boo#1180263)
- Bump version to 0.2
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Sep 1 08:42:45 UTC 2020 - Fabian Vogt <fvogt@suse.com> Tue Sep 1 08:42:45 UTC 2020 - Fabian Vogt <fvogt@suse.com>
@ -60,4 +78,3 @@ Thu Jan 10 08:06:05 UTC 2019 - Fabian Vogt <fvogt@suse.com>
Wed Oct 17 14:56:38 UTC 2018 - Fabian Vogt <fvogt@suse.com> Wed Oct 17 14:56:38 UTC 2018 - Fabian Vogt <fvogt@suse.com>
- Initial commit (fate#326856, bsc#1118103) - Initial commit (fate#326856, bsc#1118103)

View File

@ -17,7 +17,7 @@
Name: obs-service-kiwi_metainfo_helper Name: obs-service-kiwi_metainfo_helper
Version: 0.2 Version: 0.3
Release: 0 Release: 0
Summary: Service for substituting various variables in build recipes Summary: Service for substituting various variables in build recipes
License: GPL-2.0-or-later License: GPL-2.0-or-later