From da63a583441ac70adea4f6668f0fd7a8424991c2 Mon Sep 17 00:00:00 2001 From: Leo Famulari 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