2 # No way I try to deal with a crippled sh just for POSIX foo.
4 # Copyright (C) 2009 Joerg Jaspert <joerg@debian.org>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; version 2.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # Homer: Are you saying you're never going to eat any animal again? What
25 # Lisa: Dad, those all come from the same animal.
26 # Homer: Heh heh heh. Ooh, yeah, right, Lisa. A wonderful, magical animal.
30 # make sure to only use defined variables
32 # ERR traps should be inherited from functions too. (And command
33 # substitutions and subshells and whatnot, but for us the functions is
34 # the important part here)
37 # import the general variable set.
38 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
41 ########################################################################
43 ########################################################################
44 # common functions are "outsourced"
45 . "${configdir}/common"
47 # source the dinstall functions
48 . "${configdir}/dinstall.functions"
50 ########################################################################
51 ########################################################################
53 # Function to save which stage we are in, so we can restart an interrupted
54 # dinstall. Or even run actions in parallel, if we dare to, by simply
55 # backgrounding the call to this function. But that should only really be
56 # done for things we don't care much about.
58 # This should be called with the first argument being an array, with the
60 # - FUNC - the function name to call
61 # - ARGS - Possible arguments to hand to the function. Can be the empty string
62 # - TIME - The timestamp name. Can be the empty string
63 # - ERR - if this is the string false, then the call will be surrounded by
64 # set +e ... set -e calls, so errors in the function do not exit
65 # dinstall. Can be the empty string, meaning true.
67 # MAKE SURE TO KEEP THIS THE LAST FUNCTION, AFTER ALL THE VARIOUS ONES
68 # ADDED FOR DINSTALL FEATURES!
75 STAGEFILE="${stagedir}/${FUNC}"
76 if [ -f "${STAGEFILE}" ]; then
77 stamptime=$(/usr/bin/stat -c %Z "${STAGEFILE}")
79 difference=$(( $unixtime - $stamptime ))
80 if [ ${difference} -ge 14400 ]; then
81 log_error "Did already run ${FUNC}, stagefile exists, but that was ${difference} seconds ago. Please check."
83 log "Did already run ${FUNC}, not calling again..."
88 debug "Now calling function ${FUNC}. Arguments: ${ARGS}. Timestamp: ${TIME}"
90 # Make sure we are always at the same place. If a function wants to be elsewhere,
94 # Now redirect the output into $STAGEFILE.log. In case it errors out somewhere our
95 # errorhandler trap can then mail the contents of $STAGEFILE.log only, instead of a whole
96 # dinstall logfile. Short error mails ftw!
97 exec >> "${STAGEFILE}.log" 2>&1
99 if [ -f "${LOCK_STOP}" ]; then
100 log "${LOCK_STOP} exists, exiting immediately"
104 if [ "${error}" = "false" ]; then
109 # No matter what happened in the function, we make sure we have set -e default state back
112 # Make sure we are always at the same place.
115 # We always use the same umask. If a function wants to do different, fine, but we reset.
120 if [ -n "${TIME}" ]; then
124 # And the output goes back to the normal logfile
125 exec >> "$LOGFILE" 2>&1
127 # Now we should make sure that we have a usable dinstall.log, so append the $STAGEFILE.log
129 cat "${STAGEFILE}.log" >> "${LOGFILE}"
130 rm -f "${STAGEFILE}.log"
132 if [ -f "${LOCK_STOP}" ]; then
133 log "${LOCK_STOP} exists, exiting immediately"
138 ########################################################################
141 LOGFILE="$logdir/dinstall.log"
143 exec >> "$LOGFILE" 2>&1
145 # And now source our default config
146 . "${configdir}/dinstall.variables"
148 # Make sure we start out with a sane umask setting
151 # And use one locale, no matter what the caller has set
155 touch "${DINSTALLSTART}"
158 lockfile -l 3600 "${LOCK_DAILY}"
160 trap cleanup EXIT TERM HUP INT QUIT
162 touch "${LOCK_BRITNEY}"
190 TIME="External Updates"
222 lockfile "$LOCK_ACCEPTED"
226 FUNC="process_unchecked"
241 rm -f "$LOCK_ACCEPTED"
246 TIME="make-suite-file-list"
254 TIME="import-keyring"
270 TIME="pkg-file-mapping"
278 TIME="apt-ftparchive"
306 ### TODO: clean-* fixup
327 TIME="mirror hardlinks"
341 rm -f "${LOCK_DAILY}"
343 ts "locked part finished"
362 FUNC="transitionsclean"
363 TIME="transitionsclean"
395 TIME="merkel projectb push"
426 FUNC="testingsourcelist"
433 rm -f ${LOCK_BRITNEY}
445 TIME="merkel ddaccessible sync"
461 TIME="apt-ftparchive cleanup"
467 log "Daily cron scripts successful, all done"
469 exec > "$logdir/afterdinstall.log" 2>&1
480 # Now, at the very (successful) end of dinstall, make sure we remove
481 # our stage files, so the next dinstall run will do it all again.
483 touch "${DINSTALLEND}"