]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/TeXFiles.sh
Extract the necessary magic from epstopdf.
[lyx.git] / lib / scripts / TeXFiles.sh
index 75ec6c1755ad7cced064fdad2c30b760a219b54d..0572e3c3e1fbda19cc0cf3d42e24ce8a4ea70f2b 100755 (executable)
@@ -4,24 +4,32 @@
 # TeX class files      -> option cls 
 # TeX style files      -> option sty
 # bibtex style files   -> option bst
+# bibtex database files -> option bib
 #
 # with the help
 # of kpsewhich and creates a 
-# bstFiles.lst, clsFiles.lst, styFiles.lst
+# bstFiles.lst, clsFiles.lst, styFiles.lst, bibFiles.lst
 # without any parameter all files are created.
 #
 # Herbert Voss <voss@perce.org>
 #
+# Updates from Jean-Marc Lasgouttes.
+#
+# bib support added by Juergen Spitzmueller (v0.3)
+#
 CLS_STYLEFILE=clsFiles.lst
 STY_STYLEFILE=styFiles.lst
 BST_STYLEFILE=bstFiles.lst
-version='$Id: TeXFiles.sh,v 0.1 2001-10-01'
+BIB_FILES=bibFiles.lst
+version='$Id: TeXFiles.sh,v 0.3 2003-02-14'
 progname=`echo $0 | sed 's%.*/%%'`
-echo "$version"
-usage="Usage: TeXFiles.sh [-version | cls | sty | bst] 
+usage="Usage: TeXFiles.sh [-version | cls | sty | bst | bib ] 
        Default is without any Parameters,
        so that all files will be created"
 
+types=$1
+test -z "$types" && types="cls sty bst bib"
+
 #
 # MS-DOS and MS-Windows define $COMSPEC or $ComSpec and use ';' to separate
 # directories in path lists whereas Unixes uses ':'.
@@ -32,21 +40,7 @@ usage="Usage: TeXFiles.sh [-version | cls | sty | bst]
 #???????????????
 #
 if test -z "$COMSPEC" && test -z "$ComSpec"; then SEP=':'; else SEP=';'; fi
-#
-# Add the location of the script to the PATH if necessary.  This must
-# be done before kpsewhich can be called, and thus cannot be put into
-# mktex.opt
-#
-dirname=`echo $0 | sed 's%/*[^/][^/]*$%%'`
-echo "Actual Dir: $dirname"
-case $dirname in                       # $dirname correct?
-  "")                                  # Do nothing
-      ;;
-  /* | [A-z]:/*)                       # / -> Absolute name 
-      PATH="$dirname$SEP$PATH" ;;
-   *)                                          # other -> Relative name
-      PATH="`pwd`/$dirname$SEP$PATH" ;;
-esac                                   # end of case
+
 #
 # A copy of some stuff from mktex.opt, so we can run in the presence of
 # terminally damaged ls-R files.
@@ -59,58 +53,31 @@ elif test "x$1" = x--version || test "x$1" = x-version; then
   kpsewhich --version
   exit 0
 fi
-#
-# find the directories with kpsewhich. TeX has files ls-R to hold
-# the tex-tree
-#
-test $# = 0 && {
-  OIFS=$IFS; IFS=$SEP; set x `kpsewhich --show-path=ls-R 2>/dev/null`; shift; IFS=$OIFS
-}
-echo 'Delete old *files.lst, if present'
-case "$1" in
-    "cls")
-       rm -f $CLS_STYLEFILE
-       touch $CLS_STYLEFILE            # create new file
-    ;;
-    "sty")
-       rm -f $STY_STYLEFILE
-       touch $STY_STYLEFILE            # create new file
-    ;;
-    "bst")
-       rm -f $BST_STYLEFILE
-       touch $BST_STYLEFILE            # create new file
-    ;;
-    *)                                         # all other
-       rm -f $CLS_STYLEFILE $STY_STYLEFILE $BST_STYLEFILE
-       touch $CLS_STYLEFILE $STY_STYLEFILE $BST_STYLEFILE 
-    ;;
-esac
-echo "looking for all bst-style files in the latex tree";
-for TEXMFLSR in "$@"; do               # go through the dirs
-  case "$TEXMFLSR" in                  # Prepend cwd if the directory was relative.
-  "") continue ;;                      # it is an error if this case is taken.
-  /* | [A-z]:/*) ;;                    # leading /
-  *)  TEXMFLSR="`pwd`/$TEXMFLS_R"      # all other
+
+for type in $types ; do
+  echo "Indexing files of type $type"
+  case $type in 
+   cls) outfile=$CLS_STYLEFILE
+        kpsetype=.tex;;
+   sty) outfile=$STY_STYLEFILE
+        kpsetype=.tex;;
+   bst) outfile=$BST_STYLEFILE
+        kpsetype=.bst;;
+   bib) outfile=$BIB_FILES
+        kpsetype=.bib;;
+   *)   echo "ERROR: unknown type $type"
+        exit 1;;
   esac
-  echo "Dir: <$TEXMFLSR>"
-case "$1" in                           # list all files with suffix bst
-    "cls")
-       find $TEXMFLSR -name *.cls >> $CLS_STYLEFILE
-    ;;
-    "sty")
-       find $TEXMFLSR -name *.sty >> $STY_STYLEFILE
-    ;;
-    "bst")
-       find $TEXMFLSR -name *.bst >> $BST_STYLEFILE
-    ;;
-    *) 
-       find $TEXMFLSR -name *.cls >> $CLS_STYLEFILE
-       find $TEXMFLSR -name *.sty >> $STY_STYLEFILE
-       find $TEXMFLSR -name *.bst >> $BST_STYLEFILE
-    ;;
-esac
 
-  echo "done!"
+  rm -f $outfile
+  touch $outfile
+
+  dirs=`kpsewhich --show-path=$kpsetype 2>/dev/null | tr "$SEP" " " | sed -e 's%///%/%' -e 's%//%/%g' -e 's%!!%%g'`
+
+  for dir in $dirs ; do
+    find $dir -follow -name "*.$type" >>$outfile 2>/dev/null
+  done
+
 done
 #echo "list saved in $STYLEFILE"
 #echo `wc -l $CLS_STYLEFILE`           # only for information