[Qa-jenkins-scm] [jenkins.debian.net] 01/01: reproducible/openwrt|lede: ensure tmpdirs are removed after failed runs

Holger Levsen holger at layer-acht.org
Wed Aug 3 19:40:04 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 fa3ed47dd9da01e3e37b20457946d7e06e11ccb4
Author: Alexander Couzens <lynxis at fe80.eu>
Date:   Wed Aug 3 21:37:51 2016 +0200

    reproducible/openwrt|lede: ensure tmpdirs are removed after failed runs
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_lede.sh           |  6 +++---
 bin/reproducible_openwrt.sh        |  6 +++---
 bin/reproducible_openwrt_common.sh | 19 +++++++++++++++----
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/bin/reproducible_lede.sh b/bin/reproducible_lede.sh
index 57b8d2b..9767151 100755
--- a/bin/reproducible_lede.sh
+++ b/bin/reproducible_lede.sh
@@ -26,7 +26,7 @@ case $1 in
 		case $1 in
 			openwrt_build |\
 			openwrt_get_banner |\
-			openwrt_cleanup_tmpdirs) ;; # this is the allowed list
+			node_cleanup_tmpdirs) ;; # this is the allowed list
 			*)
 				echo "Unsupported remote node function $@"
 				exit 1
@@ -52,7 +52,7 @@ START=$(date +'%s')
 TMPBUILDDIR=$(mktemp --tmpdir=/srv/workspace/chroots/ -d -t rbuild-lede-build-${DATE}-XXXXXXXX)  # used to build on tmpfs
 TMPDIR=$(mktemp --tmpdir=/srv/reproducible-results -d -t rbuild-lede-results-XXXXXXXX)  # accessable in schroots, used to compare results
 BANNER_HTML=$(mktemp --tmpdir=$TMPDIR)
-trap cleanup_tmpdirs INT TERM EXIT
+trap master_cleanup_tmpdirs INT TERM EXIT
 
 cd $TMPBUILDDIR
 
@@ -250,5 +250,5 @@ irc_message reproducible-builds "$REPRODUCIBLE_URL/lede/ has been updated. ($GOO
 echo "============================================================================="
 
 # remove everything, we don't need it anymore...
-cleanup_tmpdirs
+master_cleanup_tmpdirs
 trap - INT TERM EXIT
diff --git a/bin/reproducible_openwrt.sh b/bin/reproducible_openwrt.sh
index dbc48c1..07f8679 100755
--- a/bin/reproducible_openwrt.sh
+++ b/bin/reproducible_openwrt.sh
@@ -26,7 +26,7 @@ case $1 in
 		case $1 in
 			openwrt_build |\
 			openwrt_get_banner |\
-			openwrt_cleanup_tmpdirs) ;; # this is the allowed list
+			node_cleanup_tmpdirs) ;; # this is the allowed list
 			*)
 				echo "Unsupported remote node function $@"
 				exit 1
@@ -52,7 +52,7 @@ START=$(date +'%s')
 TMPBUILDDIR=$(mktemp --tmpdir=/srv/workspace/chroots/ -d -t rbuild-openwrt-build-${DATE}-XXXXXXXX)  # used to build on tmpfs
 TMPDIR=$(mktemp --tmpdir=/srv/reproducible-results -d -t rbuild-openwrt-results-XXXXXXXX)  # accessable in schroots, used to compare results
 BANNER_HTML=$(mktemp --tmpdir=$TMPDIR)
-trap cleanup_tmpdirs INT TERM EXIT
+trap master_cleanup_tmpdirs INT TERM EXIT
 
 cd $TMPBUILDDIR
 
@@ -241,5 +241,5 @@ irc_message reproducible-builds "$REPRODUCIBLE_URL/openwrt/ has been updated. ($
 echo "============================================================================="
 
 # remove everything, we don't need it anymore...
-cleanup_tmpdirs
+master_cleanup_tmpdirs
 trap - INT TERM EXIT
diff --git a/bin/reproducible_openwrt_common.sh b/bin/reproducible_openwrt_common.sh
index 7a4a037..2041e98 100644
--- a/bin/reproducible_openwrt_common.sh
+++ b/bin/reproducible_openwrt_common.sh
@@ -9,8 +9,16 @@
 GENERIC_NODE1=profitbricks-build3-amd64.debian.net
 GENERIC_NODE2=profitbricks-build4-amd64.debian.net
 
+# run on jenkins master
+master_cleanup_tmpdirs() {
+	ssh $GENERIC_NODE1 reproducible_$TYPE node node_cleanup_tmpdirs $TMPDIR || true
+	ssh $GENERIC_NODE2 reproducible_$TYPE node node_cleanup_tmpdirs $TMPDIR || true
+	# cleanup local dirs
+	cleanup_tmpdirs
+}
+
 # only called direct on a remote build node
-openwrt_cleanup_tmpdirs() {
+node_cleanup_tmpdirs() {
 	export TMPDIR=$1
 	export TMPBUILDDIR=$TMPDIR/build
 	cleanup_tmpdirs
@@ -28,7 +36,9 @@ cleanup_tmpdirs() {
 	fi
 	rm -rf $TMPDIR
 	rm -rf $TMPBUILDDIR
-	rm -f $BANNER_HTML
+	if [ -f $BANNER_HTML ] ; then
+		rm -f $BANNER_HTML
+	fi
 }
 
 create_results_dirs() {
@@ -220,6 +230,7 @@ openwrt_build() {
 		exit 1
 	fi
 	mkdir -p $TMPBUILDDIR
+	trap cleanup_tmpdirs INT TERM EXIT
 
 	# we have also to set the TMP
 
@@ -269,7 +280,7 @@ build_two_times() {
 
 	# rsync back logs and images
 	rsync -a $GENERIC_NODE1:$TMPDIR/$RUN/ $TMPDIR/$RUN/
-	ssh $GENERIC_NODE1 reproducible_$TYPE node openwrt_cleanup_tmpdirs $TMPDIR
+	ssh $GENERIC_NODE1 reproducible_$TYPE node node_cleanup_tmpdirs $TMPDIR
 
 	## second run
 	RUN=b2
@@ -277,5 +288,5 @@ build_two_times() {
 
 	# rsync back logs and images
 	rsync -a $GENERIC_NODE2:$TMPDIR/$RUN/ $TMPDIR/$RUN/
-	ssh $GENERIC_NODE2 reproducible_$TYPE node openwrt_cleanup_tmpdirs $TMPDIR
+	ssh $GENERIC_NODE2 reproducible_$TYPE node node_cleanup_tmpdirs $TMPDIR
 }

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