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