unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Famulari <leo@famulari.name>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: Switching to Artifex Ghostscript
Date: Mon, 29 May 2017 13:50:13 -0400	[thread overview]
Message-ID: <20170529175013.GA13897@jasmine> (raw)
In-Reply-To: <87inkr8fui.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 1119 bytes --]

On Tue, May 23, 2017 at 10:42:45PM +0200, Ludovic Courtès wrote:
> Ricardo Wurmus <rekado@elephly.net> skribis:
> > Marius Bakke <mbakke@fastmail.com> writes:
> >> Leo Famulari <leo@famulari.name> writes:
> >>> Both programs are distributed under the AGPL, as far as I can tell. But
> >>> Artifex Ghostscript is actively developed, which I think is very
> >>> important for C software that is designed to handle untrusted input.
> >>
> >> Thanks for bringing this up. GNU Ghostscript seemed to go
> >> mostly-inactive[0] after Artifex changed to AGPL in 2013[1]. The latest
> >> "upstream" release is 9.21[2], we have 9.14.0 (from 2014!).
> >>
> >> I'm in favor of switching to the active fork.
> >
> > Me too.  In fact, I once tried to package Artifex Ghostscript, but
> > failed in the attempt to unbundle libraries.
> 
> Ditto.  In the discussion you mentioned above, Didier Link of
> GNU Ghostscript did not really address our concerns.

Here are patches that allow you build groff, cairo, and cups with the
Artifex Ghostscript.

I didn't take the step of replacing the GNU Ghostscript yet.

[-- Attachment #1.2: 0001-gnu-Add-Artifex-Ghostscript.patch --]
[-- Type: text/plain, Size: 7754 bytes --]

From da63a583441ac70adea4f6668f0fd7a8424991c2 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Mon, 29 May 2017 13:47:39 -0400
Subject: [PATCH 1/3] gnu: Add Artifex Ghostscript.

* gnu/packages/ghostscript.scm (artifex-ghostscript): New variable.
* gnu/packages/patches/artifex-ghostscript-runpath.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                       |   1 +
 gnu/packages/ghostscript.scm                       | 100 +++++++++++++++++++++
 .../patches/artifex-ghostscript-runpath.patch      |  18 ++++
 3 files changed, 119 insertions(+)
 create mode 100644 gnu/packages/patches/artifex-ghostscript-runpath.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index e811e9a0b..283cae208 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -504,6 +504,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/antiword-CVE-2014-8123.patch			\
   %D%/packages/patches/apr-skip-getservbyname-test.patch	\
   %D%/packages/patches/artanis-fix-Makefile.in.patch		\
+  %D%/packages/patches/artifex-ghostscript-runpath.patch	\
   %D%/packages/patches/aspell-default-dict-dir.patch		\
   %D%/packages/patches/ath9k-htc-firmware-binutils.patch	\
   %D%/packages/patches/ath9k-htc-firmware-gcc.patch		\
diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 1cb651c96..f0d96bb31 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -24,6 +24,7 @@
 (define-module (gnu packages ghostscript)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages image)
@@ -31,6 +32,8 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
   #:use-module (gnu packages tcl)
+  #:use-module (gnu packages tls)
+  #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
@@ -127,6 +130,103 @@ printing, and psresize, for adjusting page sizes.")
                                 "See LICENSE in the distribution."))
    (home-page "http://knackered.org/angus/psutils/")))
 
+(define-public artifex-ghostscript
+  (package
+    (name "artifex-ghostscript")
+    (version "9.21")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append "https://github.com/ArtifexSoftware/"
+                            "ghostpdl-downloads/releases/download/gs"
+                            (string-delete #\. version)
+                            "/ghostscript-" version ".tar.xz"))
+        (sha256
+         (base32
+          "0lyhjcrkmd5fcmh8h56bs4xr9k4jasmikv5vsix1hd4ai0ad1q9b"))
+        (patches (search-patches "artifex-ghostscript-runpath.patch"
+                                 ;; TODO:
+                                 ;;"ghostscript-CVE-2017-8291.patch"
+                                 ))
+        (modules '((guix build utils)))
+        (snippet
+          ;; Remove bundled libraries.
+          ;; TODO Try unbundling ijs, which is developed alongside Ghostscript.
+         '(begin
+            (for-each delete-file-recursively '("freetype" "jbig2dec" "jpeg"
+                                                "lcms2" "libpng"
+                                                ;;"openjpeg" ; Patched fork.
+                                                "tiff" "zlib"))))))
+    (build-system gnu-build-system)
+    (outputs '("out" "doc"))                  ;19 MiB of HTML/PS doc + examples
+    (arguments
+     `(#:disallowed-references ("doc")
+       #:configure-flags
+       (list "--with-system-libtiff"
+             "LIBS=-lz"
+             (string-append "ZLIBDIR="
+                            (assoc-ref %build-inputs "zlib") "/include")
+             "--enable-dynamic")
+       #:phases
+       (modify-phases %standard-phases
+        (add-after 'unpack 'fix-doc-dir
+          (lambda _
+            ;; Honor --docdir.
+            (substitute* "Makefile.in"
+              (("^docdir=.*$") "docdir = @docdir@\n")
+              (("^exdir=.*$") "exdir = $(docdir)/examples\n"))
+            #t))
+        (add-after 'configure 'remove-doc-reference
+          (lambda _
+            ;; Don't retain a reference to the 'doc' output in 'gs'.
+            ;; The only use of this definition is in the output of
+            ;; 'gs --help', so this change is fine.
+            (substitute* "base/gscdef.c"
+              (("GS_DOCDIR")
+               "\"~/.guix-profile/share/doc/ghostscript\""))
+            #t))
+         (add-after 'configure 'patch-config-files
+           (lambda _
+             (substitute* "base/unixhead.mak"
+               (("/bin/sh") (which "sh")))
+             #t))
+         (replace 'build
+           (lambda _
+             ;; Build 'libgs.so', but don't build the statically-linked 'gs'
+             ;; binary (saves 22 MiB).
+             (zero? (system* "make" "so" "-j"
+                             (number->string (parallel-job-count))))))
+         (replace 'install
+           (lambda _
+             (zero? (system* "make" "soinstall"))))
+         (add-after 'install 'create-gs-symlink
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               ;; Some programs depend on having a 'gs' binary available.
+               (symlink "gsc" (string-append out "/bin/gs"))
+               #t))))))
+    (native-inputs
+     `(("perl" ,perl)
+       ("python" ,python-wrapper)
+       ("tcl" ,tcl)))
+    (inputs
+     `(("freetype" ,freetype)
+       ("jbig2dec" ,jbig2dec)
+       ("lcms2" ,lcms)
+       ("libjpeg" ,libjpeg)
+       ("libpaper" ,libpaper)
+       ("libpng" ,libpng)
+       ("libtiff" ,libtiff)
+       ("zlib" ,zlib)))
+    (synopsis "PostScript and PDF interpreter")
+    (description
+     "Ghostscript is an interpreter for the PostScript language and the PDF
+file format.  It also includes a C library that implements the graphics
+capabilities of the PostScript language.  It supports a wide variety of
+output file formats and printers.")
+    (home-page "https://www.ghostscript.com/")
+    (license license:agpl3+)))
+
 (define-public ghostscript
   (package
    (name "ghostscript")
diff --git a/gnu/packages/patches/artifex-ghostscript-runpath.patch b/gnu/packages/patches/artifex-ghostscript-runpath.patch
new file mode 100644
index 000000000..9f161e45b
--- /dev/null
+++ b/gnu/packages/patches/artifex-ghostscript-runpath.patch
@@ -0,0 +1,18 @@
+diff --git a/base/unix-dll.mak b/base/unix-dll.mak
+index 9d57a99..36ef1ff 100644
+--- a/base/unix-dll.mak
++++ b/base/unix-dll.mak
+@@ -171,11 +171,11 @@ gpdl-so-links-subtarget: $(GPDL_SO) $(UNIX_DLL_MAK) $(MAKEDIRS)
+ # Build the small Ghostscript loaders, with Gtk+ and without
+ $(GSSOC_XE): gs-so-links-subtarget $(PSSRC)$(SOC_LOADER) $(UNIX_DLL_MAK) $(MAKEDIRS)
+ 	$(GLCC) -g -o $(GSSOC_XE) $(PSSRC)dxmainc.c \
+-	-L$(BINDIR) -l$(GS_SO_BASE)
++	-L$(BINDIR) -l$(GS_SO_BASE) -Wl,-rpath=$(libdir)
+ 
+ $(GSSOX_XE): gs-so-links-subtarget $(PSSRC)$(SOC_LOADER) $(UNIX_DLL_MAK) $(MAKEDIRS)
+ 	$(GLCC) -g $(SOC_CFLAGS) -o $(GSSOX_XE) $(PSSRC)$(SOC_LOADER) \
+-	-L$(BINDIR) -l$(GS_SO_BASE) $(SOC_LIBS)
++	-L$(BINDIR) -l$(GS_SO_BASE) $(SOC_LIBS) -Wl,-rpath=$(libdir)
+ 
+ $(PCLSOC_XE): gpcl6-so-links-subtarget $(PLSRC)$(REALMAIN_SRC).c $(UNIX_DLL_MAK) $(MAKEDIRS)
+ 	$(GLCC) -g -o $(PCLSOC_XE) $(PLSRC)$(REALMAIN_SRC).c -L$(BINDIR) -l$(PCL_SO_BASE)
-- 
2.13.0


[-- Attachment #1.3: 0002-gnu-ijs-Use-modify-phases-syntax.patch --]
[-- Type: text/plain, Size: 2523 bytes --]

From 8ee8b63f35909ca1b9cfd89552f08e22f28b5d10 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Mon, 29 May 2017 04:42:37 -0400
Subject: [PATCH 2/3] gnu: ijs: Use modify-phases syntax.

* gnu/packages/ghostscript.scm (ijs)[arguments]: Use modify-phases.
---
 gnu/packages/ghostscript.scm | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index f0d96bb31..1c68a04ff 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2013, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -345,24 +346,22 @@ output file formats and printers.")
       ("autoconf"   ,autoconf)))
    (arguments
     `(#:phases
-      (alist-cons-after
-       'unpack 'autogen
-       (lambda _
-         ;; need to regenerate macros
-         (system* "autoreconf" "-if")
-         ;; do not run configure
-         (substitute* "autogen.sh"
-           (("^.*\\$srcdir/configure.*") ""))
-         (system* "bash" "autogen.sh")
-
-         ;; create configure script in ./ijs/
-         (chdir "ijs")
-         ;; do not run configure
-         (substitute* "autogen.sh"
-           (("^.*\\$srcdir/configure.*") "")
-           (("^ + && echo Now type.*$")  ""))
-         (zero? (system* "bash" "autogen.sh")))
-       %standard-phases)))
+      (modify-phases %standard-phases
+        (add-after 'unpack 'autogen
+          (lambda _
+            ;; need to regenerate macros
+            (system* "autoreconf" "-if")
+            ;; do not run configure
+            (substitute* "autogen.sh"
+              (("^.*\\$srcdir/configure.*") ""))
+            (system* "bash" "autogen.sh")
+            ;; create configure script in ./ijs/
+            (chdir "ijs")
+            ;; do not run configure
+            (substitute* "autogen.sh"
+              (("^.*\\$srcdir/configure.*") "")
+              (("^ + && echo Now type.*$")  ""))
+            (zero? (system* "bash" "autogen.sh")))))))
    (synopsis "IJS driver framework for inkjet and other raster devices")
    (description
     "IJS is a protocol for transmission of raster page images.  This package
-- 
2.13.0


[-- Attachment #1.4: 0003-gnu-ijs-Update-to-9.21.0-and-switch-to-Artifex-Ghost.patch --]
[-- Type: text/plain, Size: 1631 bytes --]

From 35a515a7d2bbd95a45fde81b31201bd48a7e7588 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Mon, 29 May 2017 04:43:21 -0400
Subject: [PATCH 3/3] gnu: ijs: Update to 9.21.0 and switch to Artifex
 Ghostscript source.

* gnu/packages/ghostscript.scm (ijs): Update to 9.21.0.
[source, version, home-page]: Inherit from artifex-ghostscript.
---
 gnu/packages/ghostscript.scm | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 1c68a04ff..8676bafb9 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -332,13 +332,8 @@ output file formats and printers.")
 (define-public ijs
   (package
    (name "ijs")
-   (version "9.14.0")
-   (source (origin
-            (method url-fetch)
-            (uri (string-append "mirror://gnu/ghostscript/gnu-ghostscript-"
-                                version ".tar.xz"))
-            (sha256 (base32
-                     "0q4jj41p0qbr4mgcc9q78f5zs8cm1g57wgryhsm2yq4lfslm3ib1"))))
+   (version (package-version artifex-ghostscript))
+   (source (package-source artifex-ghostscript))
    (build-system gnu-build-system)
    (native-inputs
     `(("libtool"    ,libtool)
@@ -368,7 +363,7 @@ output file formats and printers.")
 provides the reference implementation of the raster printer driver
 architecture.")
    (license license:expat)
-   (home-page "https://www.gnu.org/software/ghostscript/")))
+   (home-page (package-home-page artifex-ghostscript))))
 
 (define-public gs-fonts
   (package
-- 
2.13.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-05-29 17:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 20:55 Switching to Artifex Ghostscript Leo Famulari
2017-05-20 21:53 ` Marius Bakke
2017-05-21 13:06   ` Ricardo Wurmus
2017-05-23 17:39     ` Leo Famulari
2017-05-26 12:02       ` Ricardo Wurmus
2017-05-23 20:42     ` Ludovic Courtès
2017-05-29 17:50       ` Leo Famulari [this message]
2017-05-29 18:33         ` Leo Famulari
2017-05-29 18:38         ` Ricardo Wurmus
2017-05-29 20:47           ` Leo Famulari
2017-05-29 22:14           ` Leo Famulari
2017-06-02 16:26             ` Leo Famulari
2017-06-02 18:16               ` Leo Famulari
2017-06-03 13:55                 ` Ludovic Courtès
2017-05-29 23:22           ` Mark H Weaver
2017-05-30  4:40             ` Leo Famulari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170529175013.GA13897@jasmine \
    --to=leo@famulari.name \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).