]> git.decadent.org.uk Git - dak.git/commitdiff
New function for tempfile generation
authorJoerg Jaspert <joerg@debian.org>
Sat, 2 Jan 2016 22:25:02 +0000 (23:25 +0100)
committerJoerg Jaspert <joerg@debian.org>
Sat, 2 Jan 2016 22:25:02 +0000 (23:25 +0100)
Especially proper adding to the TMPFILES variable to get rid of em
again.

config/debian/common
config/debian/daily.functions
config/debian/dinstall.functions
config/debian/hourly.functions

index 0177f1f6fcfd8e1a14b94f32d69a5975607946e1..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() {
index 3dae2d6d97a0282fc884583371c864213b0d03b0..e6d6f2fb9da1cc3abed67ded9cfc62b3287c07aa 100644 (file)
@@ -3,8 +3,7 @@
 # get the latest list of wnpp bugs and their source packages
 function wnppbugs() {
     log "Fetching latest list of wnpp bugs"
-    TMPLIST=$( mktemp -p ${TMPDIR} )
-    TMPFILES="${TMPFILES} ${TMPLIST}"
+    TMPLIST=$( gettempfile )
     wget -q -O${TMPLIST} --ca-directory=/etc/ssl/ca-debian https://qa.debian.org/data/bts/wnpp_rm
     chmod go+r ${TMPLIST}
     mv ${TMPLIST} ${scriptdir}/masterfiles/wnpp_rm
@@ -43,8 +42,7 @@ function newstats() {
 # Generate the contributor data
 function contributor() {
     log "Submitting data to contributors"
-    TMPCNTB=$( mktemp -p ${TMPDIR} )
-    TMPFILES="${TMPFILES} ${TMPCNTB}"
+    TMPCNTB=$( gettempfile )
     REQUESTS_CA_BUNDLE=/etc/ssl/ca-debian/ca-certificates.crt dc-tool --mine="${configdir}/contributor.source" --auth-token @"${base}/s3kr1t/contributor.auth" --source ftp.debian.org --json > ${TMPCNTB}
 
     # Post with curl as a workaround for #801506
index 25553fa26461c96a823a8827754cdf07270c08f5..872357e1a490635b5c6f621c50b2290ee07b6f51 100644 (file)
@@ -182,7 +182,7 @@ function fingerprints() {
     log "Updating fingerprints"
     dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg
 
-    OUTFILE=$(mktemp)
+    OUTFILE=$( gettempfile )
     dak import-keyring --generate-users "%s" /srv/keyring.debian.org/keyrings/debian-maintainers.gpg >"${OUTFILE}"
 
     if [ -s "${OUTFILE}" ]; then
@@ -691,8 +691,7 @@ function signotherfiles() {
     for archive in "${public_archives[@]}"; do
         log "... archive: ${archive}"
         archiveroot="$(get_archiveroot "${archive}")"
-        local TMPLO=$( mktemp -p ${TMPDIR} )
-        trap "rm -f ${TMPLO}" ERR EXIT TERM HUP INT QUIT
+        local TMPLO=$( gettempfile )
 
         cd ${archiveroot}
         rm -f extrafiles
index 5ba908537f307f9fab9d9e37ebb671c0c26db8e2..2a26461938ba3ef72c5627f0de8a567536d3a4f7 100644 (file)
@@ -54,8 +54,7 @@ function backportsacl() {
 
 # do the buildd key updates
 function builddautosigning() {
-    BUILDDFUN=$(mktemp -p "${TMPDIR}" BUILDDFUN.XXXXXX)
-    TMPFILES="${TMPFILES} ${BUILDDFUN}"
+    BUILDDFUN=$( gettempfile )
     exec >> "${BUILDDFUN}" 2>&1
     ${scriptsdir}/buildd-remove-keys
     ${scriptsdir}/buildd-add-keys