[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] reproducible: Move the function save_artifacts to reproducible_common.sh

Holger Levsen (@holger) gitlab at salsa.debian.org
Mon Jul 19 13:42:45 BST 2021



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


Commits:
2d502e4b by Roland Clobus at 2021-07-19T14:09:05+02:00
reproducible: Move the function save_artifacts to reproducible_common.sh
reproducible_live_build: Save artifacts when errors are encountered

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

- - - - -


3 changed files:

- bin/reproducible_build.sh
- bin/reproducible_common.sh
- bin/reproducible_debian_live_build.sh


Changes:

=====================================
bin/reproducible_build.sh
=====================================
@@ -42,22 +42,9 @@ create_results_dirs() {
 	mkdir -vp $DEBIAN_BASE/buildinfo/${SUITE}/${ARCH}
 }
 
-save_artifacts() {
-		local random=$(head /dev/urandom | tr -cd '[:alnum:]'| head -c5)
-		local ARTIFACTS="artifacts/r00t-me/${SRCPACKAGE}_${SUITE}_${ARCH}_tmp-${random}"
-		local URL="$DEBIAN_URL/$ARTIFACTS/"
-		local HEADER="$DEBIAN_BASE/$ARTIFACTS/.HEADER.html"
-		mkdir -p $DEBIAN_BASE/$ARTIFACTS
-		cp -r $TMPDIR/* $DEBIAN_BASE/$ARTIFACTS/ || true
-		local msg="Artifacts from this build have been preserved. They will be available for 24h only, so download them now.\n"
-		msg="${msg}WARNING: You shouldn't trust packages downloaded from this host, they can contain malware or the worst of your fears, packaged nicely in debian format.\n"
-		msg="${msg}If you are aware of this and just want to use these artifacts to investigate why $DIFFOSCOPE had issues, you can download the artifacts from the following location: $URL\n"
-		log_info "$msg"
-		echo "<p>" > $HEADER
-		printf "$msg" | sed 's#$#<br />#g' >> $HEADER
-		echo "Package page: <a href=\"$DEBIAN_URL/${SUITE}/${ARCH}/${SRCPACKAGE}\">$DEBIAN_URL/${SUITE}/${ARCH}/${SRCPACKAGE}</a><br />" >> $HEADER
-		echo "</p>" >> $HEADER
-		chmod 644 $HEADER
+notification() {
+	if [ "$SAVE_ARTIFACTS" = "1" ] ; then
+		save_artifacts debian ${SUITE}_${ARCH}_${SRCPACKAGE} $REPRODUCIBLE_URL/rb-pkg/${SUITE}/${ARCH}/${SRCPACKAGE}.html
 		# irc message
 		if [ ! -z "$NOTIFY" ] ; then
 			local MESSAGE="Artifacts for ${SRCPACKAGE}, $STATUS in ${SUITE}/${ARCH}: $URL"
@@ -70,11 +57,6 @@ save_artifacts() {
 				irc_message debian-reproducible "$MESSAGE"
 			fi
 		fi
-}
-
-notification() {
-	if [ "$SAVE_ARTIFACTS" = "1" ] ; then
-		save_artifacts  # this will also notify IRC as needed
 	else
 		case "$NOTIFY" in  # the diffoscope_err case is handled by save_artifacts()
 			''|0) ;;


=====================================
bin/reproducible_common.sh
=====================================
@@ -595,6 +595,43 @@ write_variation_table() {
 	write_page "</table></p>"
 }
 
+# Save the artifacts located in $TMPDIR
+#
+# Arguments:
+#   1          The top level
+#   2          Base folder name for the artifacts
+#   3          URL to the page with more information
+# Input variables:
+#   TMPDIR     The folder that contains the artifacts to save
+#   DIFFOSCOPE The output of 'diffoscope --version'
+# Variables from reproducible_common:
+#   REPRODUCIBLE_URL
+#   BASE
+# Variables from Jenkins:
+#   BUILD_URL
+#   BUILD_TAG
+save_artifacts() {
+	local TOP_LEVEL=$1
+	local BASE_FOLDER_NAME=$2
+	local MOREINFO_URL=$3
+	local random=$(head /dev/urandom | tr -cd '[:alnum:]'| head -c5)
+	local ARTIFACTS="${TOP_LEVEL}/artifacts/r00t-me/${BASE_FOLDER_NAME}_tmp-${random}"
+	local URL="$REPRODUCIBLE_URL/$ARTIFACTS/"
+	local HEADER="$BASE/$ARTIFACTS/.HEADER.html"
+	mkdir -p $BASE/$ARTIFACTS
+	cp -r $TMPDIR/* $BASE/$ARTIFACTS/ || true
+	local msg="Artifacts from this build have been preserved. They will be available for 24h only, so download them now.\n"
+	msg="${msg}WARNING: You shouldn't trust packages downloaded from this host, they can contain malware or the worst of your fears, packaged nicely in debian format.\n"
+	msg="${msg}If you are aware of this and just want to use these artifacts to investigate why $DIFFOSCOPE had issues, you can download the artifacts from the following location: $URL\n"
+	log_info "$msg"
+	echo "<p>" > $HEADER
+	printf "$msg" | sed 's#$#<br />#g' >> $HEADER
+	echo "<a href=\"$MOREINFO_URL\">More information</a><br />" >> $HEADER
+	echo "These files are generated by Jenkins build: <a href=\"${BUILD_URL}\">${BUILD_TAG}</a><br />" >> $HEADER
+	echo "</p>" >> $HEADER
+	chmod 644 $HEADER
+}
+
 publish_page() {
 	if [ "$1" = "" ] ; then
 		TARGET=$PAGE


=====================================
bin/reproducible_debian_live_build.sh
=====================================
@@ -300,9 +300,11 @@ PAGE=${CONFIGURATION}.html
 if [ -f "${RESULTSDIR}/${PROJECTNAME}/${CONFIGURATION}/live-image-amd64.hybrid.iso.html" ] ; then
    # Publish the output of diffoscope, there are differences
    cp -a ${RESULTSDIR}/${PROJECTNAME}/${CONFIGURATION}/live-image-amd64.hybrid.iso.html ${PAGE}
+   save_artifacts debian_live_build ${CONFIGURATION} https://wiki.debian.org/ReproducibleInstalls/LiveImages
 else
    if [ "$RESULT" != "0" ] ; then
       echo "${DIFFOSCOPE} for ${PROJECTNAME} in configuration ${CONFIGURATION} returned error code ${RESULT}" > ${PAGE}
+      save_artifacts debian_live_build ${CONFIGURATION} https://wiki.debian.org/ReproducibleInstalls/LiveImages
    else
       echo "${PROJECTNAME} in configuration ${CONFIGURATION} is reproducible" > ${PAGE}
    fi



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/2d502e4b1819fdb80188f204f27c36e95394499b

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/2d502e4b1819fdb80188f204f27c36e95394499b
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/20210719/fc81609c/attachment-0001.htm>


More information about the Qa-jenkins-scm mailing list