From 92e971ebe60f39f8244c1c8796219ad878b1617e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 1 Feb 2013 23:42:25 +0000 Subject: ltxfileinfo shell script (1feb13) git-svn-id: svn://tug.org/texlive/trunk@29005 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/support/ltxfileinfo/README | 28 ++ .../doc/support/ltxfileinfo/ltxfileinfo.pdf | Bin 0 -> 50159 bytes Master/texmf-dist/scripts/ltxfileinfo/ltxfileinfo | 385 +++++++++++++++++++++ 3 files changed, 413 insertions(+) create mode 100644 Master/texmf-dist/doc/support/ltxfileinfo/README create mode 100644 Master/texmf-dist/doc/support/ltxfileinfo/ltxfileinfo.pdf create mode 100755 Master/texmf-dist/scripts/ltxfileinfo/ltxfileinfo (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/support/ltxfileinfo/README b/Master/texmf-dist/doc/support/ltxfileinfo/README new file mode 100644 index 00000000000..763404b595f --- /dev/null +++ b/Master/texmf-dist/doc/support/ltxfileinfo/README @@ -0,0 +1,28 @@ +This is release 2.00 of the ltxfileinfo script +License: GPL + +Short description: +ltxfileinfo is a bash script; it prints information about a latex class, +style and other files to standard output. +The script is based on Uwe Lueck's readprov.sty, so it prints information +only for files that contain a \ProvidesFile, \ProvidesClass or +\ProvidesPackage statement. +The script tries to correct errors in these \Provides... statements and it +has options, useful for developers, to make errors in those statements visible. + +Usage example: + +$ ltxfileinfo article.cls +name: article.cls +date: 2007/10/19 +vers: v1.4h +info: Standard LaTeX document class +loca: /usr/local/texlive/2009/texmf-dist/tex/latex/base/article.cls + +major changes of release 2.00 relative to 1.1 +- completely rewritten as a bash script, using code from readprov.sty +- now also can evaluate xelatex oriented files +- can now handle any LaTeX file containing a \Provides... statement +- options for \Provides... statement validation + +$Id: README,v 1.5 2013/02/01 10:40:20 wybo Exp $ diff --git a/Master/texmf-dist/doc/support/ltxfileinfo/ltxfileinfo.pdf b/Master/texmf-dist/doc/support/ltxfileinfo/ltxfileinfo.pdf new file mode 100644 index 00000000000..a5eae3cb76c Binary files /dev/null and b/Master/texmf-dist/doc/support/ltxfileinfo/ltxfileinfo.pdf differ diff --git a/Master/texmf-dist/scripts/ltxfileinfo/ltxfileinfo b/Master/texmf-dist/scripts/ltxfileinfo/ltxfileinfo new file mode 100755 index 00000000000..f701a598b16 --- /dev/null +++ b/Master/texmf-dist/scripts/ltxfileinfo/ltxfileinfo @@ -0,0 +1,385 @@ +#!/bin/bash + +<&1 | grep invalid )" != "" ] ; then + date=`mark $date` + fi + fi + + # version should be 1.2 or 1.2.3, maybe prefixed with v and suffixed with zero or more lower case letters + if [[ ! "$vers" =~ ^v?[[:digit:]]+.[[:digit:]]+(.[[:digit:]]+)?[[:lower:]]*$ ]]; then vers=`mark $vers`; fi + + if [ ! "$key" ]; then + if [ $flat ]; then + echo -e "$file\t$date\t$vers\t$info" + else + cat <<-EOF + file: $file + date: $date + vers: $vers + info: $info + loca: $loca + EOF + fi + else + eval "echo \$$key" + fi +} + +if ! options=$(getopt -o hdvlifcsD \ + -l help,date,version,location,info,flat,star,color,debug -- "$@"); then exit 1; fi +eval set -- "$options" + +while [ $# -gt 0 ]; do + case $1 in + -h|--help) help;; + -d|--date) key=date;; + -v|--version) key=vers;; + -i|--info) key=info;; + -l|--location) key=loca;; + -f|--flat) flat=1;; + -s|--star) mark1=''; mark2='*';; + -c|--color) mark1=''; mark2='';; + -D|--debug) debug=1;; + (--) shift; break;; + (*) break;; + esac + shift +done + +arg=$1 +test "$arg" = "" && help +loca=`kpsewhich "$arg"` +test "$loca" = "" && die not found by kpsewhich +prov=`grep '\\\\Provides' "$loca"` +test "$prov" = "" && die no \\Provides... +test "$prov" = "${prov/ProvidesExplPackage//}" || die 'Latex3 package (not handled yet)' + +# the file must contain a \ProvidesXXX statement, where XXX is Class, Package, or File: +for i in Class Package File; do + if [[ "$prov" =~ \\Provides$i[[:space:]]*\{ ]]; then found=1; break; fi +done +test $found || die Found no \\ProvidesClass/Package/File statement + +# readprov.sty does not work on .mbs and .bst files: special treatment; +# \ProvideFile statements in them mostly refer to merlin.mbs, or other names +if [[ $arg =~ \.mbs$ || $arg =~ \.bst$ ]]; then dombsbst; fi + +DIR=`mktemp -d` +test $debug || trap "rm -rf $DIR" 0 1 2 15 +test $debug && echo $DIR +cp "$loca" $DIR +cd $DIR + +# The following code is mostly from Uwe Lueck's readprov.sty: +echo ' +\makeatletter +\def\GetFileInfo#1{% + \def\filename{#1}% + \def\@tempb##1 ##2 ##3\relax##4\relax{% + \def\filedate{##1}% + \def\fileversion{##2}% + \def\fileinfo{##3}}% + \read@file@info\@tempb{#1}} +\newcommand*{\read@file@info}[2]{% + \expandafter \expandafter \expandafter + #1\csname ver@#2\endcsname \relax? ? \relax\relax} +\newcommand*{\ReadFileInfos}[1]{% + \begingroup + \let\RP@@provfile\@providesfile + \def\@providesfile##1[##2]{\RP@@provfile{##1}[{##2}]\endinput}% + \def\ProvidesClass ##1{\ProvidesFile{##1.\@clsextension}}% + \def\ProvidesPackage##1{\ProvidesFile{##1.\@pkgextension}}% + \@for\@tempa:=#1\do{% + \edef\@tempa{\expandafter\read@no@spaces\@tempa\@nil}% + \input{\@tempa}% + \global\let\@gtempa\@tempa}% + \endgroup + \GetFileInfo\@gtempa% +} +\def\read@no@spaces#1#2\@nil{#1#2}% +\def\NeedsTeXFormat#1{\expandafter\@needsformat} +\ReadFileInfos{'$loca'} +\endinput +' > ltxfileinfo.tex + +pdflatex -interaction=batchmode ltxfileinfo.tex >& /dev/null + +IFS= # do not remove any whitespace +base=${arg%.*} # strip the extension +shopt -s nocasematch # MS people don't pay attention to case differences in file names... +while read line; do + if [[ "$line" =~ ^File:.$base ]]; then + out="$line" + while [ ${#line} -eq 79 ]; do # gather continuation lines + read line + out="$out$line" + done + fi +done