emerge-webrsync: use ${PORTAGE_TMPDIR}/portage
authorZac Medico <zmedico@gentoo.org>
Sat, 18 Aug 2012 23:59:41 +0000 (16:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 18 Aug 2012 23:59:41 +0000 (16:59 -0700)
For consistency with commit 83e677766650e73071813c0d46547647e5f66029.

bin/emerge-webrsync

index 11d608ff69a15fc2ed6fccb5f7d72204421ecb6a..5cba6b045c464eda9a1cb3dfd60c37be09609044 100755 (executable)
@@ -464,23 +464,23 @@ main() {
                exit 1
        fi
 
-       TMPDIR=${PORTAGE_TMPDIR}/emerge-webrsync
-       ${keep} || DISTDIR=${TMPDIR}
+       [[ -d ${PORTAGE_TMPDIR}/portage ]] || mkdir -p "${PORTAGE_TMPDIR}/portage"
+       TMPDIR=$(mktemp -d "${PORTAGE_TMPDIR}/portage/webrsync-XXXXXX")
+       if [[ ! -w ${TMPDIR} ]] ; then
+               eecho "TMPDIR is not writable: ${TMPDIR}"
+               exit 1
+       fi
+       trap 'cd / ; rm -rf "${TMPDIR}"' EXIT
+       cd "${TMPDIR}" || exit 1
 
-       [ ! -d "${TMPDIR}" ] && mkdir -p "${TMPDIR}"
+       ${keep} || DISTDIR=${TMPDIR}
        [ ! -d "${DISTDIR}" ] && mkdir -p "${DISTDIR}"
-       cd "${TMPDIR}" || exit 1
 
        if ${keep} && [[ ! -w ${DISTDIR} ]] ; then
                eecho "DISTDIR is not writable: ${DISTDIR}"
                exit 1
        fi
 
-       if [[ ! -w ${TMPDIR} ]] ; then
-               eecho "TMPDIR is not writable: ${TMPDIR}"
-               exit 1
-       fi
-
        # This is a sanity check to help prevent people like funtoo users
        # from accidentally wiping out their git tree.
        if [[ -n $SYNC && ${SYNC#rsync:} = $SYNC ]] ; then