summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/reproducible_build.sh')
-rwxr-xr-xbin/reproducible_build.sh34
1 files changed, 17 insertions, 17 deletions
diff --git a/bin/reproducible_build.sh b/bin/reproducible_build.sh
index fe87b232..d83b2c68 100755
--- a/bin/reproducible_build.sh
+++ b/bin/reproducible_build.sh
@@ -57,7 +57,7 @@ create_results_dirs() {
}
handle_race_condition() {
- local RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT job FROM schedule WHERE package_id='$SRCPKGID'")
+ local RESULT=$(query_db "SELECT job FROM schedule WHERE package_id='$SRCPKGID'")
local msg="Package ${SRCPACKAGE} (id=$SRCPKGID) in ${SUITE} on ${ARCH} is probably already building at $RESULT, while this is $BUILD_URL.\n"
log_warning "$msg"
printf "$(date -u) - $msg" >> /var/log/jenkins/reproducible-race-conditions.log
@@ -127,8 +127,8 @@ update_db_and_html() {
if [ -z "$VERSION" ] ; then
VERSION="None"
fi
- local OLD_STATUS=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT status FROM results WHERE package_id='${SRCPKGID}'" || \
- sqlite3 -init $INIT ${PACKAGES_DB} "SELECT status FROM results WHERE package_id='${SRCPKGID}'")
+ local OLD_STATUS=$(query_db "SELECT status FROM results WHERE package_id='${SRCPKGID}'" || \
+ query_db "SELECT status FROM results WHERE package_id='${SRCPKGID}'")
# irc+mail notifications for changing status in unstable and experimental
if [ "$SUITE" != "testing" ] ; then
if [ "${OLD_STATUS}" = "reproducible" ] && [ "$STATUS" != "depwait" ] && \
@@ -145,15 +145,15 @@ update_db_and_html() {
echo "$(date -u +'%Y-%m-%d %H:%M') $DEBIAN_URL/$SUITE/$ARCH/$SRCPACKAGE changed from $OLD_STATUS -> $STATUS" >> /srv/reproducible-results/notification-emails/$SRCPACKAGE
fi
fi
- sqlite3 -init $INIT ${PACKAGES_DB} "REPLACE INTO results (package_id, version, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPKGID', '$VERSION', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')" || \
- sqlite3 -init $INIT ${PACKAGES_DB} "REPLACE INTO results (package_id, version, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPKGID', '$VERSION', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')"
+ query_db "REPLACE INTO results (package_id, version, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPKGID', '$VERSION', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')" || \
+ query_db "REPLACE INTO results (package_id, version, status, build_date, build_duration, node1, node2, job) VALUES ('$SRCPKGID', '$VERSION', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB')"
if [ ! -z "$DURATION" ] ; then # this happens when not 404 and not_for_us
- sqlite3 -init $INIT ${PACKAGES_DB} "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job, schedule_message) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB', '$SCHEDULE_MESSAGE')" || \
- sqlite3 -init $INIT ${PACKAGES_DB} "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job, schedule_message) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB', '$SCHEDULE_MESSAGE')"
+ query_db "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job, schedule_message) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB', '$SCHEDULE_MESSAGE')" || \
+ query_db "INSERT INTO stats_build (name, version, suite, architecture, status, build_date, build_duration, node1, node2, job, schedule_message) VALUES ('$SRCPACKAGE', '$VERSION', '$SUITE', '$ARCH', '$STATUS', '$DATE', '$DURATION', '$NODE1', '$NODE2', '$JOB', '$SCHEDULE_MESSAGE')"
fi
# unmark build since it's properly finished
- sqlite3 -init $INIT ${PACKAGES_DB} "DELETE FROM schedule WHERE package_id='$SRCPKGID';" || \
- sqlite3 -init $INIT ${PACKAGES_DB} "DELETE FROM schedule WHERE package_id='$SRCPKGID';"
+ query_db "DELETE FROM schedule WHERE package_id='$SRCPKGID';" || \
+ query_db "DELETE FROM schedule WHERE package_id='$SRCPKGID';"
gen_package_html $SRCPACKAGE
echo
echo "$(date -u) - successfully updated the database and updated $DEBIAN_URL/rb-pkg/${SUITE}/${ARCH}/$SRCPACKAGE.html"
@@ -300,7 +300,7 @@ handle_reproducible() {
unregister_build() {
# unregister this build so it will immeditiatly tried again
- sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started = NULL, job = NULL WHERE package_id='$SRCPKGID'"
+ query_db "UPDATE schedule SET date_build_started = NULL, job = NULL WHERE package_id='$SRCPKGID'"
NOTIFY=""
}
@@ -422,7 +422,7 @@ call_diffoscope_on_buildinfo_files() {
}
choose_package() {
- local RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "
+ local RESULT=$(query_db "
SELECT s.suite, s.id, s.name, sch.date_scheduled, sch.save_artifacts, sch.notify, s.notify_maintainer, sch.message
FROM schedule AS sch JOIN sources AS s ON sch.package_id=s.id
WHERE sch.date_build_started is NULL
@@ -443,24 +443,24 @@ choose_package() {
# remove previous build attempts which didnt finish correctly:
JOB_PREFIX="${JOB_NAME#reproducible_builder_}/"
BAD_BUILDS=$(mktemp --tmpdir=$TMPDIR)
- sqlite3 -init $INIT ${PACKAGES_DB} "SELECT package_id, date_build_started, job FROM schedule WHERE job LIKE '${JOB_PREFIX}%'" > $BAD_BUILDS
+ query_db "SELECT package_id, date_build_started, job FROM schedule WHERE job LIKE '${JOB_PREFIX}%'" > $BAD_BUILDS
if [ -s "$BAD_BUILDS" ] ; then
local STALELOG=/var/log/jenkins/reproducible-stale-builds.log
# reproducible-stale-builds.log is mailed once a day by reproducible_maintenance.sh
echo "$(date -u) - stale builds found, cleaning db from these:" | tee -a $STALELOG
cat $BAD_BUILDS | tee -a $STALELOG
- sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started = NULL, job = NULL WHERE job LIKE '${JOB_PREFIX}%'"
+ query_db "UPDATE schedule SET date_build_started = NULL, job = NULL WHERE job LIKE '${JOB_PREFIX}%'"
echo >> $STALELOG
fi
rm -f $BAD_BUILDS
# mark build attempt, first test if none else marked a build attempt recently
echo "ok, let's check if $SRCPACKAGE is building anywhere yet…"
- RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT date_build_started FROM schedule WHERE package_id='$SRCPKGID'")
+ RESULT=$(query_db "SELECT date_build_started FROM schedule WHERE package_id='$SRCPKGID'")
if [ -z "$RESULT" ] ; then
echo "ok, $SRCPACKAGE is not building anywhere…"
# try to update the schedule with our build attempt, then check no else did it, if so, abort
- sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started='$DATE', job='$JOB' WHERE package_id='$SRCPKGID' AND date_build_started IS NULL"
- RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT date_build_started FROM schedule WHERE package_id='$SRCPKGID' AND date_build_started='$DATE' AND job='$JOB'")
+ query_db "UPDATE schedule SET date_build_started='$DATE', job='$JOB' WHERE package_id='$SRCPKGID' AND date_build_started IS NULL"
+ RESULT=$(query_db "SELECT date_build_started FROM schedule WHERE package_id='$SRCPKGID' AND date_build_started='$DATE' AND job='$JOB'")
if [ -z "$RESULT" ] ; then
echo "hm, seems $SRCPACKAGE is building somewhere… failed to update the schedule table with our build ($SRCPKGID, $DATE, $JOB)."
handle_race_condition
@@ -788,7 +788,7 @@ build_rebuild() {
if [ ! -f b1/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes ] && [ -f b1/${SRCPACKAGE}_*_${ARCH}.changes ] ; then
log_error "Version mismatch between main node (${SRCPACKAGE}_${EVERSION}_${ARCH}.dsc expected) and first build node ($(ls b1/*dsc)) for $SUITE/$ARCH, aborting. Please upgrade the schroots..."
# reschedule the package for later and quit the build without saving anything
- sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started = NULL, job = NULL, date_scheduled='$(date -u +'%Y-%m-%d %H:%M')' WHERE package_id='$SRCPKGID'"
+ 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 [ -f b1/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes ] ; then