[tex-live] mktexlsr and directory permissions

Frank Küster frank at kuesterei.ch
Tue Sep 27 17:55:46 CEST 2005


Norbert Preining <preining at logic.at> wrote:

> Hi Thomas!
>
> I just found out that mktexlsr in version 1.46 (as in TeX live) has a
> new `feature' which makes me a bit unhappy: If the directory where the
> ls-R file is located is not actually writeable, the ls-R will not be
> updated, *EVEN* if the ls-R file is indeed writeable!
>
> Now in the debian tetex packages this is no problem, as there is still
> 1.45 of mktexlsr, but in the texlive packages we got a problem:

I don't think this is a problem with the mktexlsr versions - Debian's
teTeX packages patch mktexlsr.  I think I showed the patch to Thomas a
while ago.  Unfortunately it closely mixes two issues: We cat the
tempfile into the real file instead of moving it (thus circumventing the
permissions problem), and we use a different way to create the tempfile
which is not portable.  I don't have time to take it apart now, sorry.
Here it comes,

regards, Frank

--- texk/kpathsea/mktexlsr.orig	2005-08-29 13:13:10.059771538 +0200
+++ texk/kpathsea/mktexlsr	2005-08-29 13:13:42.015245686 +0200
@@ -103,9 +103,9 @@
   db_dir=`echo "$db_file" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
 
   test -d "$db_dir" || continue
-  test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
 
   if test ! -f "$db_file"; then
+    test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
     cp /dev/null "$db_file"
     # Use same permissions as parent directory, minus x,s, or t bits.
     chmod `kpsestat -xst "$db_dir"` "$db_file"
@@ -119,11 +119,8 @@
   # Skip if we cannot write the file:
   kpseaccess -w "$db_file" || { echo "$progname: $db_file: no write permission. Skipping..." >&2; continue; }
 
-  db_dir_tmp="$db_dir/lsR$$.tmp"
-  (umask 077 && mkdir "$db_dir_tmp" ) \
-    || { echo "$progname: could not create directory '$db_dir_tmp'. Skipping..." >&2; continue; }
-  db_file_tmp="$db_dir_tmp/lsR$$.tmp"
-  rm -f "$db_file_tmp"
+  db_file_tmp=`tempfile -p ls-R` \
+    || { echo "$progname: could not create temporary file for '$db_file'. Skipping..." >&2; continue; }
 
   tty -s && echo "$progname: Updating $db_file... " >&2
   echo "$ls_R_magic" >"$db_file_tmp"
@@ -137,12 +134,8 @@
   (cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) |
     sed '/^$/{n;s%^\./%%;s%^%./%;}; /^\.$/d; /^\.\.$/d; /^[\.\/]*lsR[0-9]*\.tmp:*$/d' >>"$db_file_tmp"
 
-  # To be really safe, a loop.
-  until PERMS=`kpsestat = "$db_file"`; do sleep 1; done
-  chmod $PERMS "$db_file_tmp"
-  rm -f "$db_file"
-  mv "$db_file_tmp" "$db_file"
-  rm -rf "$db_dir_tmp"
+  cat "$db_file_tmp" > "$db_file"
+  rm -f "$db_file_tmp"
 done
 tty -s && echo "$progname: Done." >&2
 exit 0




-- 
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer



More information about the tex-live mailing list