From ff0d8d849527bec10a37bac361cc7b5d3e31ac47 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Sun, 5 Oct 2014 02:15:09 +0200 Subject: reproducible: move db creation to _setup.sh --- bin/reproducible_build.sh | 40 ++++++++-------------------------------- bin/reproducible_setup.sh | 32 ++++++++++++++++++++++++++++++++ bin/reproducible_stats.sh | 7 ++----- 3 files changed, 42 insertions(+), 37 deletions(-) (limited to 'bin') diff --git a/bin/reproducible_build.sh b/bin/reproducible_build.sh index 12ab291a..c55dc0b1 100755 --- a/bin/reproducible_build.sh +++ b/bin/reproducible_build.sh @@ -6,6 +6,14 @@ . /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 +fi + # FIXME: needed as long as #763328 (RFP: /usr/bin/diffp) is unfixed... # fetch git repo for the diffp command used later if [ -d debbindiff.git ] ; then @@ -20,38 +28,6 @@ fi mkdir -p results/ mkdir -p /var/lib/jenkins/userContent/diffp/ /var/lib/jenkins/userContent/pbuilder/ -# 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 ("FTBFS","reproducible","unreproducible","404", "not for us")), - build_date TEXT NOT NULL, - diffp_path TEXT, - PRIMARY KEY (name))' - sqlite3 ${PACKAGES_DB} ' - CREATE TABLE source_stats - (suite TEXT NOT NULL, - amount INTEGER NOT NULL, - PRIMARY KEY (suite))' - sqlite3 ${PACKAGES_DB} ' - CREATE TABLE job_sources - (name TEXT NOT NULL, - job TEXT NOT NULL)' - sqlite3 ${PACKAGES_DB} ' - CREATE TABLE sources - (name TEXT NOT NULL, - version TEXT NOT NULL)' -fi -# 30 seconds timeout when trying to get a lock -INIT=/var/lib/jenkins/reproducible.init -cat >/var/lib/jenkins/reproducible.init <<-EOF -.timeout 30000 -EOF - # this needs sid entries in sources.list: grep deb-src /etc/apt/sources.list | grep sid # try apt-get update twice, else fail gracefully, aka not. diff --git a/bin/reproducible_setup.sh b/bin/reproducible_setup.sh index 1a55f28e..1e15d21f 100755 --- a/bin/reproducible_setup.sh +++ b/bin/reproducible_setup.sh @@ -6,6 +6,38 @@ . /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 ("FTBFS","reproducible","unreproducible","404", "not for us")), + build_date TEXT NOT NULL, + diffp_path TEXT, + PRIMARY KEY (name))' + sqlite3 ${PACKAGES_DB} ' + CREATE TABLE source_stats + (suite TEXT NOT NULL, + amount INTEGER NOT NULL, + PRIMARY KEY (suite))' + sqlite3 ${PACKAGES_DB} ' + CREATE TABLE job_sources + (name TEXT NOT NULL, + job TEXT NOT NULL)' + sqlite3 ${PACKAGES_DB} ' + CREATE TABLE sources + (name TEXT NOT NULL, + version TEXT NOT NULL)' +fi +# 30 seconds timeout when trying to get a lock +INIT=/var/lib/jenkins/reproducible.init +cat >/var/lib/jenkins/reproducible.init <<-EOF +.timeout 30000 +EOF + TMPFILE=$(mktemp) cat > ${TMPFILE} <<- EOF echo "-----BEGIN PGP PUBLIC KEY BLOCK----- diff --git a/bin/reproducible_stats.sh b/bin/reproducible_stats.sh index b716685f..52f72905 100755 --- a/bin/reproducible_stats.sh +++ b/bin/reproducible_stats.sh @@ -7,16 +7,13 @@ 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 fi -# 30 seconds timeout when trying to get a lock -INIT=/var/lib/jenkins/reproducible.init -cat >/var/lib/jenkins/reproducible.init <<-EOF -.timeout 30000 -EOF SUITE=sid AMOUNT=$(sqlite3 -init $INIT $PACKAGES_DB "SELECT amount FROM source_stats WHERE suite = \"$SUITE\"" | xargs echo) -- cgit v1.2.3-70-g09d2