From 61969fd285d66b3dd5de8694884f1791d9813f44 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Sat, 18 Oct 2014 22:18:15 +0200 Subject: reproducible: add housekeeping job --- bin/reproducible_housekeeping.sh | 55 ++++++++++++++++++++++++++++++++++++++++ bin/reproducible_setup.sh | 3 --- job-cfg/reproducible.yaml | 9 +++++++ logparse/reproducible.rules | 1 + 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100755 bin/reproducible_housekeeping.sh diff --git a/bin/reproducible_housekeeping.sh b/bin/reproducible_housekeeping.sh new file mode 100755 index 00000000..717e0a23 --- /dev/null +++ b/bin/reproducible_housekeeping.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright 2014 Holger Levsen +# released under the GPLv=2 + +. /srv/jenkins/bin/common-functions.sh +common_init "$@" + +# common code defining db access +. /srv/jenkins/bin/reproducible_common.sh + +# common +set +x +REP_RESULTS=/srv/reproducible-results + +# prepare backup +mkdir -p $REP_RESULTS/backup +cd $REP_RESULTS/backup + +# keep 30 days and the 1st of the month +DAY=(date -d "30 day ago" '+%d') +DATE=$(date -d "30 day ago" '+%Y-%m-%d') +if [ "$DAY" != "01" ] && [ -f reproducible_$DATE.db.xz ] ; then + rm -f reproducible_$DATE.db.xz +fi + +# actually do the backup +DATE=$(date '+%Y-%m-%d') +if [ ! -f reproducible_$DATE.db.xz ] ; then + cp $PACKAGES_DB . + DATE=$(date '+%Y-%m-%d') + mv reproducible.db reproducible_$DATE.db + xz reproducible_$DATE.db +fi + +# find and warn about old temp directories +OLDSTUFF=$(find $REP_RESULTS -type d -name "tmp.*" -mtime +7 -exec ls -lad {} \;) +if [ ! -z "$OLDSTUFF" ] ; then + echo + echo "Warnung: old temp directories found in $REP_RESULTS" + echo "$OLDSTUFF" + echo "Please cleanup manually." + echo +fi + +# find and warn about pbuild leftovers +OLDSTUFF=$(find /var/cache/pbuilder/result/ -mtime +7 -exec ls -lad {} \;) +if [ ! -z "$OLDSTUFF" ] ; then + echo + echo "Warnung: old temp directories found in /var/cache/pbuilder/result/" + echo "$OLDSTUFF" + echo "Please cleanup manually." + echo +fi + diff --git a/bin/reproducible_setup.sh b/bin/reproducible_setup.sh index f5cab3d8..6075789f 100755 --- a/bin/reproducible_setup.sh +++ b/bin/reproducible_setup.sh @@ -9,9 +9,6 @@ common_init "$@" # common code defining db access . /srv/jenkins/bin/reproducible_common.sh -# cp db away for backup purposes -cp $PACKAGES_DB /var/lib/jenkins/userContent/reproducible.db - set +x # blacklist some packages for PKG in linux cups zurl openclipart eigen3 xmds2 ; do diff --git a/job-cfg/reproducible.yaml b/job-cfg/reproducible.yaml index f68c51b7..8fac14d2 100644 --- a/job-cfg/reproducible.yaml +++ b/job-cfg/reproducible.yaml @@ -115,6 +115,10 @@ unstable-on-warning: 'true' fail-on-error: 'true' +- job-template: + defaults: reproducible + name: '{name}_housekeeping' + - job-template: defaults: reproducible name: '{name}_setup_pbuilder' @@ -165,6 +169,11 @@ - project: name: reproducible jobs: + - '{name}_housekeeping': + my_description: 'Do some housekeeping, check no old directories are laying around, do backups, etc.' + my_timed: '0 12 * * *' + my_shell: '/srv/jenkins/bin/reproducible_housekeeping.sh' + my_recipients: 'holger@layer-acht.org' - '{name}_setup_pbuilder': my_description: 'Setup pbuilder for reproducible builds as described in https://wiki.debian.org/ReproducibleBuilds#Usage_example' my_timed: '23 0 * * *' diff --git a/logparse/reproducible.rules b/logparse/reproducible.rules index 95e3e12c..08a0a289 100644 --- a/logparse/reproducible.rules +++ b/logparse/reproducible.rules @@ -4,4 +4,5 @@ warning /Warning: .+ is not a source package, or was removed or renamed. Please investigate./ warning /Warning: Download of .+ sources failed./ warning /Warning: .+ contains invalid yaml, please fix./ +warning /Warnung: old temp directories found in .+/ -- cgit v1.2.3-70-g09d2