projects/guix·blob wip-postfix · refs

412 lines · 16.7 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013 Andreas Enge <[email protected]>
3;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <[email protected]>
4;;; Copyright © 2015 Ricardo Wurmus <[email protected]>
5;;; Copyright © 2013, 2015, 2016, 2017, 2019 Ludovic Courtès <[email protected]>
6;;; Copyright © 2017 Alex Vong <[email protected]>
7;;; Copyright © 2017, 2018, 2019, 2021, 2023 Efraim Flashner <[email protected]>
8;;; Copyright © 2017 Leo Famulari <[email protected]>
9;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
10;;; Copyright © 2018, 2020, 2022 Marius Bakke <[email protected]>
11;;; Copyright © 2019 Mathieu Othacehe <[email protected]>
12;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen <[email protected]>
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages ghostscript)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages autotools)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages cups)
34 #:use-module (gnu packages fontutils)
35 #:use-module (gnu packages image)
36 #:use-module (gnu packages man)
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages tcl)
41 #:use-module (gnu packages xorg)
42 #:use-module ((guix licenses) #:prefix license:)
43 #:use-module (guix packages)
44 #:use-module (guix download)
45 #:use-module (guix gexp)
46 #:use-module (guix utils)
47 #:use-module (guix build-system gnu)
48 #:use-module (srfi srfi-1))
49
50(define-public lcms
51 (package
52 (name "lcms")
53 (version "2.13.1")
54 (source (origin
55 (method url-fetch)
56 (uri (string-append "mirror://sourceforge/lcms/lcms/"
57 (version-major+minor version)
58 "/lcms2-" version ".tar.gz"))
59 (sha256
60 (base32
61 "121v414bg2zk0fcwx0kigr2l6nxl88nmblfn3gq5lz5jwybffwyl"))))
62 (build-system gnu-build-system)
63 (arguments
64 '(#:configure-flags '("--disable-static")))
65 (inputs
66 (list libjpeg-turbo libtiff zlib))
67 (synopsis "Little CMS, a small-footprint colour management engine")
68 (description
69 "Little CMS is a small-footprint colour management engine, with special
70focus on accuracy and performance. It uses the International Color
71Consortium standard (ICC), approved as ISO 15076-1.")
72 (license license:x11)
73 (home-page "https://www.littlecms.com/")
74 (properties '((cpe-name . "little_cms_color_engine")))))
75
76(define-public libpaper
77 (package
78 (name "libpaper")
79 (version "2.0.0")
80 (source (origin
81 (method url-fetch)
82 (uri (string-append "https://github.com/rrthomas/libpaper/releases"
83 "/download/v" version "/libpaper-"
84 version ".tar.gz"))
85 (sha256
86 (base32
87 "0aipyaqp30cn919j7w5wvlgkw0v4aqsax82i2zw4wmgck8g6ax77"))))
88 (build-system gnu-build-system)
89 (native-inputs
90 (list help2man))
91 (arguments
92 (list #:configure-flags ''("--disable-static"
93 ;; Tests require a relocatable build.
94 "--enable-relocatable")
95 ;; --enable-relocate is broken on the Hurd
96 #:tests? (not (or (target-hurd?)
97 (%current-target-system)))))
98 (outputs '("out" "debug"))
99 (home-page "https://github.com/rrthomas/libpaper")
100 (synopsis "Library for handling paper sizes")
101 (description
102 "The paper library and accompanying files are intended to provide a simple
103way for applications to take actions based on a system- or user-specified
104paper size.")
105 ;; The library is LGPL3+, everything else GPL3+.
106 (license (list license:lgpl3+ license:gpl3+))))
107
108(define-public psutils
109 (package
110 (name "psutils")
111 (version "2.09")
112 (source (origin
113 (method url-fetch)
114 (uri (string-append "https://github.com/rrthomas/psutils/releases"
115 "/download/v" version "/psutils-"
116 version ".tar.gz"))
117 (sha256
118 (base32
119 "1nmp0hb7c4a315vv1mqw2cbckvca8bzh1cv3gdvwwy24w9qba6p3"))))
120 (build-system gnu-build-system)
121 (inputs (list perl))
122 (native-inputs
123 (list libpaper))
124 (arguments
125 (list #:tests? #f ;FIXME: requires files not present in tarball
126 #:configure-flags
127 ;; Help the build system locate Perl when cross-compiling.
128 (if (%current-target-system)
129 #~(list (string-append "ac_cv_path_PERL="
130 (search-input-file %build-inputs "bin/perl")))
131 #~'())))
132 (synopsis "Collection of utilities for manipulating PostScript documents")
133 (description
134 "PSUtils is a collection of utilities for manipulating PostScript
135documents. Programs included are psnup, for placing out several logical pages
136on a single sheet of paper, psselect, for selecting pages from a document,
137pstops, for general imposition, psbook, for signature generation for booklet
138printing, and psresize, for adjusting page sizes.")
139 (home-page "https://github.com/rrthomas/psutils")
140 (license (list license:gpl3+
141 ;; This file carries the "historical" psutils license (v1),
142 ;; which is "effectively BSD 3-clause" (a quote from the file).
143 (license:non-copyleft
144 "file://extractres.in.in"
145 "See extractres.in.in in the distribution.")))))
146
147(define-public ghostscript
148 (package
149 (name "ghostscript")
150 (version "9.56.1")
151 (replacement ghostscript/fixed)
152 (source
153 (origin
154 (method url-fetch)
155 (uri (string-append "https://github.com/ArtifexSoftware/"
156 "ghostpdl-downloads/releases/download/gs"
157 (string-delete #\. version)
158 "/ghostscript-" version ".tar.xz"))
159 (sha256
160 (base32
161 "1r5qash65m6ignki6z72q4rlai9ka99xrxnmqd19n02has00cd6l"))
162 (patches (search-patches "ghostscript-no-header-creationdate.patch"
163 "ghostscript-no-header-id.patch"
164 "ghostscript-no-header-uuid.patch"))
165 (modules '((guix build utils)))
166 (snippet
167 ;; Remove bundled libraries. The bundled OpenJPEG is a patched fork so
168 ;; we leave it, at least for now.
169 ;; TODO Try unbundling ijs, which is developed alongside Ghostscript.
170 ;; Likewise for the thread-safe lcms2 fork called "lcms2art".
171 '(begin
172 (for-each delete-file-recursively '("freetype" "jbig2dec" "jpeg"
173 "libpng" "tiff" "zlib"))))))
174 (build-system gnu-build-system)
175 (outputs '("out" "doc")) ;19 MiB of HTML/PS doc + examples
176 (arguments
177 (list
178 #:disallowed-references '("doc")
179 #:configure-flags
180 #~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
181 "--with-system-libtiff"
182 "LIBS=-lz"
183 (string-append "ZLIBDIR="
184 (dirname (search-input-file %build-inputs
185 "include/zlib.h")))
186 "--enable-dynamic"
187 "--disable-compile-inits"
188 (string-append "--with-fontpath="
189 (search-input-directory
190 %build-inputs
191 "share/fonts/type1/ghostscript"))
192
193 #$@(if (%current-target-system)
194 '(;; Specify the native compiler, which is used to build 'echogs'
195 ;; and other intermediary tools when cross-compiling; see
196 ;; <https://ghostscript.com/FAQ.html>.
197 "CCAUX=gcc"
198
199 ;; Save 'config.log' etc. of the native build under
200 ;; auxtmp/, useful for debugging.
201 "--enable-save_confaux")
202 '()))
203 #:phases
204 #~(modify-phases %standard-phases
205 #$@(if (target-hurd?)
206 #~((add-after 'unpack 'patch-leptonica
207 (lambda _
208 (let ((patch-file
209 #$(local-file
210 (search-patch
211 "ghostscript-leptonica-hurd.patch"))))
212 (with-directory-excursion "leptonica"
213 (invoke "patch" "--force" "-p1" "-i" patch-file))))))
214 #~())
215 (add-before 'configure 'create-output-directory
216 (lambda _
217 ;; The configure script refuses to function if the directory
218 ;; specified as -rpath does not already exist.
219 (mkdir-p (string-append #$output "/lib"))))
220 (add-after 'configure 'remove-doc-reference
221 (lambda _
222 ;; Don't retain a reference to the 'doc' output in 'gs'.
223 ;; The only use of this definition is in the output of
224 ;; 'gs --help', so this change is fine.
225 (substitute* "base/gscdef.c"
226 (("GS_DOCDIR")
227 "\"~/.guix-profile/share/doc/ghostscript\""))))
228 (add-after 'configure 'patch-config-files
229 (lambda _
230 (substitute* "base/unixhead.mak"
231 (("/bin/sh") (which "sh")))))
232 #$@(if (%current-target-system)
233 '((add-after 'configure 'add-native-lz
234 (lambda _
235 ;; Add missing '-lz' for native tools such as 'mkromfs'.
236 (substitute* "Makefile"
237 (("^AUXEXTRALIBS=(.*)$" _ value)
238 (string-append "AUXEXTRALIBS = -lz " value "\n"))))))
239 '())
240 (replace 'build
241 (lambda _
242 ;; Build 'libgs.so', but don't build the statically-linked 'gs'
243 ;; binary (saves 22 MiB).
244 (invoke "make" "so" "-j"
245 (number->string (parallel-job-count)))))
246 (replace 'install
247 (lambda _
248 (invoke "make" "soinstall")))
249 (add-after 'install 'create-gs-symlink
250 (lambda _
251 ;; Some programs depend on having a 'gs' binary available.
252 (symlink "gsc" (string-append #$output "/bin/gs")))))))
253 (native-inputs
254 (append
255 (list perl
256 pkg-config ;needed for freetype
257 python-minimal-wrapper
258 tcl)
259 ;; When cross-compiling, some of the natively-built tools require all
260 ;; these libraries.
261 (if (%current-target-system)
262 (list zlib libjpeg-turbo)
263 '())))
264 (inputs
265 (list fontconfig
266 freetype
267 font-ghostscript
268 jbig2dec
269 libjpeg-turbo
270 libpaper
271 libpng
272 libtiff
273 zlib))
274 (synopsis "PostScript and PDF interpreter")
275 (description
276 "Ghostscript is an interpreter for the PostScript language and the PDF
277file format. It also includes a C library that implements the graphics
278capabilities of the PostScript language. It supports a wide variety of
279output file formats and printers.")
280 (home-page "https://www.ghostscript.com/")
281 (license license:agpl3+)))
282
283(define ghostscript/fixed
284 (package-with-patches
285 ghostscript
286 (search-patches "ghostscript-CVE-2023-36664.patch"
287 "ghostscript-CVE-2023-36664-fixup.patch")))
288
289(define-public ghostscript/x
290 (package/inherit ghostscript
291 (name (string-append (package-name ghostscript) "-with-x"))
292 (inputs (modify-inputs (package-inputs ghostscript)
293 (prepend libxext libxt)))))
294
295(define-public ghostscript/cups
296 (package/inherit ghostscript
297 (name "ghostscript-with-cups")
298 (inputs (modify-inputs (package-inputs ghostscript)
299 (prepend cups-minimal)))))
300
301(define-public ijs
302 (package
303 (name "ijs")
304 (version (package-version ghostscript))
305 (source (package-source ghostscript))
306 (build-system gnu-build-system)
307 (native-inputs
308 (append (if (target-riscv64?)
309 (list config)
310 '())
311 (list libtool automake autoconf)))
312 (arguments
313 `(#:phases
314 (modify-phases %standard-phases
315 (add-after 'unpack 'autogen
316 (lambda _
317 ;; need to regenerate macros
318 (system* "autoreconf" "-if")
319 ;; do not run configure
320 (substitute* "autogen.sh"
321 (("^.*\\$srcdir/configure.*") ""))
322 (system* "bash" "autogen.sh")
323 ;; create configure script in ./ijs/
324 (chdir "ijs")
325 ;; do not run configure
326 (substitute* "autogen.sh"
327 (("^.*\\$srcdir/configure.*") "")
328 (("^ + && echo Now type.*$") ""))
329 (invoke "bash" "autogen.sh")))
330 ,@(if (target-riscv64?)
331 `((add-after 'unpack 'update-config-scripts
332 (lambda* (#:key native-inputs inputs #:allow-other-keys)
333 (for-each (lambda (file)
334 (install-file
335 (search-input-file
336 (or native-inputs inputs)
337 (string-append "/bin/" file)) "ijs"))
338 '("config.guess" "config.sub")))))
339 '()))))
340 (synopsis "IJS driver framework for inkjet and other raster devices")
341 (description
342 "IJS is a protocol for transmission of raster page images. This package
343provides the reference implementation of the raster printer driver
344architecture.")
345 (license license:expat)
346 (home-page (package-home-page ghostscript))))
347
348(define-public font-ghostscript
349 (package
350 (name "font-ghostscript")
351 (version "8.11")
352 (source (origin
353 (method url-fetch)
354 (uri (string-append "mirror://sourceforge/gs-fonts/gs-fonts/"
355 version
356 "%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-"
357 version
358 ".tar.gz"))
359 (sha256 (base32
360 "00f4l10xd826kak51wsmaz69szzm2wp8a41jasr4jblz25bg7dhf"))))
361 (build-system gnu-build-system)
362 (arguments
363 `(#:tests? #f ; nothing to check, just files to copy
364
365 #:modules ((guix build gnu-build-system)
366 (guix build utils)
367 (srfi srfi-1))
368 #:phases
369 (modify-phases %standard-phases
370 (delete 'configure)
371 (delete 'build)
372 (replace 'install
373 (lambda* (#:key outputs #:allow-other-keys)
374 (let* ((out (assoc-ref outputs "out"))
375 (dir (string-append out "/share/fonts/type1/ghostscript")))
376 (mkdir-p dir)
377 (for-each
378 (lambda (file)
379 (copy-file file (string-append dir "/" file)))
380 (find-files "." "pfb|afm"))
381 #t))))))
382 (synopsis "Free replacements for the PostScript fonts")
383 (description
384 "Ghostscript fonts provides fonts and font metrics customarily distributed with
385Ghostscript. It currently includes the 35 standard PostScript fonts.")
386 (license license:gpl2)
387 (home-page "https://sourceforge.net/projects/gs-fonts/")))
388
389(define-public gs-fonts
390 (deprecated-package "gs-fonts" font-ghostscript))
391
392(define-public libspectre
393 (package
394 (name "libspectre")
395 (version "0.2.10")
396 (source (origin
397 (method url-fetch)
398 (uri (string-append "https://libspectre.freedesktop.org/releases"
399 "/libspectre-" version ".tar.gz"))
400 (sha256
401 (base32
402 "01sdaakrv5js8r6gj2r1ankyl304161z060f25mrmz3b1ylb4q6g"))))
403 (build-system gnu-build-system)
404 (inputs (list ghostscript))
405 (native-inputs (list pkg-config))
406 (synopsis "Postscript rendering library")
407 (description
408 "libspectre is a small library for rendering Postscript documents.
409It provides a convenient easy to use API for handling and rendering
410Postscript documents.")
411 (license license:gpl2+)
412 (home-page "https://www.freedesktop.org/wiki/Software/libspectre")))