Skip to content
Commits on Source (8)
......@@ -5,6 +5,12 @@
# © 2015-2018 Mattia Rizzolo <mattia@debian.org>
# released under the GPLv=2
# Exit status of this script:
# - when run in remote mode:
# - 2 → the build failed
# - 3 → the build timeouted
# - 404 → failed to download the sources
DEBUG=false
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
......@@ -101,17 +107,23 @@ save_artifacts() {
cleanup_all() {
echo "Starting cleanup."
cd # move out of $TMPDIR, if we are still inside
if [ "$SAVE_ARTIFACTS" = "1" ] ; then
save_artifacts # this will also notify IRC as needed
elif [ "$NOTIFY" = "2" ] ; then
irc_message debian-reproducible "$DEBIAN_URL/$SUITE/$ARCH/$SRCPACKAGE done: $STATUS debug: $NOTIFY"
elif [ "$NOTIFY" = "1" ] ; then
else
case "$NOTIFY" in
0) ;;
1|2)
irc_message debian-reproducible "$DEBIAN_URL/$SUITE/$ARCH/$SRCPACKAGE done: $STATUS"
elif [ "$NOTIFY" = "diffoscope" ] ; then
;;
diffoscope)
irc_message debian-reproducible-changes "$DEBIAN_URL/$SUITE/$ARCH/$SRCPACKAGE $STATUS and $DIFFOSCOPE failed"
elif [ ! -z "$NOTIFY" ] ; then
;;
*)
# a weird value of $NOTIFY that we don't know about
irc_message debian-reproducible-changes "$DEBIAN_URL/$SUITE/$ARCH/$SRCPACKAGE done: $STATUS debug: $NOTIFY"
;;
esac
fi
[ ! -f $RBUILDLOG ] || gzip -9fvn $RBUILDLOG
if [ "$MODE" = "master" ] ; then
......@@ -122,6 +134,7 @@ cleanup_all() {
rm -r $TMPDIR || true
fi
echo "All cleanup done."
print_out_duration
}
update_db_and_html() {
......@@ -238,9 +251,11 @@ handle_NFU() {
}
handle_ftbfs() {
if ! "$DEBUG" ; then set +x ; fi
local BUILD
echo "${SRCPACKAGE} failed to build from source."
cleanup_pkg_files
diff_copy_buildlogs
update_rbuildlog
local BUILD NEEDLE
for BUILD in "1" "2"; do
local nodevar="NODE$BUILD"
local node=""
......@@ -282,6 +297,7 @@ handle_ftbfs() {
update_db_and_html "FTBFS"
if [ $SAVE_ARTIFACTS -eq 1 ] ; then SAVE_ARTIFACTS=0 ; fi
if [ ! -z "$NOTIFY" ] ; then NOTIFY="failure" ; fi
exit 0
}
handle_ftbr() {
......@@ -370,6 +386,8 @@ dbd_timeout() {
}
call_diffoscope_on_changes_files() {
# filter lines describing .buildinfo files from .changes file
sed -i -e '/^ [a-f0-9]\{32,64\} .*\.buildinfo$/d' b{1,2}/$CHANGES
local TMPLOG=$(mktemp --tmpdir=$TMPDIR)
local TIMEOUT="120m"
DBDSUITE=$SUITE
......@@ -589,7 +607,6 @@ first_build() {
echo "Date: $(date)"
echo "Date UTC: $(date -u)"
echo "============================================================================="
set -x
local TMPCFG=$(mktemp -t pbuilderrc_XXXX --tmpdir=$TMPDIR)
cat > "$TMPCFG" << EOF
BUILDUSERID=1111
......@@ -619,14 +636,20 @@ EOF
--logfile b1/build.log \
${SRCPACKAGE}_${EVERSION}.dsc
) 2>&1 | log_file -
PRESULT=${PIPESTATUS[0]}
if [ $PRESULT -eq 124 ] ; then
local PRESULT=${PIPESTATUS[0]}
if ! "$DEBUG" ; then set +x ; fi
rm $TMPCFG
case $PRESULT in
124)
msg="pbuilder was killed by timeout after 18h."
log_error "$msg"
echo "$(date -u) - $msg" | tee -a b1/build.log
fi
if ! "$DEBUG" ; then set +x ; fi
rm $TMPCFG
exit 3
;;
1) # FTBFS, for whatever reason.
exit 2
;;
esac
}
second_build() {
......@@ -688,13 +711,20 @@ EOF
--buildresult $TMPDIR/b2 \
--logfile b2/build.log \
${SRCPACKAGE}_${EVERSION}.dsc
PRESULT=$?
local PRESULT=$?
set -e
if [ $PRESULT -eq 124 ] ; then
echo "$(date -u) - pbuilder was killed by timeout after 24h." | tee -a b2/build.log
fi
if ! "$DEBUG" ; then set +x ; fi
rm $TMPCFG
case $PRESULT in
124)
echo "$(date -u) - pbuilder was killed by timeout after 24h." | tee -a b2/build.log
exit 3
;;
1) # FTBFS, for whatever reason.
exit 2
;;
esac
}
check_node_is_up() {
......@@ -736,19 +766,20 @@ remote_build() {
check_node_is_up $NODE $PORT $SLEEPTIME
set +e
ssh -o "BatchMode = yes" -p $PORT $NODE /srv/jenkins/bin/reproducible_build.sh $BUILDNR ${SRCPACKAGE} ${SUITE} ${TMPDIR} "$VERSION"
RESULT=$?
# 404-256=148... (ssh 'really' only 'supports' exit codes below 255...)
if [ $RESULT -eq 148 ] ; then
local RESULT=$?
case $RESULT in
148) # 404-256=148... (ssh 'really' only 'supports' exit codes below 255...)
handle_E404
elif [ $RESULT -eq 100 ] ; then
log_error "Version mismatch between main node and build $BUILDNR, aborting. Please upgrade the schroots..."
# reschedule the package for later and quit the build without saving anything
query_db "UPDATE schedule SET date_build_started = NULL, job = NULL, date_scheduled='$(date -u +'%Y-%m-%d %H:%M')' WHERE package_id='$SRCPKGID'"
NOTIFY=""
exit 0
elif [ $RESULT -ne 0 ] ; then
;;
2|3)
handle_ftbfs
;;
0) # build succcessfully completed
;;
*)
handle_remote_error "with exit code $RESULT from $NODE for build #$BUILDNR for ${SRCPACKAGE} on ${SUITE}/${ARCH}"
fi
;;
esac
rsync -e "ssh -o 'BatchMode = yes' -p $PORT" -r $NODE:$TMPDIR/b$BUILDNR $TMPDIR/
RESULT=$?
if [ $RESULT -ne 0 ] ; then
......@@ -769,11 +800,6 @@ remote_build() {
fi
}
filter_changes_files() {
# filter lines describing .buildinfo files from .changes file
sed -i -e '/^ [a-f0-9]\{32,64\} .*\.buildinfo$/d' b{1,2}/$CHANGES
}
check_installed_build_depends() {
local TMPFILE1=$(mktemp --tmpdir=$TMPDIR)
local TMPFILE2=$(mktemp --tmpdir=$TMPDIR)
......@@ -844,23 +870,22 @@ share_buildinfo() {
}
build_rebuild() {
FTBFS=1
CHANGES="${SRCPACKAGE}_${EVERSION}_${ARCH}.changes" # changes file with expected version
mkdir b1 b2
log_info "Starting 1st build on remote node $NODE1."
remote_build 1 $NODE1
if [ -f b1/$CHANGES ] ; then
log_info "1st build successful. Starting 2nd build on remote node $NODE2."
remote_build 2 $NODE2
if [ -f b2/$CHANGES ] ; then
# both builds were fine, i.e., they did not FTBFS.
FTBFS=0
# at this point, both builds were fine, i.e., they did not FTBFS.
log_info "$CHANGES:"
log_file b1/$CHANGES
else
log_error "the second build failed, even though the first build was successful."
fi
fi
check_installed_build_depends
# save the build:
cleanup_pkg_files
diff_copy_buildlogs
update_rbuildlog
call_diffoscope_on_changes_files # defines DIFFOSCOPE, update_db_and_html defines STATUS
share_buildinfo
}
#
......@@ -934,23 +959,4 @@ log_info "${SRCPACKAGE}_${EVERSION}.dsc"
log_file ${SRCPACKAGE}_${EVERSION}.dsc
check_suitability
build_rebuild # defines FTBFS, CHANGES redefines RBUILDLOG
if [ $FTBFS -eq 0 ] ; then
check_installed_build_depends
fi
cleanup_pkg_files
diff_copy_buildlogs
update_rbuildlog
if [ $FTBFS -eq 1 ] ; then
handle_ftbfs
elif [ $FTBFS -eq 0 ] ; then
filter_changes_files
call_diffoscope_on_changes_files # defines DIFFOSCOPE, update_db_and_html defines STATUS
share_buildinfo
fi
print_out_duration
cd ..
cleanup_all
trap - INT TERM EXIT
build_rebuild