From 0cf31460831e3f9e26ae7c44df45682be8fd58bc Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Sun, 5 Jul 2015 14:44:48 +0200 Subject: reproducible NetBSD: add job and initial script, atm only testing sparc64 --- bin/reproducible_netbsd.sh | 188 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100755 bin/reproducible_netbsd.sh (limited to 'bin/reproducible_netbsd.sh') diff --git a/bin/reproducible_netbsd.sh b/bin/reproducible_netbsd.sh new file mode 100755 index 00000000..3d177aac --- /dev/null +++ b/bin/reproducible_netbsd.sh @@ -0,0 +1,188 @@ +#!/bin/bash + +# Copyright 2014-2015 Holger Levsen +# © 2015 Mattia Rizzolo +# 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 + +# build for different architectures +ARCHS="sparc64" # FIXME: actually use this... + +cleanup_tmpdirs() { + cd + rm -r $TMPDIR + rm -r $TMPBUILDDIR +} + +create_results_dirs() { + mkdir -p $BASE/netbsd/dbd +} + +save_netbsd_results(){ + RUN=$1 + cd obj/releasedir/sparc64/ + mkdir -p $TMPDIR/$RUN/ + cp -pr * $TMPDIR/$RUN/ + cd ../../.. + rm obj/releasedir/sparc64/ -r +} + +# +# main +# +TMPBUILDDIR=$(mktemp --tmpdir=/srv/workspace/chroots/ -d -t netbsd-XXXXXXXX) # used to build on tmpfs +TMPDIR=$(mktemp --tmpdir=/srv/reproducible-results -d) # accessable in schroots, used to compare results +DATE=$(date -u +'%Y-%m-%d') +START=$(date +'%s') +trap cleanup_tmpdirs INT TERM EXIT + +cd $TMPBUILDDIR +echo "=============================================================================" +echo "$(date -u) - Cloning the netbsd git repository (which is autosynced with their CVS repository)" +echo "=============================================================================" +git clone https://github.com/jsonn/src +cd netbsd +NETBSD="$(git log -1)" +NETBSD_VERSION=$(git describe --always) +echo "This is netbsd $NETBSD_VERSION." +echo +git log -1 + +echo "=============================================================================" +echo "$(date -u) - Building netbsd ${NETBSD_VERSION} - first build run." +echo "=============================================================================" +export TZ="/usr/share/zoneinfo/Etc/GMT+12" +# actually build everything +ionice -c 3 nice \ + ./build.sh -j $NUM_CPU -U -u -m sparc64 release +# save results in b1 +save_netbsd_results b1 + +echo "=============================================================================" +echo "$(date -u) - Building netbsd - second build run." +echo "=============================================================================" +export TZ="/usr/share/zoneinfo/Etc/GMT-14" +export LANG="fr_CH.UTF-8" +export LC_ALL="fr_CH.UTF-8" +export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/i/capture/the/path" +export CAPTURE_ENVIRONMENT="I capture the environment" +umask 0002 +# use allmost all cores for second build +NEW_NUM_CPU=$(echo $NUM_CPU-1|bc) +ionice -c 3 nice \ + linux64 --uname-2.6 \ + ./build.sh -j $NEW_NUM_CPU -U -u -m sparc64 release + +# reset environment to default values again +export LANG="en_GB.UTF-8" +unset LC_ALL +export TZ="/usr/share/zoneinfo/UTC" +export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:" +umask 0022 + +# save results in b2 +save_netbsd_results b2 + +# clean up builddir to save space on tmpfs +rm -r $TMPBUILDDIR/netbsd + +# run debbindiff on the results +TIMEOUT="30m" +DBDSUITE="unstable" +DBDVERSION="$(schroot --directory /tmp -c source:jenkins-reproducible-${DBDSUITE}-debbindiff debbindiff -- --version 2>&1)" +echo "=============================================================================" +echo "$(date -u) - Running $DBDVERSION on netbsd..." +echo "=============================================================================" +FILES_HTML=$(mktemp --tmpdir=$TMPDIR) +echo "
    " > $FILES_HTML +BAD_FILES=0 +GOOD_FILES=0 +ALL_FILES=0 +create_results_dirs +cd $TMPDIR/b1 +tree . +for i in * ; do + cd $i + echo " " >> $FILES_HTML + for j in $(find * -type f |sort -u ) ; do + let ALL_FILES+=1 + call_debbindiff_on_any_file $i $j + SIZE="$(du -h -b $j | cut -f1)" + SIZE="$(echo $SIZE/1024|bc)" + if [ -f $TMPDIR/$i/$j.html ] ; then + mkdir -p $BASE/netbsd/dbd/$i + mv $TMPDIR/$i/$j.html $BASE/netbsd/dbd/$i/$j.html + echo " " >> $FILES_HTML + else + SHASUM=$(sha256sum $j|cut -d " " -f1) + echo " " >> $FILES_HTML + let GOOD_FILES+=1 + rm -f $BASE/netbsd/dbd/$i/$j.html # cleanup from previous (unreproducible) tests - if needed + fi + done + cd .. + echo "
    Release files for $i
    \"unreproducible $j (${SIZE}K) is unreproducible.
    \"reproducible $j ($SHASUM, ${SIZE}K) is reproducible.
    " >> $FILES_HTML +done +GOOD_PERCENT=$(echo "scale=1 ; ($GOOD_FILES*100/$ALL_FILES)" | bc) +BAD_PERCENT=$(echo "scale=1 ; ($BAD_FILES*100/$ALL_FILES)" | bc) +# are we there yet? +if [ "$GOOD_PERCENT" = "100.0" ] ; then + MAGIC_SIGN="!" +else + MAGIC_SIGN="?" +fi + +# +# finally create the webpage +# +cd $TMPDIR ; mkdir netbsd +PAGE=netbsd/netbsd.html +cat > $PAGE <<- EOF + + + + + + NetBSD + + + +
    +
    +EOF +write_page "

    Reproducible NetBSD

    " +write_page_intro NetBSD +write_page "

    $GOOD_FILES ($GOOD_PERCENT%) out of $ALL_FILES built netbsd files were reproducible in our test setup" +if [ "$GOOD_PERCENT" = "100.0" ] ; then + write_page "!" +else + write_page ", while $BAD_FILES ($BAD_PERCENT%) failed to build from source." +fi +write_page " These tests were last run on $DATE for version ${NETBSD_VERSION}.

    " +write_explaination_table NetBSD +cat $FILES_HTML >> $PAGE +write_page "

    "
    +echo -n "$NETBSD" >> $PAGE
    +write_page "     

    " +write_page "
    " +write_page_footer NetBSD +publish_page +rm -f $FILES_HTML + +# the end +calculate_build_duration +print_out_duration +irc_message "$REPRODUCIBLE_URL/netbsd/ has been updated. ($GOOD_PERCENT% reproducible)" +echo "=============================================================================" + +# remove everything, we don't need it anymore... +cleanup_tmpdirs +trap - INT TERM EXIT -- cgit v1.2.3-70-g09d2