diff --git a/README b/README index e8c345c..79696dd 100644 --- a/README +++ b/README @@ -4,8 +4,10 @@ obs-service-kiwi_metainfo_helper This service can be enabled to run during buildtime, when it will edit the kiwi image description 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 | +| 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 | diff --git a/kiwi_metainfo_helper b/kiwi_metainfo_helper index bd52b5d..af61e73 100644 --- a/kiwi_metainfo_helper +++ b/kiwi_metainfo_helper @@ -17,3 +17,15 @@ fi sed -i"" "s#%DISTURL%#${DISTURL}#g" "${RECIPEFILE}" sed -i"" "s/%RELEASE%/${RELEASE}/g" "${RECIPEFILE}" sed -i"" "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" "${RECIPEFILE}" + +[ -f /usr/lib/os-release ] && . /usr/lib/os-release +[ -f /etc/os-release ] && . /etc/os-release + +sed -i"" "s/%OS_VERSION_ID%/${VERSION_ID}/g" "${RECIPEFILE}" +sed -i"" "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/g" "${RECIPEFILE}" + +# 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" + +sed -i"" "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${RECIPEFILE}" diff --git a/obs-service-kiwi_metainfo_helper.changes b/obs-service-kiwi_metainfo_helper.changes index 05e663d..10a50d7 100644 --- a/obs-service-kiwi_metainfo_helper.changes +++ b/obs-service-kiwi_metainfo_helper.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Jan 10 15:42:38 UTC 2019 - Fabian Vogt + +- Add %OS_VERSION_ID(_SP)% and %PRETTY_NAME% (boo#1119378) + ------------------------------------------------------------------- Thu Jan 10 08:06:05 UTC 2019 - Fabian Vogt diff --git a/obs-service-kiwi_metainfo_helper.spec b/obs-service-kiwi_metainfo_helper.spec index b26ef97..13367cc 100644 --- a/obs-service-kiwi_metainfo_helper.spec +++ b/obs-service-kiwi_metainfo_helper.spec @@ -27,6 +27,12 @@ Source0: kiwi_metainfo_helper.service Source1: kiwi_metainfo_helper Source2: README Requires: sed +# For os-release +%if 0%{?is_opensuse} +Requires: openSUSE-release +%else +Requires: sles-release +%endif BuildArch: noarch %description