unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Switching to Artifex Ghostscript
@ 2017-05-20 20:55 Leo Famulari
  2017-05-20 21:53 ` Marius Bakke
  0 siblings, 1 reply; 16+ messages in thread
From: Leo Famulari @ 2017-05-20 20:55 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

The subject of the two Ghostscripts came up last October, but we didn't
really discuss it:

https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00598.html

The canonical Ghostscript is developed by Artifex Software Inc:

https://ghostscript.com/

We package GNU Ghostscript, which is a fork of Artifex's Ghostscript:

https://www.gnu.org/software/ghostscript/

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.

If you are curious where Ghostscript is used, try this:

$ guix graph --type=reverse-package ghostscript | dot -Tsvg > /tmp/graph.svg

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  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
  0 siblings, 1 reply; 16+ messages in thread
From: Marius Bakke @ 2017-05-20 21:53 UTC (permalink / raw)
  To: Leo Famulari, guix-devel

[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]

Leo Famulari <leo@famulari.name> writes:

> The subject of the two Ghostscripts came up last October, but we didn't
> really discuss it:
>
> https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00598.html
>
> The canonical Ghostscript is developed by Artifex Software Inc:
>
> https://ghostscript.com/
>
> We package GNU Ghostscript, which is a fork of Artifex's Ghostscript:
>
> https://www.gnu.org/software/ghostscript/
>
> 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.

[0] https://ftp.gnu.org/gnu/ghostscript/
[1] https://en.wikipedia.org/wiki/Ghostscript#History
[2] https://github.com/ArtifexSoftware/ghostpdl-downloads/releases

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-20 21:53 ` Marius Bakke
@ 2017-05-21 13:06   ` Ricardo Wurmus
  2017-05-23 17:39     ` Leo Famulari
  2017-05-23 20:42     ` Ludovic Courtès
  0 siblings, 2 replies; 16+ messages in thread
From: Ricardo Wurmus @ 2017-05-21 13:06 UTC (permalink / raw)
  To: Marius Bakke; +Cc: guix-devel


Marius Bakke <mbakke@fastmail.com> writes:

> Leo Famulari <leo@famulari.name> writes:
>
>> The subject of the two Ghostscripts came up last October, but we didn't
>> really discuss it:
>>
>> https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00598.html
>>
>> The canonical Ghostscript is developed by Artifex Software Inc:
>>
>> https://ghostscript.com/
>>
>> We package GNU Ghostscript, which is a fork of Artifex's Ghostscript:
>>
>> https://www.gnu.org/software/ghostscript/
>>
>> 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.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  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
  1 sibling, 1 reply; 16+ messages in thread
From: Leo Famulari @ 2017-05-23 17:39 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 871 bytes --]

On Sun, May 21, 2017 at 03:06:41PM +0200, Ricardo Wurmus wrote:
> 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.

I'll try this in the next few days. If you still have your old attempt,
I'd be happy to see it :)

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-21 13:06   ` Ricardo Wurmus
  2017-05-23 17:39     ` Leo Famulari
@ 2017-05-23 20:42     ` Ludovic Courtès
  2017-05-29 17:50       ` Leo Famulari
  1 sibling, 1 reply; 16+ messages in thread
From: Ludovic Courtès @ 2017-05-23 20:42 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Ricardo Wurmus <rekado@elephly.net> skribis:

> Marius Bakke <mbakke@fastmail.com> writes:
>
>> Leo Famulari <leo@famulari.name> writes:
>>
>>> The subject of the two Ghostscripts came up last October, but we didn't
>>> really discuss it:
>>>
>>> https://lists.gnu.org/archive/html/guix-devel/2016-10/msg00598.html
>>>
>>> The canonical Ghostscript is developed by Artifex Software Inc:
>>>
>>> https://ghostscript.com/
>>>
>>> We package GNU Ghostscript, which is a fork of Artifex's Ghostscript:
>>>
>>> https://www.gnu.org/software/ghostscript/
>>>
>>> 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.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-23 17:39     ` Leo Famulari
@ 2017-05-26 12:02       ` Ricardo Wurmus
  0 siblings, 0 replies; 16+ messages in thread
From: Ricardo Wurmus @ 2017-05-26 12:02 UTC (permalink / raw)
  To: Leo Famulari; +Cc: guix-devel


Leo Famulari <leo@famulari.name> writes:

> On Sun, May 21, 2017 at 03:06:41PM +0200, Ricardo Wurmus wrote:
>> 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.
>
> I'll try this in the next few days. If you still have your old attempt,
> I'd be happy to see it :)

Unfortunately, I don’t have it any longer.  But some parts of it (like
the trio package) have since been merged.

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-23 20:42     ` Ludovic Courtès
@ 2017-05-29 17:50       ` Leo Famulari
  2017-05-29 18:33         ` Leo Famulari
  2017-05-29 18:38         ` Ricardo Wurmus
  0 siblings, 2 replies; 16+ messages in thread
From: Leo Famulari @ 2017-05-29 17:50 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


[-- 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 --]

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-29 17:50       ` Leo Famulari
@ 2017-05-29 18:33         ` Leo Famulari
  2017-05-29 18:38         ` Ricardo Wurmus
  1 sibling, 0 replies; 16+ messages in thread
From: Leo Famulari @ 2017-05-29 18:33 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

On Mon, May 29, 2017 at 01:50:13PM -0400, Leo Famulari wrote:
> 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.

> @@ -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)

Oops, this hunk is unecessary. It may be possible to add some
functionality by linking with libraries from these modules, but I'd
rather try to keep feature parity for the initial change to this new
source.

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-29 17:50       ` Leo Famulari
  2017-05-29 18:33         ` Leo Famulari
@ 2017-05-29 18:38         ` Ricardo Wurmus
  2017-05-29 20:47           ` Leo Famulari
                             ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: Ricardo Wurmus @ 2017-05-29 18:38 UTC (permalink / raw)
  To: Leo Famulari; +Cc: guix-devel


Leo Famulari <leo@famulari.name> writes:

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

Woo!

> +        (patches (search-patches "artifex-ghostscript-runpath.patch"
> +                                 ;; TODO:
> +                                 ;;"ghostscript-CVE-2017-8291.patch"
> +                                 ))

What’s up with this?  Is the latest release of Artifex Ghostscript
vulnerable?

> +        (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"))))))

Excellent!

> +         (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))))))

Couldn’t we just add “#:make-flags '("so")” and avoid replacing the
build phase?


> 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.

OK!

> 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.
> ---

LGTM!  Thank you!

--
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-29 18:38         ` Ricardo Wurmus
@ 2017-05-29 20:47           ` Leo Famulari
  2017-05-29 22:14           ` Leo Famulari
  2017-05-29 23:22           ` Mark H Weaver
  2 siblings, 0 replies; 16+ messages in thread
From: Leo Famulari @ 2017-05-29 20:47 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 971 bytes --]

On Mon, May 29, 2017 at 08:38:58PM +0200, Ricardo Wurmus wrote:
> 
> Leo Famulari <leo@famulari.name> writes:
> 
> > Here are patches that allow you build groff, cairo, and cups with the
> > Artifex Ghostscript.
> 
> Woo!

I'm not sure what I was thinking... I forgot to actually make groff,
cairo, and cups use this artifex-ghostscript :p

Testing now...

> > +        (patches (search-patches "artifex-ghostscript-runpath.patch"
> > +                                 ;; TODO:
> > +                                 ;;"ghostscript-CVE-2017-8291.patch"
> > +                                 ))
> 
> What’s up with this?  Is the latest release of Artifex Ghostscript
> vulnerable?

Yes, it's vulnerable. I saw this fixed in the Arch Linux package, but I
didn't check yet if there are other important bugs to fix in Ghostscript
9.21.

> Couldn’t we just add “#:make-flags '("so")” and avoid replacing the
> build phase?

I'll try this.

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  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-05-29 23:22           ` Mark H Weaver
  2 siblings, 1 reply; 16+ messages in thread
From: Leo Famulari @ 2017-05-29 22:14 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel


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

On Mon, May 29, 2017 at 08:38:58PM +0200, Ricardo Wurmus wrote:
> Leo Famulari <leo@famulari.name> writes:
> 
> > Here are patches that allow you build groff, cairo, and cups with the
> > Artifex Ghostscript.
> 
> Woo!

Actually tested and it works!

> > +        (patches (search-patches "artifex-ghostscript-runpath.patch"
> > +                                 ;; TODO:
> > +                                 ;;"ghostscript-CVE-2017-8291.patch"
> > +                                 ))
> 
> What’s up with this?  Is the latest release of Artifex Ghostscript
> vulnerable?

I added this patch in v2 of the patch series (attached).

> > +         (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))))))
> 
> Couldn’t we just add “#:make-flags '("so")” and avoid replacing the
> build phase?

It seems to work.

How should we make this transition? Should we add Artifex Ghostscript
and transition packages over to it, wait for the next core-updates, or
something else?

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

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

* gnu/packages/ghostscript.scm (artifex-ghostscript): New variable.
* gnu/packages/patches/artifex-ghostscript-CVE-2017-8291.patch,
gnu/packages/patches/artifex-ghostscript-runpath.patch: New files.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                       |   2 +
 gnu/packages/ghostscript.scm                       |  90 ++++++++++
 .../artifex-ghostscript-CVE-2017-8291.patch        | 195 +++++++++++++++++++++
 .../patches/artifex-ghostscript-runpath.patch      |  18 ++
 4 files changed, 305 insertions(+)
 create mode 100644 gnu/packages/patches/artifex-ghostscript-CVE-2017-8291.patch
 create mode 100644 gnu/packages/patches/artifex-ghostscript-runpath.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index e811e9a0b..c11010aac 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -504,6 +504,8 @@ 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/artifex-ghostscript-CVE-2017-8291.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..7fe630443 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -127,6 +127,96 @@ 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"
+                                 "artifex-ghostscript-CVE-2017-8291.patch"))
+        (modules '((guix build utils)))
+        (snippet
+          ;; Remove bundled libraries. The bundled OpenJPEG is a patched fork so
+          ;; we leave it, at least for now.
+          ;; TODO Try unbundling ijs, which is developed alongside Ghostscript.
+         '(begin
+            (for-each delete-file-recursively '("freetype" "jbig2dec" "jpeg"
+                                                "lcms2" "libpng"
+                                                "tiff" "zlib"))))))
+    (build-system gnu-build-system)
+    (outputs '("out" "doc"))                  ;19 MiB of HTML/PS doc + examples
+    (arguments
+     `(#:disallowed-references ("doc")
+       #:make-flags '("so")
+       #: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 '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-CVE-2017-8291.patch b/gnu/packages/patches/artifex-ghostscript-CVE-2017-8291.patch
new file mode 100644
index 000000000..d38bd593c
--- /dev/null
+++ b/gnu/packages/patches/artifex-ghostscript-CVE-2017-8291.patch
@@ -0,0 +1,195 @@
+Fix CVE-2017-8291:
+
+https://bugs.ghostscript.com/show_bug.cgi?id=697799
+https://bugs.ghostscript.com/show_bug.cgi?id=697808 (duplicate)
+https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8291
+
+Patches copied from upstream source repository:
+
+https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=4f83478c88c2e05d6e8d79ca4557eb039354d2f3
+https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=04b37bbce174eed24edec7ad5b920eb93db4d47d
+https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=57f20719e1cfaea77b67cb26e26de7fe4d7f9b2e
+https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=ccfd2c75ac9be4cbd369e4cbdd40ba11a0c7bdad
+
+From 4f83478c88c2e05d6e8d79ca4557eb039354d2f3 Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell@artifex.com>
+Date: Thu, 27 Apr 2017 13:03:33 +0100
+Subject: [PATCH] Bug 697799: have .eqproc check its parameters
+
+The Ghostscript custom operator .eqproc was not check the number or type of
+the parameters it was given.
+---
+ psi/zmisc3.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/psi/zmisc3.c b/psi/zmisc3.c
+index 54b304246..37293ff4b 100644
+--- a/psi/zmisc3.c
++++ b/psi/zmisc3.c
+@@ -56,6 +56,12 @@ zeqproc(i_ctx_t *i_ctx_p)
+     ref2_t stack[MAX_DEPTH + 1];
+     ref2_t *top = stack;
+ 
++    if (ref_stack_count(&o_stack) < 2)
++        return_error(gs_error_stackunderflow);
++    if (!r_is_array(op - 1) || !r_is_array(op)) {
++        return_error(gs_error_typecheck);
++    }
++
+     make_array(&stack[0].proc1, 0, 1, op - 1);
+     make_array(&stack[0].proc2, 0, 1, op);
+     for (;;) {
+-- 
+2.13.0
+
+From 04b37bbce174eed24edec7ad5b920eb93db4d47d Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell@artifex.com>
+Date: Thu, 27 Apr 2017 13:21:31 +0100
+Subject: [PATCH] Bug 697799: have .rsdparams check its parameters
+
+The Ghostscript internal operator .rsdparams wasn't checking the number or
+type of the operands it was being passed. Do so.
+---
+ psi/zfrsd.c | 22 +++++++++++++++-------
+ 1 file changed, 15 insertions(+), 7 deletions(-)
+
+diff --git a/psi/zfrsd.c b/psi/zfrsd.c
+index 191107d8a..950588d69 100644
+--- a/psi/zfrsd.c
++++ b/psi/zfrsd.c
+@@ -49,13 +49,20 @@ zrsdparams(i_ctx_t *i_ctx_p)
+     ref *pFilter;
+     ref *pDecodeParms;
+     int Intent = 0;
+-    bool AsyncRead;
++    bool AsyncRead = false;
+     ref empty_array, filter1_array, parms1_array;
+     uint i;
+-    int code;
++    int code = 0;
++
++    if (ref_stack_count(&o_stack) < 1)
++        return_error(gs_error_stackunderflow);
++    if (!r_has_type(op, t_dictionary) && !r_has_type(op, t_null)) {
++        return_error(gs_error_typecheck);
++    }
+ 
+     make_empty_array(&empty_array, a_readonly);
+-    if (dict_find_string(op, "Filter", &pFilter) > 0) {
++    if (r_has_type(op, t_dictionary)
++        && dict_find_string(op, "Filter", &pFilter) > 0) {
+         if (!r_is_array(pFilter)) {
+             if (!r_has_type(pFilter, t_name))
+                 return_error(gs_error_typecheck);
+@@ -94,12 +101,13 @@ zrsdparams(i_ctx_t *i_ctx_p)
+                 return_error(gs_error_typecheck);
+         }
+     }
+-    code = dict_int_param(op, "Intent", 0, 3, 0, &Intent);
++    if (r_has_type(op, t_dictionary))
++        code = dict_int_param(op, "Intent", 0, 3, 0, &Intent);
+     if (code < 0 && code != gs_error_rangecheck) /* out-of-range int is ok, use 0 */
+         return code;
+-    if ((code = dict_bool_param(op, "AsyncRead", false, &AsyncRead)) < 0
+-        )
+-        return code;
++    if (r_has_type(op, t_dictionary))
++        if ((code = dict_bool_param(op, "AsyncRead", false, &AsyncRead)) < 0)
++            return code;
+     push(1);
+     op[-1] = *pFilter;
+     if (pDecodeParms)
+-- 
+2.13.0
+
+From 57f20719e1cfaea77b67cb26e26de7fe4d7f9b2e Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell@artifex.com>
+Date: Wed, 3 May 2017 12:05:45 +0100
+Subject: [PATCH] Bug 697846: revision to commit 4f83478c88 (.eqproc)
+
+When using the "DELAYBIND" feature, it turns out that .eqproc can be called with
+parameters that are not both procedures. In this case, it turns out, the
+expectation is for the operator to return 'false', rather than throw an error.
+---
+ psi/zmisc3.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/psi/zmisc3.c b/psi/zmisc3.c
+index 37293ff4b..3f01d39a3 100644
+--- a/psi/zmisc3.c
++++ b/psi/zmisc3.c
+@@ -38,6 +38,15 @@ zcliprestore(i_ctx_t *i_ctx_p)
+     return gs_cliprestore(igs);
+ }
+ 
++static inline bool
++eqproc_check_type(ref *r)
++{
++    return r_has_type(r, t_array)
++           || r_has_type(r, t_mixedarray)
++           || r_has_type(r, t_shortarray)
++           || r_has_type(r, t_oparray);
++}
++
+ /* <proc1> <proc2> .eqproc <bool> */
+ /*
+  * Test whether two procedures are equal to depth 10.
+@@ -58,8 +67,10 @@ zeqproc(i_ctx_t *i_ctx_p)
+ 
+     if (ref_stack_count(&o_stack) < 2)
+         return_error(gs_error_stackunderflow);
+-    if (!r_is_array(op - 1) || !r_is_array(op)) {
+-        return_error(gs_error_typecheck);
++    if (!eqproc_check_type(op -1) || !eqproc_check_type(op)) {
++        make_false(op - 1);
++        pop(1);
++        return 0;
+     }
+ 
+     make_array(&stack[0].proc1, 0, 1, op - 1);
+-- 
+2.13.0
+
+From ccfd2c75ac9be4cbd369e4cbdd40ba11a0c7bdad Mon Sep 17 00:00:00 2001
+From: Chris Liddell <chris.liddell@artifex.com>
+Date: Thu, 11 May 2017 14:07:48 +0100
+Subject: [PATCH] Bug 697892: fix check for op stack underflow.
+
+In the original fix, I used the wrong method to check for stack underflow, this
+is using the correct method.
+---
+ psi/zfrsd.c  | 3 +--
+ psi/zmisc3.c | 3 +--
+ 2 files changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/psi/zfrsd.c b/psi/zfrsd.c
+index 950588d69..9c035b96d 100644
+--- a/psi/zfrsd.c
++++ b/psi/zfrsd.c
+@@ -54,8 +54,7 @@ zrsdparams(i_ctx_t *i_ctx_p)
+     uint i;
+     int code = 0;
+ 
+-    if (ref_stack_count(&o_stack) < 1)
+-        return_error(gs_error_stackunderflow);
++    check_op(1);
+     if (!r_has_type(op, t_dictionary) && !r_has_type(op, t_null)) {
+         return_error(gs_error_typecheck);
+     }
+diff --git a/psi/zmisc3.c b/psi/zmisc3.c
+index 3f01d39a3..43803b55b 100644
+--- a/psi/zmisc3.c
++++ b/psi/zmisc3.c
+@@ -65,8 +65,7 @@ zeqproc(i_ctx_t *i_ctx_p)
+     ref2_t stack[MAX_DEPTH + 1];
+     ref2_t *top = stack;
+ 
+-    if (ref_stack_count(&o_stack) < 2)
+-        return_error(gs_error_stackunderflow);
++    check_op(2);
+     if (!eqproc_check_type(op -1) || !eqproc_check_type(op)) {
+         make_false(op - 1);
+         pop(1);
+-- 
+2.13.0
+
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: 2520 bytes --]

From ddbbe1bd753b004ab8809dba083cfa390381703a Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Mon, 29 May 2017 04:42:37 -0400
Subject: [v2 2/4] 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 7fe630443..237c3f02f 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.
 ;;;
@@ -335,24 +336,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: 1628 bytes --]

From d0878f6c570721c425961c9d199c24fceaefa9e2 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Mon, 29 May 2017 04:43:21 -0400
Subject: [v2 3/4] 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 237c3f02f..f46308c9c 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -322,13 +322,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)
@@ -358,7 +353,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 --]

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-29 18:38         ` Ricardo Wurmus
  2017-05-29 20:47           ` Leo Famulari
  2017-05-29 22:14           ` Leo Famulari
@ 2017-05-29 23:22           ` Mark H Weaver
  2017-05-30  4:40             ` Leo Famulari
  2 siblings, 1 reply; 16+ messages in thread
From: Mark H Weaver @ 2017-05-29 23:22 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Ricardo Wurmus <rekado@elephly.net> writes:

> Leo Famulari <leo@famulari.name> writes:
>
>> +         (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))))))
>
> Couldn’t we just add “#:make-flags '("so")” and avoid replacing the
> build phase?

FWIW, I think it's a bad habit to abuse #:make-flags for targets,
because the contents of #:make-flags is also passed to 'make' during the
'install' and 'check' phases.

IMO, if we want to avoid replacing the build phase in cases like this,
it would be better to add a separate #:build-target argument.

Thoughts?

      Mark

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-29 23:22           ` Mark H Weaver
@ 2017-05-30  4:40             ` Leo Famulari
  0 siblings, 0 replies; 16+ messages in thread
From: Leo Famulari @ 2017-05-30  4:40 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

On Mon, May 29, 2017 at 07:22:18PM -0400, Mark H Weaver wrote:
> > Leo Famulari <leo@famulari.name> writes:
> >
> >> +         (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))))))
> >
> > Couldn’t we just add “#:make-flags '("so")” and avoid replacing the
> > build phase?
> 
> FWIW, I think it's a bad habit to abuse #:make-flags for targets,
> because the contents of #:make-flags is also passed to 'make' during the
> 'install' and 'check' phases.

That's a good point. For this package I think we can just re-use the
build phase replacement from the GNU Ghostscript package, as in v1 of my
patch.

> IMO, if we want to avoid replacing the build phase in cases like this,
> it would be better to add a separate #:build-target argument.
> 
> Thoughts?

Yes, it could be useful.

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-05-29 22:14           ` Leo Famulari
@ 2017-06-02 16:26             ` Leo Famulari
  2017-06-02 18:16               ` Leo Famulari
  0 siblings, 1 reply; 16+ messages in thread
From: Leo Famulari @ 2017-06-02 16:26 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

On Mon, May 29, 2017 at 06:14:57PM -0400, Leo Famulari wrote:
> How should we make this transition? Should we add Artifex Ghostscript
> and transition packages over to it, wait for the next core-updates, or
> something else?

Any opinions? Otherwise, I'll put it on the next core-updates branch, unless the
current branch is still "open for business".

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-06-02 16:26             ` Leo Famulari
@ 2017-06-02 18:16               ` Leo Famulari
  2017-06-03 13:55                 ` Ludovic Courtès
  0 siblings, 1 reply; 16+ messages in thread
From: Leo Famulari @ 2017-06-02 18:16 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 548 bytes --]

On Fri, Jun 02, 2017 at 12:26:12PM -0400, Leo Famulari wrote:
> On Mon, May 29, 2017 at 06:14:57PM -0400, Leo Famulari wrote:
> > How should we make this transition? Should we add Artifex Ghostscript
> > and transition packages over to it, wait for the next core-updates, or
> > something else?
> 
> Any opinions? Otherwise, I'll put it on the next core-updates branch, unless the
> current branch is still "open for business".

After discussing it with Ludo on IRC, I pushed to core-updates as
55af10fb987ce96966850da08f8f8d12691dee63.

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Switching to Artifex Ghostscript
  2017-06-02 18:16               ` Leo Famulari
@ 2017-06-03 13:55                 ` Ludovic Courtès
  0 siblings, 0 replies; 16+ messages in thread
From: Ludovic Courtès @ 2017-06-03 13:55 UTC (permalink / raw)
  To: Leo Famulari; +Cc: guix-devel

Leo Famulari <leo@famulari.name> skribis:

> On Fri, Jun 02, 2017 at 12:26:12PM -0400, Leo Famulari wrote:
>> On Mon, May 29, 2017 at 06:14:57PM -0400, Leo Famulari wrote:
>> > How should we make this transition? Should we add Artifex Ghostscript
>> > and transition packages over to it, wait for the next core-updates, or
>> > something else?
>> 
>> Any opinions? Otherwise, I'll put it on the next core-updates branch, unless the
>> current branch is still "open for business".
>
> After discussing it with Ludo on IRC, I pushed to core-updates as
> 55af10fb987ce96966850da08f8f8d12691dee63.

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-06-03 13:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).