summary refs log tree commit diff
path: root/pkgs/misc/tex
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2005-08-30 13:10:30 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2005-08-30 13:10:30 +0000
commit860e14cd3dddd09b7d0e03635b8ec6bec100a918 (patch)
tree92fc651387b05bfe6a0f8fab941b741f1e30cb52 /pkgs/misc/tex
parentc27109efa0a8a451d937a85656cfa985fe41ce51 (diff)
downloadnixlib-860e14cd3dddd09b7d0e03635b8ec6bec100a918.tar
nixlib-860e14cd3dddd09b7d0e03635b8ec6bec100a918.tar.gz
nixlib-860e14cd3dddd09b7d0e03635b8ec6bec100a918.tar.bz2
nixlib-860e14cd3dddd09b7d0e03635b8ec6bec100a918.tar.lz
nixlib-860e14cd3dddd09b7d0e03635b8ec6bec100a918.tar.xz
nixlib-860e14cd3dddd09b7d0e03635b8ec6bec100a918.tar.zst
nixlib-860e14cd3dddd09b7d0e03635b8ec6bec100a918.zip
* Support references to parent directories, e.g., \input{../../macros.ltx}.
svn path=/nixpkgs/trunk/; revision=3748
Diffstat (limited to 'pkgs/misc/tex')
-rw-r--r--pkgs/misc/tex/nix/copy-includes.pl29
-rw-r--r--pkgs/misc/tex/nix/run-latex.sh3
2 files changed, 28 insertions, 4 deletions
diff --git a/pkgs/misc/tex/nix/copy-includes.pl b/pkgs/misc/tex/nix/copy-includes.pl
index b81bf27f86a4..2cec62fc7cb6 100644
--- a/pkgs/misc/tex/nix/copy-includes.pl
+++ b/pkgs/misc/tex/nix/copy-includes.pl
@@ -5,11 +5,32 @@ sub createDirs;
 sub createDirs {
     my $path = shift;
     return unless $path =~ /^(.*)\/([^\/]*)$/;
-    return if -d $1;
-    createDirs $1;
-    mkdir $1 or die "cannot create directory `$1'";
+    my $dir = $1;
+    return if -d $dir;
+    return if -e $dir;
+    createDirs $dir;
+    mkdir $dir or die "cannot create directory `$dir'";
 }
 
+my $maxParents = 0;
+for (my $n = 0; $n < @ARGV; $n += 2) {
+    my $fullPath = $ARGV[$n];
+    my $relPath = $ARGV[$n + 1];
+    my $parents = 0;
+    foreach my $comp (split /\//, $relPath) {
+        $parents++ if ($comp eq "..") 
+    }
+    $maxParents = $parents if $parents > $maxParents;
+}
+
+my $startDir = "./";
+for (my $n = 0; $n < $maxParents; $n++) {
+    $startDir .= "dotdot/";
+    mkdir "$startDir" or die "cannot create directory `$startDir': $!";
+}
+
+chdir $startDir or die;
+
 for (my $n = 0; $n < @ARGV; $n += 2) {
     my $fullPath = $ARGV[$n];
     my $relPath = $ARGV[$n + 1];
@@ -18,3 +39,5 @@ for (my $n = 0; $n < @ARGV; $n += 2) {
         
     symlink $fullPath, $relPath or die "cannot create symlink `$relPath'";
 }
+
+print "$startDir\n";
diff --git a/pkgs/misc/tex/nix/run-latex.sh b/pkgs/misc/tex/nix/run-latex.sh
index 103d0771f389..65ab630f9a8e 100644
--- a/pkgs/misc/tex/nix/run-latex.sh
+++ b/pkgs/misc/tex/nix/run-latex.sh
@@ -2,7 +2,8 @@
 
 ensureDir $out
 
-perl $copyIncludes $includes
+startDir=$(perl $copyIncludes $includes)
+cd $startDir
 
 for i in $extraFiles; do
     if test -d $i; then