3
0
Fork 0
forked from mirrors/nixpkgs

* runLaTeX: support generation of Postscript.

* findLaTeXIncludes: handle the case where the input is already in the
  Nix store, and allow a different prefix to be used for searching
  included files.

svn path=/nixpkgs/trunk/; revision=8268
This commit is contained in:
Eelco Dolstra 2007-03-12 17:55:08 +00:00
parent c9c70b8d75
commit ead48be229
3 changed files with 28 additions and 14 deletions

View file

@ -5,11 +5,15 @@ rec {
runLaTeX =
{ rootFile
, generatePDF ? true
, generatePDF ? true # generate PDF, not DVI
, generatePS ? false # generate PS in addition to DVI
, extraFiles ? []
, compressBlanksInIndex ? true
, packages ? []
, searchRelativeTo ? dirOf (toString rootFile) # !!! duplication
}:
assert generatePDF -> !generatePS;
pkgs.stdenv.mkDerivation {
name = "doc";
@ -17,10 +21,10 @@ rec {
builder = ./run-latex.sh;
copyIncludes = ./copy-includes.pl;
inherit rootFile generatePDF extraFiles
inherit rootFile generatePDF generatePS extraFiles
compressBlanksInIndex;
includes = import (findLaTeXIncludes {inherit rootFile;});
includes = import (findLaTeXIncludes {inherit rootFile searchRelativeTo;});
buildInputs = [ pkgs.tetex pkgs.perl ] ++ packages;
};
@ -28,6 +32,7 @@ rec {
findLaTeXIncludes =
{ rootFile
, searchRelativeTo ? dirOf (toString rootFile)
}:
pkgs.stdenv.mkDerivation {
@ -38,6 +43,8 @@ rec {
rootFile = toString rootFile; # !!! hacky
inherit searchRelativeTo;
# Forces rebuilds.
hack = __currentTime;
};

View file

@ -3,17 +3,12 @@ use File::Basename;
my $root = $ENV{"rootFile"};
my $out = $ENV{"out"};
my $path = $ENV{"searchRelativeTo"};
my $store = $ENV{"NIX_STORE"};
open OUT, ">$out" or die;
print OUT "[\n";
# We search for files relative to the root file. TODO: search
# relative to the paths in $TEXINPUTS.
die unless substr($root, 0, 1) eq "/";
my ($x, $path, $y) = fileparse($root);
$path =~ s/\/$//;
my @workset = ();
my %doneset = ();
@ -37,11 +32,18 @@ while (scalar @workset > 0) {
# Print out the full path *and* its relative path to $root.
die if substr($fn, 0, length $path) ne $path;
my $relFN = substr($fn, (length $path) + 1);
print OUT "$fn \"$relFN\"\n";
if (substr($fn, 0, length $path) eq $path) {
my $relFN = substr($fn, (length $path) + 1);
print OUT "$fn \"$relFN\"\n";
} else {
my $base = basename $fn;
my $x = substr($fn, 0, length($store) + 1);
if (substr($fn, 0, length($store) + 1) eq "$store/") {
$base = substr($base, 33);
}
print OUT "$fn \"$base\"\n";
}
# If this is a TeX file, recursively find include in $fn.

View file

@ -94,6 +94,11 @@ if test -n "$generatePDF"; then
cp $rootNameBase.pdf $out
else
cp $rootNameBase.dvi $out
if test -n "$generatePS"; then
echo "CONVERTING TO POSTSCRIPT..."
dvips $rootNameBase.dvi -o $out/$rootNameBase.ps
echo
fi
fi