[Qa-jenkins-scm] [jenkins.debian.net] 01/03: refactor to make script more generally useful

Holger Levsen holger at layer-acht.org
Mon Apr 25 13:47:28 UTC 2016


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

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 1dc7cb84075d627295abb951c201b16f0699f7f6
Author: Holger Levsen <holger at layer-acht.org>
Date:   Mon Apr 25 15:22:53 2016 +0200

    refactor to make script more generally useful
---
 bin/diffoscope_distribution_test.sh | 50 +++++++++++++++++++++++++++++++++++++
 bin/diffoscope_pypi_test.sh         | 41 ------------------------------
 job-cfg/reproducible.yaml           |  2 +-
 3 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/bin/diffoscope_distribution_test.sh b/bin/diffoscope_distribution_test.sh
new file mode 100755
index 0000000..cbb7207
--- /dev/null
+++ b/bin/diffoscope_distribution_test.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Copyright 2014-2016 Holger Levsen <holger at layer-acht.org>
+# released under the GPLv=2
+
+DEBUG=false
+. /srv/jenkins/bin/common-functions.sh
+common_init "$@"
+
+check_pypi() {
+	TMPPYPI=$(mktemp -t diffoscope-distribution-XXXXXXXX)
+	# the following two lines are a bit fragile…
+	curl https://pypi.python.org/pypi/diffoscope/ -o $TMPPYPI
+	DIFFOSCOPE_IN_PYPI=$(grep "<title>" $TMPPYPI | cut -d ">" -f2- | cut -d ":" -f1 |cut -d " " -f2)
+	rm -f $TMPPYPI > /dev/null
+	echo
+	echo
+	if [ "$DIFFOSCOPE_IN_DEBIAN" = "$DIFFOSCOPE_IN_PYPI" ] ; then
+		echo "Yay. diffoscope in Debian has the same version as on PyPI: $DIFFOSCOPE_IN_DEBIAN"
+	elif dpkg --compare-versions "$DIFFOSCOPE_IN_DEBIAN" gt "$DIFFOSCOPE_IN_PYPI" ; then
+		echo "Fail: diffoscope in Debian: $DIFFOSCOPE_IN_DEBIAN"
+		echo "Fail: diffoscope in PyPI:   $DIFFOSCOPE_IN_PYPI"
+		exit 1
+	else
+		echo "diffoscope in Debian: $DIFFOSCOPE_IN_DEBIAN"
+		echo "diffoscope in PyPI:   $DIFFOSCOPE_IN_PYPI"
+		echo
+		echo "Failure is the default action…"
+		exit 1
+	fi
+}
+
+#
+# main
+#
+DIFFOSCOPE_IN_DEBIAN=$(rmadison diffoscope|egrep '(unstable|sid)'| awk '{print $3}' || true)
+
+case $1 in
+	pypi)	
+		DISTRIBUTION=$1
+		check_pypi
+		;;
+	*)
+		echo "Unsupported distribution."
+		exit 1
+		;;
+esac
+
+
+
diff --git a/bin/diffoscope_pypi_test.sh b/bin/diffoscope_pypi_test.sh
deleted file mode 100755
index d2fa0c8..0000000
--- a/bin/diffoscope_pypi_test.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-
-# Copyright 2014-2016 Holger Levsen <holger at layer-acht.org>
-# released under the GPLv=2
-
-DEBUG=false
-. /srv/jenkins/bin/common-functions.sh
-common_init "$@"
-
-cleanup_all() {
-	rm $TMPPYPI
-}
-
-#
-# main
-#
-TMPPYPI=$(mktemp -t diffoscope-pypi-XXXXXXXX)
-trap cleanup_all INT TERM EXIT
-
-DIFFOSCOPE_IN_DEBIAN=$(rmadison diffoscope|egrep '(unstable|sid)'| awk '{print $3}' || true)
-curl https://pypi.python.org/pypi/diffoscope/ -o $TMPPYPI
-DIFFOSCOPE_IN_PYPI=$(grep "<title>" $TMPPYPI | cut -d ">" -f2- | cut -d ":" -f1 |cut -d " " -f2)
-echo
-echo
-if [ "$DIFFOSCOPE_IN_DEBIAN" = "$DIFFOSCOPE_IN_PYPI" ] ; then
-	echo "Yay. diffoscope in Debian has the same version as on PyPI: $DIFFOSCOPE_IN_DEBIAN"
-elif dpkg --compare-versions "$DIFFOSCOPE_IN_DEBIAN" gt "$DIFFOSCOPE_IN_PYPI" ; then
-	echo "Fail: diffoscope in Debian: $DIFFOSCOPE_IN_DEBIAN"
-	echo "Fail: diffoscope in PyPI:   $DIFFOSCOPE_IN_PYPI"
-	exit 1
-else
-	echo "diffoscope in Debian: $DIFFOSCOPE_IN_DEBIAN"
-	echo "diffoscope in PyPI:   $DIFFOSCOPE_IN_PYPI"
-	echo
-	echo "Failure is the default action…"
-	exit 1
-fi
-
-# the end
-cleanup_all
-trap - INT TERM EXIT
diff --git a/job-cfg/reproducible.yaml b/job-cfg/reproducible.yaml
index f19fd32..dacf995 100644
--- a/job-cfg/reproducible.yaml
+++ b/job-cfg/reproducible.yaml
@@ -464,7 +464,7 @@
                 - 'diffoscope_pypi':
                     my_description: 'Test whether PyPI has the latest diffoscope.'
                     my_timed: '23 23 * * *'
-                    my_shell: '/srv/jenkins/bin/diffoscope_pypi_test.sh'
+                    my_shell: '/srv/jenkins/bin/diffoscope_distribution_test.sh pypi'
 
             my_shellext: ".sh"
             my_shell: '/srv/jenkins/bin/reproducible_{my_task}{my_shellext}'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list