[X2Go-Commits] [buildscripts] 01/03: bin/build-rpm-package: make SUSE version fetching more generic by using functions.

git-admin at x2go.org git-admin at x2go.org
Thu Dec 8 20:05:38 CET 2016


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

x2go pushed a commit to branch master
in repository buildscripts.

commit 73b040092d17cb9c262513f801d410a40d8ea88a
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Thu Dec 8 18:44:15 2016 +0100

    bin/build-rpm-package: make SUSE version fetching more generic by using functions.
---
 bin/build-rpm-package |   66 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 57 insertions(+), 9 deletions(-)

diff --git a/bin/build-rpm-package b/bin/build-rpm-package
index 21b97cf..47f379a 100755
--- a/bin/build-rpm-package
+++ b/bin/build-rpm-package
@@ -567,6 +567,48 @@ get_extra_repository () {
 	return 0
 }
 
+# Fetches major version out of a SUSE version string.
+# The format is expected to be "X.Y" with X and Y being positive integers.
+# The return code is either 0 or 1, with 0 meaning success and 1 failure.
+# The detected major version is written to STDOUT.
+get_suse_major_version () {
+	typeset suse_version="${1}"
+	typeset -i ret="0"
+
+	if [ -z "${suse_version}" ]; then
+		ret="1"
+	else
+		typeset -i tmp_suse_major_version="0"
+		tmp_suse_major_version="$(sed -e '/^\([0-9][0-9]*\)\.[0-9][0-9]*$/!d;s//\1/' <<< "${suse_version}")"
+
+		if [ "${tmp_suse_major_version}" -ne "0" ]; then
+			echo "${tmp_suse_major_version}"
+		fi
+	fi
+
+	return "${ret}"
+}
+
+# Fetches minor version out of a SUSE version string.
+# The format is expected to be "X.Y" with X and Y being positive integers.
+# The return code is either 0 or 1, with 0 meaning success and 1 failure.
+# The detected minor version is written to STDOUT.
+get_suse_minor_version () {
+	typeset suse_version="${1}"
+	typeset -i ret="0"
+
+	if [ -z "${suse_version}" ]; then
+		ret="1"
+	else
+		typeset -i tmp_suse_minor_version="-1"
+		tmp_suse_minor_version="$(sed -e '/^[0-9][0-9]*\.\([0-9][0-9]*\)$/!d;s//\1/' <<< "${suse_version}")"
+
+		echo "${tmp_suse_minor_version}"
+	fi
+
+	return "${ret}"
+}
+
 prepare_workspace() {
 	# make sure our local working copy is up to date...
 	if [ -d "${PROJECT_DIR}/.git" ]; then
@@ -752,11 +794,11 @@ build_packages() {
 					BUILD_RESULT="/home/abuild/rpmbuild/"
 
 					typeset -i tmp_suse_major_version="0"
-					tmp_suse_major_version="$(sed -e '/^\([0-9][0-9]*\)\.[0-9][0-9]*$/!d;s//\1/' <<< "${l_CODENAME}")"
+					tmp_suse_major_version="$(get_suse_major_version "${l_CODENAME}")"
 
-					if [ "x${tmp_suse_major_version}" = "x0" ]; then
+					if [ "${?}" -ne "0" ]; then
 						echo "Unable to extract SUSE version."
-						exit 1
+						exit "1"
 					fi
 
 					if [ "x${l_DIST}" = "xopensuse" ]; then
@@ -1010,13 +1052,19 @@ upload_packages() {
 					distro_string="OpenSuSE:"
 
 					typeset -i tmp_suse_major_version="0"
-					typeset -i tmp_suse_minor_version="-1"
-					tmp_suse_major_version="$(sed -e '/^\([0-9][0-9]*\)\.[0-9][0-9]*$/!d;s//\1/' <<< "${l_CODENAME}")"
-					tmp_suse_minor_version="$(sed -e '/^[0-9][0-9]*\.\([0-9][0-9]*\)$/!d;s//\1/' <<< "${l_CODENAME}")"
+					typeset -i tmp_suse_minor_version="0"
+					tmp_suse_major_version="$(get_suse_major_version "${l_CODENAME}")"
 
-					if [ "x${tmp_suse_major_version}" = "x0" ]; then
-						echo "Unable to extract SUSE version."
-						exit 1
+					if [ "${?}" -ne "0" ]; then
+						echo "Unable to extract major SUSE version."
+						exit "1"
+					fi
+
+					tmp_suse_minor_version="$(get_suse_minor_version "${l_CODENAME}")"
+
+					if [ "${?}" -ne "0" ]; then
+						echo "Unable to extract minor SUSE version."
+						exit "1"
 					fi
 
 					[ "${tmp_suse_major_version}" -gt "13" ] && distro_string="${distro_string}Leap:"

--
Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git


More information about the x2go-commits mailing list