From 0250501b3c240e0aca2d9b67de220475b6dc3f02dce2fe2d9f5cb87c4310ddc9 Mon Sep 17 00:00:00 2001 From: Fabian Vogt Date: Mon, 17 Jan 2022 10:06:25 +0000 Subject: [PATCH] - Fix SOURCEURL for multibuild DISTURLs - Add test suite (test.sh, sles-release-15.4-150400.32.2.x86_64.rpm) - Set SOURCEURL also in chroot builds OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-kiwi_metainfo_helper?expand=0&rev=26 --- README | 2 +- kiwi_metainfo_helper | 21 ++--- obs-service-kiwi_metainfo_helper.changes | 7 ++ obs-service-kiwi_metainfo_helper.spec | 12 ++- sles-release-15.4-150400.32.2.x86_64.rpm | 3 + test.sh | 97 ++++++++++++++++++++++++ 6 files changed, 128 insertions(+), 14 deletions(-) create mode 100644 sles-release-15.4-150400.32.2.x86_64.rpm create mode 100644 test.sh diff --git a/README b/README index d2b1c10..b6525c3 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ build-specific metainfo. | Placeholder | Value | Example | |--------------------------------------|----------------------------------------------- |-------------------------------------------------------------------------------------------------------------------------| -| %DISTURL% | The OBS dist url | obs://build.opensuse.org/openSUSE:Factory/images/0f40c57dd619e1dff9e512949b6bca09obs-opensuse-tumbleweed-image | +| %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 | diff --git a/kiwi_metainfo_helper b/kiwi_metainfo_helper index 3462642..9f0e1ac 100644 --- a/kiwi_metainfo_helper +++ b/kiwi_metainfo_helper @@ -21,16 +21,6 @@ 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" @@ -44,6 +34,17 @@ else fi fi +# 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- | cut -d: -f1) +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 + # Print all rpm files which contain os-release find_release_rpms() { find ./repos -name \*-release\*.rpm | while read rpm; do diff --git a/obs-service-kiwi_metainfo_helper.changes b/obs-service-kiwi_metainfo_helper.changes index e986a6a..d74b21a 100644 --- a/obs-service-kiwi_metainfo_helper.changes +++ b/obs-service-kiwi_metainfo_helper.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Jan 17 09:57:02 UTC 2022 - Fabian Vogt + +- Add test suite (test.sh, sles-release-15.4-150400.32.2.x86_64.rpm) +- Fix SOURCEURL for multibuild DISTURLs +- Set SOURCEURL also in chroot builds + ------------------------------------------------------------------- Thu Jan 13 09:32:09 UTC 2022 - Frederic Crozat diff --git a/obs-service-kiwi_metainfo_helper.spec b/obs-service-kiwi_metainfo_helper.spec index a9f30f7..1f2f336 100644 --- a/obs-service-kiwi_metainfo_helper.spec +++ b/obs-service-kiwi_metainfo_helper.spec @@ -26,6 +26,10 @@ URL: https://build.opensuse.org Source0: kiwi_metainfo_helper.service Source1: kiwi_metainfo_helper Source2: README +# For %%check +Source3: test.sh +Source4: sles-release-15.4-150400.32.2.x86_64.rpm +BuildRequires: diffutils Requires: /usr/bin/find Requires: /usr/bin/grep Requires: /usr/bin/sed @@ -42,10 +46,12 @@ cp %{SOURCE2} . %build %install +mkdir -p %{buildroot}%{_prefix}/lib/obs/service/ +install -m 0644 %{SOURCE0} %{buildroot}%{_prefix}/lib/obs/service/ +install -m 0755 %{SOURCE1} %{buildroot}%{_prefix}/lib/obs/service/ -mkdir -p %{buildroot}%{_prefix}/lib/obs/service -install -m 0644 %{SOURCE0} %{buildroot}%{_prefix}/lib/obs/service -install -m 0755 %{SOURCE1} %{buildroot}%{_prefix}/lib/obs/service +%check +sh %{SOURCE3} %files %doc README diff --git a/sles-release-15.4-150400.32.2.x86_64.rpm b/sles-release-15.4-150400.32.2.x86_64.rpm new file mode 100644 index 0000000..c610cd1 --- /dev/null +++ b/sles-release-15.4-150400.32.2.x86_64.rpm @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05a4bd43da6d55fa1f03bff7f3cea8c634d1dcbdc9bbb51e40472bc936c4c497 +size 427932 diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..a1e0e1e --- /dev/null +++ b/test.sh @@ -0,0 +1,97 @@ +#!/bin/sh +set -eu +tmpdir=$(mktemp -d) +trap 'rm -rf ${tmpdir}' EXIT + +sourcedir="$(realpath "$(dirname $0)")" +script="${sourcedir}/kiwi_metainfo_helper" + +cd $tmpdir + +# Setup environment + +mkdir -p ${tmpdir}/repos/ +cp "${sourcedir}/sles-release-15.4-150400.32.2.x86_64.rpm" ${tmpdir}/repos/ + +# Mock "date" +export PATH=${tmpdir}:$PATH +cat >${tmpdir}/date <<'EOF' +#!/bin/sh +exec /usr/bin/date -d "2018-10-30T09:19:02.074934628Z" "$@" +EOF +chmod a+x ${tmpdir}/date + +cat >.data <Dockerfile <.data <Dockerfile <Dockerfile <