From: Joerg Jaspert Date: Sun, 5 Sep 2010 14:26:12 +0000 (+0200) Subject: rename cron.hourly X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=99ba94686d0dc810dad10a1f5531d23bd886cf5a;p=dak.git rename cron.hourly rename scriptsdir Signed-off-by: Joerg Jaspert --- diff --git a/config/backports/cron.dinstall b/config/backports/cron.dinstall new file mode 100755 index 00000000..0841f838 --- /dev/null +++ b/config/backports/cron.dinstall @@ -0,0 +1,530 @@ +#!/bin/bash +# No way I try to deal with a crippled sh just for POSIX foo. + +# Copyright (C) 2009 Joerg Jaspert +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Homer: Are you saying you're never going to eat any animal again? What +# about bacon? +# Lisa: No. +# Homer: Ham? +# Lisa: No. +# Homer: Pork chops? +# Lisa: Dad, those all come from the same animal. +# Homer: Heh heh heh. Ooh, yeah, right, Lisa. A wonderful, magical animal. + +# exit on errors +set -e +# make sure to only use defined variables +set -u +# ERR traps should be inherited from functions too. (And command +# substitutions and subshells and whatnot, but for us the functions is +# the important part here) +set -E + +# import the general variable set. +export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars +. $SCRIPTVARS + +######################################################################## +# Functions # +######################################################################## +# common functions are "outsourced" +. "${configdir}/common" + +# source the dinstall functions +. "${configdir}/dinstall.functions" + +######################################################################## +######################################################################## + +# Function to save which stage we are in, so we can restart an interrupted +# dinstall. Or even run actions in parallel, if we dare to, by simply +# backgrounding the call to this function. But that should only really be +# done for things we don't care much about. +# +# This should be called with the first argument being an array, with the +# members +# - FUNC - the function name to call +# - ARGS - Possible arguments to hand to the function. Can be the empty string +# - TIME - The timestamp name. Can be the empty string +# - ERR - if this is the string false, then the call will be surrounded by +# set +e ... set -e calls, so errors in the function do not exit +# dinstall. Can be the empty string, meaning true. +# +# MAKE SURE TO KEEP THIS THE LAST FUNCTION, AFTER ALL THE VARIOUS ONES +# ADDED FOR DINSTALL FEATURES! +function stage() { + ARGS='GO[@]' + local "${!ARGS}" + + error=${ERR:-"true"} + + STAGEFILE="${stagedir}/${FUNC}" + if [ -f "${STAGEFILE}" ]; then + stamptime=$(/usr/bin/stat -c %Z "${STAGEFILE}") + unixtime=$(date +%s) + difference=$(( $unixtime - $stamptime )) + if [ ${difference} -ge 14400 ]; then + log_error "Did already run ${FUNC}, stagefile exists, but that was ${difference} seconds ago. Please check." + else + log "Did already run ${FUNC}, not calling again..." + fi + return + fi + + debug "Now calling function ${FUNC}. Arguments: ${ARGS}. Timestamp: ${TIME}" + + # Make sure we are always at the same place. If a function wants to be elsewhere, + # it has to cd first! + cd ${configdir} + + # Now redirect the output into $STAGEFILE.log. In case it errors out somewhere our + # errorhandler trap can then mail the contents of $STAGEFILE.log only, instead of a whole + # dinstall logfile. Short error mails ftw! + exec >> "${STAGEFILE}.log" 2>&1 + + if [ -f "${LOCK_STOP}" ]; then + log "${LOCK_STOP} exists, exiting immediately" + exit 42 + fi + + if [ "${error}" = "false" ]; then + set +e + fi + ${FUNC} ${ARGS} + + # No matter what happened in the function, we make sure we have set -e default state back + set -e + + # Make sure we are always at the same place. + cd ${configdir} + + # We always use the same umask. If a function wants to do different, fine, but we reset. + umask 022 + + touch "${STAGEFILE}" + + if [ -n "${TIME}" ]; then + ts "${TIME}" + fi + + # And the output goes back to the normal logfile + exec >> "$LOGFILE" 2>&1 + + # Now we should make sure that we have a usable dinstall.log, so append the $STAGEFILE.log + # to it. + cat "${STAGEFILE}.log" >> "${LOGFILE}" + rm -f "${STAGEFILE}.log" + + if [ -f "${LOCK_STOP}" ]; then + log "${LOCK_STOP} exists, exiting immediately" + exit 42 + fi +} + +######################################################################## + +# We need logs. +LOGFILE="$logdir/dinstall.log" + +exec >> "$LOGFILE" 2>&1 + +# And now source our default config +. "${configdir}/dinstall.variables" + +# Make sure we start out with a sane umask setting +umask 022 + +# And use one locale, no matter what the caller has set +export LANG=C +export LC_ALL=C + +touch "${DINSTALLSTART}" +ts "startup" +DINSTALLBEGIN="$(date -u +"%a %b %d %T %Z %Y (%s)")" +state "Startup" + +lockfile -l 3600 "${LOCK_DAILY}" +trap onerror ERR +trap cleanup EXIT TERM HUP INT QUIT + +touch "${LOCK_BRITNEY}" + +GO=( + FUNC="savetimestamp" + TIME="" + ARGS="" + ERR="false" +) +stage $GO + +GO=( + FUNC="merkel1" + TIME="init" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="pgdump_pre" + TIME="pg_dump1" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="updates" + TIME="External Updates" + ARGS="" + ERR="false" +) +stage $GO + +GO=( + FUNC="i18n1" + TIME="i18n 1" + ARGS="" + ERR="false" +) +stage $GO + +lockfile "$LOCK_ACCEPTED" +lockfile "$LOCK_NEW" + +GO=( + FUNC="punew" + TIME="p-u-new" + ARGS="proposedupdates" + ERR="false" +) +stage $GO + +#GO=( +# FUNC="opunew" +# TIME="o-p-u-new" +# ARGS="oldproposedupdates" +# ERR="false" +#) +#stage $GO + +GO=( + FUNC="newstage" + TIME="newstage" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="cruft" + TIME="cruft" + ARGS="" + ERR="" +) +stage $GO + +state "indices" + +GO=( + FUNC="dominate" + TIME="dominate" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="filelist" + TIME="generate-filelist" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="fingerprints" + TIME="import-keyring" + ARGS="" + ERR="false" +) +stage $GO + +GO=( + FUNC="overrides" + TIME="overrides" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="mpfm" + TIME="pkg-file-mapping" + ARGS="" + ERR="false" +) +stage $GO + +state "packages/contents" +GO=( + FUNC="packages" + TIME="apt-ftparchive" + ARGS="" + ERR="" +) +# Careful: When we ever go and remove this monster-long thing, we have to check the backgrounded +# functions before it. We no longer have a 1.5hour sync point then. +stage $GO + +state "dists/" +GO=( + FUNC="pdiff" + TIME="pdiff" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="release" + TIME="release files" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="dakcleanup" + TIME="cleanup" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="buildd_dir" + TIME="buildd_dir" + ARGS="" + ERR="" +) +stage $GO + +state "scripts" +GO=( + FUNC="mkmaintainers" + TIME="mkmaintainers" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="mkuploaders" + TIME="mkuploaders" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="copyoverrides" + TIME="copyoverrides" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="mklslar" + TIME="mklslar" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="mkfilesindices" + TIME="mkfilesindices" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="mkchecksums" + TIME="mkchecksums" + ARGS="" + ERR="" +) +stage $GO + +GO=( + FUNC="mirror" + TIME="mirror hardlinks" + ARGS="" + ERR="" +) +stage $GO + +rm -f "$LOCK_ACCEPTED" +rm -f "$LOCK_NEW" +rm -f "${LOCK_DAILY}" + +ts "locked part finished" +state "postlock" + +GO=( + FUNC="pgdump_post" + TIME="pg_dump2" + ARGS="" + ERR="" +) +stage $GO & + +GO=( + FUNC="expire" + TIME="expire_dumps" + ARGS="" + ERR="" +) +stage $GO & + +GO=( + FUNC="transitionsclean" + TIME="transitionsclean" + ARGS="" + ERR="" +) +stage $GO & + +GO=( + FUNC="reports" + TIME="reports" + ARGS="" + ERR="" +) +stage $GO & + +GO=( + FUNC="dm" + TIME="" + ARGS="" + ERR="" +) +stage $GO & + +GO=( + FUNC="bts" + TIME="" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="merkel2" + TIME="merkel projectb push" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="mirrorpush" + TIME="mirrorpush" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="i18n2" + TIME="i18n 2" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="stats" + TIME="stats" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="testingsourcelist" + TIME="" + ARGS="" + ERR="false" +) +stage $GO & + +rm -f "${LOCK_BRITNEY}" + +GO=( + FUNC="pgdakdev" + TIME="dak-dev db" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="merkel3" + TIME="merkel ddaccessible sync" + ARGS="" + ERR="false" +) +stage $GO & + +GO=( + FUNC="compress" + TIME="compress" + ARGS="" + ERR="" +) +stage $GO & + +GO=( + FUNC="aptftpcleanup" + TIME="apt-ftparchive cleanup" + ARGS="" + ERR="false" +) +stage $GO + +log "Daily cron scripts successful, all done" + +exec > "$logdir/afterdinstall.log" 2>&1 + +GO=( + FUNC="renamelogfile" + TIME="" + ARGS="" + ERR="false" +) +stage $GO +state "all done" + + +# Now, at the very (successful) end of dinstall, make sure we remove +# our stage files, so the next dinstall run will do it all again. +rm -f ${stagedir}/* +touch "${DINSTALLEND}" diff --git a/scripts/backports.org/copyoverrides b/scripts/backports.org/copyoverrides deleted file mode 100755 index a90db62d..00000000 --- a/scripts/backports.org/copyoverrides +++ /dev/null @@ -1,29 +0,0 @@ -#! /bin/sh - -set -e -. $SCRIPTVARS -echo 'Copying override files into public view ...' - -for f in $copyoverrides ; do - cd $overridedir - chmod g+w override.$f - - cd $indices - rm -f .newover-$f.gz - pc="`gzip 2>&1 -9nv <$overridedir/override.$f >.newover-$f.gz`" - set +e - nf=override.$f.gz - cmp -s .newover-$f.gz $nf - rc=$? - set -e - if [ $rc = 0 ]; then - rm -f .newover-$f.gz - elif [ $rc = 1 -o ! -f $nf ]; then - echo " installing new $nf $pc" - mv -f .newover-$f.gz $nf - chmod g+w $nf - else - echo $? $pc - exit 1 - fi -done diff --git a/scripts/backports.org/mkchecksums b/scripts/backports.org/mkchecksums deleted file mode 100755 index 575d55c5..00000000 --- a/scripts/backports.org/mkchecksums +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# Update the md5sums file - -set -e -. $SCRIPTVARS - -dsynclist=$dbdir/dsync.list -md5list=$indices/md5sums - -echo -n "Creating md5 / dsync index file ... " - -cd "$ftpdir" -dsync-flist -q generate $dsynclist --exclude $dsynclist --md5 -dsync-flist -q md5sums $dsynclist | gzip -9n > ${md5list}.gz -dsync-flist -q link-dups $dsynclist || true diff --git a/scripts/backports.org/mklslar b/scripts/backports.org/mklslar deleted file mode 100755 index 19363f1f..00000000 --- a/scripts/backports.org/mklslar +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Update the ls-lR. - -set -e -. $SCRIPTVARS - -cd $ftpdir - -filename=ls-lR - -echo "Removing any core files ..." -find -type f -name core -print0 | xargs -0r rm -v - -echo "Checking permissions on files in the FTP tree ..." -find -type f \( \! -perm -444 -o -perm +002 \) -ls -find -type d \( \! -perm -555 -o -perm +002 \) -ls - -echo "Checking symlinks ..." -symlinks -rd . - -echo "Creating recursive directory listing ... " -rm -f .$filename.new -TZ=UTC ls -lR | grep -v Archive_Maintenance_In_Progress > .$filename.new - -if [ -r ${filename}.gz ] ; then - mv -f ${filename}.gz $filename.old.gz - mv -f .$filename.new $filename - rm -f $filename.patch.gz - zcat $filename.old.gz | diff -u - $filename | gzip -9cfn - >$filename.patch.gz - rm -f $filename.old.gz -else - mv -f .$filename.new $filename -fi - -gzip -9cfN $filename >$filename.gz -rm -f $filename diff --git a/scripts/backports.org/mkmaintainers b/scripts/backports.org/mkmaintainers deleted file mode 100755 index edb0f20c..00000000 --- a/scripts/backports.org/mkmaintainers +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/sh - -echo -echo -n 'Creating Maintainers index ... ' - -set -e -. $SCRIPTVARS -cd $base/misc/ - -nonusmaint="$base/misc/Maintainers_Versions-non-US" - - -cd $indices -dak make-maintainers | sed -e "s/~[^ ]*\([ ]\)/\1/" | awk '{printf "%-20s ", $1; for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n";}' > .new-maintainers - -set +e -cmp .new-maintainers Maintainers >/dev/null -rc=$? -set -e -if [ $rc = 1 ] || [ ! -f Maintainers ] ; then - echo -n "installing Maintainers ... " - mv -f .new-maintainers Maintainers - gzip -9v .new-maintainers.gz - mv -f .new-maintainers.gz Maintainers.gz -elif [ $rc = 0 ] ; then - echo '(same as before)' - rm -f .new-maintainers -else - echo cmp returned $rc - false -fi diff --git a/scripts/backports/copyoverrides b/scripts/backports/copyoverrides new file mode 100755 index 00000000..a90db62d --- /dev/null +++ b/scripts/backports/copyoverrides @@ -0,0 +1,29 @@ +#! /bin/sh + +set -e +. $SCRIPTVARS +echo 'Copying override files into public view ...' + +for f in $copyoverrides ; do + cd $overridedir + chmod g+w override.$f + + cd $indices + rm -f .newover-$f.gz + pc="`gzip 2>&1 -9nv <$overridedir/override.$f >.newover-$f.gz`" + set +e + nf=override.$f.gz + cmp -s .newover-$f.gz $nf + rc=$? + set -e + if [ $rc = 0 ]; then + rm -f .newover-$f.gz + elif [ $rc = 1 -o ! -f $nf ]; then + echo " installing new $nf $pc" + mv -f .newover-$f.gz $nf + chmod g+w $nf + else + echo $? $pc + exit 1 + fi +done diff --git a/scripts/backports/mkchecksums b/scripts/backports/mkchecksums new file mode 100755 index 00000000..575d55c5 --- /dev/null +++ b/scripts/backports/mkchecksums @@ -0,0 +1,15 @@ +#!/bin/sh +# Update the md5sums file + +set -e +. $SCRIPTVARS + +dsynclist=$dbdir/dsync.list +md5list=$indices/md5sums + +echo -n "Creating md5 / dsync index file ... " + +cd "$ftpdir" +dsync-flist -q generate $dsynclist --exclude $dsynclist --md5 +dsync-flist -q md5sums $dsynclist | gzip -9n > ${md5list}.gz +dsync-flist -q link-dups $dsynclist || true diff --git a/scripts/backports/mklslar b/scripts/backports/mklslar new file mode 100755 index 00000000..19363f1f --- /dev/null +++ b/scripts/backports/mklslar @@ -0,0 +1,36 @@ +#!/bin/sh +# Update the ls-lR. + +set -e +. $SCRIPTVARS + +cd $ftpdir + +filename=ls-lR + +echo "Removing any core files ..." +find -type f -name core -print0 | xargs -0r rm -v + +echo "Checking permissions on files in the FTP tree ..." +find -type f \( \! -perm -444 -o -perm +002 \) -ls +find -type d \( \! -perm -555 -o -perm +002 \) -ls + +echo "Checking symlinks ..." +symlinks -rd . + +echo "Creating recursive directory listing ... " +rm -f .$filename.new +TZ=UTC ls -lR | grep -v Archive_Maintenance_In_Progress > .$filename.new + +if [ -r ${filename}.gz ] ; then + mv -f ${filename}.gz $filename.old.gz + mv -f .$filename.new $filename + rm -f $filename.patch.gz + zcat $filename.old.gz | diff -u - $filename | gzip -9cfn - >$filename.patch.gz + rm -f $filename.old.gz +else + mv -f .$filename.new $filename +fi + +gzip -9cfN $filename >$filename.gz +rm -f $filename diff --git a/scripts/backports/mkmaintainers b/scripts/backports/mkmaintainers new file mode 100755 index 00000000..edb0f20c --- /dev/null +++ b/scripts/backports/mkmaintainers @@ -0,0 +1,31 @@ +#! /bin/sh + +echo +echo -n 'Creating Maintainers index ... ' + +set -e +. $SCRIPTVARS +cd $base/misc/ + +nonusmaint="$base/misc/Maintainers_Versions-non-US" + + +cd $indices +dak make-maintainers | sed -e "s/~[^ ]*\([ ]\)/\1/" | awk '{printf "%-20s ", $1; for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n";}' > .new-maintainers + +set +e +cmp .new-maintainers Maintainers >/dev/null +rc=$? +set -e +if [ $rc = 1 ] || [ ! -f Maintainers ] ; then + echo -n "installing Maintainers ... " + mv -f .new-maintainers Maintainers + gzip -9v .new-maintainers.gz + mv -f .new-maintainers.gz Maintainers.gz +elif [ $rc = 0 ] ; then + echo '(same as before)' + rm -f .new-maintainers +else + echo cmp returned $rc + false +fi