From: Joerg Jaspert Date: Sat, 2 Jan 2016 22:25:02 +0000 (+0100) Subject: New function for tempfile generation X-Git-Url: https://git.decadent.org.uk/gitweb/?p=dak.git;a=commitdiff_plain;h=5428cbbe30b7e2b77305024f45ef2fa2ffa68490 New function for tempfile generation Especially proper adding to the TMPFILES variable to get rid of em again. --- diff --git a/config/debian/common b/config/debian/common index 0177f1f6..a568d826 100644 --- a/config/debian/common +++ b/config/debian/common @@ -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() { diff --git a/config/debian/daily.functions b/config/debian/daily.functions index 3dae2d6d..e6d6f2fb 100644 --- a/config/debian/daily.functions +++ b/config/debian/daily.functions @@ -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 diff --git a/config/debian/dinstall.functions b/config/debian/dinstall.functions index 25553fa2..872357e1 100644 --- a/config/debian/dinstall.functions +++ b/config/debian/dinstall.functions @@ -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 diff --git a/config/debian/hourly.functions b/config/debian/hourly.functions index 5ba90853..2a264619 100644 --- a/config/debian/hourly.functions +++ b/config/debian/hourly.functions @@ -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