* Add a dot2pdf function.

svn path=/nixpkgs/trunk/; revision=3232
This commit is contained in:
Eelco Dolstra 2005-06-20 22:43:35 +00:00
parent a75aef6c7a
commit 3919b35495
4 changed files with 45 additions and 10 deletions

View file

@ -5,7 +5,6 @@ sub createDirs;
sub createDirs { sub createDirs {
my $path = shift; my $path = shift;
return unless $path =~ /^(.*)\/([^\/]*)$/; return unless $path =~ /^(.*)\/([^\/]*)$/;
print "$1 BLA $2\n";
return if -d $1; return if -d $1;
createDirs $1; createDirs $1;
mkdir $1 or die "cannot create directory `$1'"; mkdir $1 or die "cannot create directory `$1'";

View file

@ -6,6 +6,7 @@ rec {
runLaTeX = runLaTeX =
{ rootFile { rootFile
, generatePDF ? true , generatePDF ? true
, extraFiles ? []
}: }:
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
@ -14,7 +15,7 @@ rec {
builder = ./run-latex.sh; builder = ./run-latex.sh;
copyIncludes = ./copy-includes.pl; copyIncludes = ./copy-includes.pl;
inherit rootFile generatePDF; inherit rootFile generatePDF extraFiles;
includes = import (findLaTeXIncludes {inherit rootFile;}); includes = import (findLaTeXIncludes {inherit rootFile;});
@ -38,4 +39,19 @@ rec {
hack = __currentTime; hack = __currentTime;
}; };
dot2pdf =
{ dotGraph
}:
pkgs.stdenv.mkDerivation {
name = "pdf";
builder = ./dot2pdf.sh;
inherit dotGraph;
buildInputs = [
pkgs.perl pkgs.tetex pkgs.graphviz pkgs.ghostscript
];
};
} }

View file

@ -0,0 +1,20 @@
. $stdenv/setup
ensureDir $out
dot2pdf() {
sourceFile=$1
targetName=$out/$(basename $(stripHash $sourceFile; echo $strippedName) .dot).pdf
echo "convering $sourceFile to $targetName..."
dot -Tps $sourceFile > tmp.ps
epstopdf --outfile $targetName tmp.ps
}
for i in $dotGraph; do
if test -d $i; then
for j in $i/*; do dot2pdf $j; done
else
dot2pdf $i
fi
done

View file

@ -4,13 +4,13 @@ ensureDir $out
perl $copyIncludes $includes perl $copyIncludes $includes
#for i in $includes; do for i in $extraFiles; do
# if test -d $i; then if test -d $i; then
# cp $i/* . ln -s $i/* .
# else else
# cp $i $(stripHash $i; echo $strippedName) ln -s $i $(stripHash $i; echo $strippedName)
# fi fi
#done done
rootName=$(basename $(stripHash "$rootFile"; echo $strippedName)) rootName=$(basename $(stripHash "$rootFile"; echo $strippedName))
echo "root name is $rootName" echo "root name is $rootName"