ogajduse / rpms / texlive

Forked from rpms/texlive 6 years ago
Clone
90f0e6d
diff -up texlive-2007/texk/kpathsea/mktexlsr.man.mktexlsr_fixes texlive-2007/texk/kpathsea/mktexlsr.man
90f0e6d
--- texlive-2007/texk/kpathsea/mktexlsr.man.mktexlsr_fixes	2006-01-17 22:41:51.000000000 +0100
90f0e6d
+++ texlive-2007/texk/kpathsea/mktexlsr.man	2008-01-06 16:13:33.000000000 +0100
90f0e6d
@@ -44,3 +44,12 @@ Print help message and exit.
90f0e6d
 .B --version
90f0e6d
 .rb
90f0e6d
 Print version information and exit.
90f0e6d
+.\"=====================================================================
90f0e6d
+.SH NOTES
90f0e6d
+When called by root with no arguments, \fBmktexlsr\fP in Debian ignores
90f0e6d
+TEXMF trees under \fI$HOME\fP. This is to avoid creating undesirable files
90f0e6d
+such as \fI/root/texmf/ls-R\fP when doing usual maintainance (it is generally
90f0e6d
+a bad idea to work with TeX as root, therefore having a file such as
90f0e6d
+\fI/root/texmf/ls-R\fP in the first place is rather pointless). If you really
90f0e6d
+want to update the ls-R databases for such TEXMF trees, simply list them
90f0e6d
+explicitely on the command-line.
90f0e6d
diff -up texlive-2007/texk/kpathsea/mktexlsr.mktexlsr_fixes texlive-2007/texk/kpathsea/mktexlsr
90f0e6d
--- texlive-2007/texk/kpathsea/mktexlsr.mktexlsr_fixes	2006-12-25 19:44:43.000000000 +0100
90f0e6d
+++ texlive-2007/texk/kpathsea/mktexlsr	2008-01-06 16:37:22.000000000 +0100
90f0e6d
@@ -82,10 +82,21 @@ test $# = 0 && {
4931932
 '
4931932
   set x `kpsewhich --show-path=ls-R | tr : '
4931932
 ' | sort | uniq`; shift
4931932
+  if test "`id -u`" -eq 0; then
4931932
+    NOROOTHOME=true
4931932
+  fi
4931932
   IFS=$OIFS
4931932
 }
4931932
 
90f0e6d
 for TEXMFLS_R in "$@"; do
90f0e6d
+  if [ "z$HOME" != 'z' ]; then
90f0e6d
+    case "$TEXMFLS_R" in
90f0e6d
+    $HOME/*) if test -n "$NOROOTHOME"; then
4931932
+  		tty -s && echo "$progname: Skipping $TEXMFLS_R" >&2
4931932
+		continue
4931932
+	   fi ;;
90f0e6d
+    esac
90f0e6d
+  fi
90f0e6d
   # Prepend cwd if the directory was relative.
90f0e6d
   case "$TEXMFLS_R" in
90f0e6d
   "") continue ;;  # Strictly speaking, it is an error if this case is taken.
90f0e6d
@@ -112,9 +123,9 @@ for TEXMFLS_R in "$@"; do
4931932
   db_dir=`echo "$db_file" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
4931932
 
4931932
   test -d "$db_dir" || continue
4931932
-  test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
4931932
 
4931932
   if test ! -f "$db_file"; then
4931932
+    test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
4931932
     cp /dev/null "$db_file"
4931932
     # Use same permissions as parent directory, minus x,s, or t bits.
4931932
     chmod `kpsestat -xst "$db_dir"` "$db_file"
90f0e6d
@@ -128,11 +139,8 @@ for TEXMFLS_R in "$@"; do
4931932
   # Skip if we cannot write the file:
4931932
   kpseaccess -w "$db_file" || { echo "$progname: $db_file: no write permission. Skipping..." >&2; continue; }
4931932
 
4931932
-  db_dir_tmp="$db_dir/lsR$$.tmp"
4931932
-  (umask 077 && mkdir "$db_dir_tmp" ) \
4931932
-    || { echo "$progname: could not create directory '$db_dir_tmp'. Skipping..." >&2; continue; }
4931932
-  db_file_tmp="$db_dir_tmp/lsR$$.tmp"
4931932
-  rm -f "$db_file_tmp"
4931932
+  db_file_tmp=`mktemp -t ls-R.XXXXXXXXXX` \
4931932
+    || { echo "$progname: could not create temporary file for '$db_file'. Skipping..." >&2; continue; }
4931932
 
4931932
   $verbose && echo "$progname: Updating $db_file... " >&2
4931932
   echo "$ls_R_magic" >"$db_file_tmp"
90f0e6d
@@ -152,12 +160,8 @@ for TEXMFLS_R in "$@"; do
4931932
    | sed -e '/\.svn.*:$/,/^$/d' \
4931932
    >>"$db_file_tmp"
4931932
 
4931932
-  # To be really safe, a loop.
4931932
-  until PERMS=`kpsestat = "$db_file"`; do sleep 1; done
4931932
-  chmod $PERMS "$db_file_tmp"
4931932
-  rm -f "$db_file"
4931932
-  mv "$db_file_tmp" "$db_file"
4931932
-  rm -rf "$db_dir_tmp"
4931932
+  cat "$db_file_tmp" > "$db_file"
4931932
+  rm -f "$db_file_tmp"
4931932
 done
4931932
 $verbose && echo "$progname: Done." >&2
4931932
 exit 0