summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2014-10-14 10:49:13 +0200
committerHolger Levsen <holger@layer-acht.org>2014-10-14 10:49:13 +0200
commitd45b58ffbf1251467162cd5eacde5833bd244f82 (patch)
tree1138b29fe58433ee80db230ce2b7068a03b5f7ba
parente2d089042ed30b1043c30fce62a53dac729a541e (diff)
downloadjenkins.debian.net-d45b58ffbf1251467162cd5eacde5833bd244f82.tar.xz
reproducible: refactor
-rwxr-xr-xbin/reproducible_build.sh16
-rwxr-xr-xbin/reproducible_common.sh50
-rwxr-xr-xbin/reproducible_schedule_on_demand.sh21
-rwxr-xr-xbin/reproducible_scheduler.sh21
-rwxr-xr-xbin/reproducible_setup.sh36
-rwxr-xr-xbin/reproducible_stats.sh18
6 files changed, 63 insertions, 99 deletions
diff --git a/bin/reproducible_build.sh b/bin/reproducible_build.sh
index 4682f15a..0ecfb10d 100755
--- a/bin/reproducible_build.sh
+++ b/bin/reproducible_build.sh
@@ -6,20 +6,8 @@
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
-# define db
-PACKAGES_DB=/var/lib/jenkins/reproducible.db
-INIT=/var/lib/jenkins/reproducible.init
-if [ ! -f $PACKAGES_DB ] ; then
- echo "$PACKAGES_DB doesn't exist, no builds possible."
- exit 1
-elif [ -f $PACKAGES_DB.lock ] ; then
- for i in $(seq 0 100) ; do
- sleep 15
- [ -f $PACKAGES_DB.lock ] || break
- done
- echo "$PACKAGES_DB.lock still exist, exiting."
- exit 1
-fi
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
# create dirs for results
mkdir -p /var/lib/jenkins/userContent/dbd/ /var/lib/jenkins/userContent/buildinfo/ /var/lib/jenkins/userContent/rbuild/
diff --git a/bin/reproducible_common.sh b/bin/reproducible_common.sh
new file mode 100755
index 00000000..9021dfc0
--- /dev/null
+++ b/bin/reproducible_common.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Copyright 2014 Holger Levsen <holger@layer-acht.org>
+# released under the GPLv=2
+
+#
+# included by all reproducible_*.sh scripts
+#
+# define db
+PACKAGES_DB=/var/lib/jenkins/reproducible.db
+INIT=/var/lib/jenkins/reproducible.init
+if [ -f $PACKAGES_DB ] && [ -f $INIT ] ; then
+ if [ -f $PACKAGES_DB.lock ] ; then
+ for i in $(seq 0 100) ; do
+ sleep 15
+ if [ -! -f $PACKAGES_DB.lock ] ; then
+ break
+ fi
+ done
+ echo "$PACKAGES_DB.lock still exist, exiting."
+ exit 1
+ fi
+elif [ ! -f ${PACKAGES_DB} ] ; then
+ echo "Warning: $PACKAGES_DB doesn't exist, creating it now."
+ echo
+ # create sqlite db if needed
+ sqlite3 ${PACKAGES_DB} '
+ CREATE TABLE source_packages
+ (name TEXT NOT NULL,
+ version TEXT NOT NULL,
+ status TEXT NOT NULL
+ CHECK (status IN ("blacklisted", "FTBFS","reproducible","unreproducible","404", "not for us")),
+ build_date TEXT NOT NULL,
+ PRIMARY KEY (name))'
+ sqlite3 ${PACKAGES_DB} '
+ CREATE TABLE sources_scheduled
+ (name TEXT NOT NULL,
+ date_scheduled TEXT NOT NULL,
+ date_build_started TEXT NOT NULL,
+ PRIMARY KEY (name))'
+ sqlite3 ${PACKAGES_DB} '
+ CREATE TABLE sources
+ (name TEXT NOT NULL,
+ version TEXT NOT NULL)'
+ # 30 seconds timeout when trying to get a lock
+ cat >/var/lib/jenkins/reproducible.init <<-EOF
+.timeout 60000
+EOF
+fi
+
diff --git a/bin/reproducible_schedule_on_demand.sh b/bin/reproducible_schedule_on_demand.sh
index dea11680..a407d1b5 100755
--- a/bin/reproducible_schedule_on_demand.sh
+++ b/bin/reproducible_schedule_on_demand.sh
@@ -6,24 +6,8 @@
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
-set +x
-
-#
-# define db
-#
-PACKAGES_DB=/var/lib/jenkins/reproducible.db
-INIT=/var/lib/jenkins/reproducible.init
-if [ ! -f $PACKAGES_DB ] ; then
- echo "$PACKAGES_DB doesn't exist, no builds possible."
- exit 1
-elif [ -f $PACKAGES_DB.lock ] ; then
- for i in $(seq 0 100) ; do
- sleep 15
- [ -f $PACKAGES_DB.lock ] || break
- done
- echo "$PACKAGES_DB.lock still exist, exiting."
- exit 1
-fi
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
schedule_packages() {
DATE="2014-10-01 00:23"
@@ -56,6 +40,7 @@ check_candidates() {
#
# main
#
+set +x
CANDIDATES="$@"
check_candidates
if [ $#{PACKAGES} -gt 256 ] ; then
diff --git a/bin/reproducible_scheduler.sh b/bin/reproducible_scheduler.sh
index f5498484..85358e27 100755
--- a/bin/reproducible_scheduler.sh
+++ b/bin/reproducible_scheduler.sh
@@ -6,24 +6,8 @@
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
-set +x
-
-#
-# define db
-#
-PACKAGES_DB=/var/lib/jenkins/reproducible.db
-INIT=/var/lib/jenkins/reproducible.init
-if [ ! -f $PACKAGES_DB ] ; then
- echo "$PACKAGES_DB doesn't exist, no builds possible."
- exit 1
-elif [ -f $PACKAGES_DB.lock ] ; then
- for i in $(seq 0 100) ; do
- sleep 15
- [ -f $PACKAGES_DB.lock ] || break
- done
- echo "$PACKAGES_DB.lock still exist, exiting."
- exit 1
-fi
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
#
# functions, see below for main
@@ -157,6 +141,7 @@ schedule_packages() {
#
# main
#
+set +x
update_apt
SCHEDULED=$(sqlite3 ${PACKAGES_DB} 'SELECT count(name) FROM sources_scheduled')
if [ $SCHEDULED -gt 250 ] ; then
diff --git a/bin/reproducible_setup.sh b/bin/reproducible_setup.sh
index 03fd4972..2c31efbc 100755
--- a/bin/reproducible_setup.sh
+++ b/bin/reproducible_setup.sh
@@ -6,40 +6,8 @@
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
-# create sqlite db
-PACKAGES_DB=/var/lib/jenkins/reproducible.db
-if [ ! -f ${PACKAGES_DB} ] ; then
- sqlite3 ${PACKAGES_DB} '
- CREATE TABLE source_packages
- (name TEXT NOT NULL,
- version TEXT NOT NULL,
- status TEXT NOT NULL
- CHECK (status IN ("blacklisted", "FTBFS","reproducible","unreproducible","404", "not for us")),
- build_date TEXT NOT NULL,
- PRIMARY KEY (name))'
- sqlite3 ${PACKAGES_DB} '
- CREATE TABLE sources_scheduled
- (name TEXT NOT NULL,
- date_scheduled TEXT NOT NULL,
- date_build_started TEXT NOT NULL,
- PRIMARY KEY (name))'
- sqlite3 ${PACKAGES_DB} '
- CREATE TABLE sources
- (name TEXT NOT NULL,
- version TEXT NOT NULL)'
-elif [ -f $PACKAGES_DB.lock ] ; then
- for i in $(seq 0 100) ; do
- sleep 15
- [ -f $PACKAGES_DB.lock ] || break
- done
- echo "$PACKAGES_DB.lock still exist, exiting."
- exit 1
-fi
-# 30 seconds timeout when trying to get a lock
-INIT=/var/lib/jenkins/reproducible.init
-cat >/var/lib/jenkins/reproducible.init <<-EOF
-.timeout 60000
-EOF
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
set +x
# blacklist some packages
diff --git a/bin/reproducible_stats.sh b/bin/reproducible_stats.sh
index 933a666d..434cd885 100755
--- a/bin/reproducible_stats.sh
+++ b/bin/reproducible_stats.sh
@@ -6,22 +6,10 @@
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
-set +x
-# define db
-PACKAGES_DB=/var/lib/jenkins/reproducible.db
-INIT=/var/lib/jenkins/reproducible.init
-if [ ! -f $PACKAGES_DB ] ; then
- echo "$PACKAGES_DB doesn't exist, no stats possible."
- exit 1
-elif [ -f $PACKAGES_DB.lock ] ; then
- for i in $(seq 0 100) ; do
- sleep 15
- [ -f $PACKAGES_DB.lock ] || break
- done
- echo "$PACKAGES_DB.lock still exist, exiting."
- exit 1
-fi
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
+set +x
declare -A GOOD
declare -A BAD
declare -A UGLY