gnu: nss: Fix build failure on armhf-linux.
[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>
4;;; Copyright © 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
5;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
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 nss)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix build-system gnu)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (gnu packages)
28 #:use-module (gnu packages check)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages perl)
31 #:use-module (gnu packages sqlite)
32 #:use-module (ice-9 match))
33
34(define-public nspr
35 (package
36 (name "nspr")
ba00235a 37 (version "4.21")
aff0cce9
LC
38 (source (origin
39 (method url-fetch)
40 (uri (string-append
41 "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
42 version "/src/nspr-" version ".tar.gz"))
43 (sha256
44 (base32
ba00235a 45 "0nkbgk0x31nfm4xl8la0a3vrnpa8gzkh7g4k65p7n880n73k5shm"))))
aff0cce9
LC
46 (build-system gnu-build-system)
47 (native-inputs
48 `(("perl" ,perl)))
49 (arguments
50 `(#:tests? #f ; no check target
51 #:configure-flags (list "--enable-64bit"
52 (string-append "LDFLAGS=-Wl,-rpath="
53 (assoc-ref %outputs "out")
54 "/lib"))
55 ;; Use fixed timestamps for reproducibility.
56 #:make-flags '("SH_DATE='1970-01-01 00:00:01'"
57 ;; This is epoch 1 in microseconds.
58 "SH_NOW=100000")
59 #:phases (modify-phases %standard-phases
60 (add-before 'configure 'chdir
61 (lambda _ (chdir "nspr") #t)))))
62 (home-page
63 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR")
64 (synopsis "Netscape API for system level and libc-like functions")
65 (description "Netscape Portable Runtime (@dfn{NSPR}) provides a
66platform-neutral API for system level and libc-like functions. It is used
67in the Mozilla clients.")
68 (license license:mpl2.0)))
69
70(define-public nss
71 (package
72 (name "nss")
8ed97b6e 73 (version "3.45")
aff0cce9
LC
74 (source (origin
75 (method url-fetch)
76 (uri (let ((version-with-underscores
77 (string-join (string-split version #\.) "_")))
78 (string-append
79 "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
80 "releases/NSS_" version-with-underscores "_RTM/src/"
81 "nss-" version ".tar.gz")))
82 (sha256
83 (base32
8ed97b6e 84 "12sfq9xvpwpc22qnjsg1if1lmchiy33byrh92wn91phz7li0abqi"))
aff0cce9
LC
85 ;; Create nss.pc and nss-config.
86 (patches (search-patches "nss-pkgconfig.patch"
58e37b54 87 "nss-freebl-stubs.patch"
aff0cce9
LC
88 "nss-increase-test-timeout.patch"))))
89 (build-system gnu-build-system)
90 (outputs '("out" "bin"))
91 (arguments
92 `(#:parallel-build? #f ; not supported
93 #:make-flags
94 (let* ((out (assoc-ref %outputs "out"))
95 (nspr (string-append (assoc-ref %build-inputs "nspr")))
96 (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
97 (list "-C" "nss" (string-append "PREFIX=" out)
98 "NSDISTMODE=copy"
99 "NSS_USE_SYSTEM_SQLITE=1"
100 (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
101 ;; Add $out/lib/nss to RPATH.
102 (string-append "RPATH=" rpath)
103 (string-append "LDFLAGS=" rpath)))
104 #:modules ((guix build gnu-build-system)
105 (guix build utils)
106 (ice-9 ftw)
107 (ice-9 match)
108 (srfi srfi-26))
109 #:phases
110 (modify-phases %standard-phases
111 (replace 'configure
112 (lambda _
113 (setenv "CC" "gcc")
114 ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
115 ,@(match (%current-system)
116 ((or "x86_64-linux" "aarch64-linux")
117 `((setenv "USE_64" "1")))
118 (_
119 '()))
120 #t))
121 (replace 'check
122 (lambda _
123 ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for testing.
124 ;; The later requires a working DNS or /etc/hosts.
125 (setenv "DOMSUF" "localdomain")
126 (setenv "USE_IP" "TRUE")
127 (setenv "IP_ADDRESS" "127.0.0.1")
128
129 ;; The "PayPalEE.cert" certificate expires every six months,
130 ;; leading to test failures:
131 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=609734>. To
132 ;; work around that, set the time to roughly the release date.
136b7d81 133 (invoke "faketime" "2019-05-01" "./nss/tests/all.sh")))
aff0cce9
LC
134 (replace 'install
135 (lambda* (#:key outputs #:allow-other-keys)
136 (let* ((out (assoc-ref outputs "out"))
137 (bin (string-append (assoc-ref outputs "bin") "/bin"))
138 (inc (string-append out "/include/nss"))
139 (lib (string-append out "/lib/nss"))
140 (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
141 ((obj) (string-append "dist/" obj)))))
142 ;; Install nss-config to $out/bin.
143 (install-file (string-append obj "/bin/nss-config")
144 (string-append out "/bin"))
145 (delete-file (string-append obj "/bin/nss-config"))
146 ;; Install nss.pc to $out/lib/pkgconfig.
147 (install-file (string-append obj "/lib/pkgconfig/nss.pc")
148 (string-append out "/lib/pkgconfig"))
149 (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
150 (rmdir (string-append obj "/lib/pkgconfig"))
151 ;; Install other files.
152 (copy-recursively "dist/public/nss" inc)
153 (copy-recursively (string-append obj "/bin") bin)
154 (copy-recursively (string-append obj "/lib") lib)
155
156 ;; FIXME: libgtest1.so is installed in the above step, and it's
157 ;; (unnecessarily) linked with several NSS libraries, but
158 ;; without the needed rpaths, causing the 'validate-runpath'
159 ;; phase to fail. Here we simply delete libgtest1.so, since it
160 ;; seems to be used only during the tests.
161 (delete-file (string-append lib "/libgtest1.so"))
162 (delete-file (string-append lib "/libgtestutil.so"))
163
164 #t))))))
165 (inputs
166 `(("sqlite" ,sqlite)
167 ("zlib" ,zlib)))
168 (propagated-inputs `(("nspr" ,nspr))) ; required by nss.pc.
169 (native-inputs `(("perl" ,perl)
170 ("libfaketime" ,libfaketime))) ;for tests
171
172 ;; The NSS test suite takes around 48 hours on Loongson 3A (MIPS) when
173 ;; another build is happening concurrently on the same machine.
174 (properties '((timeout . 216000))) ; 60 hours
175
176 (home-page
177 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS")
178 (synopsis "Network Security Services")
179 (description
180 "Network Security Services (@dfn{NSS}) is a set of libraries designed to
181support cross-platform development of security-enabled client and server
182applications. Applications built with NSS can support SSL v2 and v3, TLS,
183PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other
184security standards.")
185 (license license:mpl2.0)))