diff --git a/README b/README index 40268e0..d2b1c10 100644 --- a/README +++ b/README @@ -5,15 +5,17 @@ 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 | -| %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/0f40c57dd619e1dff9e512949b6bca09obs-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_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 a608e58..3462642 100644 --- a/kiwi_metainfo_helper +++ b/kiwi_metainfo_helper @@ -21,6 +21,16 @@ if [ -e "${BUILD_DATA}" ]; then fi files=("${RECIPEFILE}") + # generate %SOURCEURL% based on DISTURL with a special case for build.suse.de + prj=$(echo ${DISTURL} | cut -d/ -f4) + localpath=$(echo ${DISTURL} | cut -d/ -f6-) + rev=$(echo ${localpath} | cut -d- -f1) + packagename=$(echo ${localpath} | cut -d- -f2-) + 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}" + fi else echo "Warning: No build data found - chroot build?" DISTURL="local" @@ -112,5 +122,6 @@ fi sed -i"" \ -e "s#%DISTURL%#${DISTURL}#g" \ + -e "s#%SOURCEURL%#${SOURCEURL}#g" \ -e "s/%RELEASE%/${RELEASE}/g" \ -e "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" "${files[@]}" diff --git a/obs-service-kiwi_metainfo_helper.changes b/obs-service-kiwi_metainfo_helper.changes index 0a3a842..e986a6a 100644 --- a/obs-service-kiwi_metainfo_helper.changes +++ b/obs-service-kiwi_metainfo_helper.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Jan 13 09:32:09 UTC 2022 - Frederic Crozat + +- Generate SOURCEURL based on DISTURL. +- Bump version to 0.4 + ------------------------------------------------------------------- Wed Jun 2 14:23:53 UTC 2021 - Jeff Kowalczyk diff --git a/obs-service-kiwi_metainfo_helper.spec b/obs-service-kiwi_metainfo_helper.spec index 9c245f9..a9f30f7 100644 --- a/obs-service-kiwi_metainfo_helper.spec +++ b/obs-service-kiwi_metainfo_helper.spec @@ -1,7 +1,7 @@ # # spec file for package obs-service-kiwi_metainfo_helper # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: obs-service-kiwi_metainfo_helper -Version: 0.3 +Version: 0.4 Release: 0 Summary: Service for substituting various variables in build recipes License: GPL-2.0-or-later