projects/guix·blob python-team · refs

198 lines · 8.2 KiB

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