summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-12-07 12:43:07 (EST)
committer P. J. McDermott <pj@pehjota.net>2015-12-07 12:45:52 (EST)
commitd84af41141c2a578ec384f7a16169afe03bac680 (patch)
tree9fb4052aa943c2c38aa015acb7a7620944373e43 /src
parent791bfd4283f8171e9248c99e56e645460381e198 (diff)
init_vardata(): Use /tmp or ${TMPDIR}
Diffstat (limited to 'src')
-rw-r--r--src/vardata.sh24
1 files changed, 17 insertions, 7 deletions
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
}