diff options
author | Karl Berry <karl@freefriends.org> | 2012-01-03 00:44:49 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-01-03 00:44:49 +0000 |
commit | 8b2c7dfa75b8296bcb312b594a4c597d7b6c3e7f (patch) | |
tree | da683cdc308d66ad2d95a1af025491c76eab253c /Build/source/texk | |
parent | 6fe376ced37975f0da997a2e955695dc8165cdc7 (diff) |
new (renamed) script latexfileversion 0.3 (2jan12)
git-svn-id: svn://tug.org/texlive/trunk@25012 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
3 files changed, 133 insertions, 11 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am index 60ada7f660a..d2455afa888 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.am +++ b/Build/source/texk/texlive/linked_scripts/Makefile.am @@ -1,6 +1,6 @@ ## Makefile.am for the TeX Live subdirectory texk/texlive/linked_scripts/ ## -## Copyright (C) 2009-2011 Peter Breitenlohner <tex-live@tug.org> +## Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org> ## You may freely use, modify and/or distribute this file. ## ## TeX Live's extra scripts. @@ -53,6 +53,7 @@ texmf_dist_scriptsdir = $(datarootdir)/texmf-dist/scripts texmf_dist_shell_scripts = \ bibexport/bibexport.sh \ installfont/installfont-tl \ + latexfileversion/latexfileversion \ listings-ext/listings-ext.sh \ pdfjam/pdf180 \ pdfjam/pdf270 \ @@ -142,14 +143,15 @@ bin_links = \ # The idea is to install the scripts themselves in texmf*/scripts, and # have bin/arch/foo be a symlink to, say, # ../../texmf-dist/scripts/foo/foo.pl. That way we save a bit of disk -# space, but much more importantly omit duplication, and most +# space, but more importantly omit duplication, and most # importantly of all make it possible to invoke the same Perl script on # Windows (see ../w32_wrapper). -# +# # The installation into texmf*/scripts is ideally done with ctan2tl. -# The copy of the wrapper for Windows is done by hand, but (todo) -# could/should also be done by ctan2tl. The check-wrapper-consistency -# script at least checks after the fact for problems. +# The copy of the wrapper for Windows is done by hand, is done by +# ctan2tl. (And for shell scripts, its addition must be undone by +# hand.) The check-wrapper-consistency script checks after the fact for +# problems. # # We also keep a copy of all the scripts here and install into the runtime. # This is purely for other distro builders, so symlinks are not dangling in diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in index fe739c29309..a61ed0f1802 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.in +++ b/Build/source/texk/texlive/linked_scripts/Makefile.in @@ -169,14 +169,15 @@ DISTCLEANFILES = scripts.tmp # The idea is to install the scripts themselves in texmf*/scripts, and # have bin/arch/foo be a symlink to, say, # ../../texmf-dist/scripts/foo/foo.pl. That way we save a bit of disk -# space, but much more importantly omit duplication, and most +# space, but more importantly omit duplication, and most # importantly of all make it possible to invoke the same Perl script on # Windows (see ../w32_wrapper). -# +# # The installation into texmf*/scripts is ideally done with ctan2tl. -# The copy of the wrapper for Windows is done by hand, but (todo) -# could/should also be done by ctan2tl. The check-wrapper-consistency -# script at least checks after the fact for problems. +# The copy of the wrapper for Windows is done by hand, is done by +# ctan2tl. (And for shell scripts, its addition must be undone by +# hand.) The check-wrapper-consistency script checks after the fact for +# problems. # # We also keep a copy of all the scripts here and install into the runtime. # This is purely for other distro builders, so symlinks are not dangling in @@ -213,6 +214,7 @@ texmf_dist_scriptsdir = $(datarootdir)/texmf-dist/scripts texmf_dist_shell_scripts = \ bibexport/bibexport.sh \ installfont/installfont-tl \ + latexfileversion/latexfileversion \ listings-ext/listings-ext.sh \ pdfjam/pdf180 \ pdfjam/pdf270 \ diff --git a/Build/source/texk/texlive/linked_scripts/latexfileversion/latexfileversion b/Build/source/texk/texlive/linked_scripts/latexfileversion/latexfileversion new file mode 100755 index 00000000000..bae05f520aa --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/latexfileversion/latexfileversion @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +## latexfileversion +## +## This simple shell script prints the version and date of a LaTeX class or +## style file. +## +## Version 0.3, 2011-12-31, Add support for arbitrary tex input file types +## Rename from getfileversion to latexfileversion +## Version 0.2, 2011-12-30, Avoid special characters as guillemots +## Version 0.1, 2005-04-30, Initial version +## +## Copyright 2005, 2011 Harald Harders, harald.harders@gmx.de +## +## This programme may be distributed and/or modified under the +## conditions of the LaTeX Project Public License, either version 1.2 +## of this license or (at your option) any later version. +## The latest version of this license is in +## http://www.latex-project.org/lppl.txt +## and version 1.2 or later is part of all distributions of LaTeX +## version 1999/12/01 or later. +## +## This programme consists of the files +## latexfileversion, README, and ChangeLog. +VERSION=0.3 + +# help screen +if [ -z "$1" ] +then + echo 'latexfileversion v'$VERSION >&2 + echo '' >&2 + echo 'This programme prints the version and date of a LaTeX class or' >&2 + echo 'style file.' >&2 + echo '' >&2 + echo 'Syntax:' >&2 + echo 'latexfileversion <file>' >&2 + echo '' >&2 + echo 'This programme handles style files (extension .sty),' >&2 + echo 'class files (extension .cls), and other tex input files.' >&2 + echo 'The file extension must be given.' >&2 + exit 1 +fi + +# make temporary directory +TMPDIR=`mktemp -d /tmp/latexfileversion.XXXXXX` || exit 1 +cd $TMPDIR + +# extract basenames for extensions .cls and .sty +FILE=$1 +STYLE=${1%%.sty} +CLASS=${1%%.cls} + +# handle .cls files and .sty files seperately +if [ "$CLASS.cls" == "$FILE" ] +then + echo -n "Looking for class file '$CLASS.cls': " + # generate temporary LaTeX file +( +cat << EOM +\documentclass{$CLASS} +\nofiles +\makeatletter +\def\GetFileInfo#1{% + \def\filename{#1}% + \def\@tempb##1 ##2 ##3\relax##4\relax{% + \def\filedate{##1}% + \def\fileversion{##2}% + \def\fileinfo{##3}}% + \edef\@tempa{\csname ver@#1\endcsname}% + \expandafter\@tempb\@tempa\relax? ? \relax\relax} +\makeatother +\GetFileInfo{$CLASS.cls} +\typeout{VERSION \fileversion, \filedate} +\begin{document} +\end{document} +EOM +) > latexfileversion.tex +else + if [ "$STYLE.sty" == "$FILE" ] + then + echo -n "Looking for style file '$STYLE.sty': " + # generate temporary LaTeX file +( +cat << EOM +\documentclass{ltxdoc} +\nofiles +\usepackage{$STYLE} +\GetFileInfo{$STYLE.sty} +\typeout{VERSION \fileversion, \filedate} +\begin{document} +\end{document} +EOM +) > latexfileversion.tex + else + echo -n "Looking for file '$FILE': " + # generate temporary LaTeX file +( +cat << EOM +\documentclass{ltxdoc} +\nofiles +\input{$FILE} +\GetFileInfo{$FILE} +\typeout{VERSION \fileversion, \filedate} +\begin{document} +\end{document} +EOM +) > latexfileversion.tex + fi +fi + +# run temporary LaTeX file which writes »VERSION ...« into the logfile +pdflatex -interaction=nonstopmode latexfileversion.tex > /dev/null +# extract the line containing »VERSION« and remove »VERSION « +grep -e '^VERSION' latexfileversion.log | sed 's/VERSION //' + +# delete temporary directory +rm -rf $TMPDIR + +#EOF |