[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] reproducible alpine: generate alpine html

Holger Levsen gitlab at salsa.debian.org
Fri Jun 7 17:02:14 BST 2019



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


Commits:
9a094dae by kpcyrd at 2019-06-07T16:02:04Z
reproducible alpine: generate alpine html

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

- - - - -


2 changed files:

- bin/reproducible_build_alpine_pkg.sh
- bin/reproducible_common.sh


Changes:

=====================================
bin/reproducible_build_alpine_pkg.sh
=====================================
@@ -464,7 +464,7 @@ echo "$(date -u) - $REPRODUCIBLE_URL/alpine/$REPOSITORY/$SRCPACKAGE/ updated."
 # force update of HTML snipplet in reproducible_html_alpine.sh
 [ ! -f $BASE/alpine/$REPOSITORY/$SRCPACKAGE/pkg.state ] || rm $BASE/alpine/$REPOSITORY/$SRCPACKAGE/pkg.state
 HTML_BUFFER=''
-create_pkg_html
+create_alpine_pkg_html
 update_pkg_in_db
 
 cd


=====================================
bin/reproducible_common.sh
=====================================
@@ -1166,3 +1166,180 @@ create_pkg_html() {
 	chmod 644 $ARCHLINUX_PKG_PATH/pkg.html
 	echo $STATE > $ARCHLINUX_PKG_PATH/pkg.state
 }
+
+create_alpine_pkg_html() {
+	local ALPINE_PKG_PATH=$ALPINE_BASE/$REPOSITORY/$SRCPACKAGE
+	local HTML_BUFFER=$(mktemp -t alpinerb-html-XXXXXXXX)
+	local buffer_message
+	local STATE
+
+	# clear files from previous builds
+	cd "$ALPINE_PKG_PATH"
+	for file in build1.log build2.log build1.version build2.version *BUILDINFO.txt *.html; do
+		if [ -f $file ] && [ pkg.build_duration -nt $file ] ; then
+			rm $file
+			echo "$ALPINE_PKG_PATH/$file older than $ALPINE_PKG_PATH/pkg.build_duration, thus deleting it."
+		fi
+	done
+
+	echo "     <tr>" >> $HTML_BUFFER
+	echo "      <td>$REPOSITORY</td>" >> $HTML_BUFFER
+	echo "      <td>$SRCPACKAGE</td>" >> $HTML_BUFFER
+	echo "      <td>$VERSION</td>" >> $HTML_BUFFER
+	echo "      <td>" >> $HTML_BUFFER
+	#
+	#
+	if [ -z "$(cd $ALPINE_PKG_PATH/ ; ls *.apk.html 2>/dev/null)" ] ; then
+		# this horrible if elif elif elif elif...  monster should be replaced
+		# by using pacman's exit code which is possible since sometime in 2018
+
+		# check different states and figure out what the page should look like
+		if find_in_buildlogs '^error: failed to prepare transaction \(conflicting dependencies\)'; then
+			STATE=DEPWAIT_0
+			buffer_message='could not resolve dependencies as there are conflicts'
+		elif find_in_buildlogs '==> ERROR: (Could not resolve all dependencies|.pacman. failed to install missing dependencies)'; then
+			if find_in_buildlogs 'error: failed to init transaction \(unable to lock database\)'; then
+				STATE=DEPWAIT_2
+				buffer_message='pacman could not lock database'
+			else
+				STATE=DEPWAIT_1
+				buffer_message='could not resolve dependencies'
+			fi
+		elif find_in_buildlogs '^error: unknown package: '; then
+			STATE=404_0
+			buffer_message='unknown package'
+		elif find_in_buildlogs '(==> ERROR: Failure while downloading|==> ERROR: One or more PGP signatures could not be verified|==> ERROR: One or more files did not pass the validity check|==> ERROR: Integrity checks \(.*\) differ in size from the source array|==> ERROR: Failure while branching|==> ERROR: Failure while creating working copy|Failed to source PKGBUILD.*PKGBUILD)'; then
+			REASON="download failed"
+			EXTRA_REASON=""
+			STATE=404_0
+			if find_in_buildlogs 'FAILED \(unknown public key'; then
+				STATE=404_6
+				EXTRA_REASON="to verify source with PGP due to unknown public key"
+			elif find_in_buildlogs 'The requested URL returned error: 403'; then
+				STATE=404_2
+				EXTRA_REASON="with 403 - forbidden"
+			elif find_in_buildlogs 'The requested URL returned error: 500'; then
+				STATE=404_4
+				EXTRA_REASON="with 500 - internal server error"
+			elif find_in_buildlogs 'The requested URL returned error: 503'; then
+				STATE=404_5
+				EXTRA_REASON="with 503 - service unavailable"
+			elif find_in_buildlogs '==> ERROR: One or more PGP signatures could not be verified'; then
+				STATE=404_7
+				EXTRA_REASON="to verify source with PGP signatures"
+			elif find_in_buildlogs '(SSL certificate problem: unable to get local issuer certificate|^bzr: ERROR: .SSL: CERTIFICATE_VERIFY_FAILED)'; then
+				STATE=404_1
+				EXTRA_REASON="with SSL problem"
+			elif find_in_buildlogs '==> ERROR: One or more files did not pass the validity check'; then
+				STATE=404_8
+				REASON="downloaded ok but failed to verify source"
+			elif find_in_buildlogs '==> ERROR: Integrity checks \(.*\) differ in size from the source array'; then
+				STATE=404_9
+				REASON="Integrity checks differ in size from the source array"
+			elif find_in_buildlogs 'The requested URL returned error: 404'; then
+				STATE=404_3
+				EXTRA_REASON="with 404 - file not found"
+			elif find_in_buildlogs 'fatal: the remote end hung up unexpectedly'; then
+				STATE=404_A
+				EXTRA_REASON="could not clone git repository"
+			elif find_in_buildlogs 'The requested URL returned error: 504'; then
+				STATE=404_B
+				EXTRA_REASON="with 504 - gateway timeout"
+			elif find_in_buildlogs '==> ERROR: Failure while downloading .* git repo'; then
+				STATE=404_C
+				EXTRA_REASON="from git repo"
+			fi
+			buffer_message="$REASON $EXTRA_REASON"
+		elif find_in_buildlogs '==> ERROR: (install file .* does not exist or is not a regular file|The download program wget is not installed)'; then
+			STATE=FTBFS_0
+			buffer_message='failed to build, requirements not met'
+		elif find_in_buildlogs '==> ERROR: A failure occurred in check'; then
+			STATE=FTBFS_1
+			buffer_message='failed to build while running tests'
+		elif find_in_buildlogs '==> ERROR: (An unknown error has occurred|A failure occurred in (build|package|prepare))'; then
+			STATE=FTBFS_2
+			buffer_message='failed to build'
+		elif find_in_buildlogs 'makepkg was killed by timeout after'; then
+			STATE=FTBFS_3
+			buffer_message='failed to build, killed by timeout'
+		elif find_in_buildlogs '==> ERROR: .* contains invalid characters:'; then
+			STATE=FTBFS_4
+			buffer_message='failed to build, pkg relations contain invalid characters'
+		else
+			STATE=$(query_db "SELECT r.status FROM results AS r
+				JOIN sources as s on s.id=r.package_id
+				WHERE s.architecture='x86_64'
+				AND s.name='$SRCPACKAGE'
+				AND s.suite='alpine_$REPOSITORY';")
+			if [ "$STATE" = "BLACKLISTED" ] ; then
+				buffer_message='blacklisted'
+			else
+				STATE=UNKNOWN
+				buffer_message='probably failed to build from source, please investigate'
+			fi
+		fi
+		# print build failures
+		if [ "$STATE" = "UNKNOWN" ]; then
+			echo "       $buffer_message" >> $HTML_BUFFER
+		else
+			include_icon $STATE "$buffer_message"
+		fi
+	else
+		local STATE=GOOD
+		local SOME_GOOD=false
+		for ARTIFACT in $(cd $ALPINE_PKG_PATH/ ; ls *.apk.html) ; do
+			if [ -z "$(echo $ARTIFACT | grep $VERSION)" ] ; then
+				echo "deleting $ARTIFACT as version is not $VERSION"
+				rm -f $ARTIFACT
+				continue
+			elif [ ! -z "$(grep 'build reproducible in our test framework' $ALPINE_PKG_PATH/$ARTIFACT)" ] ; then
+				SOME_GOOD=true
+				include_icon $STATE "<a href=\"/alpine/$REPOSITORY/$SRCPACKAGE/$ARTIFACT\">${ARTIFACT:0:-5}</a> is reproducible in our current test framework<br />"
+			else
+				# change $STATE unless we have found .buildinfo differences already...
+				if [ "$STATE" != "FTBR_0" ] ; then
+					STATE=FTBR_1
+				fi
+				# this shouldnt happen, but (for now) it does, so lets mark them…
+				EXTRA_REASON=""
+				if [ ! -z "$(grep 'class="source">.BUILDINFO' $ALPINE_PKG_PATH/$ARTIFACT)" ] ; then
+					STATE=FTBR_0
+					EXTRA_REASON=" with variations in .BUILDINFO"
+				fi
+				include_icon $STATE "<a href=\"/alpine/$REPOSITORY/$SRCPACKAGE/$ARTIFACT\">${ARTIFACT:0:-5}</a> is unreproducible$EXTRA_REASON<br />"
+			fi
+		done
+		# we only count source packages…
+		if [[ $STATE = FTBR_1 && $SOME_GOOD = true ]]; then
+			STATE=FTBR_2
+		fi
+	fi
+	echo "      </td>" >> $HTML_BUFFER
+	echo "      <td>$DATE" >> $HTML_BUFFER
+	local DURATION=$(cat $ALPINE_PKG_PATH/pkg.build_duration 2>/dev/null || true)
+	if [ -n "$DURATION" ]; then
+		local HOUR=$(echo "$DURATION/3600"|bc)
+		local MIN=$(echo "($DURATION-$HOUR*3600)/60"|bc)
+		local SEC=$(echo "$DURATION-$HOUR*3600-$MIN*60"|bc)
+		BUILD_DURATION="<br />${HOUR}h:${MIN}m:${SEC}s"
+	else
+		BUILD_DURATION=" "
+	fi
+	echo "       $BUILD_DURATION</td>" >> $HTML_BUFFER
+
+	echo "      <td>" >> $HTML_BUFFER
+	for LOG in build1.log build2.log ; do
+		if [ -f $ALPINE_PKG_PATH/$LOG ] ; then
+			if [ "$LOG" = "build2.log" ] ; then
+				echo "       <br />" >> $HTML_BUFFER
+			fi
+			get_filesize $ALPINE_PKG_PATH/$LOG
+			echo "       <a href=\"/alpine/$REPOSITORY/$SRCPACKAGE/$LOG\">$LOG</a> ($SIZE)" >> $HTML_BUFFER
+		fi
+	done
+	echo "      </td>" >> $HTML_BUFFER
+	echo "     </tr>" >> $HTML_BUFFER
+	mv $HTML_BUFFER $ALPINE_PKG_PATH/pkg.html
+	chmod 644 $ALPINE_PKG_PATH/pkg.html
+	echo $STATE > $ALPINE_PKG_PATH/pkg.state
+}



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/commit/9a094dae1ea344fe6d7d01f363e233ea6c93af6a

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/commit/9a094dae1ea344fe6d7d01f363e233ea6c93af6a
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/20190607/e4d4be4f/attachment-0001.html>


More information about the Qa-jenkins-scm mailing list