[Qa-jenkins-scm] [jenkins.debian.net] 01/02: reproducible_lede: fix escaping and most of the shell shock warnings

Holger Levsen holger at layer-acht.org
Sat Jan 20 20:19:45 UTC 2018


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 54be1b3e0c6130e7ebbee56f63fd6750965a4c62
Author: Alexander Couzens <lynxis at fe80.eu>
Date:   Sat Nov 11 01:38:56 2017 +0100

    reproducible_lede: fix escaping and most of the shell shock warnings
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_lede.sh        | 128 ++++++++++++++++----------------
 bin/reproducible_lede_common.sh | 157 ++++++++++++++++++++--------------------
 2 files changed, 143 insertions(+), 142 deletions(-)

diff --git a/bin/reproducible_lede.sh b/bin/reproducible_lede.sh
index d7ebcd6..08c2cd0 100755
--- a/bin/reproducible_lede.sh
+++ b/bin/reproducible_lede.sh
@@ -20,7 +20,7 @@ common_init "$@"
 . /srv/jenkins/bin/reproducible_lede_common.sh
 set -e
 
-echo "$0 got called with '$@'"
+echo "$0 got called with '$*'"
 # this script is called from positions
 # * it's called from the reproducible_wrapper when running on the master
 # * it's called from reproducible_opewnrt_common when doing remote builds
@@ -36,11 +36,11 @@ case $1 in
 			node_save_logs |\
 			node_cleanup_tmpdirs) ;; # this is the allowed list
 			*)
-				echo "Unsupported remote node function $@"
+				echo "Unsupported remote node function $*"
 				exit 1
 				;;
 		esac
-		$@
+		"$@"
 		trap - INT TERM EXIT
 		exit 0
 	;;
@@ -50,7 +50,7 @@ case $1 in
 		LEDE_CONFIG=$3
 	;;
 	*)
-		echo "Unsupported mode $1. Arguments are $@"
+		echo "Unsupported mode $1. Arguments are $*"
 		exit 1
 	;;
 esac
@@ -60,12 +60,12 @@ esac
 #
 DATE=$(date -u +'%Y-%m-%d')
 START=$(date +'%s')
-TMPBUILDDIR=$(mktemp --tmpdir=/srv/workspace/chroots/ -d -t rbuild-lede-build-${DATE}-XXXXXXXX)  # used to build on tmpfs
+TMPBUILDDIR=$(mktemp --tmpdir=/srv/workspace/chroots/ -d -t "rbuild-lede-build-${DATE}-XXXXXXXX")  # used to build on tmpfs
 RESULTSDIR=$(mktemp --tmpdir=/srv/reproducible-results -d -t rbuild-lede-results-XXXXXXXX)  # accessable in schroots, used to compare results
-BANNER_HTML=$(mktemp --tmpdir=$RESULTSDIR)
+BANNER_HTML=$(mktemp "--tmpdir=$RESULTSDIR")
 trap master_cleanup_tmpdirs INT TERM EXIT
 
-cd $TMPBUILDDIR
+cd "$TMPBUILDDIR"
 
 create_results_dirs lede
 
@@ -86,23 +86,23 @@ echo "==========================================================================
 TOOLCHAIN_HTML=$RESULTSDIR/toolchain.html
 
 # clean up builddir to save space on tmpfs
-rm -rf $TMPBUILDDIR/lede
+rm -rf "$TMPBUILDDIR/lede"
 
 # run diffoscope on the results
 # (this needs refactoring rather badly)
 TIMEOUT="30m"
-DIFFOSCOPE="$(schroot --directory /tmp -c source:jenkins-reproducible-${DBDSUITE}-diffoscope diffoscope -- --version 2>&1)"
+DIFFOSCOPE="$(schroot --directory /tmp -c "source:jenkins-reproducible-${DBDSUITE}-diffoscope" diffoscope -- --version 2>&1)"
 echo "============================================================================="
 echo "$(date -u) - Running $DIFFOSCOPE on LEDE images and packages."
 echo "============================================================================="
-DBD_HTML=$(mktemp --tmpdir=$RESULTSDIR)
-DBD_GOOD_PKGS_HTML=$(mktemp --tmpdir=$RESULTSDIR)
-DBD_BAD_PKGS_HTML=$(mktemp --tmpdir=$RESULTSDIR)
+DBD_HTML=$(mktemp "--tmpdir=$RESULTSDIR")
+DBD_GOOD_PKGS_HTML=$(mktemp "--tmpdir=$RESULTSDIR")
+DBD_BAD_PKGS_HTML=$(mktemp "--tmpdir=$RESULTSDIR")
 # run diffoscope on the images
 GOOD_IMAGES=0
 ALL_IMAGES=0
 SIZE=""
-cd $RESULTSDIR/b1/targets
+cd "$RESULTSDIR/b1/targets"
 tree .
 
 # call_diffoscope requires TMPDIR
@@ -111,45 +111,45 @@ TMPDIR=$RESULTSDIR
 # iterate over all images (merge b1 and b2 images into one list)
 # call diffoscope on the images
 for target in * ; do
-	cd $target
+	cd "$target"
 	for subtarget in * ; do
-		cd $subtarget
+		cd "$subtarget"
 
 		# search images in both paths to find non-existing ones
-		IMGS1=$(find * -type f -name "*.bin" -o -name "*.squashfs" | sort -u )
-		pushd $RESULTSDIR/b2/targets/$target/$subtarget
-		IMGS2=$(find * -type f -name "*.bin" -o -name "*.squashfs" | sort -u )
+		IMGS1=$(find -- * -type f -name "*.bin" -o -name "*.squashfs" | sort -u )
+		pushd "$RESULTSDIR/b2/targets/$target/$subtarget"
+		IMGS2=$(find -- * -type f -name "*.bin" -o -name "*.squashfs" | sort -u )
 		popd
 
-		echo "       <table><tr><th>Images for <code>$target/$subtarget</code></th></tr>" >> $DBD_HTML
-		for image in $(printf "$IMGS1\n$IMGS2" | sort -u ) ; do
+		echo "       <table><tr><th>Images for <code>$target/$subtarget</code></th></tr>" >> "$DBD_HTML"
+		for image in $(printf "%s\n%s" "$IMGS1" "$IMGS2" | sort -u ) ; do
 			let ALL_IMAGES+=1
-			if [ ! -f $RESULTSDIR/b1/targets/$target/$subtarget/$image -o ! -f $RESULTSDIR/b2/targets/$target/$subtarget/$image ] ; then
-				echo "         <tr><td><img src=\"/userContent/static/weather-storm.png\" alt=\"ftbfs icon\" /> $image (${SIZE}) failed to build.</td></tr>" >> $DBD_HTML
-				rm -f $BASE/lede/dbd/targets/$target/$subtarget/$image.html # cleanup from previous (unreproducible) tests - if needed
+			if [ ! -f "$RESULTSDIR/b1/targets/$target/$subtarget/$image" ] || [ ! -f "$RESULTSDIR/b2/targets/$target/$subtarget/$image" ] ; then
+				echo "         <tr><td><img src=\"/userContent/static/weather-storm.png\" alt=\"ftbfs icon\" /> $image (${SIZE}) failed to build.</td></tr>" >> "$DBD_HTML"
+				rm -f "$BASE/lede/dbd/targets/$target/$subtarget/$image.html" # cleanup from previous (unreproducible) tests - if needed
 				continue
 			fi
 
 			if [ "$(sha256sum "$RESULTSDIR/b1/targets/$target/$subtarget/$image" "$RESULTSDIR/b2/targets/$target/$subtarget/$image" \
 				| cut -f 1 -d ' ' | uniq -c  | wc -l)" != "1" ] ; then
-				call_diffoscope targets/$target/$subtarget $image
+				call_diffoscope "targets/$target/$subtarget" "$image"
 			else
 				echo "$(date -u) - targets/$target/$subtarget/$image is reproducible, yip!"
 			fi
-			get_filesize $image
-			if [ -f $RESULTSDIR/targets/$target/$subtarget/$image.html ] ; then
-				mkdir -p $BASE/lede/dbd/targets/$target/$subtarget
-				mv $RESULTSDIR/targets/$target/$subtarget/$image.html $BASE/lede/dbd/targets/$target/$subtarget/$image.html
-				echo "         <tr><td><a href=\"dbd/targets/$target/$subtarget/$image.html\"><img src=\"/userContent/static/weather-showers-scattered.png\" alt=\"unreproducible icon\" /> $image</a> (${SIZE}) is unreproducible.</td></tr>" >> $DBD_HTML
+			get_filesize "$image"
+			if [ -f "$RESULTSDIR/targets/$target/$subtarget/$image.html" ] ; then
+				mkdir -p "$BASE/lede/dbd/targets/$target/$subtarget"
+				mv "$RESULTSDIR/targets/$target/$subtarget/$image.html" "$BASE/lede/dbd/targets/$target/$subtarget/$image.html"
+				echo "         <tr><td><a href=\"dbd/targets/$target/$subtarget/$image.html\"><img src=\"/userContent/static/weather-showers-scattered.png\" alt=\"unreproducible icon\" /> $image</a> (${SIZE}) is unreproducible.</td></tr>" >> "$DBD_HTML"
 			else
-				SHASUM=$(sha256sum $image|cut -d " " -f1)
-				echo "         <tr><td><img src=\"/userContent/static/weather-clear.png\" alt=\"reproducible icon\" /> $image ($SHASUM, $SIZE) is reproducible.</td></tr>" >> $DBD_HTML
+				SHASUM=$(sha256sum "$image" |cut -d " " -f1)
+				echo "         <tr><td><img src=\"/userContent/static/weather-clear.png\" alt=\"reproducible icon\" /> $image ($SHASUM, $SIZE) is reproducible.</td></tr>" >> "$DBD_HTML"
 				let GOOD_IMAGES+=1
-				rm -f $BASE/lede/dbd/targets/$target/$subtarget/$image.html # cleanup from previous (unreproducible) tests - if needed
+				rm -f "$BASE/lede/dbd/targets/$target/$subtarget/$image.html" # cleanup from previous (unreproducible) tests - if needed
 			fi
 		done
 		cd ..
-		echo "       </table>" >> $DBD_HTML
+		echo "       </table>" >> "$DBD_HTML"
 	done
 	cd ..
 done
@@ -157,49 +157,49 @@ GOOD_PERCENT_IMAGES=$(echo "scale=1 ; ($GOOD_IMAGES*100/$ALL_IMAGES)" | bc)
 # run diffoscope on the packages
 GOOD_PACKAGES=0
 ALL_PACKAGES=0
-cd $RESULTSDIR/b1
+cd "$RESULTSDIR/b1"
 for i in * ; do
-	cd $i
+	cd "$i"
 
 	# search packages in both paths to find non-existing ones
-	PKGS1=$(find * -type f -name "*.ipk" | sort -u )
-	pushd $RESULTSDIR/b2/$i
-	PKGS2=$(find * -type f -name "*.ipk" | sort -u )
+	PKGS1=$(find -- * -type f -name "*.ipk" | sort -u )
+	pushd "$RESULTSDIR/b2/$i"
+	PKGS2=$(find -- * -type f -name "*.ipk" | sort -u )
 	popd
 
-	for j in $(printf "$PKGS1\n$PKGS2" | sort -u ) ; do
+	for j in $(printf "%s\n%s" "$PKGS1" "$PKGS2" | sort -u ) ; do
 		let ALL_PACKAGES+=1
-		if [ ! -f $RESULTSDIR/b1/$i/$j -o ! -f $RESULTSDIR/b2/$i/$j ] ; then
-			echo "         <tr><td><img src=\"/userContent/static/weather-storm.png\" alt=\"ftbfs icon\" /> $j (${SIZE}) failed to build.</td></tr>" >> $DBD_BAD_PKGS_HTML
-			rm -f $BASE/lede/dbd/$i/$j.html # cleanup from previous (unreproducible) tests - if needed
+		if [ ! -f "$RESULTSDIR/b1/$i/$j" ] || [ ! -f "$RESULTSDIR/b2/$i/$j" ] ; then
+			echo "         <tr><td><img src=\"/userContent/static/weather-storm.png\" alt=\"ftbfs icon\" /> $j (${SIZE}) failed to build.</td></tr>" >> "$DBD_BAD_PKGS_HTML"
+			rm -f "$BASE/lede/dbd/$i/$j.html" # cleanup from previous (unreproducible) tests - if needed
 			continue
 		fi
 
-		if [ "$(sha256sum $RESULTSDIR/b1/$i/$j $RESULTSDIR/b2/$i/$j | cut -f 1 -d ' ' | uniq -c  | wc -l)" != "1" ] ; then
-			call_diffoscope $i $j
+		if [ "$(sha256sum "$RESULTSDIR/b1/$i/$j" "$RESULTSDIR/b2/$i/$j" | cut -f 1 -d ' ' | uniq -c  | wc -l)" != "1" ] ; then
+			call_diffoscope "$i" "$j"
 		else
 			echo "$(date -u) - $i/$j is reproducible, yip!"
 		fi
-		get_filesize $j
-		if [ -f $RESULTSDIR/$i/$j.html ] ; then
-			mkdir -p $BASE/lede/dbd/$i/$(dirname $j)
-			mv $RESULTSDIR/$i/$j.html $BASE/lede/dbd/$i/$j.html
-			echo "         <tr><td><a href=\"dbd/$i/$j.html\"><img src=\"/userContent/static/weather-showers-scattered.png\" alt=\"unreproducible icon\" /> $j</a> ($SIZE) is unreproducible.</td></tr>" >> $DBD_BAD_PKGS_HTML
+		get_filesize "$j"
+		if [ -f "$RESULTSDIR/$i/$j.html" ] ; then
+			mkdir -p "$BASE/lede/dbd/$i/$(dirname "$j")"
+			mv "$RESULTSDIR/$i/$j.html" "$BASE/lede/dbd/$i/$j.html"
+			echo "         <tr><td><a href=\"dbd/$i/$j.html\"><img src=\"/userContent/static/weather-showers-scattered.png\" alt=\"unreproducible icon\" /> $j</a> ($SIZE) is unreproducible.</td></tr>" >> "$DBD_BAD_PKGS_HTML"
 		else
-			SHASUM=$(sha256sum $j|cut -d " " -f1)
-			echo "         <tr><td><img src=\"/userContent/static/weather-clear.png\" alt=\"reproducible icon\" /> $j ($SHASUM, $SIZE) is reproducible.</td></tr>" >> $DBD_GOOD_PKGS_HTML
+			SHASUM=$(sha256sum "$j" |cut -d " " -f1)
+			echo "         <tr><td><img src=\"/userContent/static/weather-clear.png\" alt=\"reproducible icon\" /> $j ($SHASUM, $SIZE) is reproducible.</td></tr>" >> "$DBD_GOOD_PKGS_HTML"
 			let GOOD_PACKAGES+=1
-			rm -f $BASE/lede/dbd/$i/$j.html # cleanup from previous (unreproducible) tests - if needed
+			rm -f "$BASE/lede/dbd/$i/$j.html" # cleanup from previous (unreproducible) tests - if needed
 		fi
 	done
 	cd ..
 done
-echo "       <table><tr><th>Unreproducible and otherwise broken packages</th></tr>" >> $DBD_HTML
-cat $DBD_BAD_PKGS_HTML >> $DBD_HTML
-echo "       </table>" >> $DBD_HTML
-echo "       <table><tr><th>Reproducible packages</th></tr>" >> $DBD_HTML
-cat $DBD_GOOD_PKGS_HTML >> $DBD_HTML
-echo "       </table>" >> $DBD_HTML
+echo "       <table><tr><th>Unreproducible and otherwise broken packages</th></tr>" >> "$DBD_HTML"
+cat "$DBD_BAD_PKGS_HTML" >> "$DBD_HTML"
+echo "       </table>" >> "$DBD_HTML"
+echo "       <table><tr><th>Reproducible packages</th></tr>" >> "$DBD_HTML"
+cat "$DBD_GOOD_PKGS_HTML" >> "$DBD_HTML"
+echo "       </table>" >> "$DBD_HTML"
 GOOD_PERCENT_PACKAGES=$(echo "scale=1 ; ($GOOD_PACKAGES*100/$ALL_PACKAGES)" | bc)
 # are we there yet?
 if [ "$GOOD_PERCENT_IMAGES" = "100.0" ] || [ "$GOOD_PERCENT_PACKAGES" = "100.0" ]; then
@@ -211,9 +211,9 @@ fi
 #
 #  finally create the webpage
 #
-cd $RESULTSDIR ; mkdir lede
+cd "$RESULTSDIR" ; mkdir lede
 PAGE=lede/lede_$LEDE_TARGET.html
-cat > $PAGE <<- EOF
+cat > "$PAGE" <<- EOF
 <!DOCTYPE html>
 <html lang="en-US">
   <head>
@@ -230,7 +230,7 @@ cat > $PAGE <<- EOF
     <div id="content">
         <pre>
 EOF
-cat $BANNER_HTML >> $PAGE
+cat "$BANNER_HTML" >> "$PAGE"
 write_page "       </pre>"
 write_page "     </div><div id=\"main-content\">"
 write_page "       <h1>LEDE - <em>reproducible</em> wireless freedom$MAGIC_SIGN</h1>"
@@ -238,12 +238,12 @@ write_page_intro LEDE
 write_page "       <p>$GOOD_IMAGES ($GOOD_PERCENT_IMAGES%) out of $ALL_IMAGES built images and $GOOD_PACKAGES ($GOOD_PERCENT_PACKAGES%) out of $ALL_PACKAGES built packages were reproducible in our test setup."
 write_page "        These tests were last run on $DATE for version ${OPENWRT_VERSION} using ${DIFFOSCOPE}.</p>"
 write_variation_table LEDE
-cat $DBD_HTML >> $PAGE
-cat $TOOLCHAIN_HTML >> $PAGE
+cat "$DBD_HTML" >> "$PAGE"
+cat "$TOOLCHAIN_HTML" >> "$PAGE"
 write_page "    </div>"
 write_page_footer LEDE
 publish_page
-rm -f $DBD_HTML $DBD_GOOD_PKGS_HTML $DBD_BAD_PKGS_HTML $TOOLCHAIN_HTML $BANNER_HTML
+rm -f "$DBD_HTML" "$DBD_GOOD_PKGS_HTML" "$DBD_BAD_PKGS_HTML" "$TOOLCHAIN_HTML" "$BANNER_HTML"
 
 # the end
 calculate_build_duration
diff --git a/bin/reproducible_lede_common.sh b/bin/reproducible_lede_common.sh
index 0ff70ec..d0e35ad 100644
--- a/bin/reproducible_lede_common.sh
+++ b/bin/reproducible_lede_common.sh
@@ -25,7 +25,7 @@ node_cleanup_tmpdirs() {
 		echo "Something very strange with \$TMPBUILDDIR=$TMPBUILDDIR exiting instead of doing cleanup."
 		exit 1
 	fi
-	rm -rf $TMPBUILDDIR
+	rm -rf "$TMPBUILDDIR"
 }
 
 node_create_tmpdirs() {
@@ -35,7 +35,7 @@ node_create_tmpdirs() {
 		echo "Something very strange with \$TMPBUILDDIR=$TMPBUILDDIR exiting instead of doing create."
 		exit 1
 	fi
-	mkdir -p $TMPBUILDDIR/download
+	mkdir -p "$TMPBUILDDIR/download"
 }
 
 # called as trap handler and also to cleanup after a success build
@@ -44,16 +44,16 @@ master_cleanup_tmpdirs() {
 	# in a success build the logs are saved on a different function
 	if [ "$1" != "success" ] ; then
 		# job failed
-		ssh $GENERIC_NODE1 reproducible_$TYPE node node_save_logs $TMPBUILDDIR || true
-		ssh $GENERIC_NODE2 reproducible_$TYPE node node_save_logs $TMPBUILDDIR || true
+		ssh "$GENERIC_NODE1" "reproducible_$TYPE" node node_save_logs "$TMPBUILDDIR" || true
+		ssh "$GENERIC_NODE2" "reproducible_$TYPE" node node_save_logs "$TMPBUILDDIR" || true
 		# save failure logs
-		mkdir -p $WORKSPACE/results/
-		rsync -av $GENERIC_NODE1:$RESULTSDIR/build_logs.tar.xz $WORKSPACE/results/build_logs_b1.tar.xz || true
-		rsync -av $GENERIC_NODE2:$RESULTSDIR/build_logs.tar.xz $WORKSPACE/results/build_logs_b2.tar.xz || true
+		mkdir -p "$WORKSPACE/results/"
+		rsync -av "$GENERIC_NODE1:$RESULTSDIR/build_logs.tar.xz" "$WORKSPACE/results/build_logs_b1.tar.xz" || true
+		rsync -av "$GENERIC_NODE2:$RESULTSDIR/build_logs.tar.xz" "$WORKSPACE/results/build_logs_b2.tar.xz" || true
 	fi
 
-	ssh $GENERIC_NODE1 reproducible_$TYPE node node_cleanup_tmpdirs $TMPBUILDDIR || true
-	ssh $GENERIC_NODE2 reproducible_$TYPE node node_cleanup_tmpdirs $TMPBUILDDIR || true
+	ssh "$GENERIC_NODE1" "reproducible_$TYPE" node node_cleanup_tmpdirs "$TMPBUILDDIR" || true
+	ssh "$GENERIC_NODE2" "reproducible_$TYPE" node node_cleanup_tmpdirs "$TMPBUILDDIR" || true
 
 	cd
 	# (very simple) check we are deleting the right stuff
@@ -62,50 +62,50 @@ master_cleanup_tmpdirs() {
 		echo "Something very strange with \$RESULTSDIR=$RESULTSDIR or \$TMPBUILDDIR=$TMPBUILDDIR, exiting instead of doing cleanup."
 		exit 1
 	fi
-	rm -rf $RESULTSDIR
-	rm -rf $TMPBUILDDIR
-	if [ -f $BANNER_HTML ] ; then
-		rm -f $BANNER_HTML
+	rm -rf "$RESULTSDIR"
+	rm -rf "$TMPBUILDDIR"
+	if [ -f "$BANNER_HTML" ] ; then
+		rm -f "$BANNER_HTML"
 	fi
 }
 
 create_results_dirs() {
 	local project=$1
-	mkdir -p $BASE/$project/dbd
+	mkdir -p "$BASE/$project/dbd"
 }
 
 node_document_environment() {
 	local tmpdir=$1
 	local toolchain_html=$tmpdir/toolchain.html
 
-	cd $tmpdir/build/source
-	cat /dev/null > $toolchain_html
-	echo "     <table><tr><th>git commit built</th></tr><tr><td><code>" >> $toolchain_html
-	git log -1 >> $toolchain_html
-	echo "     </code></td></tr></table>" >> $toolchain_html
+	cd "$tmpdir/build/source"
+	cat /dev/null > "$toolchain_html"
+	echo "     <table><tr><th>git commit built</th></tr><tr><td><code>" >> "$toolchain_html"
+	git log -1 >> "$toolchain_html"
+	echo "     </code></td></tr></table>" >> "$toolchain_html"
 
-	echo "<table><tr><th>Target toolchains built</th></tr>" >> $toolchain_html
+	echo "<table><tr><th>Target toolchains built</th></tr>" >> "$toolchain_html"
 	for i in $(ls -1d staging_dir/toolchain*|cut -d "-" -f2-|xargs echo) ; do
-		echo " <tr><td><code>$i</code></td></tr>" >> $toolchain_html
+		echo " <tr><td><code>$i</code></td></tr>" >> "$toolchain_html"
 	done
-	echo "</table>" >> $toolchain_html
-	echo "<table><tr><th>Contents of <code>build_dir/host/</code></th></tr>" >> $toolchain_html
+	echo "</table>" >> "$toolchain_html"
+	echo "<table><tr><th>Contents of <code>build_dir/host/</code></th></tr>" >> "$toolchain_html"
 	for i in $(ls -1 build_dir/host/) ; do
-		echo " <tr><td>$i</td></tr>" >> $toolchain_html
+		echo " <tr><td>$i</td></tr>" >> "$toolchain_html"
 	done
-	echo "</table>" >> $toolchain_html
-	echo "<table><tr><th>Downloaded software</th></tr>" >> $toolchain_html
+	echo "</table>" >> "$toolchain_html"
+	echo "<table><tr><th>Downloaded software</th></tr>" >> "$toolchain_html"
 	for i in $(ls -1 dl/) ; do
-		echo " <tr><td>$i</td></tr>" >> $toolchain_html
+		echo " <tr><td>$i</td></tr>" >> "$toolchain_html"
 	done
-	echo "</table>" >> $toolchain_html
-	echo "<table><tr><th>Debian $(cat /etc/debian_version) package on $(dpkg --print-architecture)</th><th>installed version</th></tr>" >> $toolchain_html
+	echo "</table>" >> "$toolchain_html"
+	echo "<table><tr><th>Debian $(cat /etc/debian_version) package on $(dpkg --print-architecture)</th><th>installed version</th></tr>" >> "$toolchain_html"
 	for i in gcc binutils bzip2 flex python perl make findutils grep diffutils unzip gawk util-linux zlib1g-dev libc6-dev git subversion ; do
-		echo " <tr><td>$i</td><td>" >> $toolchain_html
-		dpkg -s $i|grep '^Version'|cut -d " " -f2 >> $toolchain_html
-		echo " </td></tr>" >> $toolchain_html
+		echo " <tr><td>$i</td><td>" >> "$toolchain_html"
+		dpkg -s $i|grep '^Version'|cut -d " " -f2 >> "$toolchain_html"
+		echo " </td></tr>" >> "$toolchain_html"
 	done
-	echo "</table>" >> $toolchain_html
+	echo "</table>" >> "$toolchain_html"
 	cd -
 }
 
@@ -126,7 +126,7 @@ node_save_logs() {
 		tar cJf "$tmpdir/build_logs.tar.xz" -C "$tmpdir/build/source" ./logs
 	fi
 
-	node_document_environment $tmpdir
+	node_document_environment "$tmpdir"
 }
 
 # RUN - is b1 or b2. b1 for first run, b2 for second
@@ -138,14 +138,14 @@ save_lede_results() {
 	# first save all images and target specific packages
 	pushd bin/targets
 	for target in * ; do
-		pushd $target || continue
+		pushd "$target" || continue
 		for subtarget in * ; do
-			pushd $subtarget || continue
+			pushd "$subtarget" || continue
 
 			# save firmware images
-			mkdir -p $TMPDIR/$RUN/targets/$target/$subtarget/
+			mkdir -p "$TMPDIR/$RUN/targets/$target/$subtarget/"
 			for image in $(find * -name "*.bin" -o -name "*.squashfs") ; do
-				cp -p $image $TMPDIR/$RUN/targets/$target/$subtarget/
+				cp -p "$image" "$TMPDIR/$RUN/targets/$target/$subtarget/"
 			done
 
 			# save subtarget specific packages
@@ -167,12 +167,12 @@ save_lede_results() {
 	# arch is like mips_34kc_dsp
 	pushd bin/packages/
 	for arch in * ; do
-		pushd $arch || continue
+		pushd "$arch" || continue
 		for feed in * ; do
-			pushd $feed || continue
+			pushd "$feed" || continue
 			for package in $(find * -name "*.ipk") ; do
-				mkdir -p $TMPDIR/$RUN/packages/$arch/$feed/$(dirname $package)
-				cp -p $package $TMPDIR/$RUN/packages/$arch/$feed/$(dirname $package)/
+				mkdir -p "$TMPDIR/$RUN/packages/$arch/$feed/$(dirname "$package")"
+				cp -p "$package" "$TMPDIR/$RUN/packages/$arch/$feed/$(dirname "$package")/"
 			done
 			popd
 		done
@@ -187,17 +187,17 @@ save_openwrt_results() {
 	RUN=$1
 	cd bin
 	for i in * ; do
-		cd $i
+		cd "$i"
 		# save images
-		mkdir -p $TMPDIR/$RUN/$i
+		mkdir -p "$TMPDIR/$RUN/$i"
 		for j in $(find * -name "*.bin" -o -name "*.squashfs") ; do
-			cp -p $j $TMPDIR/$RUN/$i/
+			cp -p "$j" "$TMPDIR/$RUN/$i/"
 		done
 		# save packages
 		cd packages
 		for j in $(find * -name "*.ipk") ; do
-			mkdir -p $TMPDIR/$RUN/$i/$(dirname $j)
-			cp -p $j $TMPDIR/$RUN/$i/$(dirname $j)/
+			mkdir -p "$TMPDIR/$RUN/$i/$(dirname "$j")"
+			cp -p "$j" "$TMPDIR/$RUN/$i/$(dirname "$j")/"
 		done
 		cd ../..
 	done
@@ -223,7 +223,7 @@ openwrt_apply_variations() {
 		# umask 0002
 
 		# use allmost all cores for second build
-		export NEW_NUM_CPU=$(echo $NUM_CPU-1|bc)
+		export NEW_NUM_CPU=$(echo "$NUM_CPU-1" | bc)
 		export MAKE=make
 	fi
 }
@@ -313,13 +313,13 @@ openwrt_download() {
 	local TMPBUILDDIR=$3
 	local tries=5
 
-	cd $TMPBUILDDIR/download
+	cd "$TMPBUILDDIR/download"
 
 	# checkout the repo
 	echo "================================================================================"
 	echo "$(date -u) - Cloning git repository from $OPENWRT_GIT_REPO $OPENWRT_GIT_BRANCH. "
 	echo "================================================================================"
-	git clone -b $OPENWRT_GIT_BRANCH $OPENWRT_GIT_REPO source
+	git clone -b "$OPENWRT_GIT_BRANCH" "$OPENWRT_GIT_REPO" source
 	cd source
 
 	echo "================================================================================"
@@ -334,8 +334,8 @@ openwrt_download() {
 	./scripts/feeds install -a
 
 	# configure openwrt because otherwise it wont download everything
-	openwrt_config $CONFIG
-	while ! make tools/tar/compile download -j $NUM_CPU IGNORE_ERRORS=ym BUILD_LOG=1 ; do
+	openwrt_config "$CONFIG"
+	while ! make tools/tar/compile download -j "$NUM_CPU" IGNORE_ERRORS=ym BUILD_LOG=1 ; do
 		tries=$((tries - 1))
 		if [ $tries -eq 0 ] ; then
 			echo "================================================================================"
@@ -349,7 +349,7 @@ openwrt_download() {
 openwrt_get_banner() {
 	local TMPDIR=$1
 	local TYPE=$2
-	cd $TMPDIR/build/source
+	cd "$TMPDIR/build/source"
 	echo "===bannerbegin==="
 	find staging_dir/ -name banner | grep etc/banner|head -1| xargs cat /dev/null
 	echo "===bannerend==="
@@ -373,18 +373,18 @@ openwrt_build() {
 	mv "$TMPDIR/download" "$TMPBUILDDIR"
 
 	# openwrt/lede is checkouted under /download
-	cd $TMPBUILDDIR/source
+	cd "$TMPBUILDDIR/source"
 
 	# set tz, date, core, ..
-	openwrt_apply_variations $RUN
+	openwrt_apply_variations "$RUN"
 
 	openwrt_build_toolchain
 	# build images and packages
-	openwrt_compile $TYPE $RUN $TARGET
+	openwrt_compile "$TYPE" "$RUN" "$TARGET"
 
 	# save the results
-	[ "$TYPE" = "lede" ] && save_lede_results $RUN
-	[ "$TYPE" = "openwrt" ] && save_openwrt_results $RUN
+	[ "$TYPE" = "lede" ] && save_lede_results "$RUN"
+	[ "$TYPE" = "openwrt" ] && save_openwrt_results "$RUN"
 
 	# copy logs
 	node_save_logs "$TMPDIR"
@@ -401,46 +401,47 @@ build_two_times() {
 	CONFIG=$3
 
 	# create openwrt
-	ssh $GENERIC_NODE1 reproducible_$TYPE node node_create_tmpdirs $TMPBUILDDIR
-	ssh $GENERIC_NODE2 reproducible_$TYPE node node_create_tmpdirs $TMPBUILDDIR
-	mkdir -p $TMPBUILDDIR/download/
+	ssh "$GENERIC_NODE1" "reproducible_$TYPE" node node_create_tmpdirs "$TMPBUILDDIR"
+	ssh "$GENERIC_NODE2" "reproducible_$TYPE" node node_create_tmpdirs "$TMPBUILDDIR"
+	mkdir -p "$TMPBUILDDIR/download/"
 
 	# create results directory saved by jenkins as artifacts
-	mkdir -p $WORKSPACE/results/
+	mkdir -p "$WORKSPACE/results/"
 
 	# download and prepare openwrt on node b1
-	ssh $GENERIC_NODE1 reproducible_$TYPE node openwrt_download $TARGET $CONFIG $TMPBUILDDIR
+	ssh "$GENERIC_NODE1" "reproducible_$TYPE" node openwrt_download "$TARGET" "$CONFIG" "$TMPBUILDDIR"
 
 	echo "== master"
 	ls -la "$TMPBUILDDIR/download/" || true
 	echo "== node1"
-	ssh $GENERIC_NODE1 reproducible_$TYPE node node_debug $TMPBUILDDIR
+	ssh "$GENERIC_NODE1" "reproducible_$TYPE" node node_debug "$TMPBUILDDIR"
 	echo "== node2"
-	ssh $GENERIC_NODE2 reproducible_$TYPE node node_debug $TMPBUILDDIR
+	ssh "$GENERIC_NODE2" "reproducible_$TYPE" node node_debug "$TMPBUILDDIR"
 
-	rsync -a $GENERIC_NODE1:$TMPBUILDDIR/download/ $TMPBUILDDIR/download/
-	rsync -a $TMPBUILDDIR/download/ $GENERIC_NODE2:$TMPBUILDDIR/download/
+	rsync -a "$GENERIC_NODE1:$TMPBUILDDIR/download/" "$TMPBUILDDIR/download/"
+	rsync -a "$TMPBUILDDIR/download/" "$GENERIC_NODE2:$TMPBUILDDIR/download/"
 
 	## first run
 	RUN=b1
-	ssh $GENERIC_NODE1 reproducible_$TYPE node openwrt_build $TYPE $RUN $TARGET $CONFIG $TMPBUILDDIR
-	ssh $GENERIC_NODE1 reproducible_$TYPE node openwrt_get_banner $TMPBUILDDIR $TYPE > $BANNER_HTML
+	ssh "$GENERIC_NODE1" "reproducible_$TYPE" node openwrt_build "$TYPE" "$RUN" "$TARGET" "$CONFIG" "$TMPBUILDDIR"
+	ssh "$GENERIC_NODE1" "reproducible_$TYPE" node openwrt_get_banner "$TMPBUILDDIR" "$TYPE" > "$BANNER_HTML"
 	# cut away everything before begin and after the end…
 	# (thats noise generated by the way we run this via reproducible_common.sh)
-	cat $BANNER_HTML | sed '/===bannerend===/,$d' | tac | sed '/===bannerbegin===/,$d' | tac > $BANNER_HTML
+	cat "$BANNER_HTML" | sed '/===bannerend===/,$d' | tac | sed '/===bannerbegin===/,$d' | tac > "$BANNER_HTML.out"
+    mv "$BANNER_HTML".out "$BANNER_HTML"
 
 	# rsync back logs and images
-	rsync -av $GENERIC_NODE1:$TMPBUILDDIR/$RUN/ $RESULTSDIR/$RUN/
-	rsync -av $GENERIC_NODE1:$TMPBUILDDIR/build_logs.tar.xz $WORKSPACE/results/build_logs_b1.tar.xz
-	rsync -av $GENERIC_NODE1:$TMPBUILDDIR/toolchain.html $RESULTSDIR/toolchain.html
-	ssh $GENERIC_NODE1 reproducible_$TYPE node node_cleanup_tmpdirs $TMPBUILDDIR
+	rsync -av "$GENERIC_NODE1:$TMPBUILDDIR/$RUN/" "$RESULTSDIR/$RUN/"
+	rsync -av "$GENERIC_NODE1:$TMPBUILDDIR/build_logs.tar.xz" "$WORKSPACE/results/build_logs_b1.tar.xz"
+	rsync -av "$GENERIC_NODE1:$TMPBUILDDIR/toolchain.html" "$RESULTSDIR/toolchain.html"
+	ssh "$GENERIC_NODE1" "reproducible_$TYPE" node node_cleanup_tmpdirs "$TMPBUILDDIR"
 
 	## second run
 	RUN=b2
-	ssh $GENERIC_NODE2 reproducible_$TYPE node openwrt_build $TYPE $RUN $TARGET $CONFIG $TMPBUILDDIR
+	ssh "$GENERIC_NODE2" "reproducible_$TYPE" node openwrt_build "$TYPE" "$RUN" "$TARGET" "$CONFIG" "$TMPBUILDDIR"
 
 	# rsync back logs and images
-	rsync -av $GENERIC_NODE2:$TMPBUILDDIR/$RUN/ $RESULTSDIR/$RUN/
-	rsync -av $GENERIC_NODE2:$TMPBUILDDIR/build_logs.tar.xz $WORKSPACE/results/build_logs_b2.tar.xz
-	ssh $GENERIC_NODE2 reproducible_$TYPE node node_cleanup_tmpdirs $TMPBUILDDIR
+	rsync -av "$GENERIC_NODE2:$TMPBUILDDIR/$RUN/" "$RESULTSDIR/$RUN/"
+	rsync -av "$GENERIC_NODE2:$TMPBUILDDIR/build_logs.tar.xz" "$WORKSPACE/results/build_logs_b2.tar.xz"
+	ssh "$GENERIC_NODE2" "reproducible_$TYPE" node node_cleanup_tmpdirs "$TMPBUILDDIR"
 }

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