[X2Go-Commits] [buildscripts] 02/03: bin/build-rpm-package: always pass --dist ... for obs-build to workaround current breakage in auto-detection with OpenSuSE Leap 15.3+ and also SLE 15 SP1+.

git-admin at x2go.org git-admin at x2go.org
Tue Feb 21 23:14:47 CET 2023


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository buildscripts.

commit 76dc3c8a81f88b1bfcfbd10be2ec91c612b4dd11
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sat Feb 18 20:12:56 2023 +0100

    bin/build-rpm-package: always pass --dist ... for obs-build to workaround current breakage in auto-detection with OpenSuSE Leap 15.3+ and also SLE 15 SP1+.
---
 bin/build-rpm-package | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/bin/build-rpm-package b/bin/build-rpm-package
index 5bd226a..387fb9a 100755
--- a/bin/build-rpm-package
+++ b/bin/build-rpm-package
@@ -706,6 +706,41 @@ opensuse_is_legacy () {
 	return "${ret}"
 }
 
+# Generates a value that can be passed to obs-build's --dist parameter.
+# Takes the distribution name (either 'sle' or 'opensuse') and the major and
+# minor version number.
+# Outputs the generated dist value.
+generate_suse_dist_value () {
+	typeset distname="${1:?"Error: no *SuSE distribution name passed to ${FUNCNAME}()."}"
+	typeset major_version="${2:?"Error: no *SuSE major version passed to ${FUNCNAME}()."}"
+	typeset minor_version="${3:?"Error: no *SuSE minor version passed to ${FUNCNAME}()."}"
+
+	if [ 'sle' != "${distname}" ] && [ 'opensuse' != "${distname}" ]; then
+		printf 'Invalid distribution name '"'"'%s'"'"' passed to %s, only '"'"'sle'"'"' and '"'"'opensuse'"'"' are supported.' "${distname}" "${FUNCNAME}" >&2
+		return '1'
+	fi
+
+	typeset ret='sl'
+	if [ 'sle' = "${distname}" ]; then
+		ret="${ret}"'e'
+	fi
+
+	if [ '9999' = "${major_version}" ]; then
+		if [ 'opensuse' != "${distname}" ]; then
+			printf 'Invalid major version '"'"'%s'"'"' passed to %s for distribution name '"'"'%s'"'"', this is unsupported.' "${major_version}" "${FUNCNAME}" "${distname}" >&2
+			return '2'
+		fi
+
+		ret="${ret}"'tumbleweed'
+	else
+		ret="${ret}${major_version}.${minor_version}"
+	fi
+
+	printf '%s\n' "${ret}"
+
+	return '0'
+}
+
 # Creates an obs-build configuration inside the temporary working directory.
 # Takes the temporary working directory and a subdirectory containing the
 # obs-build configuration files.
@@ -1028,6 +1063,26 @@ build_packages() {
 						fi
 					fi
 
+					# While obs-build has an auto-detection feature that tries to look at the
+					# DISTRIBUTION RPM tag of the "rpm" package downloaded from the official
+					# main or update repository we're providing, this stopped working with
+					# Leap 15.3, since a lot of binary packages are now copied directly from
+					# some SLE version, without rebuilding them. This leads to the "rpm"
+					# package's DISTRIBUTION tag set to values like "SUSE Linux Enterprise
+					# 15", which is not suitable for the auto-detection to work correctly.
+					# We're going to override this detection by providing a --dist argument.
+					typeset dist_value=''
+					dist_value="$(generate_suse_dist_value "${l_DIST}"
+									       "${tmp_suse_major_version}"
+									       "${tmp_suse_minor_version}")"
+
+					if [ '0' -ne "${?}" ]; then
+						printf 'Unable to generate *SuSE dist value.' >&2
+						exit '1'
+					fi
+
+					extra_obs_build_args+=( '--dist' "${dist_value}" )
+
 					if [ "x${l_DIST}" = "xopensuse" ]; then
 						typeset -i legacy_release="0"
 

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/buildscripts.git


More information about the x2go-commits mailing list