From d84af41141c2a578ec384f7a16169afe03bac680 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 07 Dec 2015 12:43:07 -0500 Subject: init_vardata(): Use /tmp or ${TMPDIR} --- (limited to 'src') diff --git a/src/vardata.sh b/src/vardata.sh index 0c68d67..768cdf7 100644 --- a/src/vardata.sh +++ b/src/vardata.sh @@ -24,17 +24,27 @@ vardatadir= init_vardata() { - local dir= + local tmpdir='' + local dir='' - if ${in_place}; then - vardatadir="${builddir}/var" - for dir in ${VARDATA_DIRS}; do - mkdir -p "${vardatadir}/${dir}" - done + if [ "x${TMPDIR:+set}" = 'xset' ]; then + tmpdir="${TMPDIR}" else - vardatadir="${PKGLOCALSTATEDIR}" + tmpdir='/tmp' fi + rand + vardatadir="${tmpdir}/${PACKAGE}-$(printf '%010d' ${rand_x})" + if ! mkdir "${vardatadir}"; then + error 2 "$(get_msg 'temp_mkdir_fail')" "${vardatadir}" + fi + for dir in ${VARDATA_DIRS}; do + if ! mkdir "${vardatadir}/${dir}"; then + error 2 "$(get_msg 'temp_mkdir_fail')" \ + "${vardatadir}/${dir}" + fi + done + return 0 } -- cgit v0.9.1