]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/common
New function for tempfile generation
[dak.git] / config / debian / common
index 0754159ea93b41e7fbd0cd50dce0627def7d429c..a568d82657b0e559c55b838f708054473f0cdc75 100644 (file)
@@ -23,6 +23,19 @@ function debug () {
     fi
 }
 
+# Get a tempfile, add it to the right variable to get rid of it,
+# and return it
+function gettempfile() {
+    local MAKEDIR=${1:-false}
+    local TMPARGS=""
+    if [[ ${MAKEDIR} == true ]]; then
+        TMPARGS="--directory"
+    fi
+    local TMPFILE=$( mktemp -p ${TMPDIR} ${TMPARGS} )
+    TMPFILES="${TEMPFILES} ${TMPFILE}"
+    echo "${TMPFILE}"
+}
+
 # Function that only cleans tempfiles, but does not exit or otherwise
 # care about any exit status
 function cleantempfiles() {
@@ -347,7 +360,11 @@ function stage() {
 
     # Now we should make sure that we have a usable ${PROGRAM}.log, so
     # append the $STAGEFILE.log to it.
-    /usr/bin/ts "%b %d %H:%M:%S ${HOSTNAME} ${PROGRAM}[$$]: ${FUNC} " < "${STAGEFILE}.log"
+    if [[ ${TIMESTAMP} == true ]]; then
+        /usr/bin/ts "%b %d %H:%M:%S ${HOSTNAME} ${PROGRAM}[$$]: ${FUNC} " < "${STAGEFILE}.log"
+    else
+        cat "${STAGEFILE}.log"
+    fi
     rm -f "${STAGEFILE}.log"
 
     log "########## ${PROGRAM} END: ${FUNC} ##########"