gnu: emacs-svg-icon: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / netpbm.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages netpbm)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages compression)
24 #:use-module (gnu packages flex)
25 #:use-module (gnu packages ghostscript)
26 #:use-module (gnu packages image)
27 #:use-module (gnu packages perl)
28 #:use-module (gnu packages pkg-config)
29 #:use-module (gnu packages python)
30 #:use-module (gnu packages xml)
31 #:use-module (gnu packages xorg)
32 #:use-module (guix build-system gnu)
33 #:use-module ((guix licenses) #:select (gpl2))
34 #:use-module (guix packages)
35 #:use-module (guix svn-download))
36
37 (define-public netpbm
38 (package
39 (name "netpbm")
40 (version "10.78.3")
41 (source (origin
42 (method svn-fetch)
43 ;; At the time of first packaging, the "super-stable" and
44 ;; "stable" versions did not compile with newer libpng;
45 ;; we needed the "advanced" version.
46 ;; The currently highest stable version is 10.47.53,
47 ;; the currently highest advanced version is 10.69.4,
48 ;; svn release 2397.
49 ;; To determine the correct release: "svn log version.mk".
50 (uri (svn-reference
51 (url "http://svn.code.sf.net/p/netpbm/code/advanced")
52 (revision 2965)))
53 (sha256
54 (base32
55 "1k7as9qi1942wyjxpvbf02wg0h4braw44m3m3vvi8sm9y5z1m967"))
56 (patches (search-patches "netpbm-CVE-2017-2586.patch"
57 "netpbm-CVE-2017-2587.patch"))
58 (file-name (string-append name "-" version "-checkout"))
59 (modules '((guix build utils)))
60 (snippet
61 '(begin
62 ;; Remove non-FSDG-compliant code.
63
64 (define-syntax drop
65 (syntax-rules (in)
66 ;; Remove PROGRAM from DIRECTORY/Makefile, and remove
67 ;; DIRECTORY/PROGRAM and DIRECTORY/PROGRAM.c.
68 ((_ program ... in directory)
69 (begin
70 (substitute* (string-append directory "/Makefile")
71 ((program) "") ...)
72
73 (let* ((subdir (string-append directory "/" program))
74 (dot-c (string-append subdir ".c")))
75 (when (file-exists? subdir)
76 (delete-file-recursively subdir))
77 (when (file-exists? dot-c)
78 (delete-file dot-c)))
79
80 ...))))
81
82 ;; Drop advertisement for non-free program.
83 (drop "hpcdtoppm" in "converter/ppm")
84
85 ;; Drop programs without a license, see
86 ;; <http://packages.debian.org/changelogs/pool/main/n/netpbm-free/netpbm-free_10.0-12.2/libnetpbm10.copyright>.
87 (drop "pbmto4425" "pbmtoln03" "pbmtolps" "pbmtopk" "pktopbm"
88 in "converter/pbm")
89 (drop "spottopgm" in "converter/pgm")
90 (drop "ppmtopjxl" in "converter/ppm")
91
92 ;; Remove timestamps from the generated code.
93 (substitute* "buildtools/makepointerman"
94 (("gmctime[(][)]")
95 "\"Thu Jan 1 00:00:00 1970\""))
96 (substitute* "buildtools/stamp-date"
97 (("^DATE=.*")
98 "DATE=\"Thu Jan 01 00:00:00+0000 1970\"\n")
99 (("^USER=.*")
100 "USER=Guix\n"))
101 #t))))
102
103 (build-system gnu-build-system)
104 (inputs `(("ghostscript" ,ghostscript)
105 ("libjpeg" ,libjpeg-turbo)
106 ("libpng" ,libpng)
107 ("libtiff" ,libtiff)
108 ("libxml2" ,libxml2)
109 ("xorg-rgb" ,xorg-rgb)
110 ("zlib" ,zlib)))
111 (native-inputs
112 `(("flex" ,flex)
113 ("perl" ,perl)
114 ("pkg-config" ,pkg-config)
115 ("python" ,python-wrapper)))
116 (arguments
117 `(#:modules ((guix build gnu-build-system)
118 (guix build utils)
119 (ice-9 match))
120 #:phases
121 (modify-phases %standard-phases
122 (replace 'configure
123 (lambda* (#:key inputs outputs #:allow-other-keys)
124 (copy-file "config.mk.in" "config.mk")
125 (chmod "config.mk" #o664)
126 (let ((f (open-file "config.mk" "a")))
127 (display "CC=gcc\n" f)
128 (display "CFLAGS_SHLIB += -fPIC\n" f)
129 (display "TIFFLIB = libtiff.so\n" f)
130 (display "JPEGLIB = libjpeg.so\n" f)
131 (display "ZLIB = libz.so\n" f)
132 (display (string-append "LDFLAGS += -Wl,-rpath=" %output "/lib") f)
133 (close-port f))
134
135 (let ((rgb (string-append (assoc-ref inputs "xorg-rgb")
136 "/share/X11/rgb.txt")))
137 (substitute* "config.mk"
138 (("/usr/share/netpbm/rgb.txt") rgb))
139
140 ;; Our Ghostscript no longer provides the 'gs' command, only
141 ;; 'gsc', so look for that instead.
142 (substitute* "converter/other/pstopnm.c"
143 (("\"%s/gs\"")
144 "\"%s/gsc\"")
145 (("/usr/bin/gs")
146 (string-append (assoc-ref inputs "ghostscript") "/bin/gsc"))))
147 #t))
148 (add-before 'check 'setup-check
149 (lambda _
150 ;; install temporarily into /tmp/netpbm
151 (invoke "make" "package")
152 ;; remove test requiring X
153 (substitute* "test/all-in-place.test" (("pamx") ""))
154 ;; do not worry about non-existing file
155 (substitute* "test/all-in-place.test" (("^rm ") "rm -f "))
156 ;; remove four tests that fail for unknown reasons
157 (substitute* "test/Test-Order"
158 (("all-in-place.test") "")
159 (("pnmpsnr.test") "")
160 (("pnmremap1.test") "")
161 (("gif-roundtrip.test") "")
162
163 ;; These two tests started failing in netpbm-10.78.3.
164 (("jpeg-roundtrip.test") "")
165 (("pbmtext.test") "")
166
167 ;; Skip tests that use nonfree programs that we don't build.
168 (("ps-alt-roundtrip.test") "" )
169 (("pbm-misc-converters.test") ""))
170 #t))
171 (replace 'install
172 (lambda* (#:key outputs make-flags #:allow-other-keys)
173 (let ((out (assoc-ref outputs "out")))
174 (apply invoke "make" "package"
175 (string-append "pkgdir=" out) make-flags)
176 ;; Remove superfluous files.
177 (with-directory-excursion out
178 (for-each delete-file-recursively
179 '("config_template" "pkginfo" "README" "VERSION"
180 "link/" "misc/"))
181 ;; Install the required ‘libnetpbm.so’ link.
182 ;; See <https://issues.guix.gnu.org/issue/40376>.
183 (with-directory-excursion "lib"
184 (symlink
185 (match (find-files "." "^libnetpbm\\.so\\.[^.]*\\.[^.]*$")
186 ((head _ ...) head))
187 "libnetpbm.so"))
188 #t)))))))
189 (synopsis "Toolkit for manipulation of images")
190 (description
191 "Netpbm is a toolkit for the manipulation of graphic images, including
192 the conversion of images between a variety of different formats.
193 There are over 300 separate tools in the package including converters for
194 about 100 graphics formats.")
195 (license gpl2)
196 (home-page "http://netpbm.sourceforge.net/")))