summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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
}