texlive/texlive-mktexlsr_fixes.patch

82 lines
3.4 KiB
Diff

diff -up texlive-2007/texk/kpathsea/mktexlsr.man.mktexlsr_fixes texlive-2007/texk/kpathsea/mktexlsr.man
--- texlive-2007/texk/kpathsea/mktexlsr.man.mktexlsr_fixes 2006-01-17 22:41:51.000000000 +0100
+++ texlive-2007/texk/kpathsea/mktexlsr.man 2008-01-06 16:13:33.000000000 +0100
@@ -44,3 +44,12 @@ Print help message and exit.
.B --version
.rb
Print version information and exit.
+.\"=====================================================================
+.SH NOTES
+When called by root with no arguments, \fBmktexlsr\fP in Debian ignores
+TEXMF trees under \fI$HOME\fP. This is to avoid creating undesirable files
+such as \fI/root/texmf/ls-R\fP when doing usual maintainance (it is generally
+a bad idea to work with TeX as root, therefore having a file such as
+\fI/root/texmf/ls-R\fP in the first place is rather pointless). If you really
+want to update the ls-R databases for such TEXMF trees, simply list them
+explicitely on the command-line.
diff -up texlive-2007/texk/kpathsea/mktexlsr.mktexlsr_fixes texlive-2007/texk/kpathsea/mktexlsr
--- texlive-2007/texk/kpathsea/mktexlsr.mktexlsr_fixes 2006-12-25 19:44:43.000000000 +0100
+++ texlive-2007/texk/kpathsea/mktexlsr 2008-01-06 16:37:22.000000000 +0100
@@ -82,10 +82,21 @@ test $# = 0 && {
'
set x `kpsewhich --show-path=ls-R | tr : '
' | sort | uniq`; shift
+ if test "`id -u`" -eq 0; then
+ NOROOTHOME=true
+ fi
IFS=$OIFS
}
for TEXMFLS_R in "$@"; do
+ if [ "z$HOME" != 'z' ]; then
+ case "$TEXMFLS_R" in
+ $HOME/*) if test -n "$NOROOTHOME"; then
+ tty -s && echo "$progname: Skipping $TEXMFLS_R" >&2
+ continue
+ fi ;;
+ esac
+ fi
# Prepend cwd if the directory was relative.
case "$TEXMFLS_R" in
"") continue ;; # Strictly speaking, it is an error if this case is taken.
@@ -112,9 +123,9 @@ for TEXMFLS_R in "$@"; do
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"
@@ -128,11 +139,8 @@ for TEXMFLS_R in "$@"; do
# 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=`mktemp -t ls-R.XXXXXXXXXX` \
+ || { echo "$progname: could not create temporary file for '$db_file'. Skipping..." >&2; continue; }
$verbose && echo "$progname: Updating $db_file... " >&2
echo "$ls_R_magic" >"$db_file_tmp"
@@ -152,12 +160,8 @@ for TEXMFLS_R in "$@"; do
| sed -e '/\.svn.*:$/,/^$/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
$verbose && echo "$progname: Done." >&2
exit 0