summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
authorDmitry Kalinkin <dmitry.kalinkin@gmail.com>2018-10-29 16:10:24 -0400
committerDmitry Kalinkin <dmitry.kalinkin@gmail.com>2018-10-29 16:56:45 -0400
commit20643a78073ecd95e960317c6b7488ba0febbf06 (patch)
tree25222b1c3afee884c5c5d16afb350a740eb6c15f /pkgs/tools
parent2337c7522af3b186d4d7ecefe9e19c33aafc6626 (diff)
downloadnixlib-20643a78073ecd95e960317c6b7488ba0febbf06.tar
nixlib-20643a78073ecd95e960317c6b7488ba0febbf06.tar.gz
nixlib-20643a78073ecd95e960317c6b7488ba0febbf06.tar.bz2
nixlib-20643a78073ecd95e960317c6b7488ba0febbf06.tar.lz
nixlib-20643a78073ecd95e960317c6b7488ba0febbf06.tar.xz
nixlib-20643a78073ecd95e960317c6b7488ba0febbf06.tar.zst
nixlib-20643a78073ecd95e960317c6b7488ba0febbf06.zip
texlive: provide repstopdf
repstopdf is supposed to be a symlink to epstopdf. Then epstopdf looks
at "$0" to detect when restricted mode needs to be enabled.  Unfortunately
our wrapper will drop all intermediate symlinks, which messes up "$0".
Restricted mode appears to be a security feature, so a test is
introduced to verify that the wrapper works as expected.
Diffstat (limited to 'pkgs/tools')
-rw-r--r--pkgs/tools/typesetting/tex/texlive/combine.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkgs/tools/typesetting/tex/texlive/combine.nix b/pkgs/tools/typesetting/tex/texlive/combine.nix
index f76b71ced3cf..ea2926748198 100644
--- a/pkgs/tools/typesetting/tex/texlive/combine.nix
+++ b/pkgs/tools/typesetting/tex/texlive/combine.nix
@@ -218,9 +218,30 @@ in buildEnv {
         ln -sv "$(realpath $s)" "$out/bin/$tName" # wrapped below
       done
     )
+  '' +
+    # A hacky way to provide repstopdf
+    #  * Copy is done to have a correct "$0" so that epstopdf enables the restricted mode
+    #  * ./bin/repstopdf needs to be a symlink to be processed by wrapBin
+  ''
+    if [[ -e ./bin/epstopdf ]]; then
+      cp $(realpath ./bin/epstopdf) ./share/texmf/scripts/repstopdf
+      ln -s "$out"/share/texmf/scripts/repstopdf ./bin/repstopdf
+    fi
+  '' +
+    # finish up the wrappers
+  ''
     rm "$out"/bin/*-sys
     wrapBin
   '' +
+    # Perform a small test to verify that the restricted mode get enabled when
+    # needed (detected by checking if it disallows --gscmd)
+  ''
+    if [[ -e ./bin/epstopdf ]]; then
+      echo "Testing restricted mode for {,r}epstopdf"
+      ! (epstopdf --gscmd echo /dev/null 2>&1 || true) | grep forbidden
+      (repstopdf --gscmd echo /dev/null 2>&1 || true) | grep forbidden
+    fi
+  '' +
   # TODO: a context trigger https://www.preining.info/blog/2015/06/debian-tex-live-2015-the-new-layout/
     # http://wiki.contextgarden.net/ConTeXt_Standalone#Unix-like_platforms_.28Linux.2FMacOS_X.2FFreeBSD.2FSolaris.29