gnu: gcc-4.7: Hide package.
[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
ebff3469 429(define %icecat-version "60.6.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
ebff3469 451 "0fvxqxg48c0xrffb720gxfjayz3xqam2xnsz5piri64dcjvxgcyd"))))
948879ee
MW
452
453 (upstream-icecat-base-version "60.3.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 "0icnl64nxcyf7dprpdpygxhabsvyhps8c3ixysj9bcdlj9q34ib1"))))
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 "19wal7hkbb4wvk40hs6d7a5paal2bfday08hwssm02srcbv48fj0"))))
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")
548 (("^sed .* debian/" all)
549 (string-append "echo warning: skipped: " all))
550 (("^debian/rules " all)
551 (string-append "echo warning: skipped: " all))
552 (("^find extensions/gnu/ ")
553 "find extensions/gnu/ | sort ")
554 (("/bin/sed")
555 #+(file-append (canonical-package sed) "/bin/sed"))))
556
557 (format #t "Unpacking upstream firefox tarball...~%")
558 (force-output)
559 (invoke "tar" "xf" #+upstream-firefox-source)
560 (rename-file firefox-dir icecat-dir)
561
562 (with-directory-excursion icecat-dir
563 (for-each mkdir-p '("l10n" "debian/config"))
564 (call-with-output-file "debian/control" (const #t))
565 (format #t "Running makeicecat script...~%")
566 (force-output)
567 (invoke "bash" "/tmp/gnuzilla/makeicecat")
568 (for-each delete-file-recursively '("l10n" "debian")))
569
570 (format #t (string-append "Unpacking l10n/* and debian/* from"
571 " upstream IceCat tarball...~%"))
572 (force-output)
573 (unless (string=? icecat-dir old-icecat-dir)
574 (symlink icecat-dir old-icecat-dir))
575 (invoke "tar" "xf" #+upstream-icecat-source
576 (string-append old-icecat-dir "/l10n")
577 (string-append old-icecat-dir "/debian"))
578
8cf160e1 579 (format #t "Packing new IceCat tarball...~%")
948879ee
MW
580 (force-output)
581 (invoke "tar" "cfa" #$output
8cf160e1
MW
582 ;; Avoid non-determinism in the archive. We set the
583 ;; mtime of files in the archive to early 1980 because
584 ;; the build process fails if the mtime of source
585 ;; files is pre-1980, due to the creation of zip
586 ;; archives.
587 "--mtime=@315619200" ; 1980-01-02 UTC
948879ee
MW
588 "--owner=root:0"
589 "--group=root:0"
590 "--sort=name"
591 icecat-dir)
592
593 #t))))))))
594
be0f6112
AE
595(define-public icecat
596 (package
597 (name "icecat")
24886c13 598 (version %icecat-version)
46ce12d0 599 (source icecat-source)
be0f6112
AE
600 (build-system gnu-build-system)
601 (inputs
602 `(("alsa-lib" ,alsa-lib)
1ae6df81 603 ("bzip2" ,bzip2)
90e1cdae 604 ("cups" ,cups)
be0f6112 605 ("dbus-glib" ,dbus-glib)
90e1cdae
MW
606 ("gdk-pixbuf" ,gdk-pixbuf)
607 ("glib" ,glib)
002c3e6d
MW
608 ("gtk+" ,gtk+)
609 ("gtk+-2" ,gtk+-2)
257e3247 610 ("graphite2" ,graphite2)
74c7af9f
MW
611 ("pango" ,pango)
612 ("freetype" ,freetype)
257e3247 613 ("harfbuzz" ,harfbuzz)
90e1cdae
MW
614 ("hunspell" ,hunspell)
615 ("libcanberra" ,libcanberra)
616 ("libgnome" ,libgnome)
7cba7647 617 ("libjpeg-turbo" ,libjpeg-turbo)
94e96f7f
MW
618 ("libogg" ,libogg)
619 ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
620 ("libvorbis" ,libvorbis)
74c7af9f 621 ("libxft" ,libxft)
94e96f7f 622 ("libevent" ,libevent)
90e1cdae
MW
623 ("libxinerama" ,libxinerama)
624 ("libxscrnsaver" ,libxscrnsaver)
9f7ae77f 625 ("libxcomposite" ,libxcomposite)
be0f6112 626 ("libxt" ,libxt)
1ae6df81 627 ("libffi" ,libffi)
e67ad553 628 ("ffmpeg" ,ffmpeg)
037d5913 629 ("libvpx" ,libvpx-1.7)
13b284d9
MW
630 ("icu4c" ,icu4c)
631 ("pixman" ,pixman)
74c7af9f 632 ("pulseaudio" ,pulseaudio)
be0f6112 633 ("mesa" ,mesa)
90e1cdae 634 ("mit-krb5" ,mit-krb5)
6d328879
MW
635 ;; See <https://bugs.gnu.org/32833>
636 ;; and related comments in the 'snippet' above.
637 ;; UNBUNDLE-ME! ("nspr" ,nspr)
638 ;; UNBUNDLE-ME! ("nss" ,nss)
9bc79c11 639 ("sqlite" ,sqlite)
90e1cdae 640 ("startup-notification" ,startup-notification)
be0f6112 641 ("unzip" ,unzip)
1ae6df81
LC
642 ("zip" ,zip)
643 ("zlib" ,zlib)))
c4c4cc05 644 (native-inputs
46ce12d0
MW
645 ;; The following patches are specific to the Guix packaging of IceCat,
646 ;; and therefore we prefer to leave them out of 'source', which should be
647 ;; a tarball suitable for compilation on any system that IceCat supports.
648 ;; (Bug fixes and security fixes, however, should go in 'source').
649 `(("icecat-avoid-bundled-libraries.patch"
650 ,(search-patch "icecat-avoid-bundled-libraries.patch"))
651 ("icecat-use-system-graphite2+harfbuzz.patch"
652 ,(search-patch "icecat-use-system-graphite2+harfbuzz.patch"))
653 ("icecat-use-system-media-libs.patch"
654 ,(search-patch "icecat-use-system-media-libs.patch"))
655
656 ("patch" ,(canonical-package patch))
657
658 ;; Icecat 60 checks for rust>=1.24
659 ("rust" ,rust-1.24)
89f9df6c 660 ("cargo" ,rust-1.24 "cargo")
8d956d86
MW
661 ("llvm" ,llvm-3.9.1)
662 ("clang" ,clang-3.9.1)
e67ad553 663 ("perl" ,perl)
c4c4cc05
JD
664 ("python" ,python-2) ; Python 3 not supported
665 ("python2-pysqlite" ,python2-pysqlite)
002c3e6d 666 ("yasm" ,yasm)
bfb48f4f 667 ("pkg-config" ,pkg-config)
002c3e6d 668 ("autoconf" ,autoconf-2.13)
bfb48f4f 669 ("which" ,which)))
be0f6112 670 (arguments
74c7af9f
MW
671 `(#:tests? #f ; no check target
672 #:out-of-source? #t ; must be built outside of the source directory
73b1b4eb
LC
673
674 ;; XXX: There are RUNPATH issues such as
675 ;; $prefix/lib/icecat-31.6.0/plugin-container NEEDing libmozalloc.so,
676 ;; which is not in its RUNPATH, but they appear to be harmless in
677 ;; practice somehow. See <http://hydra.gnu.org/build/378133>.
678 #:validate-runpath? #f
679
8d956d86 680 #:configure-flags `("--enable-default-toolkit=cairo-gtk3"
9502ea3e
MW
681
682 "--with-distribution-id=org.gnu"
683
90e1cdae
MW
684 "--enable-startup-notification"
685 "--enable-pulseaudio"
90e1cdae 686
9502ea3e
MW
687 "--disable-tests"
688 "--disable-updater"
689 "--disable-crashreporter"
690 "--disable-maintenance-service"
691 "--disable-eme"
90e1cdae 692 "--disable-gconf"
e67ad553 693
90e1cdae 694 ;; Building with debugging symbols takes ~5GiB, so
1ae6df81
LC
695 ;; disable it.
696 "--disable-debug"
697 "--disable-debug-symbols"
698
8d956d86
MW
699 ;; Clang is needed to build Stylo, Mozilla's new
700 ;; CSS engine. We must specify the clang paths
701 ;; manually, because otherwise the Mozilla build
702 ;; system looks in the directories returned by
703 ;; llvm-config --bindir and llvm-config --libdir,
704 ;; which return paths in the llvm package where
705 ;; clang is not found.
706 ,(string-append "--with-clang-path="
707 (assoc-ref %build-inputs "clang")
708 "/bin/clang")
709 ,(string-append "--with-libclang-path="
710 (assoc-ref %build-inputs "clang")
711 "/lib")
712
5bdec7d6
MW
713 ;; Hack to work around missing
714 ;; "unofficial" branding in icecat.
bfb48f4f
MW
715 "--enable-official-branding"
716
90e1cdae 717 ;; Avoid bundled libraries.
1ae6df81 718 "--with-system-zlib"
90e1cdae 719 "--with-system-bz2"
7cba7647 720 "--with-system-jpeg" ; must be libjpeg-turbo
94e96f7f
MW
721 "--with-system-libevent"
722 "--with-system-ogg"
723 "--with-system-vorbis"
724 ;; "--with-system-theora" ; wants theora-1.2, not yet released
13b284d9 725 "--with-system-libvpx"
483ab08f 726 "--with-system-icu"
6d328879
MW
727
728 ;; See <https://bugs.gnu.org/32833>
729 ;; and related comments in the 'snippet' above.
730 ;; UNBUNDLE-ME! "--with-system-nspr"
731 ;; UNBUNDLE-ME! "--with-system-nss"
732
257e3247
MW
733 "--with-system-harfbuzz"
734 "--with-system-graphite2"
13b284d9 735 "--enable-system-pixman"
5b17fabc 736 "--enable-system-ffi"
90e1cdae 737 "--enable-system-hunspell"
9128e323 738 "--enable-system-sqlite"
1ae6df81 739
98a046cd
AE
740 ;; Fails with "--with-system-png won't work because
741 ;; the system's libpng doesn't have APNG support".
742 ;; According to
743 ;; http://sourceforge.net/projects/libpng-apng/ ,
744 ;; "the Animated Portable Network Graphics (APNG)
745 ;; is an unofficial extension of the Portable
746 ;; Network Graphics (PNG) format";
747 ;; we probably do not wish to support it.
1ae6df81 748 ;; "--with-system-png"
5b17fabc 749 )
1ae6df81 750
7d141788
IP
751 #:imported-modules ,%cargo-utils-modules ;for `generate-checksums'
752
9f7ae77f 753 #:modules ((ice-9 ftw)
6cde5c34
LC
754 (ice-9 rdelim)
755 (ice-9 match)
9f7ae77f 756 ,@%gnu-build-system-modules)
be0f6112 757 #:phases
90e1cdae 758 (modify-phases %standard-phases
46ce12d0
MW
759 (add-after 'unpack 'apply-guix-specific-patches
760 (lambda* (#:key inputs native-inputs #:allow-other-keys)
761 (let ((patch (string-append (assoc-ref (or native-inputs inputs)
762 "patch")
763 "/bin/patch")))
764 (for-each (match-lambda
765 ((label . file)
766 (when (and (string-prefix? "icecat-" label)
767 (string-suffix? ".patch" label))
768 (format #t "applying '~a'...~%" file)
769 (invoke patch "--force" "--no-backup-if-mismatch"
770 "-p1" "--input" file))))
771 (or native-inputs inputs)))
772 #t))
773 (add-after 'apply-guix-specific-patches 'remove-bundled-libraries
774 (lambda _
775 ;; Remove bundled libraries that we don't use, since they may
776 ;; contain unpatched security flaws, they waste disk space and
777 ;; memory, and may cause confusion.
778 (for-each (lambda (file)
779 (format #t "deleting '~a'...~%" file)
780 (delete-file-recursively file))
781 '(;; FIXME: Removing the bundled icu breaks configure.
782 ;; * The bundled icu headers are used in some places.
783 ;; * The version number is taken from the bundled copy.
784 ;;"intl/icu"
785 ;;
786 ;; FIXME: A script from the bundled nspr is used.
787 ;;"nsprpub"
788 ;;
789 ;; FIXME: With the update to IceCat 60, using system NSS
790 ;; broke certificate validation. See
791 ;; <https://bugs.gnu.org/32833>. For now, we use
792 ;; the bundled NSPR and NSS. TODO: Investigate,
793 ;; and try to unbundle these libraries again.
794 ;; UNBUNDLE-ME! "security/nss"
795 ;;
796 ;; TODO: Use more system media libraries. See:
797 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
798 ;; * libtheora: esr60 wants v1.2, not yet released.
799 ;; * soundtouch: avoiding the bundled library would
800 ;; result in some loss of functionality. There's
801 ;; also an issue with exception handling
802 ;; configuration. It seems that this is needed in
803 ;; some moz.build:
804 ;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
805 ;; * libopus
806 ;; * speex
807 ;;
808 "modules/freetype2"
809 "modules/zlib"
810 "modules/libbz2"
811 "ipc/chromium/src/third_party/libevent"
812 "media/libjpeg"
813 "media/libvpx"
814 "media/libogg"
815 "media/libvorbis"
816 ;; "media/libtheora" ; wants theora-1.2, not yet released
817 "media/libtremor"
818 "gfx/harfbuzz"
819 "gfx/graphite2"
820 "js/src/ctypes/libffi"
821 "db/sqlite3"))
822 #t))
823 (add-after 'remove-bundled-libraries 'link-libxul-with-libraries
824 (lambda _
825 ;; libxul.so dynamically opens libraries, so here we explicitly
826 ;; link them into libxul.so instead.
827 ;;
828 ;; TODO: It might be preferable to patch in absolute file names in
829 ;; calls to dlopen or PR_LoadLibrary, but that didn't seem to
830 ;; work. More investigation is needed.
831 (substitute* "toolkit/library/moz.build"
832 (("^# This library needs to be last" all)
833 (string-append "OS_LIBS += [
9f7ae77f 834 'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5',
002c3e6d 835 'avcodec', 'avutil', 'pulse' ]\n\n"
46ce12d0
MW
836 all)))
837 #t))
94e96f7f
MW
838 (replace 'bootstrap
839 (lambda _
46ce12d0
MW
840 (invoke "sh" "-c" "autoconf old-configure.in > old-configure")
841 ;; 'configure' must be newer than 'old-configure.in', or else the
842 ;; build system will raise an alarm and abort.
843 (invoke "touch" "configure")))
e67ad553 844 (add-after 'patch-source-shebangs 'patch-cargo-checksums
257e3247 845 (lambda _
7d141788 846 (use-modules (guix build cargo-utils))
e67ad553
MW
847 (let ((null-file "/dev/null")
848 (null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
849 (substitute* '("Cargo.lock" "servo/Cargo.lock")
850 (("(\"checksum .* = )\".*\"" all name)
851 (string-append name "\"" null-hash "\"")))
852 (for-each
853 (lambda (filename)
854 (delete-file filename)
855 (let ((dir (dirname filename)))
856 (display (string-append
857 "patch-cargo-checksums: generate-checksums for "
858 dir "\n"))
859 (generate-checksums dir null-file)))
860 (find-files "third_party/rust" ".cargo-checksum.json")))
861 #t))
8d956d86
MW
862 (add-before 'configure 'augment-CPLUS_INCLUDE_PATH
863 (lambda* (#:key build inputs #:allow-other-keys)
864 ;; Here, we add additional entries to CPLUS_INCLUDE_PATH, to work
865 ;; around a problem that otherwise occurs when attempting to
866 ;; build Stylo, which requires Rust and Clang. Without these
867 ;; additional entries, errors occur during the build indicating
868 ;; that the <cstddef> and "c++config.h" headers cannot be found.
869 ;; Note that the 'build' keyword argument contains the GNU
870 ;; triplet, e.g. "x86_64-unknown-linux-gnu".
871 (let ((gcc (assoc-ref inputs "gcc")))
872 (setenv "CPLUS_INCLUDE_PATH"
873 (string-append gcc "/include/c++" ":"
874 gcc "/include/c++/" build ":"
46ce12d0
MW
875 (getenv "CPLUS_INCLUDE_PATH"))))
876 #t))
877 (replace 'configure
878 ;; configure does not work followed by both "SHELL=..." and
879 ;; "CONFIG_SHELL=..."; set environment variables instead
880 (lambda* (#:key outputs configure-flags #:allow-other-keys)
881 (let* ((out (assoc-ref outputs "out"))
882 (bash (which "bash"))
883 (abs-srcdir (getcwd))
884 (srcdir (string-append "../" (basename abs-srcdir)))
885 (flags `(,(string-append "--prefix=" out)
886 ,(string-append "--with-l10n-base="
887 abs-srcdir "/l10n")
888 ,@configure-flags)))
889 (setenv "SHELL" bash)
890 (setenv "CONFIG_SHELL" bash)
891 (setenv "AUTOCONF" (which "autoconf")) ; must be autoconf-2.13
892 (setenv "CC" "gcc") ; apparently needed when Stylo is enabled
893 (mkdir "../build")
894 (chdir "../build")
895 (format #t "build directory: ~s~%" (getcwd))
896 (format #t "configure flags: ~s~%" flags)
897 (apply invoke bash
898 (string-append srcdir "/configure")
899 flags))))
6cde5c34
LC
900 (add-before 'configure 'install-desktop-entry
901 (lambda* (#:key outputs #:allow-other-keys)
902 ;; Install the '.desktop' file.
903 (define (swallow-%%-directives input output)
904 ;; Interpret '%%ifdef' directives found in the '.desktop' file.
905 (let loop ((state 'top))
906 (match (read-line input 'concat)
907 ((? eof-object?)
908 #t)
909 ((? string? line)
910 (cond ((string-prefix? "%%ifdef" line)
911 (loop 'ifdef))
912 ((string-prefix? "%%else" line)
913 (loop 'else))
914 ((string-prefix? "%%endif" line)
915 (loop 'top))
916 (else
917 (case state
918 ((top else)
919 (display line output)
920 (loop state))
921 (else
922 (loop state)))))))))
923
924 (let* ((out (assoc-ref outputs "out"))
925 (applications (string-append out "/share/applications")))
926 (call-with-input-file "debian/icecat.desktop.in"
927 (lambda (input)
928 (call-with-output-file "debian/icecat.desktop"
929 (lambda (output)
930 (swallow-%%-directives input output)))))
931
932 (substitute* "debian/icecat.desktop"
933 (("@MOZ_DISPLAY_NAME@")
934 "GNU IceCat")
935 (("^Exec=@MOZ_APP_NAME@")
936 (string-append "Exec=" out "/bin/icecat"))
937 (("@MOZ_APP_NAME@")
938 "icecat"))
939 (install-file "debian/icecat.desktop" applications)
88a8ce87
AG
940 #t)))
941 (add-after 'install-desktop-entry 'install-icons
942 (lambda* (#:key outputs #:allow-other-keys)
943 (let ((out (assoc-ref outputs "out")))
944 (with-directory-excursion "browser/branding/official"
945 (for-each
946 (lambda (file)
947 (let* ((size (string-filter char-numeric? file))
948 (icons (string-append out "/share/icons/hicolor/"
949 size "x" size "/apps")))
950 (mkdir-p icons)
951 (copy-file file (string-append icons "/icecat.png"))))
952 '("default16.png" "default22.png" "default24.png"
953 "default32.png" "default48.png" "content/icon64.png"
3f27124e
MW
954 "mozicon128.png" "default256.png"))
955 #t))))
6e75740f
CL
956 ;; This fixes the file chooser crash that happens with GTK 3.
957 (add-after 'install 'wrap-program
958 (lambda* (#:key inputs outputs #:allow-other-keys)
959 (let* ((out (assoc-ref outputs "out"))
960 (lib (string-append out "/lib"))
961 (gtk (assoc-ref inputs "gtk+"))
962 (gtk-share (string-append gtk "/share")))
963 (wrap-program (car (find-files lib "^icecat$"))
3f27124e
MW
964 `("XDG_DATA_DIRS" ":" prefix (,gtk-share)))
965 #t))))))
6fd52309 966 (home-page "https://www.gnu.org/software/gnuzilla/")
be0f6112
AE
967 (synopsis "Entirely free browser derived from Mozilla Firefox")
968 (description
969 "IceCat is the GNU version of the Firefox browser. It is entirely free
c5779c93 970software, which does not recommend non-free plugins and addons. It also
79c311b8 971features built-in privacy-protecting features.")
63e8bb12 972 (license license:mpl2.0) ;and others, see toolkit/content/license.html
99effc8f
LC
973 (properties
974 `((ftp-directory . "/gnu/gnuzilla")
975 (cpe-name . "firefox_esr")
bfb48f4f 976 (cpe-version . ,(first (string-split version #\-)))))))
f5301f00
LC
977
978(define-public conkeror
979 ;; The Conkeror web browser relied on XULRunner, which IceCat > 50 no longer
980 ;; provides. See <http://conkeror.org> for the original web page.
981 (deprecated-package "conkeror" icecat))