You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
8.6 KiB

  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, 2019 Efraim Flashner <efraim@flashner.co.il>
  5. ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  6. ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  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. (define-public nspr
  34. (package
  35. (name "nspr")
  36. (version "4.25")
  37. (source (origin
  38. (method url-fetch)
  39. (uri (string-append
  40. "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
  41. version "/src/nspr-" version ".tar.gz"))
  42. (sha256
  43. (base32
  44. "0mjjk2b7ika3v4y99cnaqz3z1iq1a50r1psn9i3s87gr46z0khqb"))))
  45. (build-system gnu-build-system)
  46. (native-inputs
  47. `(("perl" ,perl)))
  48. (arguments
  49. `(#:tests? #f ; no check target
  50. #:configure-flags (list "--disable-static"
  51. "--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
  66. platform-neutral API for system level and libc-like functions. It is used
  67. in the Mozilla clients.")
  68. (license license:mpl2.0)))
  69. (define-public nss
  70. (package
  71. (name "nss")
  72. (version "3.52.1")
  73. (source (origin
  74. (method url-fetch)
  75. (uri (let ((version-with-underscores
  76. (string-join (string-split version #\.) "_")))
  77. (string-append
  78. "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
  79. "releases/NSS_" version-with-underscores "_RTM/src/"
  80. "nss-" version ".tar.gz")))
  81. (sha256
  82. (base32
  83. "0y4jb9095f7bbgw7d7kvzm4c3g4p5i6y68fwhb8wlkpb7b1imj5w"))
  84. ;; Create nss.pc and nss-config.
  85. (patches (search-patches "nss-pkgconfig.patch"
  86. "nss-increase-test-timeout.patch"))
  87. (modules '((guix build utils)))
  88. (snippet
  89. '(begin
  90. ;; Delete the bundled copy of these libraries.
  91. (delete-file-recursively "nss/lib/zlib")
  92. (delete-file-recursively "nss/lib/sqlite")
  93. #t))))
  94. (build-system gnu-build-system)
  95. (outputs '("out" "bin"))
  96. (arguments
  97. `(#:parallel-build? #f ; not supported
  98. #:make-flags
  99. (let* ((out (assoc-ref %outputs "out"))
  100. (nspr (string-append (assoc-ref %build-inputs "nspr")))
  101. (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
  102. (list "-C" "nss" (string-append "PREFIX=" out)
  103. "NSDISTMODE=copy"
  104. "NSS_USE_SYSTEM_SQLITE=1"
  105. (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
  106. ;; Add $out/lib/nss to RPATH.
  107. (string-append "RPATH=" rpath)
  108. (string-append "LDFLAGS=" rpath)))
  109. #:modules ((guix build gnu-build-system)
  110. (guix build utils)
  111. (ice-9 ftw)
  112. (ice-9 match)
  113. (srfi srfi-26))
  114. #:phases
  115. (modify-phases %standard-phases
  116. (replace 'configure
  117. (lambda _
  118. (setenv "CC" "gcc")
  119. ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
  120. ,@(match (%current-system)
  121. ((or "x86_64-linux" "aarch64-linux")
  122. `((setenv "USE_64" "1")))
  123. (_
  124. '()))
  125. #t))
  126. (replace 'check
  127. (lambda _
  128. ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for testing.
  129. ;; The later requires a working DNS or /etc/hosts.
  130. (setenv "DOMSUF" "localdomain")
  131. (setenv "USE_IP" "TRUE")
  132. (setenv "IP_ADDRESS" "127.0.0.1")
  133. ;; The "PayPalEE.cert" certificate expires every six months,
  134. ;; leading to test failures:
  135. ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=609734>. To
  136. ;; work around that, set the time to roughly the release date.
  137. (invoke "faketime" "2020-02-01" "./nss/tests/all.sh")))
  138. (replace 'install
  139. (lambda* (#:key outputs #:allow-other-keys)
  140. (let* ((out (assoc-ref outputs "out"))
  141. (bin (string-append (assoc-ref outputs "bin") "/bin"))
  142. (inc (string-append out "/include/nss"))
  143. (lib (string-append out "/lib/nss"))
  144. (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
  145. ((obj) (string-append "dist/" obj)))))
  146. ;; Install nss-config to $out/bin.
  147. (install-file (string-append obj "/bin/nss-config")
  148. (string-append out "/bin"))
  149. (delete-file (string-append obj "/bin/nss-config"))
  150. ;; Install nss.pc to $out/lib/pkgconfig.
  151. (install-file (string-append obj "/lib/pkgconfig/nss.pc")
  152. (string-append out "/lib/pkgconfig"))
  153. (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
  154. (rmdir (string-append obj "/lib/pkgconfig"))
  155. ;; Install other files.
  156. (copy-recursively "dist/public/nss" inc)
  157. (copy-recursively (string-append obj "/bin") bin)
  158. (copy-recursively (string-append obj "/lib") lib)
  159. ;; FIXME: libgtest1.so is installed in the above step, and it's
  160. ;; (unnecessarily) linked with several NSS libraries, but
  161. ;; without the needed rpaths, causing the 'validate-runpath'
  162. ;; phase to fail. Here we simply delete libgtest1.so, since it
  163. ;; seems to be used only during the tests.
  164. (delete-file (string-append lib "/libgtest1.so"))
  165. (delete-file (string-append lib "/libgtestutil.so"))
  166. #t))))))
  167. (inputs
  168. `(("sqlite" ,sqlite)
  169. ("zlib" ,zlib)))
  170. (propagated-inputs `(("nspr" ,nspr))) ; required by nss.pc.
  171. (native-inputs `(("perl" ,perl)
  172. ("libfaketime" ,libfaketime))) ;for tests
  173. ;; The NSS test suite takes around 48 hours on Loongson 3A (MIPS) when
  174. ;; another build is happening concurrently on the same machine.
  175. (properties '((timeout . 216000))) ; 60 hours
  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
  181. support cross-platform development of security-enabled client and server
  182. applications. Applications built with NSS can support SSL v2 and v3, TLS,
  183. PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other
  184. security standards.")
  185. (license license:mpl2.0)))