summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2018-01-17 00:55:32 +0000
committerNorbert Preining <preining@logic.at>2018-01-17 00:55:32 +0000
commitf3836c4a04ab445b2d3935c9742886747a9aeea6 (patch)
tree808699f0a36d2a1c16cf728efcd8db41b0ed0dd0 /Build/source
parenta9f3323d7b51bc2dc022e421d134cac02a665272 (diff)
mktexlsr (treefile): use mktemp with fallback option
git-svn-id: svn://tug.org/texlive/trunk@46343 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/kpathsea/ChangeLog4
-rwxr-xr-xBuild/source/texk/kpathsea/mktexlsr13
2 files changed, 16 insertions, 1 deletions
diff --git a/Build/source/texk/kpathsea/ChangeLog b/Build/source/texk/kpathsea/ChangeLog
index 519a539ee41..ad1756b462c 100644
--- a/Build/source/texk/kpathsea/ChangeLog
+++ b/Build/source/texk/kpathsea/ChangeLog
@@ -1,3 +1,7 @@
+2018-01-17 Norbert Preining <norbert@preining.info>
+
+ * mktexlsr (treefile): use mktemp with fallback option for temporary file.
+
2018-01-16 Karl Berry <karl@freefriends.org>
* kpathsea.pc.in (Cflags): remove -I${libdir} per Debian.
diff --git a/Build/source/texk/kpathsea/mktexlsr b/Build/source/texk/kpathsea/mktexlsr
index 8d4a38018f9..bd3eb50d6e4 100755
--- a/Build/source/texk/kpathsea/mktexlsr
+++ b/Build/source/texk/kpathsea/mktexlsr
@@ -73,7 +73,18 @@ if tty -s; then verbose=true; else verbose=false; fi
dry_run=false
trees=
-treefile="${TMPDIR-/tmp}/mktexlsrtrees$$.tmp"
+# initialize treefile by either mktemp or some random name
+# code taken from pdfjam and adjusted
+{
+ treefile=`
+ (umask 077 && mktemp "${TMPDIR-/tmp}/mktexlsrtrees.XXXXXXXXXX") 2>/dev/null
+ ` && test -n "$treefile" && test -f "$treefile"
+} || {
+ ## We'll use awk to make random number, for portability
+ random=`awk 'END { srand(); printf ("%d\n", rand()*1000000); }' /dev/null`
+ treefile="${TMPDIR-/tmp}/mktexlsrtrees$$.$random"
+} || exit $?
+
trap 'cd /; rm -f $treefile; test -z "$db_dir_tmp" || rm -rf "$db_dir_tmp";
exit' 0 1 2 3 7 13 15