Merge branch 'master' into core-updates
[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, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
8 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
9 ;;; Copyright © 2017 ng0 <ng0@n0.is>
10 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
12 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
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)
30 #:use-module ((srfi srfi-1) #:hide (zip))
31 #:use-module (ice-9 match)
32 #:use-module (gnu packages)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (guix packages)
35 #:use-module (guix download)
36 #:use-module (guix git-download)
37 #:use-module (guix gexp)
38 #:use-module (guix store)
39 #:use-module (guix monads)
40 #:use-module (guix utils)
41 #:use-module (guix build-system gnu)
42 #:use-module (guix build-system cargo)
43 #:use-module (gnu packages admin)
44 #:use-module (gnu packages audio)
45 #:use-module (gnu packages autotools)
46 #:use-module (gnu packages base)
47 #:use-module (gnu packages bash)
48 #:use-module (gnu packages databases)
49 #:use-module (gnu packages glib)
50 #:use-module (gnu packages gtk)
51 #:use-module (gnu packages gnome)
52 #:use-module (gnu packages libcanberra)
53 #:use-module (gnu packages cups)
54 #:use-module (gnu packages kerberos)
55 #:use-module (gnu packages linux)
56 #:use-module (gnu packages perl)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages compression)
59 #:use-module (gnu packages fontutils)
60 #:use-module (gnu packages libevent)
61 #:use-module (gnu packages libreoffice) ;for hunspell
62 #:use-module (gnu packages image)
63 #:use-module (gnu packages libffi)
64 #:use-module (gnu packages pulseaudio)
65 #:use-module (gnu packages python)
66 #:use-module (gnu packages python-xyz)
67 #:use-module (gnu packages xorg)
68 #:use-module (gnu packages gl)
69 #:use-module (gnu packages assembly)
70 #:use-module (gnu packages rust)
71 #:use-module (gnu packages llvm)
72 #:use-module (gnu packages nss)
73 #:use-module (gnu packages icu4c)
74 #:use-module (gnu packages video)
75 #:use-module (gnu packages xiph)
76 #:use-module (gnu packages xdisorg)
77 #:use-module (gnu packages readline)
78 #:use-module (gnu packages sqlite))
79
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
91 "1fig2wf4f10v43mqx67y68z6h77sy900d1w0pz9qarrqx57rc7ij"))
92 (patches (search-patches "mozjs17-aarch64-support.patch"))
93 (modules '((guix build utils)))
94 (snippet
95 ;; Fix incompatibility with Perl 5.22+.
96 '(begin
97 (substitute* '("js/src/config/milestone.pl")
98 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE"))
99 #t))))
100 (build-system gnu-build-system)
101 (native-inputs
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)))
109 (arguments
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
116 ;; This test times out on slower hardware.
117 (lambda _
118 (delete-file "js/src/jit-test/tests/basic/bug698584.js")
119 #t))
120 (add-before 'configure 'chdir
121 (lambda _
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"))
130 (invoke "./configure" (string-append "--prefix=" out)
131 ,@(if (string=? "aarch64-linux"
132 (%current-system))
133 '("--host=aarch64-unknown-linux-gnu")
134 '()))))))))
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
139 in C/C++.")
140 (license license:mpl2.0))) ; and others for some files
141
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
153 "1n1phk8r3l8icqrrap4czplnylawa0ddc2cc4cgdz46x3lrkybz6"))
154 (modules '((guix build utils)))
155 (patches (search-patches "mozjs24-aarch64-support.patch"))
156 (snippet
157 ;; Fix incompatibility with Perl 5.22+.
158 '(begin
159 (substitute* '("js/src/config/milestone.pl")
160 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE"))
161 #t))))
162 (arguments
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"))
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 '())))))))))
181 (inputs
182 `(("libffi" ,libffi)
183 ("zlib" ,zlib)))))
184
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
193 "https://anduin.linuxfromscratch.org/BLFS/mozjs/"
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"))
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"
258
259 ;; Intl API requires bundled ICU.
260 "--without-intl-api")))))))
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
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.
303 "--without-intl-api"
304
305 ;; Without this gnome-shell will crash at runtime.
306 "--disable-jemalloc")
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
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
407 (define (mozilla-patch file-name changeset hash)
408 "Return an origin for CHANGESET from the mozilla-esr60 repository."
409 (origin
410 (method url-fetch)
411 (uri (string-append "https://hg.mozilla.org/releases/mozilla-esr60/raw-rev/"
412 changeset))
413 (sha256 (base32 hash))
414 (file-name file-name)))
415
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
421 from forcing GEXP-PROMISE."
422 (mlet %store-monad ((guile (package->derivation guile system)))
423 (gexp->derivation (or name "computed-origin")
424 (force gexp-promise)
425 #:graft? #f ;nothing to graft
426 #:system system
427 #:guile-for-build guile)))
428
429 (define %icecat-version "60.8.0-guix1")
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
451 "1gkz90clarbhgfxhq91s0is6lw6bfymyjb0xbyyswdg68kcqfcy1"))))
452
453 (upstream-icecat-base-version "60.7.0") ; maybe older than base-version
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
466 "09xqdfd8rwbn2n6m7n059qf1psbrj5v5kfzm7gg5xng22ddxawv8"))))
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
478 "1vqhb0py28hnwcynbaad304ziciz1kn5bv1qg2q4f7g13js3b1hf"))))
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"
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"))
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")
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
559 (mkdir "l10n")
560 (format #t "Running makeicecat script...~%")
561 (force-output)
562 (invoke "bash" "/tmp/gnuzilla/makeicecat")
563 (delete-file-recursively "l10n"))
564
565 (format #t (string-append "Unpacking l10n/* from"
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
571 (string-append old-icecat-dir "/l10n"))
572
573 (format #t "Packing new IceCat tarball...~%")
574 (force-output)
575 (invoke "tar" "cfa" #$output
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
582 "--owner=root:0"
583 "--group=root:0"
584 "--sort=name"
585 icecat-dir)
586
587 #t))))))))
588
589 (define-public icecat
590 (package
591 (name "icecat")
592 (version %icecat-version)
593 (source icecat-source)
594 (build-system gnu-build-system)
595 (inputs
596 `(("alsa-lib" ,alsa-lib)
597 ("bzip2" ,bzip2)
598 ("cups" ,cups)
599 ("dbus-glib" ,dbus-glib)
600 ("gdk-pixbuf" ,gdk-pixbuf)
601 ("glib" ,glib)
602 ("gtk+" ,gtk+)
603 ("gtk+-2" ,gtk+-2)
604 ("graphite2" ,graphite2)
605 ("pango" ,pango)
606 ("freetype" ,freetype)
607 ("harfbuzz" ,harfbuzz)
608 ("hunspell" ,hunspell)
609 ("libcanberra" ,libcanberra)
610 ("libgnome" ,libgnome)
611 ("libjpeg-turbo" ,libjpeg-turbo)
612 ("libogg" ,libogg)
613 ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
614 ("libvorbis" ,libvorbis)
615 ("libxft" ,libxft)
616 ("libevent" ,libevent)
617 ("libxinerama" ,libxinerama)
618 ("libxscrnsaver" ,libxscrnsaver)
619 ("libxcomposite" ,libxcomposite)
620 ("libxt" ,libxt)
621 ("libffi" ,libffi)
622 ("ffmpeg" ,ffmpeg)
623 ("libvpx" ,libvpx-1.7)
624 ("icu4c" ,icu4c)
625 ("pixman" ,pixman)
626 ("pulseaudio" ,pulseaudio)
627 ("mesa" ,mesa)
628 ("mit-krb5" ,mit-krb5)
629 ;; See <https://bugs.gnu.org/32833>
630 ;; and related comments in the 'remove-bundled-libraries' phase.
631 ;; UNBUNDLE-ME! ("nspr" ,nspr)
632 ;; UNBUNDLE-ME! ("nss" ,nss)
633 ("sqlite" ,sqlite)
634 ("startup-notification" ,startup-notification)
635 ("unzip" ,unzip)
636 ("zip" ,zip)
637 ("zlib" ,zlib)))
638 (native-inputs
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)
654 ("cargo" ,rust-1.24 "cargo")
655 ("llvm" ,llvm-3.9.1)
656 ("clang" ,clang-3.9.1)
657 ("perl" ,perl)
658 ("python" ,python-2) ; Python 3 not supported
659 ("python2-pysqlite" ,python2-pysqlite)
660 ("yasm" ,yasm)
661 ("pkg-config" ,pkg-config)
662 ("autoconf" ,autoconf-2.13)
663 ("which" ,which)))
664 (arguments
665 `(#:tests? #f ; no check target
666 #:out-of-source? #t ; must be built outside of the source directory
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
674 #:configure-flags `("--enable-default-toolkit=cairo-gtk3"
675
676 "--with-distribution-id=org.gnu"
677
678 "--enable-startup-notification"
679 "--enable-pulseaudio"
680
681 "--disable-tests"
682 "--disable-updater"
683 "--disable-crashreporter"
684 "--disable-maintenance-service"
685 "--disable-eme"
686 "--disable-gconf"
687
688 ;; Building with debugging symbols takes ~5GiB, so
689 ;; disable it.
690 "--disable-debug"
691 "--disable-debug-symbols"
692
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
707 ;; Hack to work around missing
708 ;; "unofficial" branding in icecat.
709 "--enable-official-branding"
710
711 ;; Avoid bundled libraries.
712 "--with-system-zlib"
713 "--with-system-bz2"
714 "--with-system-jpeg" ; must be libjpeg-turbo
715 "--with-system-libevent"
716 "--with-system-ogg"
717 "--with-system-vorbis"
718 ;; "--with-system-theora" ; wants theora-1.2, not yet released
719 "--with-system-libvpx"
720 "--with-system-icu"
721
722 ;; See <https://bugs.gnu.org/32833>
723 ;; and related comments in the
724 ;; 'remove-bundled-libraries' phase below.
725 ;; UNBUNDLE-ME! "--with-system-nspr"
726 ;; UNBUNDLE-ME! "--with-system-nss"
727
728 "--with-system-harfbuzz"
729 "--with-system-graphite2"
730 "--enable-system-pixman"
731 "--enable-system-ffi"
732 "--enable-system-hunspell"
733 "--enable-system-sqlite"
734
735 ;; Fails with "--with-system-png won't work because
736 ;; the system's libpng doesn't have APNG support".
737 ;; According to
738 ;; http://sourceforge.net/projects/libpng-apng/ ,
739 ;; "the Animated Portable Network Graphics (APNG)
740 ;; is an unofficial extension of the Portable
741 ;; Network Graphics (PNG) format";
742 ;; we probably do not wish to support it.
743 ;; "--with-system-png"
744 )
745
746 #:imported-modules ,%cargo-utils-modules ;for `generate-checksums'
747
748 #:modules ((ice-9 ftw)
749 (ice-9 rdelim)
750 (ice-9 match)
751 ,@%gnu-build-system-modules)
752 #:phases
753 (modify-phases %standard-phases
754 (add-after 'unpack 'apply-guix-specific-patches
755 (lambda* (#:key inputs native-inputs #:allow-other-keys)
756 (let ((patch (string-append (assoc-ref (or native-inputs inputs)
757 "patch")
758 "/bin/patch")))
759 (for-each (match-lambda
760 ((label . file)
761 (when (and (string-prefix? "icecat-" label)
762 (string-suffix? ".patch" label))
763 (format #t "applying '~a'...~%" file)
764 (invoke patch "--force" "--no-backup-if-mismatch"
765 "-p1" "--input" file))))
766 (or native-inputs inputs)))
767 #t))
768 (add-after 'apply-guix-specific-patches 'remove-bundled-libraries
769 (lambda _
770 ;; Remove bundled libraries that we don't use, since they may
771 ;; contain unpatched security flaws, they waste disk space and
772 ;; memory, and may cause confusion.
773 (for-each (lambda (file)
774 (format #t "deleting '~a'...~%" file)
775 (delete-file-recursively file))
776 '(;; FIXME: Removing the bundled icu breaks configure.
777 ;; * The bundled icu headers are used in some places.
778 ;; * The version number is taken from the bundled copy.
779 ;;"intl/icu"
780 ;;
781 ;; FIXME: A script from the bundled nspr is used.
782 ;;"nsprpub"
783 ;;
784 ;; FIXME: With the update to IceCat 60, using system NSS
785 ;; broke certificate validation. See
786 ;; <https://bugs.gnu.org/32833>. For now, we use
787 ;; the bundled NSPR and NSS. TODO: Investigate,
788 ;; and try to unbundle these libraries again.
789 ;; UNBUNDLE-ME! "security/nss"
790 ;;
791 ;; TODO: Use more system media libraries. See:
792 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
793 ;; * libtheora: esr60 wants v1.2, not yet released.
794 ;; * soundtouch: avoiding the bundled library would
795 ;; result in some loss of functionality. There's
796 ;; also an issue with exception handling
797 ;; configuration. It seems that this is needed in
798 ;; some moz.build:
799 ;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
800 ;; * libopus
801 ;; * speex
802 ;;
803 "modules/freetype2"
804 "modules/zlib"
805 "modules/libbz2"
806 "ipc/chromium/src/third_party/libevent"
807 "media/libjpeg"
808 "media/libvpx"
809 "media/libogg"
810 "media/libvorbis"
811 ;; "media/libtheora" ; wants theora-1.2, not yet released
812 "media/libtremor"
813 "gfx/harfbuzz"
814 "gfx/graphite2"
815 "js/src/ctypes/libffi"
816 "db/sqlite3"))
817 #t))
818 (add-after 'remove-bundled-libraries 'link-libxul-with-libraries
819 (lambda _
820 ;; libxul.so dynamically opens libraries, so here we explicitly
821 ;; link them into libxul.so instead.
822 ;;
823 ;; TODO: It might be preferable to patch in absolute file names in
824 ;; calls to dlopen or PR_LoadLibrary, but that didn't seem to
825 ;; work. More investigation is needed.
826 (substitute* "toolkit/library/moz.build"
827 (("^# This library needs to be last" all)
828 (string-append "OS_LIBS += [
829 'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5',
830 'avcodec', 'avutil', 'pulse' ]\n\n"
831 all)))
832 #t))
833 (replace 'bootstrap
834 (lambda _
835 (invoke "sh" "-c" "autoconf old-configure.in > old-configure")
836 ;; 'configure' must be newer than 'old-configure.in', or else the
837 ;; build system will raise an alarm and abort.
838 (invoke "touch" "configure")))
839 (add-after 'patch-source-shebangs 'patch-cargo-checksums
840 (lambda _
841 (use-modules (guix build cargo-utils))
842 (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
843 (substitute* '("Cargo.lock" "servo/Cargo.lock")
844 (("(\"checksum .* = )\".*\"" all name)
845 (string-append name "\"" null-hash "\"")))
846 (for-each
847 (lambda (filename)
848 (delete-file filename)
849 (let ((dir (dirname filename)))
850 (display (string-append
851 "patch-cargo-checksums: generate-checksums for "
852 dir "\n"))
853 (generate-checksums dir)))
854 (find-files "third_party/rust" ".cargo-checksum.json")))
855 #t))
856 (add-before 'configure 'augment-CPLUS_INCLUDE_PATH
857 (lambda* (#:key build inputs #:allow-other-keys)
858 ;; Here, we add additional entries to CPLUS_INCLUDE_PATH, to work
859 ;; around a problem that otherwise occurs when attempting to
860 ;; build Stylo, which requires Rust and Clang. Without these
861 ;; additional entries, errors occur during the build indicating
862 ;; that the <cstddef> and "c++config.h" headers cannot be found.
863 ;; Note that the 'build' keyword argument contains the GNU
864 ;; triplet, e.g. "x86_64-unknown-linux-gnu".
865 (let ((gcc (assoc-ref inputs "gcc")))
866 (setenv "CPLUS_INCLUDE_PATH"
867 (string-append gcc "/include/c++" ":"
868 gcc "/include/c++/" build)))
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))))
893 (add-before 'configure 'install-desktop-entry
894 (lambda* (#:key outputs #:allow-other-keys)
895 ;; Install the '.desktop' file.
896 (let* ((desktop-file "taskcluster/docker/icecat-snap/icecat.desktop")
897 (out (assoc-ref outputs "out"))
898 (applications (string-append out "/share/applications")))
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)
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"
920 "mozicon128.png" "default256.png"))
921 #t))))
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$"))
930 `("XDG_DATA_DIRS" ":" prefix (,gtk-share)))
931 #t))))))
932 (home-page "https://www.gnu.org/software/gnuzilla/")
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
936 software, which does not recommend non-free plugins and addons. It also
937 features built-in privacy-protecting features.")
938 (license license:mpl2.0) ;and others, see toolkit/content/license.html
939 (properties
940 `((ftp-directory . "/gnu/gnuzilla")
941 (cpe-name . "firefox_esr")
942 (cpe-version . ,(first (string-split version #\-)))))))
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))