#!/bin/bash # Copyright 2014-2015 Holger Levsen # released under the GPLv=2 DEBUG=true . /srv/jenkins/bin/common-functions.sh common_init "$@" # common code defining db access . /srv/jenkins/bin/reproducible_common.sh set -e cleanup_tmpdirs() { cd $RSSH "sudo chflags -R noschg $TMPDIR" $RSSH "rm -r $TMPDIR" rm $TMPDIR -r $RSSH 'sudo rm -rf /usr/src' } create_results_dirs() { mkdir -p $BASE/freebsd/dbd } save_freebsd_results(){ local RUN=$1 echo "=============================================================================" echo "$(date -u) - Saving freebsd ${FREEBSD_VERSION} artifacts for $RUN." echo "=============================================================================" mkdir -p $TMPDIR/$RUN/ # copy results over DUMMY_DATE="$(date -u +'%Y-%m-%d')T00:00:00Z" $RSSH "sudo find $TMPDIR -newer $TMPDIR -exec touch -d '$DUMMY_DATE' {} \;" $RSSH "sudo find $TMPDIR -print0 | LC_ALL=C sort -z | sudo tar --null -T - --no-recursion -cJf $TMPDIR.tar.xz" $RSCP:$TMPDIR.tar.xz $TMPDIR/$RUN/$TARGET_NAME.tar.xz $RSSH "sudo chflags -R noschg $TMPDIR ; sudo rm -r $TMPDIR $TMPDIR.tar.xz ; mkdir $TMPDIR" } # # main # FREEBSD_TARGET="release/10.2.0" RSSH="ssh freebsd-jenkins.debian.net" RSCP="scp -r freebsd-jenkins.debian.net" TMPBUILDDIR=/usr/src $RSSH 'sudo rm -rf /usr/src ; sudo mkdir /usr/src ; sudo chown jenkins /usr/src' ### this is tmpfs on linux, we should move this to tmpfs on freebsd too TMPDIR=$($RSSH 'TMPDIR=/srv/reproducible-results mktemp -d') # used to compare results DATE=$(date -u +'%Y-%m-%d') START=$(date +'%s') trap cleanup_tmpdirs INT TERM EXIT echo "=============================================================================" echo "$(date -u) - FreeBSD host info" echo "=============================================================================" $RSSH freebsd-version echo "=============================================================================" echo "$(date -u) - Cloning the freebsd git repository (which is autosynced with their CVS repository)" echo "=============================================================================" $RSSH git clone --depth 1 --branch $FREEBSD_TARGET https://github.com/freebsd/freebsd.git $TMPBUILDDIR FREEBSD=$($RSSH "cd $TMPBUILDDIR ; git log -1") FREEBSD_VERSION=$($RSSH "cd $TMPBUILDDIR ; git describe --always") echo "This is freebsd $FREEBSD_VERSION." echo $RSSH "cd $TMPBUILDDIR ; git log -1" TARGET_NAME=$(echo "freebsd_${FREEBSD_TARGET}_git${FREEBSD_VERSION}" | sed "s#/#-#g") echo "=============================================================================" echo "$(date -u) - Building freebsd ${FREEBSD_VERSION} - first build run." echo "=============================================================================" export TZ="/usr/share/zoneinfo/Etc/GMT+12" export LANG="en_GB.UTF-8" # actually build everything NUM_CPU=4 # if someone could tell me how to determine this on freebsd, this would be neat $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG sudo make -j $NUM_CPU buildworld" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG sudo make -j $NUM_CPU buildkernel" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG DESTDIR=$TMPDIR sudo make -j $NUM_CPU installworld" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG DESTDIR=$TMPDIR sudo make -j $NUM_CPU installkernel" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG DESTDIR=$TMPDIR sudo make -j $NUM_CPU distribution" # save results in b1 save_freebsd_results b1 echo "=============================================================================" echo "$(date -u) - Building freebsd - 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="$PATH:/i/capture/the/path" ###umask 0002 # use allmost all cores for second build NEW_NUM_CPU=$(echo $NUM_CPU-1|bc) # actually build everything $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG LC_ALL=$LC_ALL sudo make -j $NEW_NUM_CPU buildworld" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG LC_ALL=$LC_ALL sudo make -j $NEW_NUM_CPU buildkernel" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG LC_ALL=$LC_ALL DESTDIR=$TMPDIR sudo make -j $NEW_NUM_CPU installworld" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG LC_ALL=$LC_ALL DESTDIR=$TMPDIR sudo make -j $NEW_NUM_CPU installkernel" $RSSH "cd $TMPBUILDDIR ; TZ=$TZ LANG=$LANG LC_ALL=$LC_ALL DESTDIR=$TMPDIR sudo make -j $NEW_NUM_CPU distribution" # save results in b2 save_freebsd_results b2 # 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 # run diffoscope on the results TIMEOUT="30m" DBDSUITE="unstable" DIFFOSCOPE="$(schroot --directory /tmp -c source:jenkins-reproducible-${DBDSUITE}-debbindiff debbindiff -- --version 2>&1)" echo "=============================================================================" echo "$(date -u) - Running $DIFFOSCOPE on freebsd..." echo "=============================================================================" FILES_HTML=$(mktemp --tmpdir=$TMPDIR) echo "