Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / ghostscript.scm
index 1240b1d..3239ab4 100644 (file)
@@ -2,11 +2,12 @@
 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
-;;; Copyright © 2013, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
-;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
-  #:use-module (guix build-system trivial))
+  #:use-module (guix build-system trivial)
+  #:use-module (srfi srfi-1))
 
 (define-public lcms
   (package
             (method url-fetch)
             (uri (string-append "mirror://sourceforge/lcms/lcms/" version
                                 "/lcms2-" version ".tar.gz"))
+
+            (patches (search-patches "lcms-CVE-2018-16435.patch"))
             (sha256 (base32
                      "083xisy6z01zhm7p7rgk4bx9d6zlr8l20qkfv1g29ylnhgwzvij8"))))
    (build-system gnu-build-system)
-   (inputs `(("libjpeg-8" ,libjpeg-8)
+   (inputs `(("libjpeg" ,libjpeg)
              ("libtiff" ,libtiff)
              ("zlib" ,zlib)))
    (synopsis "Little CMS, a small-footprint colour management engine")
@@ -132,8 +137,13 @@ printing, and psresize, for adjusting page sizes.")
 (define-public ghostscript
   (package
     (name "ghostscript")
+    (version "9.27")
+
+    ;; The problems addressed by GHOSTSCRIPT/FIXED are not security-related,
+    ;; but they have a significant impact on usability, hence this graft.
+    ;; TODO: Ungraft on next update cycle.
     (replacement ghostscript/fixed)
-    (version "9.23")
+
     (source
       (origin
         (method url-fetch)
@@ -143,9 +153,8 @@ printing, and psresize, for adjusting page sizes.")
                             "/ghostscript-" version ".tar.xz"))
         (sha256
          (base32
-          "1ng8d9fm5lza7k1f7ybc791275c07z5hcmpkrl2i226nshkxrkhz"))
-        (patches (search-patches "ghostscript-runpath.patch"
-                                 "ghostscript-no-header-creationdate.patch"
+          "06dnj0mxyaryfbwlsjwaqf847w91w2h8f108kxxcc41nrnx1y3zw"))
+        (patches (search-patches "ghostscript-no-header-creationdate.patch"
                                  "ghostscript-no-header-id.patch"
                                  "ghostscript-no-header-uuid.patch"))
         (modules '((guix build utils)))
@@ -162,8 +171,17 @@ printing, and psresize, for adjusting page sizes.")
     (outputs '("out" "doc"))                  ;19 MiB of HTML/PS doc + examples
     (arguments
      `(#:disallowed-references ("doc")
+       ;; XXX: Starting with version 9.27, building the tests in parallel
+       ;; occasionally fails like this:
+       ;;  In file included from ./base/memory_.h:23:0,
+       ;;                   from ./obj/gsmd5.h:1,
+       ;;                   from ./obj/gsmd5.c:56:
+       ;;  ./base/std.h:25:10: fatal error: arch.h: No such file or directory
+       #:parallel-tests? #f
        #:configure-flags
-       (list "--with-system-libtiff"
+       (list (string-append "LDFLAGS=-Wl,-rpath="
+                            (assoc-ref %outputs "out") "/lib")
+             "--with-system-libtiff"
              "LIBS=-lz"
              (string-append "ZLIBDIR="
                             (assoc-ref %build-inputs "zlib") "/include")
@@ -181,6 +199,12 @@ printing, and psresize, for adjusting page sizes.")
                    '()))
        #:phases
        (modify-phases %standard-phases
+        (add-before 'configure 'create-output-directory
+          (lambda* (#:key outputs #:allow-other-keys)
+            ;; The configure script refuses to function if the directory
+            ;; specified as -rpath does not already exist.
+            (mkdir-p (string-append (assoc-ref outputs "out") "/lib"))
+            #t))
         (add-after 'configure 'remove-doc-reference
           (lambda _
             ;; Don't retain a reference to the 'doc' output in 'gs'.
@@ -252,14 +276,23 @@ output file formats and printers.")
     (license license:agpl3+)))
 
 (define-public ghostscript/fixed
-  (hidden-package
-    (package
-      (inherit ghostscript)
-      (source
-        (origin
-          (inherit (package-source ghostscript))
-          (patches (append (origin-patches (package-source ghostscript))
-                           (search-patches "ghostscript-CVE-2018-10194.patch"))))))))
+  ;; This adds the Freetype dependency (among other things), which fixes the
+  ;; rendering issues described in <https://issues.guix.gnu.org/issue/34877>.
+  (package/inherit
+   ghostscript
+   (arguments
+    (substitute-keyword-arguments (package-arguments ghostscript)
+      ((#:configure-flags flags ''())
+       `(append (list "--disable-compile-inits"
+                      (string-append "--with-fontpath="
+                                     (assoc-ref %build-inputs "gs-fonts")
+                                     "/share/fonts/type1/ghostscript"))
+                ,flags))))
+   (native-inputs `(("pkg-config" ,pkg-config)    ;needed for freetype
+                    ,@(package-native-inputs ghostscript)))
+   (inputs `(("gs-fonts" ,gs-fonts)
+             ("fontconfig" ,fontconfig)
+             ,@(package-inputs ghostscript)))))
 
 (define-public ghostscript/x
   (package/inherit ghostscript