Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / ghostscript.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2013, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
6 ;;; Copyright © 2017 Alex Vong <alexvong1995@gmail.com>
7 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages ghostscript)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages autotools)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages fontutils)
30 #:use-module (gnu packages image)
31 #:use-module (gnu packages perl)
32 #:use-module (gnu packages pkg-config)
33 #:use-module (gnu packages python)
34 #:use-module (gnu packages tcl)
35 #:use-module (gnu packages xorg)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (guix packages)
38 #:use-module (guix download)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system trivial))
41
42 (define-public lcms
43 (package
44 (name "lcms")
45 (version "2.8")
46 (source (origin
47 (method url-fetch)
48 (uri (string-append "mirror://sourceforge/lcms/lcms/" version
49 "/lcms2-" version ".tar.gz"))
50 (patches (search-patches "lcms-CVE-2016-10165.patch"))
51 (sha256 (base32
52 "08pvl289g0mbznzx5l6ibhaldsgx41kwvdn2c974ga9fkli2pl36"))))
53 (build-system gnu-build-system)
54 (inputs `(("libjpeg-8" ,libjpeg-8)
55 ("libtiff" ,libtiff)
56 ("zlib" ,zlib)))
57 (synopsis "Little CMS, a small-footprint colour management engine")
58 (description
59 "Little CMS is a small-footprint colour management engine, with special
60 focus on accuracy and performance. It uses the International Color
61 Consortium standard (ICC), approved as ISO 15076-1.")
62 (license license:x11)
63 (home-page "http://www.littlecms.com/")
64 (properties '((cpe-name . "little_cms_color_engine")))))
65
66 (define-public libpaper
67 (package
68 (name "libpaper")
69 (version "1.1.24")
70 (source (origin
71 (method url-fetch)
72 (uri (string-append
73 ;; Debian moved their libpaper-1.1.24 to archive.debian.net
74 ;; but in the move the hash of their tarball changed.
75 "http://pkgs.fedoraproject.org/repo/pkgs/libpaper/libpaper_"
76 version ".tar.gz/5bc87d494ba470aba54f6d2d51471834/libpaper_"
77 version ".tar.gz"))
78 (sha256 (base32
79 "0zhcx67afb6b5r936w5jmaydj3ks8zh83n9rm5sv3m3k8q8jib1q"))))
80 (build-system gnu-build-system)
81 (synopsis "Library for handling paper sizes")
82 (description
83 "The paper library and accompanying files are intended to provide a simple
84 way for applications to take actions based on a system- or user-specified
85 paper size.")
86 (license license:gpl2)
87 (home-page "https://packages.qa.debian.org/libp/libpaper.html")))
88
89 (define-public psutils
90 (package
91 (name "psutils")
92 (version "17")
93 (source (origin
94 (method url-fetch)
95 (uri "ftp://ftp.knackered.org/pub/psutils/psutils.tar.gz")
96 (sha256 (base32
97 "1r4ab1fvgganm02kmm70b2r1azwzbav2am41gbigpa2bb1wynlrq"))))
98 (build-system gnu-build-system)
99 (inputs `(("perl" ,perl)))
100 (arguments
101 `(#:tests? #f ; none provided
102 #:phases
103 (alist-replace
104 'configure
105 (lambda* (#:key inputs outputs #:allow-other-keys #:rest args)
106 (let ((perl (assoc-ref inputs "perl"))
107 (out (assoc-ref outputs "out")))
108 (copy-file "Makefile.unix" "Makefile")
109 (substitute* "Makefile"
110 (("/usr/local/bin/perl") (string-append perl "/bin/perl")))
111 (substitute* "Makefile"
112 (("/usr/local") out))
113 ;; for the install phase
114 (substitute* "Makefile"
115 (("-mkdir") "mkdir -p"))
116 ;; drop installation of non-free files
117 (substitute* "Makefile"
118 ((" install.include") ""))))
119 %standard-phases)))
120 (synopsis "Collection of utilities for manipulating PostScript documents")
121 (description
122 "PSUtils is a collection of utilities for manipulating PostScript
123 documents. Programs included are psnup, for placing out several logical pages
124 on a single sheet of paper, psselect, for selecting pages from a document,
125 pstops, for general imposition, psbook, for signature generation for booklet
126 printing, and psresize, for adjusting page sizes.")
127 (license (license:non-copyleft "file://LICENSE"
128 "See LICENSE in the distribution."))
129 (home-page "http://knackered.org/angus/psutils/")))
130
131 (define-public ghostscript
132 (package
133 (name "ghostscript")
134 (version "9.21")
135 (source
136 (origin
137 (method url-fetch)
138 (uri (string-append "https://github.com/ArtifexSoftware/"
139 "ghostpdl-downloads/releases/download/gs"
140 (string-delete #\. version)
141 "/ghostscript-" version ".tar.xz"))
142 (sha256
143 (base32
144 "0lyhjcrkmd5fcmh8h56bs4xr9k4jasmikv5vsix1hd4ai0ad1q9b"))
145 (patches (search-patches "ghostscript-runpath.patch"
146 "ghostscript-CVE-2017-8291.patch"))
147 (modules '((guix build utils)))
148 (snippet
149 ;; Remove bundled libraries. The bundled OpenJPEG is a patched fork so
150 ;; we leave it, at least for now.
151 ;; TODO Try unbundling ijs, which is developed alongside Ghostscript.
152 '(begin
153 (for-each delete-file-recursively '("freetype" "jbig2dec" "jpeg"
154 "lcms2" "libpng"
155 "tiff" "zlib"))))))
156 (build-system gnu-build-system)
157 (outputs '("out" "doc")) ;19 MiB of HTML/PS doc + examples
158 (arguments
159 `(#:disallowed-references ("doc")
160 #:configure-flags
161 (list "--with-system-libtiff"
162 "LIBS=-lz"
163 (string-append "ZLIBDIR="
164 (assoc-ref %build-inputs "zlib") "/include")
165 "--enable-dynamic")
166 #:phases
167 (modify-phases %standard-phases
168 (add-after 'unpack 'fix-doc-dir
169 (lambda _
170 ;; Honor --docdir.
171 (substitute* "Makefile.in"
172 (("^docdir=.*$") "docdir = @docdir@\n")
173 (("^exdir=.*$") "exdir = $(docdir)/examples\n"))
174 #t))
175 (add-after 'configure 'remove-doc-reference
176 (lambda _
177 ;; Don't retain a reference to the 'doc' output in 'gs'.
178 ;; The only use of this definition is in the output of
179 ;; 'gs --help', so this change is fine.
180 (substitute* "base/gscdef.c"
181 (("GS_DOCDIR")
182 "\"~/.guix-profile/share/doc/ghostscript\""))
183 #t))
184 (add-after 'configure 'patch-config-files
185 (lambda _
186 (substitute* "base/unixhead.mak"
187 (("/bin/sh") (which "sh")))
188 #t))
189 (replace 'build
190 (lambda _
191 ;; Build 'libgs.so', but don't build the statically-linked 'gs'
192 ;; binary (saves 22 MiB).
193 (zero? (system* "make" "so" "-j"
194 (number->string (parallel-job-count))))))
195 (replace 'install
196 (lambda _
197 (zero? (system* "make" "soinstall"))))
198 (add-after 'install 'create-gs-symlink
199 (lambda* (#:key outputs #:allow-other-keys)
200 (let ((out (assoc-ref outputs "out")))
201 ;; Some programs depend on having a 'gs' binary available.
202 (symlink "gsc" (string-append out "/bin/gs"))
203 #t))))))
204 (native-inputs
205 `(("perl" ,perl)
206 ("python" ,python-wrapper)
207 ("tcl" ,tcl)))
208 (inputs
209 `(("freetype" ,freetype)
210 ("jbig2dec" ,jbig2dec)
211 ("lcms2" ,lcms)
212 ("libjpeg" ,libjpeg)
213 ("libpaper" ,libpaper)
214 ("libpng" ,libpng)
215 ("libtiff" ,libtiff)
216 ("zlib" ,zlib)))
217 (synopsis "PostScript and PDF interpreter")
218 (description
219 "Ghostscript is an interpreter for the PostScript language and the PDF
220 file format. It also includes a C library that implements the graphics
221 capabilities of the PostScript language. It supports a wide variety of
222 output file formats and printers.")
223 (home-page "https://www.ghostscript.com/")
224 (license license:agpl3+)))
225
226 (define-public ghostscript/x
227 (package/inherit ghostscript
228 (name (string-append (package-name ghostscript) "-with-x"))
229 (inputs `(("libxext" ,libxext)
230 ("libxt" ,libxt)
231 ,@(package-inputs ghostscript)))))
232
233 (define-public ijs
234 (package
235 (name "ijs")
236 (version (package-version ghostscript))
237 (source (package-source ghostscript))
238 (build-system gnu-build-system)
239 (native-inputs
240 `(("libtool" ,libtool)
241 ("automake" ,automake)
242 ("autoconf" ,autoconf)))
243 (arguments
244 `(#:phases
245 (modify-phases %standard-phases
246 (add-after 'unpack 'autogen
247 (lambda _
248 ;; need to regenerate macros
249 (system* "autoreconf" "-if")
250 ;; do not run configure
251 (substitute* "autogen.sh"
252 (("^.*\\$srcdir/configure.*") ""))
253 (system* "bash" "autogen.sh")
254 ;; create configure script in ./ijs/
255 (chdir "ijs")
256 ;; do not run configure
257 (substitute* "autogen.sh"
258 (("^.*\\$srcdir/configure.*") "")
259 (("^ + && echo Now type.*$") ""))
260 (zero? (system* "bash" "autogen.sh")))))))
261 (synopsis "IJS driver framework for inkjet and other raster devices")
262 (description
263 "IJS is a protocol for transmission of raster page images. This package
264 provides the reference implementation of the raster printer driver
265 architecture.")
266 (license license:expat)
267 (home-page (package-home-page ghostscript))))
268
269 (define-public gs-fonts
270 (package
271 (name "gs-fonts")
272 (version "8.11")
273 (source (origin
274 (method url-fetch)
275 (uri (string-append "mirror://sourceforge/gs-fonts/gs-fonts/"
276 version
277 "%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-"
278 version
279 ".tar.gz"))
280 (sha256 (base32
281 "00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf"))))
282 (build-system gnu-build-system)
283 (arguments
284 `(#:tests? #f ; nothing to check, just files to copy
285
286 #:modules ((guix build gnu-build-system)
287 (guix build utils)
288 (srfi srfi-1))
289 #:phases
290 (modify-phases %standard-phases
291 (delete 'configure)
292 (delete 'build)
293 (replace 'install
294 (lambda* (#:key outputs #:allow-other-keys)
295 (let* ((out (assoc-ref outputs "out"))
296 (dir (string-append out "/share/fonts/type1/ghostscript")))
297 (mkdir-p dir)
298 (for-each
299 (lambda (file)
300 (copy-file file (string-append dir "/" file)))
301 (find-files "." "pfb|afm"))))))))
302 (synopsis "Free replacements for the PostScript fonts")
303 (description
304 "Ghostscript fonts provides fonts and font metrics customarily distributed with
305 Ghostscript. It currently includes the 35 standard PostScript fonts.")
306 (license license:gpl2)
307 (home-page "https://sourceforge.net/projects/gs-fonts/")))
308
309 (define-public libspectre
310 (package
311 (name "libspectre")
312 (version "0.2.7")
313 (source (origin
314 (method url-fetch)
315 (uri (string-append "https://libspectre.freedesktop.org/releases/libspectre-"
316 version ".tar.gz"))
317 (sha256 (base32
318 "1v63lqc6bhhxwkpa43qmz8phqs8ci4dhzizyy16d3vkb20m846z8"))))
319 (build-system gnu-build-system)
320 (inputs `(("ghostscript" ,ghostscript)))
321 (native-inputs `(("pkg-config" ,pkg-config)))
322 (synopsis "Postscript rendering library")
323 (description
324 "libspectre is a small library for rendering Postscript documents.
325 It provides a convenient easy to use API for handling and rendering
326 Postscript documents.")
327 (license license:gpl2+)
328 (home-page "http://www.freedesktop.org/wiki/Software/libspectre")))