summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/reproducible_build.sh18
-rwxr-xr-xbin/reproducible_db_maintenance.py21
-rwxr-xr-xbin/reproducible_scheduler.py4
3 files changed, 32 insertions, 11 deletions
diff --git a/bin/reproducible_build.sh b/bin/reproducible_build.sh
index 79bc3060..e8256318 100755
--- a/bin/reproducible_build.sh
+++ b/bin/reproducible_build.sh
@@ -24,8 +24,8 @@ create_results_dirs() {
handle_race_condition() {
echo | tee -a $BUILDLOG
- local RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT builder FROM schedule WHERE package_id='$SRCPKGID'")
- local msg="Warning, package ${SRCPACKAGE} (id=$SRCPKGID) in ${SUITE} is building at $RESULT, this is $BUILD_URL.\n"
+ local RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT job FROM schedule WHERE package_id='$SRCPKGID'")
+ local msg="Warning, package ${SRCPACKAGE} (id=$SRCPKGID) in ${SUITE} on ${ARCH} is probably already building at $RESULT, while this is $BUILD_URL.\n"
printf "$msg" | tee -a $BUILDLOG
printf "$(date -u) - $msg" >> /var/log/jenkins/reproducible-race-conditions.log
echo "$(date -u) - Terminating this build quickly and nicely..." | tee -a $RBUILDLOG
@@ -275,7 +275,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='', builder='' WHERE package_id='$SRCPKGID'"
+ sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started='', job='' WHERE package_id='$SRCPKGID'"
NOTIFY=""
}
@@ -401,7 +401,7 @@ call_diffoscope_on_changes_files() {
choose_package() {
local RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "
- SELECT s.suite, s.id, s.name, sch.date_scheduled, sch.save_artifacts, sch.notify, s.notify_maintainer, sch.builder
+ SELECT s.suite, s.id, s.name, sch.date_scheduled, sch.save_artifacts, sch.notify, s.notify_maintainer
FROM schedule AS sch JOIN sources AS s ON sch.package_id=s.id
WHERE sch.date_build_started=''
AND s.architecture='$ARCH'
@@ -421,13 +421,13 @@ choose_package() {
# remove previous build attempts which didnt finish correctly:
BUILDER_PREFIX="${JOB_NAME#reproducible_builder_}/"
BAD_BUILDS=$(mktemp --tmpdir=$TMPDIR)
- sqlite3 -init $INIT ${PACKAGES_DB} "SELECT package_id, date_build_started, builder FROM schedule WHERE builder LIKE '${BUILDER_PREFIX}%'" > $BAD_BUILDS
+ sqlite3 -init $INIT ${PACKAGES_DB} "SELECT package_id, date_build_started, job FROM schedule WHERE job LIKE '${BUILDER_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='', builder='' WHERE builder LIKE '${BUILDER_PREFIX}%'"
+ sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started='', job='' WHERE job LIKE '${BUILDER_PREFIX}%'"
echo >> $STALELOG
fi
rm -f $BAD_BUILDS
@@ -437,8 +437,8 @@ choose_package() {
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', builder='$JOB' WHERE package_id='$SRCPKGID' AND date_build_started=''"
- RESULT=$(sqlite3 -init $INIT ${PACKAGES_DB} "SELECT date_build_started FROM schedule WHERE package_id='$SRCPKGID' AND date_build_started='$DATE' AND builder='$JOB'")
+ sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started='$DATE', job='$JOB' WHERE package_id='$SRCPKGID' AND date_build_started=''"
+ RESULT=$(sqlite3 -init $INIT ${PACKAGES_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
@@ -693,7 +693,7 @@ build_rebuild() {
if [ ! -f b1/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes ] && [ -f b1/${SRCPACKAGE}_*_${ARCH}.changes ] ; then
echo "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..." | tee -a ${RBUILDLOG}
# reschedule the package for later and quit the build without saving anything
- sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started='', builder='', date_scheduled='$(date -u +'%Y-%m-%d %H:%M')' WHERE package_id='$SRCPKGID'"
+ sqlite3 -init $INIT ${PACKAGES_DB} "UPDATE schedule SET date_build_started='', job='', date_scheduled='$(date -u +'%Y-%m-%d %H:%M')' WHERE package_id='$SRCPKGID'"
NOTIFY=""
exit 0
elif [ -f b1/${SRCPACKAGE}_${EVERSION}_${ARCH}.changes ] ; then
diff --git a/bin/reproducible_db_maintenance.py b/bin/reproducible_db_maintenance.py
index ec01205c..9bed6591 100755
--- a/bin/reproducible_db_maintenance.py
+++ b/bin/reproducible_db_maintenance.py
@@ -525,6 +525,27 @@ schema_updates = {
'DROP TABLE results',
'ALTER TABLE results_tmp RENAME TO results',
'INSERT INTO rb_schema VALUES ("24", "' + now + '")'],
+ 25: [ # rename the builder column also on the schedule table.
+ '''CREATE TABLE schedule_tmp
+ (id INTEGER PRIMARY KEY,
+ package_id INTEGER NOT NULL,
+ date_scheduled TEXT NOT NULL,
+ scheduler TEXT,
+ date_build_started TEXT,
+ job TEXT,
+ notify TEXT NOT NULL DEFAULT '',
+ save_artifacts INTEGER DEFAULT 0,
+ UNIQUE (package_id),
+ FOREIGN KEY(package_id) REFERENCES sources(id))''',
+ 'UPDATE schedule SET notify = "" WHERE notify IS NULL',
+ '''INSERT INTO schedule_tmp (id, package_id, date_scheduled, scheduler,
+ date_build_started, job, notify, save_artifacts)
+ SELECT id, package_id, date_scheduled, scheduler,
+ date_build_started, builder, notify, save_artifacts
+ FROM schedule''',
+ 'DROP TABLE schedule',
+ 'ALTER TABLE schedule_tmp RENAME TO schedule',
+ 'INSERT INTO rb_schema VALUES ("25", "' + now + '")'],
}
diff --git a/bin/reproducible_scheduler.py b/bin/reproducible_scheduler.py
index 31d0f3f6..3149cef2 100755
--- a/bin/reproducible_scheduler.py
+++ b/bin/reproducible_scheduler.py
@@ -301,8 +301,8 @@ def schedule_packages(packages):
pkgs = ((x, packages[x]) for x in packages)
log.debug('IDs about to be scheduled: ' + str(packages.keys()))
query = 'INSERT INTO schedule ' + \
- '(package_id, date_scheduled, date_build_started) ' + \
- 'VALUES (?, ?, "")'
+ '(package_id, date_scheduled) ' + \
+ 'VALUES (?, ?)'
cursor = conn_db.cursor()
cursor.executemany(query, pkgs)
conn_db.commit()