gnu: ungoogled-chromium: Increase build timeout.
[jackhill/guix/guix.git] / gnu / packages / gnuzilla.scm
CommitLineData
be0f6112 1;;; GNU Guix --- Functional package management for GNU
5deea4fc 2;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
aff0cce9 3;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
948879ee 4;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
1aaaff1a 5;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
89f9df6c 6;;; Copyright © 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
88a8ce87 7;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
8db94716 8;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
47956fa0 9;;; Copyright © 2017 ng0 <ng0@n0.is>
71a96ecb 10;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
192a59d0 11;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
7d141788 12;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
be0f6112
AE
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages gnuzilla)
07d4d9b7 30 #:use-module ((srfi srfi-1) #:hide (zip))
1461dd24 31 #:use-module (ice-9 match)
be0f6112 32 #:use-module (gnu packages)
b5b73a82 33 #:use-module ((guix licenses) #:prefix license:)
be0f6112
AE
34 #:use-module (guix packages)
35 #:use-module (guix download)
192a59d0 36 #:use-module (guix git-download)
948879ee
MW
37 #:use-module (guix gexp)
38 #:use-module (guix store)
39 #:use-module (guix monads)
aaac423c 40 #:use-module (guix utils)
be0f6112 41 #:use-module (guix build-system gnu)
e67ad553 42 #:use-module (guix build-system cargo)
948879ee 43 #:use-module (gnu packages admin)
94e96f7f 44 #:use-module (gnu packages audio)
002c3e6d 45 #:use-module (gnu packages autotools)
bfb48f4f 46 #:use-module (gnu packages base)
948879ee 47 #:use-module (gnu packages bash)
1aaaff1a 48 #:use-module (gnu packages databases)
be0f6112 49 #:use-module (gnu packages glib)
be0f6112 50 #:use-module (gnu packages gtk)
90e1cdae
MW
51 #:use-module (gnu packages gnome)
52 #:use-module (gnu packages libcanberra)
53 #:use-module (gnu packages cups)
89e34644 54 #:use-module (gnu packages kerberos)
be0f6112
AE
55 #:use-module (gnu packages linux)
56 #:use-module (gnu packages perl)
57 #:use-module (gnu packages pkg-config)
1ae6df81 58 #:use-module (gnu packages compression)
74c7af9f 59 #:use-module (gnu packages fontutils)
1ae6df81 60 #:use-module (gnu packages libevent)
90e1cdae 61 #:use-module (gnu packages libreoffice) ;for hunspell
e55354b8 62 #:use-module (gnu packages image)
1ae6df81 63 #:use-module (gnu packages libffi)
74c7af9f 64 #:use-module (gnu packages pulseaudio)
be0f6112 65 #:use-module (gnu packages python)
44d10b1f 66 #:use-module (gnu packages python-xyz)
be0f6112 67 #:use-module (gnu packages xorg)
200726ed 68 #:use-module (gnu packages gl)
01497dfe 69 #:use-module (gnu packages assembly)
e67ad553 70 #:use-module (gnu packages rust)
8d956d86 71 #:use-module (gnu packages llvm)
aff0cce9 72 #:use-module (gnu packages nss)
13b284d9
MW
73 #:use-module (gnu packages icu4c)
74 #:use-module (gnu packages video)
94e96f7f 75 #:use-module (gnu packages xiph)
13b284d9 76 #:use-module (gnu packages xdisorg)
cd0322a3
RW
77 #:use-module (gnu packages readline)
78 #:use-module (gnu packages sqlite))
be0f6112 79
4923e06f
SB
80(define-public mozjs
81 (package
82 (name "mozjs")
83 (version "17.0.0")
84 (source (origin
85 (method url-fetch)
86 (uri (string-append
87 "https://ftp.mozilla.org/pub/mozilla.org/js/"
88 name version ".tar.gz"))
89 (sha256
90 (base32
68716289 91 "1fig2wf4f10v43mqx67y68z6h77sy900d1w0pz9qarrqx57rc7ij"))
a64b7da5 92 (patches (search-patches "mozjs17-aarch64-support.patch"))
68716289
SB
93 (modules '((guix build utils)))
94 (snippet
95 ;; Fix incompatibility with Perl 5.22+.
6cbee49d
MW
96 '(begin
97 (substitute* '("js/src/config/milestone.pl")
98 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE"))
99 #t))))
4923e06f
SB
100 (build-system gnu-build-system)
101 (native-inputs
f403c676
EF
102 `(("perl" ,perl)
103 ("pkg-config" ,pkg-config)
104 ("python" ,python-2)))
105 (propagated-inputs
106 `(("nspr" ,nspr))) ; in the Requires.private field of mozjs-17.0.pc
107 (inputs
108 `(("zlib" ,zlib)))
4923e06f 109 (arguments
56486b3a
EF
110 `(;; XXX: parallel build fails, lacking:
111 ;; mkdir -p "system_wrapper_js/"
112 #:parallel-build? #f
113 #:phases
114 (modify-phases %standard-phases
115 (add-after 'unpack 'delete-timedout-test
a64b7da5 116 ;; This test times out on slower hardware.
e15793c8
MW
117 (lambda _
118 (delete-file "js/src/jit-test/tests/basic/bug698584.js")
119 #t))
56486b3a 120 (add-before 'configure 'chdir
4923e06f 121 (lambda _
56486b3a
EF
122 (chdir "js/src")
123 #t))
124 (replace 'configure
125 ;; configure fails if it is followed by SHELL and CONFIG_SHELL
126 (lambda* (#:key outputs #:allow-other-keys)
127 (let ((out (assoc-ref outputs "out")))
128 (setenv "SHELL" (which "sh"))
129 (setenv "CONFIG_SHELL" (which "sh"))
e15793c8
MW
130 (invoke "./configure" (string-append "--prefix=" out)
131 ,@(if (string=? "aarch64-linux"
132 (%current-system))
133 '("--host=aarch64-unknown-linux-gnu")
134 '()))))))))
4923e06f
SB
135 (home-page
136 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey")
137 (synopsis "Mozilla javascript engine")
138 (description "SpiderMonkey is Mozilla's JavaScript engine written
139in C/C++.")
87158e85 140 (license license:mpl2.0))) ; and others for some files
4923e06f 141
cefdcb38
SB
142(define-public mozjs-24
143 (package (inherit mozjs)
144 (name "mozjs")
145 (version "24.2.0")
146 (source (origin
147 (method url-fetch)
148 (uri (string-append
149 "https://ftp.mozilla.org/pub/mozilla.org/js/"
150 name "-" version ".tar.bz2"))
151 (sha256
152 (base32
68716289
SB
153 "1n1phk8r3l8icqrrap4czplnylawa0ddc2cc4cgdz46x3lrkybz6"))
154 (modules '((guix build utils)))
26f38d31 155 (patches (search-patches "mozjs24-aarch64-support.patch"))
68716289
SB
156 (snippet
157 ;; Fix incompatibility with Perl 5.22+.
6cbee49d
MW
158 '(begin
159 (substitute* '("js/src/config/milestone.pl")
160 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE"))
161 #t))))
cefdcb38 162 (arguments
aaac423c
EF
163 (substitute-keyword-arguments (package-arguments mozjs)
164 ((#:phases phases)
165 `(modify-phases ,phases
166 (replace 'configure
167 (lambda* (#:key outputs #:allow-other-keys)
168 (let ((out (assoc-ref outputs "out")))
169 ;; configure fails if it is followed by SHELL and CONFIG_SHELL
170 (setenv "SHELL" (which "sh"))
171 (setenv "CONFIG_SHELL" (which "sh"))
6073ef75
MW
172 (invoke "./configure"
173 (string-append "--prefix=" out)
174 "--with-system-nspr"
175 "--enable-system-ffi"
176 "--enable-threadsafe"
177 ,@(if (string=? "aarch64-linux"
178 (%current-system))
179 '("--host=aarch64-unknown-linux-gnu")
180 '())))))))))
cefdcb38
SB
181 (inputs
182 `(("libffi" ,libffi)
183 ("zlib" ,zlib)))))
184
29f381ba
CL
185(define-public mozjs-38
186 (package
187 (inherit mozjs)
188 (name "mozjs")
189 (version "38.2.1.rc0")
190 (source (origin
191 (method url-fetch)
192 (uri (string-append
747c8f2a 193 "https://anduin.linuxfromscratch.org/BLFS/mozjs/"
29f381ba
CL
194 name "-" version ".tar.bz2"))
195 (sha256
196 (base32
197 "0p4bmbpgkfsj54xschcny0a118jdrdgg0q29rwxigg3lh5slr681"))
198 (patches
199 (search-patches
200 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1269317 for
201 ;; GCC 6 compatibility.
202
203 "mozjs38-version-detection.patch" ; for 0ad
204 "mozjs38-tracelogger.patch"
205
206 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1339931.
207 "mozjs38-pkg-config-version.patch"
208 "mozjs38-shell-version.patch"))
209 (modules '((guix build utils)))
210 (snippet
211 '(begin
212 ;; Fix incompatibility with sed 4.4.
213 (substitute* "js/src/configure"
214 (("\\^\\[:space:\\]") "^[[:space:]]"))
215
216 ;; The headers are symlinks to files that are in /tmp, so they
217 ;; end up broken. Copy them instead.
218 (substitute*
219 "python/mozbuild/mozbuild/backend/recursivemake.py"
220 (("\\['dist_include'\\].add_symlink")
221 "['dist_include'].add_copy"))
222
223 ;; Remove bundled libraries.
224 (for-each delete-file-recursively
225 '("intl"
226 "js/src/ctypes/libffi"
227 "js/src/ctypes/libffi-patches"
228 "modules/zlib"))
229 #t))))
230 (arguments
231 `(;; XXX: parallel build fails, lacking:
232 ;; mkdir -p "system_wrapper_js/"
233 #:parallel-build? #f
234 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1008470.
235 #:tests? #f
236 #:phases
237 (modify-phases %standard-phases
238 (replace 'configure
239 (lambda* (#:key outputs #:allow-other-keys)
240 (let ((out (assoc-ref outputs "out")))
241 (chdir "js/src")
242 (setenv "SHELL" (which "sh"))
243 (setenv "CONFIG_SHELL" (which "sh"))
5f70b6d4
MW
244 (invoke "./configure"
245 (string-append "--prefix=" out)
246 "--enable-ctypes"
247 "--enable-gcgenerational"
248 "--enable-optimize"
249 "--enable-pie"
250 "--enable-readline"
251 "--enable-shared-js"
252 "--enable-system-ffi"
253 "--enable-threadsafe"
254 "--enable-xterm-updates"
255 "--with-system-icu"
256 "--with-system-nspr"
257 "--with-system-zlib"
29f381ba 258
5f70b6d4
MW
259 ;; Intl API requires bundled ICU.
260 "--without-intl-api")))))))
29f381ba
CL
261 (native-inputs
262 `(("perl" ,perl)
263 ("pkg-config" ,pkg-config)
264 ("python-2" ,python-2)))
265 (inputs
266 `(("libffi" ,libffi)
267 ("readline" ,readline)
268 ("icu4c" ,icu4c)
269 ("zlib" ,zlib)))))
270
192a59d0
RW
271(define-public mozjs-52
272 ;; No releases yet at <https://archive.mozilla.org/pub/spidermonkey/releases/>.
273 ;; While we could take a snapshot of the complete mozilla-esr52 repository at
274 ;; <https://treeherder.mozilla.org/#/jobs?repo=mozilla-esr52&filter-searchStr=sm-tc>,
275 ;; we take the Debian version instead, because it is easier to work with.
276 (let ((commit "6507e63cc416fd7a3269e390efe712f8b56f374a")
277 (revision "1"))
278 (package (inherit mozjs-38)
279 (version (git-version "52.0" revision commit))
280 (source (origin
281 (method git-fetch)
282 (uri (git-reference
283 (url "https://salsa.debian.org/gnome-team/mozjs52.git")
284 (commit commit)))
285 (file-name (git-file-name "mozjs" version))
286 (sha256
287 (base32
288 "1ny0s53r8wn4byys87h784xrq1xg767akmfm6gqrbvrz57mlm3q2"))))
289 (arguments
290 `(#:tests? #f ; depends on repository metadata
291 #:configure-flags
292 '("--enable-ctypes"
293 "--enable-optimize"
294 "--enable-pie"
295 "--enable-readline"
296 "--enable-shared-js"
297 "--enable-system-ffi"
298 "--with-system-icu"
299 "--with-system-nspr"
300 "--with-system-zlib"
301
302 ;; Intl API requires bundled ICU.
6cc147a3
RW
303 "--without-intl-api"
304
305 ;; Without this gnome-shell will crash at runtime.
306 "--disable-jemalloc")
192a59d0
RW
307 #:phases
308 (modify-phases %standard-phases
309 (add-after 'unpack 'patch-and-chdir
310 (lambda* (#:key inputs #:allow-other-keys)
311 ;; This patch prevents a segfault when executing JS_Init().
312 ;; The build does not fail without this patch, but the
313 ;; configure phase of the gjs package would fail.
314 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1176787
315 (make-file-writable "js/src/old-configure.in")
316 (make-file-writable "js/src/old-configure")
317 (make-file-writable "mozglue/build/moz.build")
318 (invoke "patch" "-p1" "--force"
319 "--input" "debian/patches/disable-mozglue.patch")
320 (invoke "touch" "js/src/configure")
321 (chdir "js/src")
322 #t))
323 (replace 'configure
324 (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
325 ;; The configure script does not accept environment variables
326 ;; as arguments.
327 (let ((out (assoc-ref outputs "out")))
328 (setenv "SHELL" (which "sh"))
329 (setenv "CONFIG_SHELL" (which "sh"))
330 (setenv "AUTOCONF" (string-append (assoc-ref inputs "autoconf")
331 "/bin/autoconf"))
332 (apply invoke "./configure"
333 (cons (string-append "--prefix=" out)
334 configure-flags))))))))
335 (native-inputs
336 `(("autoconf" ,autoconf-2.13)
337 ("automake" ,automake)
338 ,@(package-native-inputs mozjs-38))))))
339
204cfbe1
RW
340(define-public mozjs-60
341 ;; No releases yet at <https://archive.mozilla.org/pub/spidermonkey/releases/>.
342 ;; While we could take a snapshot of the complete mozilla-esr60 repository at
343 ;; <https://treeherder.mozilla.org/#/jobs?repo=mozilla-esr60&filter-searchStr=sm-tc>,
344 ;; we take the Debian version instead, because it is easier to work with.
345 (package
346 (inherit mozjs-38)
347 (version "60.2.3-2")
348 (source (origin
349 (method git-fetch)
350 (uri (git-reference
351 (url "https://salsa.debian.org/gnome-team/mozjs60.git")
352 (commit (string-append "debian/" version))))
353 (file-name (git-file-name "mozjs" version))
354 (sha256
355 (base32
356 "091w050rwzrdcbgyi934k2viyccmlqxrp13sm2mql71mabb5dai6"))))
357 (arguments
358 `(#:tests? #f ; FIXME: all tests pass, but then the check phase fails anyway.
359 #:test-target "check-jstests"
360 #:configure-flags
361 '("--enable-ctypes"
362 "--enable-optimize"
363 "--enable-pie"
364 "--enable-readline"
365 "--enable-shared-js"
366 "--enable-system-ffi"
367 "--with-system-nspr"
368 "--with-system-zlib"
369 "--with-system-icu"
370 "--with-intl-api"
371 ;; This is important because without it gjs will segfault during the
372 ;; configure phase. With jemalloc only the standalone mozjs console
373 ;; will work.
374 "--disable-jemalloc")
375 #:phases
376 (modify-phases %standard-phases
377 (replace 'configure
378 (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
379 ;; The configure script does not accept environment variables as
380 ;; arguments. It also must be run from a different directory,
381 ;; but not the root directory either.
382 (let ((out (assoc-ref outputs "out")))
383 (mkdir "run-configure-from-here")
384 (chdir "run-configure-from-here")
385 (setenv "SHELL" (which "sh"))
386 (setenv "CONFIG_SHELL" (which "sh"))
387 (setenv "AUTOCONF" (string-append (assoc-ref inputs "autoconf")
388 "/bin/autoconf"))
389 (apply invoke "../js/src/configure"
390 (cons (string-append "--prefix=" out)
391 configure-flags))
392 #t)))
393 (add-after 'unpack 'disable-broken-tests
394 (lambda _
395 ;; This test assumes that /bin exists and contains certain
396 ;; executables.
397 (delete-file "js/src/tests/shell/os.js")
398 #t)))))
399 (native-inputs
400 `(("autoconf" ,autoconf)
401 ("automake" ,automake)
402 ("which" ,which)
403 ("perl" ,perl)
404 ("pkg-config" ,pkg-config)
405 ("python" ,python-2)))))
406
bfb48f4f 407(define (mozilla-patch file-name changeset hash)
ae71cd8a 408 "Return an origin for CHANGESET from the mozilla-esr60 repository."
bfb48f4f
MW
409 (origin
410 (method url-fetch)
ae71cd8a 411 (uri (string-append "https://hg.mozilla.org/releases/mozilla-esr60/raw-rev/"
bfb48f4f
MW
412 changeset))
413 (sha256 (base32 hash))
414 (file-name file-name)))
415
948879ee
MW
416(define* (computed-origin-method gexp-promise hash-algo hash
417 #:optional (name "source")
418 #:key (system (%current-system))
419 (guile (default-guile)))
420 "Return a derivation that executes the G-expression that results
421from forcing GEXP-PROMISE."
422 (mlet %store-monad ((guile (package->derivation guile system)))
423 (gexp->derivation (or name "computed-origin")
424 (force gexp-promise)
2a1ec7bc 425 #:graft? #f ;nothing to graft
948879ee
MW
426 #:system system
427 #:guile-for-build guile)))
428
c2c4ac0f 429(define %icecat-version "60.7.2-guix1")
948879ee
MW
430
431;; 'icecat-source' is a "computed" origin that generates an IceCat tarball
432;; from the corresponding upstream Firefox ESR tarball, using the 'makeicecat'
433;; script from the upstream IceCat project.
434(define icecat-source
435 (let* ((base-version (first (string-split %icecat-version #\-)))
436
437 (major-version (first (string-split base-version #\.)))
438 (minor-version (second (string-split base-version #\.)))
439 (sub-version (third (string-split base-version #\.)))
440
441 (upstream-firefox-version (string-append base-version "esr"))
442 (upstream-firefox-source
443 (origin
444 (method url-fetch)
445 (uri (string-append
446 "https://ftp.mozilla.org/pub/firefox/releases/"
447 upstream-firefox-version "/source/"
448 "firefox-" upstream-firefox-version ".source.tar.xz"))
449 (sha256
450 (base32
c2c4ac0f 451 "1hkaq8mavmn2wphfbrlq3v56jvmvfi2nyvrkjgr28rc01jkqx4ca"))))
948879ee 452
05947d92 453 (upstream-icecat-base-version "60.7.0") ; maybe older than base-version
948879ee
MW
454 (upstream-icecat-gnu-version "1")
455 (upstream-icecat-version (string-append upstream-icecat-base-version
456 "-gnu"
457 upstream-icecat-gnu-version))
458 (upstream-icecat-source
459 (origin
460 (method url-fetch)
461 (uri (string-append
462 "mirror://gnu/gnuzilla/" upstream-icecat-base-version
463 "/icecat-" upstream-icecat-version ".tar.bz2"))
464 (sha256
465 (base32
05947d92 466 "09xqdfd8rwbn2n6m7n059qf1psbrj5v5kfzm7gg5xng22ddxawv8"))))
948879ee
MW
467
468 (gnuzilla-commit (string-append "v" upstream-icecat-base-version))
469 (gnuzilla-source
470 (origin
471 (method git-fetch)
472 (uri (git-reference
473 (url "git://git.savannah.gnu.org/gnuzilla.git")
474 (commit gnuzilla-commit)))
475 (file-name (git-file-name "gnuzilla" upstream-icecat-base-version))
476 (sha256
477 (base32
05947d92 478 "1vqhb0py28hnwcynbaad304ziciz1kn5bv1qg2q4f7g13js3b1hf"))))
948879ee
MW
479
480 (makeicecat-patch
481 (local-file (search-patch "icecat-makeicecat.patch"))))
482
483 (origin
484 (method computed-origin-method)
485 (file-name (string-append "icecat-" %icecat-version ".tar.xz"))
486 (sha256 #f)
487 (uri
488 (delay
489 (with-imported-modules '((guix build utils))
490 #~(begin
491 (use-modules (guix build utils))
492 (let ((firefox-dir
493 (string-append "firefox-" #$base-version))
494 (icecat-dir
495 (string-append "icecat-" #$%icecat-version))
496 (old-icecat-dir
497 (string-append "icecat-" #$upstream-icecat-base-version)))
498
499 (mkdir "/tmp/bin")
500 (set-path-environment-variable
501 "PATH" '("bin")
502 (list "/tmp"
503 #+(canonical-package bash)
504 #+(canonical-package coreutils)
505 #+(canonical-package findutils)
506 #+(canonical-package patch)
507 #+(canonical-package xz)
508 #+(canonical-package sed)
509 #+(canonical-package grep)
510 #+(canonical-package bzip2)
511 #+(canonical-package gzip)
512 #+(canonical-package tar)
513 #+rename))
514
515 (symlink #+(file-append rename "/bin/rename")
516 "/tmp/bin/prename")
517
518 ;; We copy the gnuzilla source directory because it is
519 ;; read-only in 'gnuzilla-source', and the makeicecat script
520 ;; uses "cp -a" to copy parts of it and assumes that the
521 ;; copies will be writable.
522 (copy-recursively #+gnuzilla-source "/tmp/gnuzilla"
523 #:log (%make-void-port "w"))
524
525 (with-directory-excursion "/tmp/gnuzilla"
526 (make-file-writable "makeicecat")
527 (invoke "patch" "--force" "--no-backup-if-mismatch"
528 "-p1" "--input" #+makeicecat-patch)
529 (patch-shebang "makeicecat")
530 (substitute* "makeicecat"
3e605b69
MW
531 (("^FFMAJOR=(.*)" all ffmajor)
532 (unless (string=? #$major-version
533 (string-trim-both ffmajor))
534 ;; The makeicecat script cannot be expected to work
535 ;; properly on a different version of Firefox, even if
536 ;; no errors occur during execution.
537 (error "makeicecat major version mismatch"))
948879ee
MW
538 (string-append "FFMAJOR=" #$major-version "\n"))
539 (("^FFMINOR=.*")
540 (string-append "FFMINOR=" #$minor-version "\n"))
541 (("^FFSUB=.*")
542 (string-append "FFSUB=" #$sub-version "\n"))
543 (("^GNUVERSION=.*")
544 (string-append "GNUVERSION="
545 #$upstream-icecat-gnu-version "\n"))
546 (("^DATA=.*")
547 "DATA=/tmp/gnuzilla/data\n")
948879ee
MW
548 (("^find extensions/gnu/ ")
549 "find extensions/gnu/ | sort ")
550 (("/bin/sed")
551 #+(file-append (canonical-package sed) "/bin/sed"))))
552
553 (format #t "Unpacking upstream firefox tarball...~%")
554 (force-output)
555 (invoke "tar" "xf" #+upstream-firefox-source)
556 (rename-file firefox-dir icecat-dir)
557
558 (with-directory-excursion icecat-dir
05947d92 559 (mkdir "l10n")
948879ee
MW
560 (format #t "Running makeicecat script...~%")
561 (force-output)
562 (invoke "bash" "/tmp/gnuzilla/makeicecat")
05947d92 563 (delete-file-recursively "l10n"))
948879ee 564
05947d92 565 (format #t (string-append "Unpacking l10n/* from"
948879ee
MW
566 " upstream IceCat tarball...~%"))
567 (force-output)
568 (unless (string=? icecat-dir old-icecat-dir)
569 (symlink icecat-dir old-icecat-dir))
570 (invoke "tar" "xf" #+upstream-icecat-source
05947d92 571 (string-append old-icecat-dir "/l10n"))
948879ee 572
8cf160e1 573 (format #t "Packing new IceCat tarball...~%")
948879ee
MW
574 (force-output)
575 (invoke "tar" "cfa" #$output
8cf160e1
MW
576 ;; Avoid non-determinism in the archive. We set the
577 ;; mtime of files in the archive to early 1980 because
578 ;; the build process fails if the mtime of source
579 ;; files is pre-1980, due to the creation of zip
580 ;; archives.
581 "--mtime=@315619200" ; 1980-01-02 UTC
948879ee
MW
582 "--owner=root:0"
583 "--group=root:0"
584 "--sort=name"
585 icecat-dir)
586
587 #t))))))))
588
be0f6112
AE
589(define-public icecat
590 (package
591 (name "icecat")
24886c13 592 (version %icecat-version)
46ce12d0 593 (source icecat-source)
be0f6112
AE
594 (build-system gnu-build-system)
595 (inputs
596 `(("alsa-lib" ,alsa-lib)
1ae6df81 597 ("bzip2" ,bzip2)
90e1cdae 598 ("cups" ,cups)
be0f6112 599 ("dbus-glib" ,dbus-glib)
90e1cdae
MW
600 ("gdk-pixbuf" ,gdk-pixbuf)
601 ("glib" ,glib)
002c3e6d
MW
602 ("gtk+" ,gtk+)
603 ("gtk+-2" ,gtk+-2)
257e3247 604 ("graphite2" ,graphite2)
74c7af9f
MW
605 ("pango" ,pango)
606 ("freetype" ,freetype)
257e3247 607 ("harfbuzz" ,harfbuzz)
90e1cdae
MW
608 ("hunspell" ,hunspell)
609 ("libcanberra" ,libcanberra)
610 ("libgnome" ,libgnome)
7cba7647 611 ("libjpeg-turbo" ,libjpeg-turbo)
94e96f7f
MW
612 ("libogg" ,libogg)
613 ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
614 ("libvorbis" ,libvorbis)
74c7af9f 615 ("libxft" ,libxft)
94e96f7f 616 ("libevent" ,libevent)
90e1cdae
MW
617 ("libxinerama" ,libxinerama)
618 ("libxscrnsaver" ,libxscrnsaver)
9f7ae77f 619 ("libxcomposite" ,libxcomposite)
be0f6112 620 ("libxt" ,libxt)
1ae6df81 621 ("libffi" ,libffi)
e67ad553 622 ("ffmpeg" ,ffmpeg)
037d5913 623 ("libvpx" ,libvpx-1.7)
13b284d9
MW
624 ("icu4c" ,icu4c)
625 ("pixman" ,pixman)
74c7af9f 626 ("pulseaudio" ,pulseaudio)
be0f6112 627 ("mesa" ,mesa)
90e1cdae 628 ("mit-krb5" ,mit-krb5)
6d328879
MW
629 ;; See <https://bugs.gnu.org/32833>
630 ;; and related comments in the 'snippet' above.
631 ;; UNBUNDLE-ME! ("nspr" ,nspr)
632 ;; UNBUNDLE-ME! ("nss" ,nss)
9bc79c11 633 ("sqlite" ,sqlite)
90e1cdae 634 ("startup-notification" ,startup-notification)
be0f6112 635 ("unzip" ,unzip)
1ae6df81
LC
636 ("zip" ,zip)
637 ("zlib" ,zlib)))
c4c4cc05 638 (native-inputs
46ce12d0
MW
639 ;; The following patches are specific to the Guix packaging of IceCat,
640 ;; and therefore we prefer to leave them out of 'source', which should be
641 ;; a tarball suitable for compilation on any system that IceCat supports.
642 ;; (Bug fixes and security fixes, however, should go in 'source').
643 `(("icecat-avoid-bundled-libraries.patch"
644 ,(search-patch "icecat-avoid-bundled-libraries.patch"))
645 ("icecat-use-system-graphite2+harfbuzz.patch"
646 ,(search-patch "icecat-use-system-graphite2+harfbuzz.patch"))
647 ("icecat-use-system-media-libs.patch"
648 ,(search-patch "icecat-use-system-media-libs.patch"))
649
650 ("patch" ,(canonical-package patch))
651
652 ;; Icecat 60 checks for rust>=1.24
653 ("rust" ,rust-1.24)
89f9df6c 654 ("cargo" ,rust-1.24 "cargo")
8d956d86
MW
655 ("llvm" ,llvm-3.9.1)
656 ("clang" ,clang-3.9.1)
e67ad553 657 ("perl" ,perl)
c4c4cc05
JD
658 ("python" ,python-2) ; Python 3 not supported
659 ("python2-pysqlite" ,python2-pysqlite)
002c3e6d 660 ("yasm" ,yasm)
bfb48f4f 661 ("pkg-config" ,pkg-config)
002c3e6d 662 ("autoconf" ,autoconf-2.13)
bfb48f4f 663 ("which" ,which)))
be0f6112 664 (arguments
74c7af9f
MW
665 `(#:tests? #f ; no check target
666 #:out-of-source? #t ; must be built outside of the source directory
73b1b4eb
LC
667
668 ;; XXX: There are RUNPATH issues such as
669 ;; $prefix/lib/icecat-31.6.0/plugin-container NEEDing libmozalloc.so,
670 ;; which is not in its RUNPATH, but they appear to be harmless in
671 ;; practice somehow. See <http://hydra.gnu.org/build/378133>.
672 #:validate-runpath? #f
673
8d956d86 674 #:configure-flags `("--enable-default-toolkit=cairo-gtk3"
9502ea3e
MW
675
676 "--with-distribution-id=org.gnu"
677
90e1cdae
MW
678 "--enable-startup-notification"
679 "--enable-pulseaudio"
90e1cdae 680
9502ea3e
MW
681 "--disable-tests"
682 "--disable-updater"
683 "--disable-crashreporter"
684 "--disable-maintenance-service"
685 "--disable-eme"
90e1cdae 686 "--disable-gconf"
e67ad553 687
90e1cdae 688 ;; Building with debugging symbols takes ~5GiB, so
1ae6df81
LC
689 ;; disable it.
690 "--disable-debug"
691 "--disable-debug-symbols"
692
8d956d86
MW
693 ;; Clang is needed to build Stylo, Mozilla's new
694 ;; CSS engine. We must specify the clang paths
695 ;; manually, because otherwise the Mozilla build
696 ;; system looks in the directories returned by
697 ;; llvm-config --bindir and llvm-config --libdir,
698 ;; which return paths in the llvm package where
699 ;; clang is not found.
700 ,(string-append "--with-clang-path="
701 (assoc-ref %build-inputs "clang")
702 "/bin/clang")
703 ,(string-append "--with-libclang-path="
704 (assoc-ref %build-inputs "clang")
705 "/lib")
706
5bdec7d6
MW
707 ;; Hack to work around missing
708 ;; "unofficial" branding in icecat.
bfb48f4f
MW
709 "--enable-official-branding"
710
90e1cdae 711 ;; Avoid bundled libraries.
1ae6df81 712 "--with-system-zlib"
90e1cdae 713 "--with-system-bz2"
7cba7647 714 "--with-system-jpeg" ; must be libjpeg-turbo
94e96f7f
MW
715 "--with-system-libevent"
716 "--with-system-ogg"
717 "--with-system-vorbis"
718 ;; "--with-system-theora" ; wants theora-1.2, not yet released
13b284d9 719 "--with-system-libvpx"
483ab08f 720 "--with-system-icu"
6d328879
MW
721
722 ;; See <https://bugs.gnu.org/32833>
723 ;; and related comments in the 'snippet' above.
724 ;; UNBUNDLE-ME! "--with-system-nspr"
725 ;; UNBUNDLE-ME! "--with-system-nss"
726
257e3247
MW
727 "--with-system-harfbuzz"
728 "--with-system-graphite2"
13b284d9 729 "--enable-system-pixman"
5b17fabc 730 "--enable-system-ffi"
90e1cdae 731 "--enable-system-hunspell"
9128e323 732 "--enable-system-sqlite"
1ae6df81 733
98a046cd
AE
734 ;; Fails with "--with-system-png won't work because
735 ;; the system's libpng doesn't have APNG support".
736 ;; According to
737 ;; http://sourceforge.net/projects/libpng-apng/ ,
738 ;; "the Animated Portable Network Graphics (APNG)
739 ;; is an unofficial extension of the Portable
740 ;; Network Graphics (PNG) format";
741 ;; we probably do not wish to support it.
1ae6df81 742 ;; "--with-system-png"
5b17fabc 743 )
1ae6df81 744
7d141788
IP
745 #:imported-modules ,%cargo-utils-modules ;for `generate-checksums'
746
9f7ae77f 747 #:modules ((ice-9 ftw)
6cde5c34
LC
748 (ice-9 rdelim)
749 (ice-9 match)
9f7ae77f 750 ,@%gnu-build-system-modules)
be0f6112 751 #:phases
90e1cdae 752 (modify-phases %standard-phases
46ce12d0
MW
753 (add-after 'unpack 'apply-guix-specific-patches
754 (lambda* (#:key inputs native-inputs #:allow-other-keys)
755 (let ((patch (string-append (assoc-ref (or native-inputs inputs)
756 "patch")
757 "/bin/patch")))
758 (for-each (match-lambda
759 ((label . file)
760 (when (and (string-prefix? "icecat-" label)
761 (string-suffix? ".patch" label))
762 (format #t "applying '~a'...~%" file)
763 (invoke patch "--force" "--no-backup-if-mismatch"
764 "-p1" "--input" file))))
765 (or native-inputs inputs)))
766 #t))
767 (add-after 'apply-guix-specific-patches 'remove-bundled-libraries
768 (lambda _
769 ;; Remove bundled libraries that we don't use, since they may
770 ;; contain unpatched security flaws, they waste disk space and
771 ;; memory, and may cause confusion.
772 (for-each (lambda (file)
773 (format #t "deleting '~a'...~%" file)
774 (delete-file-recursively file))
775 '(;; FIXME: Removing the bundled icu breaks configure.
776 ;; * The bundled icu headers are used in some places.
777 ;; * The version number is taken from the bundled copy.
778 ;;"intl/icu"
779 ;;
780 ;; FIXME: A script from the bundled nspr is used.
781 ;;"nsprpub"
782 ;;
783 ;; FIXME: With the update to IceCat 60, using system NSS
784 ;; broke certificate validation. See
785 ;; <https://bugs.gnu.org/32833>. For now, we use
786 ;; the bundled NSPR and NSS. TODO: Investigate,
787 ;; and try to unbundle these libraries again.
788 ;; UNBUNDLE-ME! "security/nss"
789 ;;
790 ;; TODO: Use more system media libraries. See:
791 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
792 ;; * libtheora: esr60 wants v1.2, not yet released.
793 ;; * soundtouch: avoiding the bundled library would
794 ;; result in some loss of functionality. There's
795 ;; also an issue with exception handling
796 ;; configuration. It seems that this is needed in
797 ;; some moz.build:
798 ;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
799 ;; * libopus
800 ;; * speex
801 ;;
802 "modules/freetype2"
803 "modules/zlib"
804 "modules/libbz2"
805 "ipc/chromium/src/third_party/libevent"
806 "media/libjpeg"
807 "media/libvpx"
808 "media/libogg"
809 "media/libvorbis"
810 ;; "media/libtheora" ; wants theora-1.2, not yet released
811 "media/libtremor"
812 "gfx/harfbuzz"
813 "gfx/graphite2"
814 "js/src/ctypes/libffi"
815 "db/sqlite3"))
816 #t))
817 (add-after 'remove-bundled-libraries 'link-libxul-with-libraries
818 (lambda _
819 ;; libxul.so dynamically opens libraries, so here we explicitly
820 ;; link them into libxul.so instead.
821 ;;
822 ;; TODO: It might be preferable to patch in absolute file names in
823 ;; calls to dlopen or PR_LoadLibrary, but that didn't seem to
824 ;; work. More investigation is needed.
825 (substitute* "toolkit/library/moz.build"
826 (("^# This library needs to be last" all)
827 (string-append "OS_LIBS += [
9f7ae77f 828 'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5',
002c3e6d 829 'avcodec', 'avutil', 'pulse' ]\n\n"
46ce12d0
MW
830 all)))
831 #t))
94e96f7f
MW
832 (replace 'bootstrap
833 (lambda _
46ce12d0
MW
834 (invoke "sh" "-c" "autoconf old-configure.in > old-configure")
835 ;; 'configure' must be newer than 'old-configure.in', or else the
836 ;; build system will raise an alarm and abort.
837 (invoke "touch" "configure")))
e67ad553 838 (add-after 'patch-source-shebangs 'patch-cargo-checksums
257e3247 839 (lambda _
7d141788 840 (use-modules (guix build cargo-utils))
e88735b4 841 (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
e67ad553
MW
842 (substitute* '("Cargo.lock" "servo/Cargo.lock")
843 (("(\"checksum .* = )\".*\"" all name)
844 (string-append name "\"" null-hash "\"")))
845 (for-each
846 (lambda (filename)
847 (delete-file filename)
848 (let ((dir (dirname filename)))
849 (display (string-append
850 "patch-cargo-checksums: generate-checksums for "
851 dir "\n"))
e88735b4 852 (generate-checksums dir)))
e67ad553
MW
853 (find-files "third_party/rust" ".cargo-checksum.json")))
854 #t))
8d956d86
MW
855 (add-before 'configure 'augment-CPLUS_INCLUDE_PATH
856 (lambda* (#:key build inputs #:allow-other-keys)
857 ;; Here, we add additional entries to CPLUS_INCLUDE_PATH, to work
858 ;; around a problem that otherwise occurs when attempting to
859 ;; build Stylo, which requires Rust and Clang. Without these
860 ;; additional entries, errors occur during the build indicating
861 ;; that the <cstddef> and "c++config.h" headers cannot be found.
862 ;; Note that the 'build' keyword argument contains the GNU
863 ;; triplet, e.g. "x86_64-unknown-linux-gnu".
864 (let ((gcc (assoc-ref inputs "gcc")))
865 (setenv "CPLUS_INCLUDE_PATH"
866 (string-append gcc "/include/c++" ":"
867 gcc "/include/c++/" build ":"
46ce12d0
MW
868 (getenv "CPLUS_INCLUDE_PATH"))))
869 #t))
870 (replace 'configure
871 ;; configure does not work followed by both "SHELL=..." and
872 ;; "CONFIG_SHELL=..."; set environment variables instead
873 (lambda* (#:key outputs configure-flags #:allow-other-keys)
874 (let* ((out (assoc-ref outputs "out"))
875 (bash (which "bash"))
876 (abs-srcdir (getcwd))
877 (srcdir (string-append "../" (basename abs-srcdir)))
878 (flags `(,(string-append "--prefix=" out)
879 ,(string-append "--with-l10n-base="
880 abs-srcdir "/l10n")
881 ,@configure-flags)))
882 (setenv "SHELL" bash)
883 (setenv "CONFIG_SHELL" bash)
884 (setenv "AUTOCONF" (which "autoconf")) ; must be autoconf-2.13
885 (setenv "CC" "gcc") ; apparently needed when Stylo is enabled
886 (mkdir "../build")
887 (chdir "../build")
888 (format #t "build directory: ~s~%" (getcwd))
889 (format #t "configure flags: ~s~%" flags)
890 (apply invoke bash
891 (string-append srcdir "/configure")
892 flags))))
6cde5c34
LC
893 (add-before 'configure 'install-desktop-entry
894 (lambda* (#:key outputs #:allow-other-keys)
895 ;; Install the '.desktop' file.
05947d92
MW
896 (let* ((desktop-file "taskcluster/docker/icecat-snap/icecat.desktop")
897 (out (assoc-ref outputs "out"))
6cde5c34 898 (applications (string-append out "/share/applications")))
05947d92
MW
899 (substitute* desktop-file
900 (("^Exec=icecat") (string-append "Exec=" out "/bin/icecat"))
901 (("IceCat") "GNU IceCat")
902 (("Icon=.*") "Icon=icecat\n")
903 (("NewWindow") "new-window")
904 (("NewPrivateWindow") "new-private-window"))
905 (install-file desktop-file applications)
88a8ce87
AG
906 #t)))
907 (add-after 'install-desktop-entry 'install-icons
908 (lambda* (#:key outputs #:allow-other-keys)
909 (let ((out (assoc-ref outputs "out")))
910 (with-directory-excursion "browser/branding/official"
911 (for-each
912 (lambda (file)
913 (let* ((size (string-filter char-numeric? file))
914 (icons (string-append out "/share/icons/hicolor/"
915 size "x" size "/apps")))
916 (mkdir-p icons)
917 (copy-file file (string-append icons "/icecat.png"))))
918 '("default16.png" "default22.png" "default24.png"
919 "default32.png" "default48.png" "content/icon64.png"
3f27124e
MW
920 "mozicon128.png" "default256.png"))
921 #t))))
6e75740f
CL
922 ;; This fixes the file chooser crash that happens with GTK 3.
923 (add-after 'install 'wrap-program
924 (lambda* (#:key inputs outputs #:allow-other-keys)
925 (let* ((out (assoc-ref outputs "out"))
926 (lib (string-append out "/lib"))
927 (gtk (assoc-ref inputs "gtk+"))
928 (gtk-share (string-append gtk "/share")))
929 (wrap-program (car (find-files lib "^icecat$"))
3f27124e
MW
930 `("XDG_DATA_DIRS" ":" prefix (,gtk-share)))
931 #t))))))
6fd52309 932 (home-page "https://www.gnu.org/software/gnuzilla/")
be0f6112
AE
933 (synopsis "Entirely free browser derived from Mozilla Firefox")
934 (description
935 "IceCat is the GNU version of the Firefox browser. It is entirely free
c5779c93 936software, which does not recommend non-free plugins and addons. It also
79c311b8 937features built-in privacy-protecting features.")
63e8bb12 938 (license license:mpl2.0) ;and others, see toolkit/content/license.html
99effc8f
LC
939 (properties
940 `((ftp-directory . "/gnu/gnuzilla")
941 (cpe-name . "firefox_esr")
bfb48f4f 942 (cpe-version . ,(first (string-split version #\-)))))))
f5301f00
LC
943
944(define-public conkeror
945 ;; The Conkeror web browser relied on XULRunner, which IceCat > 50 no longer
946 ;; provides. See <http://conkeror.org> for the original web page.
947 (deprecated-package "conkeror" icecat))