Revert "Revert "gnu: nss: Build for aarch64-linux with 64-bit support.""
[jackhill/guix/guix.git] / gnu / packages / gnuzilla.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
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 gnuzilla)
25 #:use-module ((srfi srfi-1) #:hide (zip))
26 #:use-module (ice-9 match)
27 #:use-module (gnu packages)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix build-system gnu)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages databases)
34 #:use-module (gnu packages glib)
35 #:use-module (gnu packages gstreamer)
36 #:use-module (gnu packages gtk)
37 #:use-module (gnu packages gnome)
38 #:use-module (gnu packages libcanberra)
39 #:use-module (gnu packages cups)
40 #:use-module (gnu packages kerberos)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages compression)
45 #:use-module (gnu packages fontutils)
46 #:use-module (gnu packages libevent)
47 #:use-module (gnu packages libreoffice) ;for hunspell
48 #:use-module (gnu packages image)
49 #:use-module (gnu packages libffi)
50 #:use-module (gnu packages pulseaudio)
51 #:use-module (gnu packages python)
52 #:use-module (gnu packages xorg)
53 #:use-module (gnu packages gl)
54 #:use-module (gnu packages assembly)
55 #:use-module (gnu packages icu4c)
56 #:use-module (gnu packages video)
57 #:use-module (gnu packages xdisorg)
58 #:use-module (gnu packages zip))
59
60 (define-public mozjs
61 (package
62 (name "mozjs")
63 (version "17.0.0")
64 (source (origin
65 (method url-fetch)
66 (uri (string-append
67 "https://ftp.mozilla.org/pub/mozilla.org/js/"
68 name version ".tar.gz"))
69 (sha256
70 (base32
71 "1fig2wf4f10v43mqx67y68z6h77sy900d1w0pz9qarrqx57rc7ij"))
72 (modules '((guix build utils)))
73 (snippet
74 ;; Fix incompatibility with Perl 5.22+.
75 '(substitute* '("js/src/config/milestone.pl")
76 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE")))))
77 (build-system gnu-build-system)
78 (native-inputs
79 `(("perl" ,perl)
80 ("python" ,python-2)))
81 (arguments
82 `(;; XXX: parallel build fails, lacking:
83 ;; mkdir -p "system_wrapper_js/"
84 #:parallel-build? #f
85 #:phases
86 (alist-cons-before
87 'configure 'chdir
88 (lambda _
89 (chdir "js/src"))
90 (alist-replace
91 'configure
92 ;; configure fails if it is followed by SHELL and CONFIG_SHELL
93 (lambda* (#:key outputs #:allow-other-keys)
94 (let ((out (assoc-ref outputs "out")))
95 (setenv "SHELL" (which "sh"))
96 (setenv "CONFIG_SHELL" (which "sh"))
97 (zero? (system*
98 "./configure" (string-append "--prefix=" out)))))
99 %standard-phases))))
100 (home-page
101 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey")
102 (synopsis "Mozilla javascript engine")
103 (description "SpiderMonkey is Mozilla's JavaScript engine written
104 in C/C++.")
105 (license license:mpl2.0))) ; and others for some files
106
107 (define-public mozjs-24
108 (package (inherit mozjs)
109 (name "mozjs")
110 (version "24.2.0")
111 (source (origin
112 (method url-fetch)
113 (uri (string-append
114 "https://ftp.mozilla.org/pub/mozilla.org/js/"
115 name "-" version ".tar.bz2"))
116 (sha256
117 (base32
118 "1n1phk8r3l8icqrrap4czplnylawa0ddc2cc4cgdz46x3lrkybz6"))
119 (modules '((guix build utils)))
120 (snippet
121 ;; Fix incompatibility with Perl 5.22+.
122 '(substitute* '("js/src/config/milestone.pl")
123 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE")))))
124 (arguments
125 '(;; XXX: parallel build fails, lacking:
126 ;; mkdir -p "system_wrapper_js/"
127 #:parallel-build? #f
128 #:phases
129 (modify-phases %standard-phases
130 (replace
131 'configure
132 (lambda* (#:key outputs #:allow-other-keys)
133 (let ((out (assoc-ref outputs "out")))
134 (chdir "js/src")
135 ;; configure fails if it is follwed by SHELL and CONFIG_SHELL
136 (setenv "SHELL" (which "sh"))
137 (setenv "CONFIG_SHELL" (which "sh"))
138 (zero? (system* "./configure"
139 (string-append "--prefix=" out)
140 "--with-system-nspr"
141 "--enable-system-ffi"
142 "--enable-threadsafe"))))))))
143 (native-inputs
144 `(("perl" ,perl)
145 ("pkg-config" ,pkg-config)
146 ("python" ,python-2)))
147 (propagated-inputs
148 `(("nspr" ,nspr))) ; in the Requires.private field of mozjs-24.pc
149 (inputs
150 `(("libffi" ,libffi)
151 ("zlib" ,zlib)))))
152
153 (define-public nspr
154 (package
155 (name "nspr")
156 (version "4.13.1")
157 (source (origin
158 (method url-fetch)
159 (uri (string-append
160 "https://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v"
161 version "/src/nspr-" version ".tar.gz"))
162 (sha256
163 (base32
164 "1arkg08l6zlp8v44shqbk2c8qzwd913lgh60fb3yfxls6d8ifk2y"))))
165 (build-system gnu-build-system)
166 (native-inputs
167 `(("perl" ,perl)))
168 (arguments
169 `(#:tests? #f ; no check target
170 #:configure-flags (list "--enable-64bit"
171 (string-append "LDFLAGS=-Wl,-rpath="
172 (assoc-ref %outputs "out")
173 "/lib"))
174 #:phases (alist-cons-before
175 'configure 'chdir
176 (lambda _
177 (chdir "nspr"))
178 %standard-phases)))
179 (home-page
180 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR")
181 (synopsis "Netscape API for system level and libc-like functions")
182 (description "Netscape Portable Runtime (NSPR) provides a
183 platform-neutral API for system level and libc-like functions. It is used
184 in the Mozilla clients.")
185 (license license:mpl2.0)))
186
187 (define-public nss
188 (package
189 (name "nss")
190 (version "3.29.2")
191 (source (origin
192 (method url-fetch)
193 (uri (let ((version-with-underscores
194 (string-join (string-split version #\.) "_")))
195 (string-append
196 "https://ftp.mozilla.org/pub/mozilla.org/security/nss/"
197 "releases/NSS_" version-with-underscores "_RTM/src/"
198 "nss-" version ".tar.gz")))
199 (sha256
200 (base32
201 "149807rmzb76hnh48rw4m9jw83iw0168njzchz0hmbsgc8mk0i5w"))
202 ;; Create nss.pc and nss-config.
203 (patches (search-patches "nss-pkgconfig.patch"))))
204 (build-system gnu-build-system)
205 (outputs '("out" "bin"))
206 (arguments
207 `(#:parallel-build? #f ; not supported
208 #:make-flags
209 (let* ((out (assoc-ref %outputs "out"))
210 (nspr (string-append (assoc-ref %build-inputs "nspr")))
211 (rpath (string-append "-Wl,-rpath=" out "/lib/nss")))
212 (list "-C" "nss" (string-append "PREFIX=" out)
213 "NSDISTMODE=copy"
214 "NSS_USE_SYSTEM_SQLITE=1"
215 (string-append "NSPR_INCLUDE_DIR=" nspr "/include/nspr")
216 ;; Add $out/lib/nss to RPATH.
217 (string-append "RPATH=" rpath)
218 (string-append "LDFLAGS=" rpath)))
219 #:modules ((guix build gnu-build-system)
220 (guix build utils)
221 (ice-9 ftw)
222 (ice-9 match)
223 (srfi srfi-26))
224 #:phases
225 (modify-phases %standard-phases
226 (replace 'configure
227 (lambda _
228 (setenv "CC" "gcc")
229 ;; Tells NSS to build for the 64-bit ABI if we are 64-bit system.
230 ,@(match (%current-system)
231 ((or "x86_64-linux" "aarch64-linux")
232 `((setenv "USE_64" "1")))
233 (_
234 '()))
235 #t))
236 (replace 'check
237 (lambda _
238 ;; Use 127.0.0.1 instead of $HOST.$DOMSUF as HOSTADDR for testing.
239 ;; The later requires a working DNS or /etc/hosts.
240 (setenv "DOMSUF" "(none)")
241 (setenv "USE_IP" "TRUE")
242 (setenv "IP_ADDRESS" "127.0.0.1")
243 (zero? (system* "./nss/tests/all.sh"))))
244 (replace 'install
245 (lambda* (#:key outputs #:allow-other-keys)
246 (let* ((out (assoc-ref outputs "out"))
247 (bin (string-append (assoc-ref outputs "bin") "/bin"))
248 (inc (string-append out "/include/nss"))
249 (lib (string-append out "/lib/nss"))
250 (obj (match (scandir "dist" (cut string-suffix? "OBJ" <>))
251 ((obj) (string-append "dist/" obj)))))
252 ;; Install nss-config to $out/bin.
253 (install-file (string-append obj "/bin/nss-config")
254 (string-append out "/bin"))
255 (delete-file (string-append obj "/bin/nss-config"))
256 ;; Install nss.pc to $out/lib/pkgconfig.
257 (install-file (string-append obj "/lib/pkgconfig/nss.pc")
258 (string-append out "/lib/pkgconfig"))
259 (delete-file (string-append obj "/lib/pkgconfig/nss.pc"))
260 (rmdir (string-append obj "/lib/pkgconfig"))
261 ;; Install other files.
262 (copy-recursively "dist/public/nss" inc)
263 (copy-recursively (string-append obj "/bin") bin)
264 (copy-recursively (string-append obj "/lib") lib)
265
266 ;; FIXME: libgtest1.so is installed in the above step, and it's
267 ;; (unnecessarily) linked with several NSS libraries, but
268 ;; without the needed rpaths, causing the 'validate-runpath'
269 ;; phase to fail. Here we simply delete libgtest1.so, since it
270 ;; seems to be used only during the tests.
271 (delete-file (string-append lib "/libgtest1.so"))
272
273 #t))))))
274 (inputs
275 `(("sqlite" ,sqlite)
276 ("zlib" ,zlib)))
277 (propagated-inputs `(("nspr" ,nspr))) ; required by nss.pc.
278 (native-inputs `(("perl" ,perl)))
279
280 ;; The NSS test suite takes around 48 hours on Loongson 3A (MIPS) when
281 ;; another build is happening concurrently on the same machine.
282 (properties '((timeout . 216000))) ; 60 hours
283
284 (home-page
285 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS")
286 (synopsis "Network Security Services")
287 (description
288 "Network Security Services (NSS) is a set of libraries designed to support
289 cross-platform development of security-enabled client and server applications.
290 Applications built with NSS can support SSL v2 and v3, TLS, PKCS #5, PKCS #7,
291 PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other security
292 standards.")
293 (license license:mpl2.0)))
294
295 (define (mozilla-patch file-name changeset hash)
296 "Return an origin for CHANGESET from the mozilla-esr45 repository."
297 (origin
298 (method url-fetch)
299 (uri (string-append "https://hg.mozilla.org/releases/mozilla-esr45/raw-rev/"
300 changeset))
301 (sha256 (base32 hash))
302 (file-name file-name)))
303
304 (define-public icecat
305 (package
306 (name "icecat")
307 (version "45.7.0-gnu1")
308 (source
309 (origin
310 (method url-fetch)
311 (uri (string-append "mirror://gnu/gnuzilla/"
312 (first (string-split version #\-))
313 "/" name "-" version ".tar.bz2"))
314 (sha256
315 (base32
316 "1mn73liylqzxk441f28wk326yglqs8zcwqs4zz51s8i2id2jsnv3"))
317 (patches
318 (list
319 (search-patch "icecat-avoid-bundled-libraries.patch")
320 (search-patch "icecat-binutils.patch")
321 (mozilla-patch "icecat-CVE-2017-5398-pt01.patch" "1a39a54b5fea" "0k3sbf2w2yng2rpv6wl9zrm5cbsgq3pslr19xwrk8sk753as79fp")
322 (mozilla-patch "icecat-CVE-2017-5402.patch" "9828c3bb7b73" "0zgks0v9sqhwwkmry4daswvjwk6aqln6abx0iac1vwqqpg6swff6")
323 (mozilla-patch "icecat-CVE-2017-5398-pt02.patch" "fa3268a1147e" "1jyd1hvp42pz5l15agmb1jhw74b38x8xnj9ih5v4pskv41bgmyg5")
324 (mozilla-patch "icecat-CVE-2017-5400.patch" "347c10e4d6d1" "1w6yrm97l477q4ripbj0nimc87p4jscabvihpncxqbq9xzc4km7p")
325 (mozilla-patch "icecat-CVE-2017-5410.patch" "fe4a2cda54ad" "0spcs93hpz13d8670jgvww80f0ynrbhwbh62fkv27lpr6wmqwqh1")
326 (mozilla-patch "icecat-CVE-2017-5401.patch" "c38f8546be5f" "1sa22w9kzgynsn4c6zh4d66byskk5kffzbvlzrhyzvqjddypf9p8")
327 (mozilla-patch "icecat-CVE-2017-5398-pt03.patch" "41c80ecafa99" "0r33arr5wcgl00zgncasiyl65bmm6jy45clxnbb75nzjmsd1zx1s")
328 (mozilla-patch "icecat-CVE-2017-5405.patch" "381552c888b4" "1sjhh390cx1jqx74lxk6qd8f8ccppqgagqfhc9pnbm2m67hxvkj9")
329 (mozilla-patch "icecat-CVE-2017-5407.patch" "4ba337cdb998" "0vyknizid2z9nvl31m08c7fknizhv8dh8m54apm39k8lx77vf70p")
330 (mozilla-patch "icecat-CVE-2017-5398-pt04.patch" "886650fac531" "18fsr5dmav96ja0dah7mj34n8mjpckp0bbc32zjyaj5qx0m4h5cw")
331 (mozilla-patch "icecat-CVE-2017-5409.patch" "0a22becb23cd" "19fshrq4qkj5s0mjrads6by84gy7rsq3k57gha6sw6rvx8chjaz6")
332 (mozilla-patch "icecat-CVE-2017-5398-pt05.patch" "a0ead6ef09eb" "1hpsq81hhhq2a2dcq2dfndiwx93vvp5rfq0cgv6kwk2bsrq77wqq")
333 (mozilla-patch "icecat-CVE-2017-5398-pt06.patch" "d3fede027d06" "1aw02p367cm0ayijdiiawlb7qhab6jwqwkakj317yd1cjnmkalwr")
334 (mozilla-patch "icecat-CVE-2017-5398-pt07.patch" "ffca0f060bb4" "0qwisfp7idjj5nc1vp1afrf5lj66l2gp7rllkjmrqpz6cyfc708v")
335 (mozilla-patch "icecat-CVE-2017-5398-pt08.patch" "4aa65b44dcb9" "07j6dz2b7hp1bkfvkxwgpn2wc3hqrgjgwpaz96fcpz8yadg2fssw")
336 (mozilla-patch "icecat-bug-1318914.patch" "30e2382d800f" "0w8zky5i7zc5q943x37rdvi4wbcing0q7w9fcgvnnh5li2sbrsy8")
337 (mozilla-patch "icecat-CVE-2017-5408.patch" "403d2300adc2" "06r4j48rc1fd9gvmvqy68mlqah5xfxpkvwmxk0gnqc364kpq9slk")
338 (mozilla-patch "icecat-CVE-2017-5398-pt09.patch" "546ab5e99568" "05rdb9bm3n4lj0zq5a95xnwsb0vzirb9mbc2wf9xbi4xlamsgvvw")
339 (mozilla-patch "icecat-bug-1311380.patch" "ef6eeb7f8846" "1w19is5blbrwf3wlmy6wzgabih8sxp2kmkffqcj2g4jypfwyqn73")
340 (mozilla-patch "icecat-CVE-2017-5398-pt10.patch" "eec69810d80e" "1r20abhw7b38igsrdpkhcfwx9i9gmcxikv4y3sjr4wkbp684f7av")
341 (mozilla-patch "icecat-CVE-2017-5398-pt11.patch" "fec35ce6e68b" "1imdfrs8dxz44rhsmvydh29w5j64cij6g5ggrmhvz3386xvlil2v")
342 (mozilla-patch "icecat-CVE-2017-5398-pt12.patch" "725e2a217722" "06gfhi2ich279rjnxi15fb4igimsxnv5w6bx4g91js8wbvp2r3v0")
343 (mozilla-patch "icecat-CVE-2017-5398-pt13.patch" "d905a2e3a4d9" "1ibxi2s0czj47b739zmmjzbln8lpn27hdg4b17w58vhbhzkq31cx")
344 (mozilla-patch "icecat-CVE-2017-5398-pt14.patch" "0032560ae945" "0md3p5cix6nzbj5m199awc9gk52pygy5s9lx3a38vh3xvd92lsbj")
345 (mozilla-patch "icecat-CVE-2017-5398-pt15.patch" "91dda1e79ad8" "0b5h8fhagczfqkdgby982w6qgkw9y11zxxpdbn89rwmjpyp9nghx")
346 (mozilla-patch "icecat-CVE-2017-5404.patch" "556dd9e4a9e3" "0mbdx4xn1xs67n47ys9m42lc5ny96rz21ala848yajpdlxsz680g")
347 (mozilla-patch "icecat-bug-1341137-pt1.patch" "e86e0423dad1" "0dk1v7lcs61nx76qxcibha3ygqri15ldcvwwsrsayff9fq6k0v4y")
348 (mozilla-patch "icecat-bug-1341137-pt2.patch" "9aebee8b8cb9" "0m7p5iprhhwdv89aqqg7fla5szw6v7x2sll4ns0zg60pk4vm6izq")
349 (mozilla-patch "icecat-bug-1341137-pt3.patch" "69f3d44bdb48" "1ad7rw6nmg3c49ylqxlqqkb6cm2f0ygfzrigs6b60a2zkjqhbl0h")
350 (mozilla-patch "icecat-bug-1341137-pt4.patch" "22546e2cee64" "0gbwxa3p7qkq53hwnvxcqhx8h34qmnjdxy0h3ajik4mw76vrna9s")
351 (mozilla-patch "icecat-bug-1341137-pt5.patch" "e5083d8a855a" "1247vbpqzf007nigbxxqd6nwgr1dxd4p8cd0dr45afqh19vhlapj")
352 (mozilla-patch "icecat-bug-1339122.patch" "b0d156c7445e" "026jp5bb565yvhkmmicgygcn1lmak85p0466yl1vnjlx1rc8n724")))
353 (modules '((guix build utils)))
354 (snippet
355 '(begin
356 (use-modules (ice-9 ftw))
357 ;; Remove bundled libraries that we don't use, since they may
358 ;; contain unpatched security flaws, they waste disk space and
359 ;; network bandwidth, and may cause confusion.
360 (for-each delete-file-recursively
361 '(;; FIXME: Removing the bundled icu breaks configure.
362 ;; * The bundled icu headers are used in some places.
363 ;; * The version number is taken from the bundled copy.
364 ;;"intl/icu"
365 ;;
366 ;; FIXME: A script from the bundled nspr is used.
367 ;;"nsprpub"
368 ;;
369 ;; TODO: Use system media libraries. Waiting for:
370 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
371 ;; * libogg
372 ;; * libtheora
373 ;; * libvorbis
374 ;; * libtremor (not yet in guix)
375 ;; * libopus
376 ;; * speex
377 ;; * soundtouch (not yet in guix)
378 ;;
379 ;; TODO: Use system harfbuzz. Waiting for:
380 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=847568>
381 ;;
382 ;; TODO: Use system graphite2.
383 ;;
384 "modules/freetype2"
385 "modules/zlib"
386 "modules/libbz2"
387 "ipc/chromium/src/third_party/libevent"
388 "media/libjpeg"
389 "media/libvpx"
390 "security/nss"
391 "gfx/cairo"
392 "js/src/ctypes/libffi"
393 "db/sqlite3"))
394 ;; Delete .pyc files, typically present in icecat source tarballs
395 (for-each delete-file (find-files "." "\\.pyc$"))
396 ;; Delete obj-* directories, sometimes present in icecat tarballs
397 (for-each delete-file-recursively
398 (scandir "." (lambda (name)
399 (string-prefix? "obj-" name))))
400 #t))))
401 (build-system gnu-build-system)
402 (inputs
403 `(("alsa-lib" ,alsa-lib)
404 ("bzip2" ,bzip2)
405 ("cairo" ,cairo)
406 ("cups" ,cups)
407 ("dbus-glib" ,dbus-glib)
408 ("gdk-pixbuf" ,gdk-pixbuf)
409 ("glib" ,glib)
410 ("gstreamer" ,gstreamer)
411 ("gst-plugins-base" ,gst-plugins-base)
412 ("gtk+" ,gtk+-2)
413 ("pango" ,pango)
414 ("freetype" ,freetype)
415 ("hunspell" ,hunspell)
416 ("libcanberra" ,libcanberra)
417 ("libgnome" ,libgnome)
418 ("libjpeg-turbo" ,libjpeg-turbo)
419 ("libxft" ,libxft)
420 ("libevent" ,libevent-2.0)
421 ("libxinerama" ,libxinerama)
422 ("libxscrnsaver" ,libxscrnsaver)
423 ("libxcomposite" ,libxcomposite)
424 ("libxt" ,libxt)
425 ("libffi" ,libffi)
426 ("libvpx" ,libvpx)
427 ("icu4c" ,icu4c)
428 ("pixman" ,pixman)
429 ("pulseaudio" ,pulseaudio)
430 ("mesa" ,mesa)
431 ("mit-krb5" ,mit-krb5)
432 ("nspr" ,nspr)
433 ("nss" ,nss)
434 ("sqlite" ,sqlite)
435 ("startup-notification" ,startup-notification)
436 ("unzip" ,unzip)
437 ("yasm" ,yasm)
438 ("zip" ,zip)
439 ("zlib" ,zlib)))
440 (native-inputs
441 `(("perl" ,perl)
442 ("python" ,python-2) ; Python 3 not supported
443 ("python2-pysqlite" ,python2-pysqlite)
444 ("pkg-config" ,pkg-config)
445 ("which" ,which)))
446 (arguments
447 `(#:tests? #f ; no check target
448 #:out-of-source? #t ; must be built outside of the source directory
449 #:parallel-build? #f
450
451 ;; XXX: There are RUNPATH issues such as
452 ;; $prefix/lib/icecat-31.6.0/plugin-container NEEDing libmozalloc.so,
453 ;; which is not in its RUNPATH, but they appear to be harmless in
454 ;; practice somehow. See <http://hydra.gnu.org/build/378133>.
455 #:validate-runpath? #f
456
457 #:configure-flags '("--enable-default-toolkit=cairo-gtk2"
458 "--enable-pango"
459 "--enable-gio"
460 "--enable-svg"
461 "--enable-canvas"
462 "--enable-mathml"
463 "--enable-startup-notification"
464 "--enable-pulseaudio"
465 "--enable-gstreamer=1.0"
466
467 "--disable-gnomevfs"
468 "--disable-gconf"
469 "--disable-gnomeui"
470
471 ;; Building with debugging symbols takes ~5GiB, so
472 ;; disable it.
473 "--disable-debug"
474 "--disable-debug-symbols"
475
476 ;; Hack to work around missing
477 ;; "unofficial" branding in icecat.
478 "--enable-official-branding"
479
480 ;; Avoid bundled libraries.
481 "--with-system-zlib"
482 "--with-system-bz2"
483 "--with-system-jpeg" ; must be libjpeg-turbo
484 "--with-system-libevent"
485 "--with-system-libvpx"
486 "--with-system-icu"
487 "--with-system-nspr"
488 "--with-system-nss"
489 "--enable-system-pixman"
490 "--enable-system-cairo"
491 "--enable-system-ffi"
492 "--enable-system-hunspell"
493 "--enable-system-sqlite"
494
495 ;; Fails with "--with-system-png won't work because
496 ;; the system's libpng doesn't have APNG support".
497 ;; According to
498 ;; http://sourceforge.net/projects/libpng-apng/ ,
499 ;; "the Animated Portable Network Graphics (APNG)
500 ;; is an unofficial extension of the Portable
501 ;; Network Graphics (PNG) format";
502 ;; we probably do not wish to support it.
503 ;; "--with-system-png"
504 )
505
506 #:modules ((ice-9 ftw)
507 (ice-9 rdelim)
508 (ice-9 match)
509 ,@%gnu-build-system-modules)
510 #:phases
511 (modify-phases %standard-phases
512 (add-after
513 'unpack 'ensure-no-mtimes-pre-1980
514 (lambda _
515 ;; Without this, the 'source/test/addons/packed.xpi' and
516 ;; 'source/test/addons/simple-prefs.xpi' targets fail while trying
517 ;; to create zip archives.
518 (let ((early-1980 315619200)) ; 1980-01-02 UTC
519 (ftw "." (lambda (file stat flag)
520 (unless (<= early-1980 (stat:mtime stat))
521 (utime file early-1980 early-1980))
522 #t))
523 #t)))
524 (add-after
525 'unpack 'remove-h264parse-from-blacklist
526 (lambda _
527 ;; Remove h264parse from gstreamer format helper blacklist. It
528 ;; was put there to work around a bug in a pre-1.0 version of
529 ;; gstreamer. See:
530 ;; https://www.mozilla.org/en-US/security/advisories/mfsa2015-47/
531 (substitute* "dom/media/gstreamer/GStreamerFormatHelper.cpp"
532 (("^ \"h264parse\",\n") ""))
533 #t))
534 (add-after
535 'unpack 'arrange-to-link-libxul-with-libraries-it-might-dlopen
536 (lambda _
537 ;; libxul.so dynamically opens libraries, so here we explicitly
538 ;; link them into libxul.so instead.
539 ;;
540 ;; TODO: It might be preferable to patch in absolute file names in
541 ;; calls to dlopen or PR_LoadLibrary, but that didn't seem to
542 ;; work. More investigation is needed.
543 (substitute* "toolkit/library/moz.build"
544 (("^# This needs to be last")
545 "OS_LIBS += [
546 'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5',
547 'gstreamer-1.0', 'gstapp-1.0', 'gstvideo-1.0' ]\n\n"))
548 #t))
549 (replace
550 'configure
551 ;; configure does not work followed by both "SHELL=..." and
552 ;; "CONFIG_SHELL=..."; set environment variables instead
553 (lambda* (#:key outputs configure-flags #:allow-other-keys)
554 (let* ((out (assoc-ref outputs "out"))
555 (bash (which "bash"))
556 (abs-srcdir (getcwd))
557 (srcdir (string-append "../" (basename abs-srcdir)))
558 (flags `(,(string-append "--prefix=" out)
559 ,(string-append "--with-l10n-base="
560 abs-srcdir "/l10n")
561 ,@configure-flags)))
562 (setenv "SHELL" bash)
563 (setenv "CONFIG_SHELL" bash)
564 (mkdir "../build")
565 (chdir "../build")
566 (format #t "build directory: ~s~%" (getcwd))
567 (format #t "configure flags: ~s~%" flags)
568 (zero? (apply system* bash
569 (string-append srcdir "/configure")
570 flags)))))
571 (add-before 'configure 'install-desktop-entry
572 (lambda* (#:key outputs #:allow-other-keys)
573 ;; Install the '.desktop' file.
574 (define (swallow-%%-directives input output)
575 ;; Interpret '%%ifdef' directives found in the '.desktop' file.
576 (let loop ((state 'top))
577 (match (read-line input 'concat)
578 ((? eof-object?)
579 #t)
580 ((? string? line)
581 (cond ((string-prefix? "%%ifdef" line)
582 (loop 'ifdef))
583 ((string-prefix? "%%else" line)
584 (loop 'else))
585 ((string-prefix? "%%endif" line)
586 (loop 'top))
587 (else
588 (case state
589 ((top else)
590 (display line output)
591 (loop state))
592 (else
593 (loop state)))))))))
594
595 (let* ((out (assoc-ref outputs "out"))
596 (applications (string-append out "/share/applications")))
597 (call-with-input-file "debian/icecat.desktop.in"
598 (lambda (input)
599 (call-with-output-file "debian/icecat.desktop"
600 (lambda (output)
601 (swallow-%%-directives input output)))))
602
603 (substitute* "debian/icecat.desktop"
604 (("@MOZ_DISPLAY_NAME@")
605 "GNU IceCat")
606 (("^Exec=@MOZ_APP_NAME@")
607 (string-append "Exec=" out "/bin/icecat"))
608 (("@MOZ_APP_NAME@")
609 "icecat"))
610 (install-file "debian/icecat.desktop" applications)
611 #t)))
612 (add-after 'install-desktop-entry 'install-icons
613 (lambda* (#:key outputs #:allow-other-keys)
614 (let ((out (assoc-ref outputs "out")))
615 (with-directory-excursion "browser/branding/official"
616 (for-each
617 (lambda (file)
618 (let* ((size (string-filter char-numeric? file))
619 (icons (string-append out "/share/icons/hicolor/"
620 size "x" size "/apps")))
621 (mkdir-p icons)
622 (copy-file file (string-append icons "/icecat.png"))))
623 '("default16.png" "default22.png" "default24.png"
624 "default32.png" "default48.png" "content/icon64.png"
625 "mozicon128.png" "default256.png")))))))))
626 (home-page "http://www.gnu.org/software/gnuzilla/")
627 (synopsis "Entirely free browser derived from Mozilla Firefox")
628 (description
629 "IceCat is the GNU version of the Firefox browser. It is entirely free
630 software, which does not recommend non-free plugins and addons. It also
631 features built-in privacy-protecting features.")
632 (license license:mpl2.0) ;and others, see toolkit/content/license.html
633 (properties
634 `((ftp-directory . "/gnu/gnuzilla")
635 (cpe-name . "firefox_esr")
636 (cpe-version . ,(first (string-split version #\-)))))))