gnu: sdcc: Remove non-free code.
[jackhill/guix/guix.git] / gnu / packages / nss.scm
CommitLineData
aff0cce9
LC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
2c267e63 4;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il>
aff0cce9 5;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
71949dac 6;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
1896c0c6 7;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de>
aff0cce9
LC
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24(define-module (gnu packages nss)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix build-system gnu)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages check)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages sqlite)
34 #:use-module (ice-9 match))
35
36(define-public nspr
37 (package
38 (name "nspr")
dabd2fc3 39 (version "4.25")
aff0cce9
LC
40 (source (origin
41 (method url-fetch)
42 (uri (string-append
43 "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
44 version "/src/nspr-" version ".tar.gz"))
45 (sha256
46 (base32
dabd2fc3 47 "0mjjk2b7ika3v4y99cnaqz3z1iq1a50r1psn9i3s87gr46z0khqb"))))
aff0cce9
LC
48 (build-system gnu-build-system)
49 (native-inputs
50 `(("perl" ,perl)))
51 (arguments
52 `(#:tests? #f ; no check target
ceb4b1d7
MB
53 #:configure-flags (list "--disable-static"
54 "--enable-64bit"
aff0cce9
LC
55 (string-append "LDFLAGS=-Wl,-rpath="
56 (assoc-ref %outputs "out")
57 "/lib"))
58 ;; Use fixed timestamps for reproducibility.
59 #:make-flags '("SH_DATE='1970-01-01 00:00:01'"
60 ;; This is epoch 1 in microseconds.
61 "SH_NOW=100000")
62 #:phases (modify-phases %standard-phases
63 (add-before 'configure 'chdir
64 (lambda _ (chdir "nspr") #t)))))
65 (home-page
66 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR")
67 (synopsis "Netscape API for system level and libc-like functions")
68 (description "Netscape Portable Runtime (@dfn{NSPR}) provides a
69platform-neutral API for system level and libc-like functions. It is used
70in the Mozilla clients.")
71 (license license:mpl2.0)))
72
73(define-public nss
74 (package
75 (name "nss")
8ab211db 76 (version "3.52.1")
aff0cce9
LC
77 (source (origin
78 (method url-fetch)
79 (uri (let ((version-with-underscores
80 (string-join (string-split version #\.) "_")))
81 (string-append
82 "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
83 "releases/NSS_" version-with-underscores "_RTM/src/"
84 "nss-" version ".tar.gz")))
85 (sha256
86 (base32
8ab211db 87 "0y4jb9095f7bbgw7d7kvzm4c3g4p5i6y68fwhb8wlkpb7b1imj5w"))
aff0cce9
LC
88 ;; Create nss.pc and nss-config.
89 (patches (search-patches "nss-pkgconfig.patch"
21d0b644
MB
90 "nss-increase-test-timeout.patch"))
91 (modules '((guix build utils)))
92 (snippet
93 '(begin
71949dac 94 ;; Delete the bundled copy of these libraries.
21d0b644
MB
95 (delete-file-recursively "nss/lib/zlib")
96 (delete-file-recursively "nss/lib/sqlite")
97 #t))))
aff0cce9
LC
98 (build-system gnu-build-system)
99 (outputs '("out" "bin"))
100 (arguments
101 `(#:parallel-build? #f ; not supported
102 #:make-flags
103 (let* ((out (assoc-ref %outputs "out"))
104 (nspr (string-append (assoc-ref %build-inputs "nspr")))
105 (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
106 (list "-C" "nss" (string-append "PREFIX=" out)
107 "NSDISTMODE=copy"
108 "NSS_USE_SYSTEM_SQLITE=1"
109 (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
110 ;; Add $out/lib/nss to RPATH.
111 (string-append "RPATH=" rpath)
112 (string-append "LDFLAGS=" rpath)))
113 #:modules ((guix build gnu-build-system)
114 (guix build utils)
115 (ice-9 ftw)
116 (ice-9 match)
117 (srfi srfi-26))
118 #:phases
119 (modify-phases %standard-phases
120 (replace 'configure
121 (lambda _
122 (setenv "CC" "gcc")
123 ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
124 ,@(match (%current-system)
125 ((or "x86_64-linux" "aarch64-linux")
126 `((setenv "USE_64" "1")))
127 (_
128 '()))
129 #t))
130 (replace 'check
131 (lambda _
132 ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for testing.
133 ;; The later requires a working DNS or /etc/hosts.
134 (setenv "DOMSUF" "localdomain")
135 (setenv "USE_IP" "TRUE")
136 (setenv "IP_ADDRESS" "127.0.0.1")
137
138 ;; The "PayPalEE.cert" certificate expires every six months,
139 ;; leading to test failures:
140 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=609734>. To
141 ;; work around that, set the time to roughly the release date.
8ff645f3 142 (invoke "faketime" "2020-02-01" "./nss/tests/all.sh")))
aff0cce9
LC
143 (replace 'install
144 (lambda* (#:key outputs #:allow-other-keys)
145 (let* ((out (assoc-ref outputs "out"))
146 (bin (string-append (assoc-ref outputs "bin") "/bin"))
147 (inc (string-append out "/include/nss"))
148 (lib (string-append out "/lib/nss"))
149 (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
150 ((obj) (string-append "dist/" obj)))))
151 ;; Install nss-config to $out/bin.
152 (install-file (string-append obj "/bin/nss-config")
153 (string-append out "/bin"))
154 (delete-file (string-append obj "/bin/nss-config"))
155 ;; Install nss.pc to $out/lib/pkgconfig.
156 (install-file (string-append obj "/lib/pkgconfig/nss.pc")
157 (string-append out "/lib/pkgconfig"))
158 (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
159 (rmdir (string-append obj "/lib/pkgconfig"))
160 ;; Install other files.
161 (copy-recursively "dist/public/nss" inc)
162 (copy-recursively (string-append obj "/bin") bin)
163 (copy-recursively (string-append obj "/lib") lib)
164
165 ;; FIXME: libgtest1.so is installed in the above step, and it's
166 ;; (unnecessarily) linked with several NSS libraries, but
167 ;; without the needed rpaths, causing the 'validate-runpath'
168 ;; phase to fail. Here we simply delete libgtest1.so, since it
169 ;; seems to be used only during the tests.
170 (delete-file (string-append lib "/libgtest1.so"))
171 (delete-file (string-append lib "/libgtestutil.so"))
172
173 #t))))))
174 (inputs
175 `(("sqlite" ,sqlite)
176 ("zlib" ,zlib)))
177 (propagated-inputs `(("nspr" ,nspr))) ; required by nss.pc.
178 (native-inputs `(("perl" ,perl)
179 ("libfaketime" ,libfaketime))) ;for tests
180
181 ;; The NSS test suite takes around 48 hours on Loongson 3A (MIPS) when
182 ;; another build is happening concurrently on the same machine.
183 (properties '((timeout . 216000))) ; 60 hours
184
185 (home-page
186 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS")
187 (synopsis "Network Security Services")
188 (description
189 "Network Security Services (@dfn{NSS}) is a set of libraries designed to
190support cross-platform development of security-enabled client and server
191applications. Applications built with NSS can support SSL v2 and v3, TLS,
192PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other
193security standards.")
194 (license license:mpl2.0)))
1896c0c6 195
df3752e1 196(define-public nss-3.57
1896c0c6
JB
197 (package
198 (inherit nss)
df3752e1 199 (version "3.57")
1896c0c6
JB
200 (source (origin
201 (method url-fetch)
202 (uri (let ((version-with-underscores
203 (string-join (string-split version #\.) "_")))
204 (string-append
205 "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
206 "releases/NSS_" version-with-underscores "_RTM/src/"
207 "nss-" version ".tar.gz")))
208 (sha256
209 (base32
df3752e1 210 "10n3pncg6k81ikjz12la147rppwqn57bkrdl9gb820w6pq0nra2m"))
1896c0c6
JB
211 ;; Create nss.pc and nss-config.
212 (patches (search-patches "nss-3.56-pkgconfig.patch"
213 "nss-increase-test-timeout.patch"))
214 (modules '((guix build utils)))
215 (snippet
216 '(begin
217 ;; Delete the bundled copy of these libraries.
218 (delete-file-recursively "nss/lib/zlib")
219 (delete-file-recursively "nss/lib/sqlite")
220 #t))))
221 (arguments
222 `(#:parallel-build? #f ; not supported
223 #:make-flags
224 (let* ((out (assoc-ref %outputs "out"))
225 (nspr (string-append (assoc-ref %build-inputs "nspr")))
226 (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
227 (list "-C" "nss" (string-append "PREFIX=" out)
228 "NSDISTMODE=copy"
229 "NSS_USE_SYSTEM_SQLITE=1"
230 (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
231 ;; Add $out/lib/nss to RPATH.
232 (string-append "RPATH=" rpath)
233 (string-append "LDFLAGS=" rpath)))
234 #:modules ((guix build gnu-build-system)
235 (guix build utils)
236 (ice-9 ftw)
237 (ice-9 match)
238 (srfi srfi-26))
239 #:phases
240 (modify-phases %standard-phases
241 (replace 'configure
242 (lambda _
243 (setenv "CC" "gcc")
244 ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
245 ,@(match (%current-system)
246 ((or "x86_64-linux" "aarch64-linux")
247 `((setenv "USE_64" "1")))
248 (_
249 '()))
250 #t))
251 (replace 'check
252 (lambda _
253 ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for testing.
254 ;; The later requires a working DNS or /etc/hosts.
255 (setenv "DOMSUF" "localdomain")
256 (setenv "USE_IP" "TRUE")
257 (setenv "IP_ADDRESS" "127.0.0.1")
258
259 ;; The "PayPalEE.cert" certificate expires every six months,
260 ;; leading to test failures:
261 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=609734>. To
262 ;; work around that, set the time to roughly the release date.
263 (invoke "faketime" "2020-02-01" "./nss/tests/all.sh")))
264 (replace 'install
265 (lambda* (#:key outputs #:allow-other-keys)
266 (let* ((out (assoc-ref outputs "out"))
267 (bin (string-append (assoc-ref outputs "bin") "/bin"))
268 (inc (string-append out "/include/nss"))
269 (lib (string-append out "/lib/nss"))
270 (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
271 ((obj) (string-append "dist/" obj)))))
272 ;; Install nss-config to $out/bin.
273 (install-file (string-append obj "/bin/nss-config")
274 (string-append out "/bin"))
275 (delete-file (string-append obj "/bin/nss-config"))
276 ;; Install nss.pc to $out/lib/pkgconfig.
277 (install-file (string-append obj "/lib/pkgconfig/nss.pc")
278 (string-append out "/lib/pkgconfig"))
279 (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
280 (rmdir (string-append obj "/lib/pkgconfig"))
281 ;; Install other files.
282 (copy-recursively "dist/public/nss" inc)
283 (copy-recursively (string-append obj "/bin") bin)
284 (copy-recursively (string-append obj "/lib") lib)
285 #t))))))))