texlive[42425] Build/source/texk/kpathsea: silent mkdir before

commits+karl at tug.org commits+karl at tug.org
Wed Nov 2 22:34:12 CET 2016


Revision: 42425
          http://tug.org/svn/texlive?view=revision&revision=42425
Author:   karl
Date:     2016-11-02 22:34:11 +0100 (Wed, 02 Nov 2016)
Log Message:
-----------
silent mkdir before reporting mkdir to try to work around race condition, https://bugs.debian.org/794228

Modified Paths:
--------------
    trunk/Build/source/texk/kpathsea/ChangeLog
    trunk/Build/source/texk/kpathsea/mktexdir

Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog	2016-11-02 20:29:17 UTC (rev 42424)
+++ trunk/Build/source/texk/kpathsea/ChangeLog	2016-11-02 21:34:11 UTC (rev 42425)
@@ -1,3 +1,9 @@
+2016-11-02  Karl Berry  <karl at tug.org>
+
+	* mktexdir: try a silent mkdir before a non-silent mkdir,
+	to try to work around the inevitable race condition.
+	https://bugs.debian.org/794228.
+
 2016-08-04  Karl Berry  <karl at tug.org>
 
 	* texmf.cnf (max_strings.bibtex, et al.): increase to 100,000

Modified: trunk/Build/source/texk/kpathsea/mktexdir
===================================================================
--- trunk/Build/source/texk/kpathsea/mktexdir	2016-11-02 20:29:17 UTC (rev 42424)
+++ trunk/Build/source/texk/kpathsea/mktexdir	2016-11-02 21:34:11 UTC (rev 42425)
@@ -1,10 +1,11 @@
 #!/bin/sh
-# mkinstalldirs (now mktexdir) -- make directory hierarchy.
+# mktexdir (was mkinstalldirs) -- make directory hierarchy.
 # Author: Noah Friedman <friedman at prep.ai.mit.edu>, created: 1993-05-16.
 # Public domain.
 # 
 # Modified for sticky directory creation, --help, --version, more,
 # by Thomas Esser, Karl Berry, Olaf Weber, et al.
+# Maintained as part of TeX Live, http://tug.org/tex-live.
 
 version='$Id$'
 progname=`echo $0 | sed 's%.*/%%'`
@@ -50,7 +51,18 @@
      pathcomp="$pathcomp$d"
 
      if test ! -d "./$pathcomp"; then
-        mkdir "./$pathcomp" || { errstatus=$?; break; }
+        # This shell stuff is not atomic, therefore ./$pathcomp
+        # may have been created in another process and this mkdir will
+        # fail despite the above test, so do it silently:
+        mkdir "./$pathcomp" >/dev/null 2>&1
+        
+        # So, if ./$pathcomp is a directory now, call it good.
+        if test ! -d "./$pathcomp"; then
+          # Otherwise, presumably it's a real error.  Do the mkdir again
+          # and let the error be seen, and quit the loop.
+          # (Report at https://bugs.debian.org/794228.)
+          mkdir "./$pathcomp" || { errstatus=$?; break; }
+        fi
         chmod `kpsestat ${MT_APPEND_MASK} "$pathcomp"/..` "./$pathcomp"
      fi
 
@@ -59,3 +71,6 @@
 done
 
 exit $errstatus
+
+# P.S. We don't want to rely on mkdir -p, because of possible
+# portability programs. See current mkinstalldirs source (in Automake).



More information about the tex-live-commits mailing list