[Qa-jenkins-scm] [jenkins.debian.net] 01/01: WIP
Holger Levsen
holger at moszumanska.debian.org
Fri Jun 5 00:32:45 UTC 2015
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch coreboot
in repository jenkins.debian.net.
commit 1ceea7130bfe1d5c7edd392d483407b53002c4d7
Author: Holger Levsen <holger at layer-acht.org>
Date: Fri Jun 5 02:32:18 2015 +0200
WIP
---
bin/reproducible_coreboot.sh | 187 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 187 insertions(+)
diff --git a/bin/reproducible_coreboot.sh b/bin/reproducible_coreboot.sh
new file mode 100755
index 0000000..4134858
--- /dev/null
+++ b/bin/reproducible_coreboot.sh
@@ -0,0 +1,187 @@
+#!/bin/bash
+
+# Copyright 2014-2015 Holger Levsen <holger at layer-acht.org>
+# © 2015 Mattia Rizzolo <mattia at mapreri.org>
+# released under the GPLv=2
+
+DEBUG=false
+. /srv/jenkins/bin/common-functions.sh
+common_init "$@"
+
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
+
+set -e
+
+# support for different architectures (we start with i386 only)
+ARCHS="i386"
+
+create_results_dirs() {
+ mkdir -p $BASE/coreboot
+}
+
+calculate_build_duration() {
+ END=$(date +'%s')
+ DURATION=$(( $END - $START ))
+}
+
+print_out_duration() {
+ local HOUR=$(echo "$DURATION/3600"|bc)
+ local MIN=$(echo "($DURATION-$HOUR*3600)/60"|bc)
+ local SEC=$(echo "$DURATION-$HOUR*3600-$MIN*60"|bc)
+ echo "$(date) - total duration: ${HOUR}h ${MIN}m ${SEC}s." | tee -a ${RBUILDLOG}
+}
+
+init_debbindiff() {
+ # the schroot for debbindiff gets updated once a day. wait patiently if that's the case
+ if [ -f $DBDCHROOT_WRITELOCK ] || [ -f $DBDCHROOT_READLOCK ] ; then
+ for i in $(seq 0 200) ; do # this loop also exists in _common.sh and _setup_schroot.sh
+ sleep 15
+ echo "sleeping 15s, debbindiff schroot is locked."
+ if [ ! -f $DBDCHROOT_WRITELOCK ] && [ ! -f $DBDCHROOT_READLOCK ] ; then
+ break
+ fi
+ done
+ if [ -f $DBDCHROOT_WRITELOCK ] || [ -f $DBDCHROOT_READLOCK ] ; then
+ echo "Warning: lock $DBDCHROOT_WRITELOCK or $DBDCHROOT_READLOCK still exists, exiting."
+ exit 1
+ fi
+ else
+ # we create (more) read-lock(s) but stop on write locks...
+ # write locks are only done by the schroot setup job
+ touch $DBDCHROOT_READLOCK
+ fi
+}
+
+call_debbindiff() {
+ init_debbindiff # check and set up locks for chroot
+ local TMPLOG=(mktemp --tmpdir=$TMPDIR)
+ echo | tee -a ${RBUILDLOG}
+ local TIMEOUT="30m" # don't forget to also change the "seq 0 200" loop 33 lines above
+ DBDSUITE=$SUITE
+ if [ "$SUITE" = "experimental" ] ; then
+ # there is no extra debbindiff-schroot for experimental because we specical case ghc enough already ;)
+ DBDSUITE="unstable"
+ fi
+ DBDVERSION="$(schroot --directory /tmp -c source:jenkins-reproducible-${DBDSUITE}-debbindiff debbindiff -- --version 2>&1)"
+ echo "$(date) - $DBDVERSION will be used to compare the two builds:" | tee -a ${RBUILDLOG}
+ set +e
+ set -x
+ ( timeout $TIMEOUT schroot \
+ --directory $TMPDIR \
+ -c source:jenkins-reproducible-${DBDSUITE}-debbindiff \
+ debbindiff -- \
+ --html ./${DBDREPORT} \
+ ./b1/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes \
+ ./b2/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes 2>&1 \
+ ) 2>&1 >> $TMPLOG
+ RESULT=$?
+ if ! "$DEBUG" ; then set +x ; fi
+ set -e
+ cat $TMPLOG | tee -a $RBUILDLOG # print dbd output
+ rm -f $DBDCHROOT_READLOCK $TMPLOG
+ echo | tee -a ${RBUILDLOG}
+ case $RESULT in
+ 0)
+ echo handle_reproducible
+ ;;
+ 1)
+ echo handle_ftbr "$DBDVERSION found issues, please investigate $REPRODUCIBLE_URL/dbd/${SUITE}/${ARCH}/${DBDREPORT}"
+ ;;
+ 2)
+ echo handle_ftbr "$DBDVERSION had trouble comparing the two builds. Please investigate $REPRODUCIBLE_URL/rbuild/${SUITE}/${ARCH}/${SRCPACKAGE}_${EVERSION}.rbuild.log"
+ ;;
+ 124)
+ if [ ! -s ./${DBDREPORT} ] ; then
+ echo "$(date) - $DBDVERSION produced no output and was killed after running into timeout after ${TIMEOUT}..." >> ${DBDREPORT}
+ else
+ local msg="$DBDVERSION was killed after running into timeout after $TIMEOUT"
+ msg="$msg, but there is still $REPRODUCIBLE_URL/dbd/$SUITE/$ARCH/$DDBREPORT"
+ fi
+ echo $msg
+ ;;
+ *)
+ echo handle_ftbr "Something weird with $DBDVERSION (exit with $RESULT) happened and I don't know how to handle it"
+ ;;
+ esac
+ print_out_duration
+}
+
+build_rebuild() {
+ FTBFS=1
+ local TMPCFG=$(mktemp -t pbuilderrc_XXXX --tmpdir=$TMPDIR)
+ local NUM_CPU=$(cat /proc/cpuinfo |grep ^processor|wc -l)
+ mkdir b1 b2
+ set -x
+ printf "BUILDUSERID=1111\nBUILDUSERNAME=pbuilder1\n" > $TMPCFG
+ ( timeout -k 12h 12h nice ionice -c 3 sudo \
+ DEB_BUILD_OPTIONS="parallel=$NUM_CPU" \
+ TZ="/usr/share/zoneinfo/Etc/GMT+12" \
+ pbuilder --build \
+ --configfile $TMPCFG \
+ --debbuildopts "-b" \
+ --basetgz /var/cache/pbuilder/$SUITE-reproducible-base.tgz \
+ --buildresult b1 \
+ ${SRCPACKAGE}_*.dsc \
+ ) 2>&1 | tee -a $RBUILDLOG
+ if ! "$DEBUG" ; then set +x ; fi
+ if [ -f b1/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes ] ; then
+ # the first build did not FTBFS, try rebuild it.
+ check_for_race_conditions
+ echo "============================================================================="
+ echo "Re-building ${SRCPACKAGE}/${VERSION} in ${SUITE} on ${ARCH} now."
+ echo "============================================================================="
+ set -x
+ printf "BUILDUSERID=2222\nBUILDUSERNAME=pbuilder2\n" > $TMPCFG
+ ( timeout -k 12h 12h nice ionice -c 3 sudo \
+ DEB_BUILD_OPTIONS="parallel=$(echo $NUM_CPU-1|bc)" \
+ TZ="/usr/share/zoneinfo/Etc/GMT-14" \
+ LANG="fr_CH.UTF-8" \
+ LC_ALL="fr_CH.UTF-8" \
+ /usr/bin/linux64 --uname-2.6 \
+ /usr/bin/unshare --uts -- \
+ /usr/sbin/pbuilder --build \
+ --configfile $TMPCFG \
+ --hookdir /etc/pbuilder/rebuild-hooks \
+ --debbuildopts "-b" \
+ --basetgz /var/cache/pbuilder/$SUITE-reproducible-base.tgz \
+ --buildresult b2 \
+ ${SRCPACKAGE}_${EVERSION}.dsc
+ ) 2>&1 | tee -a ${RBUILDLOG}
+ if ! "$DEBUG" ; then set +x ; fi
+ if [ -f b2/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes ] ; then
+ # both builds were fine, i.e., they did not FTBFS.
+ FTBFS=0
+ cat b1/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes | tee -a ${RBUILDLOG}
+ else
+ echo "The second build failed, even though the first build was successful." | tee -a ${RBUILDLOG}
+ fi
+ fi
+ cleanup_userContent
+ update_rbuildlog
+ rm $TMPCFG
+ if [ $FTBFS -eq 1 ] ; then handle_ftbfs ; fi
+}
+
+
+#
+# below is what controls the world
+#
+
+TMPDIR=$(mktemp --tmpdir=/srv/reproducible-results -d) # where everything actually happens
+trap cleanup_all INT TERM EXIT
+cd $TMPDIR
+
+DATE=$(date +'%Y-%m-%d %H:%M')
+START=$(date +'%s')
+
+build_rebuild # defines FTBFS redefines RBUILDLOG
+if [ $FTBFS -eq 0 ] ; then
+ call_debbindiff # defines DBDVERSION, update_db_and_html defines STATUS
+fi
+
+check_for_race_conditions
+cd ..
+cleanup_all
+trap - INT TERM EXIT
+
--
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