ghostscript.scm 14 KB

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