Accepting request 867214 from home:favogt:boo1180263
- Read os-release from the to be installed RPMs. This avoids pulling in distribution-release when not necessary (boo#1180263) OBS-URL: https://build.opensuse.org/request/show/867214 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-kiwi_metainfo_helper?expand=0&rev=17
This commit is contained in:
parent
22e3d1aaec
commit
29126d06c0
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -eu
|
set -euo pipefail
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
if [ "${BUILD_DIST+x}" != "x" ]; then
|
if [ "${BUILD_DIST+x}" != "x" ]; then
|
||||||
@ -33,17 +33,49 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -f /usr/lib/os-release ] && . /usr/lib/os-release
|
# Print all rpm files which contain os-release
|
||||||
[ -f /etc/os-release ] && . /etc/os-release
|
find_release_rpms() {
|
||||||
|
find ./repos -name \*-release\*.rpm | while read rpm; do
|
||||||
|
if rpm -qlp "${rpm}" | grep -qE "^(/etc/os-release|/usr/lib/os-release)$"; then
|
||||||
|
echo "${rpm}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Special case for SLE X "SP 0", make sure it has .0
|
if grep -q "%OS_" ${files[@]}; then
|
||||||
VERSION_ID_SP="${VERSION_ID}"
|
# Needs os-release, search for RPMs
|
||||||
[[ "${VERSION_ID_SP%}" == *"."* ]] || VERSION_ID_SP="${VERSION_ID}.0"
|
relpkgs=($(find_release_rpms))
|
||||||
|
|
||||||
|
if [ ${#relpkgs[@]} -lt 1 ]; then
|
||||||
|
echo "No release package found, but recipe uses %OS_*% placeholders"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${#relpkgs[@]} -gt 1 ]; then
|
||||||
|
echo "Multiple release packages found, don't know which os-release to use"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the content
|
||||||
|
tempdir=$(mktemp -d)
|
||||||
|
trap "rm -r ${tempdir}" EXIT
|
||||||
|
rpm2cpio "${relpkgs[0]}" | cpio -idD "${tempdir}"
|
||||||
|
|
||||||
|
# And source it
|
||||||
|
[ -f "${tempdir}/usr/lib/os-release" ] && . "${tempdir}/usr/lib/os-release"
|
||||||
|
[ -f "${tempdir}/etc/os-release" ] && . "${tempdir}/etc/os-release"
|
||||||
|
|
||||||
|
# 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"" \
|
||||||
|
-e "s/%OS_VERSION_ID%/${VERSION_ID}/g" \
|
||||||
|
-e "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/g" \
|
||||||
|
-e "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i"" \
|
sed -i"" \
|
||||||
-e "s#%DISTURL%#${DISTURL}#g" \
|
-e "s#%DISTURL%#${DISTURL}#g" \
|
||||||
-e "s/%RELEASE%/${RELEASE}/g" \
|
-e "s/%RELEASE%/${RELEASE}/g" \
|
||||||
-e "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" \
|
-e "s/%BUILDTIME%/$(date --utc +%FT%T.%NZ)/g" "${files[@]}"
|
||||||
-e "s/%OS_VERSION_ID%/${VERSION_ID}/g" \
|
|
||||||
-e "s/%OS_PRETTY_NAME%/${PRETTY_NAME}/g" \
|
|
||||||
-e "s/%OS_VERSION_ID_SP%/${VERSION_ID_SP}/g" "${files[@]}"
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
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
|
||||||
|
in distribution-release when not necessary (boo#1180263)
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
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>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package obs-service-kiwi_metainfo_helper
|
# spec file for package obs-service-kiwi_metainfo_helper
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020 SUSE LLC
|
# Copyright (c) 2021 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: obs-service-kiwi_metainfo_helper
|
Name: obs-service-kiwi_metainfo_helper
|
||||||
Version: 0.1
|
Version: 0.2
|
||||||
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
|
||||||
@ -26,12 +26,9 @@ URL: https://build.opensuse.org
|
|||||||
Source0: kiwi_metainfo_helper.service
|
Source0: kiwi_metainfo_helper.service
|
||||||
Source1: kiwi_metainfo_helper
|
Source1: kiwi_metainfo_helper
|
||||||
Source2: README
|
Source2: README
|
||||||
Requires: sed
|
Requires: /usr/bin/find
|
||||||
# Technically, this should read os-release inside the built image, but doing
|
Requires: /usr/bin/grep
|
||||||
# that is much more complex. As obsrepositories:// has to be used anyway,
|
Requires: /usr/bin/sed
|
||||||
# using the system's os-release is fine for now.
|
|
||||||
Requires: (sles-release or openSUSE-release)
|
|
||||||
Conflicts: dummy-release
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
|
Loading…
Reference in New Issue
Block a user