about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDoron Behar <doron.behar@gmail.com>2023-04-14 09:46:01 -0700
committerGitHub <noreply@github.com>2023-04-14 09:46:01 -0700
commitdcc87a8f7b5ab6b5fcd1442c1b797fb5e2359be1 (patch)
treec5d4086f3b68dfd71e7d561dcd8773ceba5ffe63
parent2ba48cc8dee2249526efeda1d2c629a2ec625229 (diff)
parent393343e2fc32029b56d0b84683156bcb40b4cf63 (diff)
Merge pull request #225415 from doronbehar/pkg/ps2eps
ps2eps: init at 1.70
-rw-r--r--pkgs/tools/typesetting/ps2eps/default.nix68
-rw-r--r--pkgs/tools/typesetting/ps2eps/hardcode-deps.patch26
-rw-r--r--pkgs/top-level/all-packages.nix2
3 files changed, 96 insertions, 0 deletions
diff --git a/pkgs/tools/typesetting/ps2eps/default.nix b/pkgs/tools/typesetting/ps2eps/default.nix
new file mode 100644
index 0000000000000..c8f558889c60e
--- /dev/null
+++ b/pkgs/tools/typesetting/ps2eps/default.nix
@@ -0,0 +1,68 @@
+{ lib
+, fetchFromGitHub
+, perlPackages
+, substituteAll
+, ghostscript
+, installShellFiles
+}:
+
+
+perlPackages.buildPerlPackage rec {
+  pname = "ps2eps";
+  version = "1.70";
+
+  src = fetchFromGitHub {
+    owner = "roland-bless";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-SPLwsGKLVhANoqSQ/GJ938cYjbjMbUOXkNn9so3aJTA=";
+  };
+  patches = [
+    (substituteAll {
+      src = ./hardcode-deps.patch;
+      gs = "${ghostscript}/bin/gs";
+      # bbox cannot be substituted here because substituteAll doesn't know what
+      # will be the $out path of the main derivation
+    })
+  ];
+
+  nativeBuildInputs = [
+    installShellFiles
+  ];
+
+  configurePhase = "true";
+
+  buildPhase = ''
+    runHook preBuild
+
+    make -C src/C bbox
+    patchShebangs src/perl/ps2eps
+    substituteInPlace src/perl/ps2eps \
+      --replace @bbox@ $out/bin/bbox
+
+    runHook postBuild
+  '';
+
+  # Override buildPerlPackage's outputs setting
+  outputs = ["out" "man"];
+  installPhase = ''
+    runHook preInstall
+
+    installManPage \
+      doc/ps2eps.1 \
+      doc/bbox.1
+
+    install -D src/perl/ps2eps $out/bin/ps2eps
+    install -D src/C/bbox $out/bin/bbox
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    inherit (src.meta) homepage;
+    description = "Calculate correct bounding boxes for PostScript and PDF files";
+    license = licenses.gpl2Plus;
+    platforms = platforms.unix;
+    maintainers = [ maintainers.doronbehar ];
+  };
+}
diff --git a/pkgs/tools/typesetting/ps2eps/hardcode-deps.patch b/pkgs/tools/typesetting/ps2eps/hardcode-deps.patch
new file mode 100644
index 0000000000000..b8846ab61d07c
--- /dev/null
+++ b/pkgs/tools/typesetting/ps2eps/hardcode-deps.patch
@@ -0,0 +1,26 @@
+diff --git i/src/perl/ps2eps w/src/perl/ps2eps
+index 1122a81..31d6a9a 100755
+--- i/src/perl/ps2eps
++++ w/src/perl/ps2eps
+@@ -43,19 +43,13 @@ Getopt::Long::Configure("no_ignore_case");
+ 
+ $prgname= "ps2eps";
+ 
+-if (! -d "/usr/bin")
+-{ # we assume that we are running under native windows
+-  $ghostscriptname = "gswin32c";
+-  $NULLDEV = "nul";
+-} 
+-else 
+ { # Unix or cygwin
+-  $ghostscriptname = "gs";
++  $ghostscriptname = "@gs@";
+   $NULLDEV = "/dev/null 2>&1";
+ }
+ 
+ $bboxver=`bbox >$NULLDEV -V`;
+-$bboxname= ($?== -1) ? "" : "bbox";
++$bboxname= ($?== -1) ? "" : "@bbox@";
+ $version= '$Id: ps2eps,v 1.70 2018-01-09 18:00:00 bless Exp $'; #'
+ $insertPScode= 1;     # Insert surrounding Postscript code
+ $infhandle = STDIN;   # Standard input is the default input file
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 2a89ff3dcc298..8a06420574b56 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -33099,6 +33099,8 @@ with pkgs;
 
   ps2client = callPackage ../applications/networking/ps2client { };
 
+  ps2eps = callPackage ../tools/typesetting/ps2eps { };
+
   psi = libsForQt5.callPackage ../applications/networking/instant-messengers/psi { };
 
   psi-plus = libsForQt5.callPackage ../applications/networking/instant-messengers/psi-plus { };