[X2Go-Commits] [buildscripts] 04/12: bin/common.sh: add formerly SUSE-specific version fetching functions.

git-admin at x2go.org git-admin at x2go.org
Thu Apr 6 08:34:54 CEST 2017


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

x2go pushed a commit to branch master
in repository buildscripts.

commit 992236e7f5646f102ae86bb7e6a4b1e80c3a462c
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Thu Apr 6 08:26:05 2017 +0200

    bin/common.sh: add formerly SUSE-specific version fetching functions.
---
 bin/common.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/bin/common.sh b/bin/common.sh
index 4ea5345..7308857 100644
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -100,3 +100,45 @@ unlock_workspace () {
 delay_build () {
 	sleep "$(((${RANDOM} % 100) + 1))s"
 }
+
+# Fetches major version out of a generic 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_generic_major_version () {
+	typeset version="${1}"
+	typeset -i ret="0"
+
+	if [ -z "${version}" ]; then
+		ret="1"
+	else
+		typeset -i tmp_major_version="0"
+		tmp_major_version="$(sed -e '/^\([0-9][0-9]*\)\.[0-9][0-9]*$/!d;s//\1/' <<< "${version}")"
+
+		if [ "${tmp_major_version}" -ne "0" ]; then
+			echo "${tmp_major_version}"
+		fi
+	fi
+
+	return "${ret}"
+}
+
+# Fetches minor version out of a generic 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_generic_minor_version () {
+	typeset version="${1}"
+	typeset -i ret="0"
+
+	if [ -z "${version}" ]; then
+		ret="1"
+	else
+		typeset -i tmp_minor_version="-1"
+		tmp_minor_version="$(sed -e '/^[0-9][0-9]*\.\([0-9][0-9]*\)$/!d;s//\1/' <<< "${version}")"
+
+		echo "${tmp_minor_version}"
+	fi
+
+	return "${ret}"
+}

--
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