[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] 4 commits: reproducible Debian live: refactoring

Holger Levsen (@holger) gitlab at salsa.debian.org
Fri Sep 16 21:56:16 BST 2022



Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net


Commits:
24f1e880 by Holger Levsen at 2022-09-16T22:29:46+02:00
reproducible Debian live: refactoring

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
90b43eeb by Holger Levsen at 2022-09-16T22:40:10+02:00
reproducible Debian live: document ssh trickery and make it a bit more secure

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
f3e5437d by Holger Levsen at 2022-09-16T22:54:28+02:00
reproducible Debian live: refactoring

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -
2eaf0515 by Holger Levsen at 2022-09-16T22:56:05+02:00
reproducible Debian live: refactoring

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


2 changed files:

- bin/reproducible_debian_live_build.sh
- bin/reproducible_debian_live_sync_result.sh


Changes:

=====================================
bin/reproducible_debian_live_build.sh
=====================================
@@ -16,25 +16,41 @@ common_init "$@"
 set -e
 set -o pipefail # see eg http://petereisentraut.blogspot.com/2010/11/pipefail.html
 
+# always cleanup
+cleanup() {
+	local RESULT=$1
+	publish_results $RESULT
+	output_echo "Cleanup ${RESULT}"
+	# Cleanup the workspace
+	if [ ! -z "${BUILDDIR}" ]; then
+		sudo rm -rf --one-file-system ${BUILDDIR}
+	fi
+	# Cleanup the results
+	if [ ! -z "${RESULTSDIR}" ]; then
+		rm -rf --one-file-system ${RESULTSDIR}
+	fi
+}
+
 # Copy a single file to the web server
 #
 # Argument 1 = description (one word)
 # Argument 2 = absolute path of a file that will be published on the web server
 # Argument 3 = filename for the published file
 publish_file() {
-	local DESCRIPTION=$1
-	local ORIGINAL_FILE=$2
-	local PUBLISHED_NAME
-	PUBLISHED_NAME=$(basename "$3")
+	local ACTION=$1
+	local DESCRIPTION=$2
+	local ORIGINAL_FILE=$3
+	local PUBLISHED_NAME=$(basename "$4")
 
-	ssh jenkins at jenkins.debian.net "${DESCRIPTION}" "${ORIGINAL_FILE}" "${PUBLISHED_NAME}"
+	# this uses bin/reproducible_debian_live_sync_result.sh via ~/.ssh/authorized_keys
+	ssh jenkins at jenkins.debian.net "${ACTION}" "${DESCRIPTION}" "${ORIGINAL_FILE}" "${PUBLISHED_NAME}"
 }
 
-cleanup() {
+publish_results() {
 	local RESULT=$1
-	output_echo "Publishing results."
+	output_echo "Publishing results: ${RESULT}"
 
-	# Remove previously published files if they exist
+	# Remotely remove previously published files if they don't exist locally
 	[ ! -f ${DESKTOP}-${SUITE}.iso ] || publish_file delete ISOfile ${DESKTOP}-${SUITE}.iso
 	[ ! -f ${DESKTOP}-${SUITE}.txt ] || publish_file delete Summary ${DESKTOP}-${SUITE}.txt
 	[ ! -f ${DESKTOP}-${SUITE}.html ] || publish_file delete DiffoscopeOutput ${DESKTOP}-${SUITE}.html
@@ -44,8 +60,8 @@ cleanup() {
 
 		# Upload the ISO file and its summary to the web server
 		ISONAME=${DESKTOP}-${SUITE}.iso
-		publish_file ISOfile ${RESULTSDIR}/b1/${PROJECTNAME}/${DESKTOP}/live-image-amd64.hybrid.iso ${ISONAME}
-		publish_file Summary ${RESULTSDIR}/summary_build1.txt ${DESKTOP}-${SUITE}.txt
+		publish_file publish ISOfile ${RESULTSDIR}/b1/${PROJECTNAME}/${DESKTOP}/live-image-amd64.hybrid.iso ${ISONAME}
+		publish_file publish Summary ${RESULTSDIR}/summary_build1.txt ${DESKTOP}-${SUITE}.txt
 
 		# Invoke openQA
 		OPEN_QA_CLI="schroot --directory ${RESULTSDIR} -c source:jenkins-reproducible-unstable-diffoscope -- openqa-cli"
@@ -68,23 +84,13 @@ cleanup() {
 		if [ -f "${RESULTSDIR}/${PROJECTNAME}/${DESKTOP}/live-image-amd64.hybrid.iso.html" ]; then
 			# Publish the output of diffoscope, there are differences
 			output_echo "Publishing the output of diffoscope, there are differences."
-			publish_file DiffoscopeOutput ${RESULTSDIR}/${PROJECTNAME}/${DESKTOP}/live-image-amd64.hybrid.iso.html ${DESKTOP}-${SUITE}.html
+			publish_file publish DiffoscopeOutput ${RESULTSDIR}/${PROJECTNAME}/${DESKTOP}/live-image-amd64.hybrid.iso.html ${DESKTOP}-${SUITE}.html
 		else
 			output_echo "Error: Something went wrong."
 			printenv >environment.txt
-			publish_file Environment ${PWD}/environment.txt ${DESKTOP}-${SUITE}.txt
+			publish_file publish Environment ${PWD}/environment.txt ${DESKTOP}-${SUITE}.txt
 		fi
 	fi
-
-	output_echo "Cleanup ${RESULT}"
-	# Cleanup the workspace
-	if [ ! -z "${BUILDDIR}" ]; then
-		sudo rm -rf --one-file-system ${BUILDDIR}
-	fi
-	# Cleanup the results
-	if [ ! -z "${RESULTSDIR}" ]; then
-		rm -rf --one-file-system ${RESULTSDIR}
-	fi
 }
 
 #


=====================================
bin/reproducible_debian_live_sync_result.sh
=====================================
@@ -11,6 +11,8 @@ common_init "$@"
 . /srv/jenkins/bin/reproducible_common.sh
 
 set -u
+set -e
+set -o pipefail # see eg http://petereisentraut.blogspot.com/2010/11/pipefail.html
 
 PROJECT=debian_live_build
 NODE=osuosl173-amd64.debian.net
@@ -21,8 +23,7 @@ NODE=osuosl173-amd64.debian.net
 rsync_remote_results() {
     local description=$1
     local origfile=$2
-    local filename
-    filename=$(basename "$3")
+    local filename=$(basename "$3")
     echo "$(date -u) - Starting to sync $description to '$filename'."
     # Copy the new results from the build node to the web server node
     cd "$BASE"/"$PROJECT"
@@ -37,8 +38,7 @@ rsync_remote_results() {
 delete_live_build_file() {
     local description=$1
     local filetodelete=$2
-    local filename
-    filename=$(basename "$filetodelete")
+    local filename=$(basename "$filetodelete")
     echo "$(date -u) - Delete $description: '$filename'."
     cd "$BASE"/"$PROJECT"
     if [[ "$filename" != "$filetodelete" ]]; then
@@ -57,8 +57,12 @@ parse_arguments() {
     if [ "$1" == "delete" ]; then
         shift
         delete_live_build_file "$@"
-    else
+    elif [ "$1" == "publish" ]; then
+        shift
         rsync_remote_results "$@"
+    else
+        echo "Undefined action: $1"
+        exit 1
     fi
 }
 



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/8298b3bd507d36cb92cc7704baec3fc45e3ec330...2eaf0515615f116d33bbab6cb73e61bd659c9e5f

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/8298b3bd507d36cb92cc7704baec3fc45e3ec330...2eaf0515615f116d33bbab6cb73e61bd659c9e5f
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20220916/932ab4d2/attachment-0001.htm>


More information about the Qa-jenkins-scm mailing list