gnu: icecat-source: Make sure 'makeicecat' is the right version.
[guix.git] / gnu / packages / gnuzilla.scm
blobc9b14cfd16232544ad85f012947087306cb9cc7e
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/>.
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))
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
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)))))
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.
203                 "mozjs38-version-detection.patch" ; for 0ad
204                 "mozjs38-tracelogger.patch"
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:]]"))
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"))
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"
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)))))
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"
302            ;; Intl API requires bundled ICU.
303            "--without-intl-api"
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))))))
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)))))
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)))
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)))
429 (define %icecat-version "60.6.2-guix1")
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 #\-)))
437          (major-version (first  (string-split base-version #\.)))
438          (minor-version (second (string-split base-version #\.)))
439          (sub-version   (third  (string-split base-version #\.)))
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               "0fvxqxg48c0xrffb720gxfjayz3xqam2xnsz5piri64dcjvxgcyd"))))
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"))))
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"))))
480          (makeicecat-patch
481           (local-file (search-patch "icecat-makeicecat.patch"))))
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)))
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))
515                 (symlink #+(file-append rename "/bin/rename")
516                          "/tmp/bin/prename")
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"))
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                     (("^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"))))
557                 (format #t "Unpacking upstream firefox tarball...~%")
558                 (force-output)
559                 (invoke "tar" "xf" #+upstream-firefox-source)
560                 (rename-file firefox-dir icecat-dir)
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")))
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"))
579                 (format #t "Packing new IceCat tarball...~%")
580                 (force-output)
581                 (invoke "tar" "cfa" #$output
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
588                         "--owner=root:0"
589                         "--group=root:0"
590                         "--sort=name"
591                         icecat-dir)
593                 #t))))))))
595 (define-public icecat
596   (package
597     (name "icecat")
598     (version %icecat-version)
599     (source
600      (origin
601       (inherit icecat-source)
602       (patches (search-patches "icecat-avoid-bundled-libraries.patch"
603                                "icecat-use-system-graphite2+harfbuzz.patch"
604                                "icecat-use-system-media-libs.patch"))
605       (modules '((guix build utils)))
606       (snippet
607        '(begin
608           (use-modules (ice-9 ftw))
609           ;; Remove bundled libraries that we don't use, since they may
610           ;; contain unpatched security flaws, they waste disk space and
611           ;; network bandwidth, and may cause confusion.
612           (for-each delete-file-recursively
613                     '(;; FIXME: Removing the bundled icu breaks configure.
614                       ;;   * The bundled icu headers are used in some places.
615                       ;;   * The version number is taken from the bundled copy.
616                       ;;"intl/icu"
617                       ;;
618                       ;; FIXME: A script from the bundled nspr is used.
619                       ;;"nsprpub"
620                       ;;
621                       ;; FIXME: With the update to IceCat 60, using system NSS
622                       ;;        broke certificate validation.  See
623                       ;;        <https://bugs.gnu.org/32833>.  For now, we use
624                       ;;        the bundled NSPR and NSS.  TODO: Investigate,
625                       ;;        and try to unbundle these libraries again.
626                       ;; UNBUNDLE-ME! "security/nss"
627                       ;;
628                       ;; TODO: Use more system media libraries.  See:
629                       ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
630                       ;;   * libtheora: esr60 wants v1.2, not yet released.
631                       ;;   * soundtouch: avoiding the bundled library would
632                       ;;     result in some loss of functionality.  There's
633                       ;;     also an issue with exception handling
634                       ;;     configuration.  It seems that this is needed in
635                       ;;     some moz.build:
636                       ;;       DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
637                       ;;   * libopus
638                       ;;   * speex
639                       ;;
640                       "modules/freetype2"
641                       "modules/zlib"
642                       "modules/libbz2"
643                       "ipc/chromium/src/third_party/libevent"
644                       "media/libjpeg"
645                       "media/libvpx"
646                       "media/libogg"
647                       "media/libvorbis"
648                       ;; "media/libtheora" ; wants theora-1.2, not yet released
649                       "media/libtremor"
650                       "gfx/harfbuzz"
651                       "gfx/graphite2"
652                       "js/src/ctypes/libffi"
653                       "db/sqlite3"))
654           ;; Delete .pyc files, typically present in icecat source tarballs
655           (for-each delete-file (find-files "." "\\.pyc$"))
656           ;; Delete obj-* directories, sometimes present in icecat tarballs
657           (for-each delete-file-recursively
658                     (scandir "." (lambda (name)
659                                    (string-prefix? "obj-" name))))
660           #t))))
661     (build-system gnu-build-system)
662     (inputs
663      `(("alsa-lib" ,alsa-lib)
664        ("bzip2" ,bzip2)
665        ("cups" ,cups)
666        ("dbus-glib" ,dbus-glib)
667        ("gdk-pixbuf" ,gdk-pixbuf)
668        ("glib" ,glib)
669        ("gtk+" ,gtk+)
670        ("gtk+-2" ,gtk+-2)
671        ("graphite2" ,graphite2)
672        ("pango" ,pango)
673        ("freetype" ,freetype)
674        ("harfbuzz" ,harfbuzz)
675        ("hunspell" ,hunspell)
676        ("libcanberra" ,libcanberra)
677        ("libgnome" ,libgnome)
678        ("libjpeg-turbo" ,libjpeg-turbo)
679        ("libogg" ,libogg)
680        ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
681        ("libvorbis" ,libvorbis)
682        ("libxft" ,libxft)
683        ("libevent" ,libevent)
684        ("libxinerama" ,libxinerama)
685        ("libxscrnsaver" ,libxscrnsaver)
686        ("libxcomposite" ,libxcomposite)
687        ("libxt" ,libxt)
688        ("libffi" ,libffi)
689        ("ffmpeg" ,ffmpeg)
690        ("libvpx" ,libvpx-1.7)
691        ("icu4c" ,icu4c)
692        ("pixman" ,pixman)
693        ("pulseaudio" ,pulseaudio)
694        ("mesa" ,mesa)
695        ("mit-krb5" ,mit-krb5)
696        ;; See <https://bugs.gnu.org/32833>
697        ;;   and related comments in the 'snippet' above.
698        ;; UNBUNDLE-ME! ("nspr" ,nspr)
699        ;; UNBUNDLE-ME! ("nss" ,nss)
700        ("sqlite" ,sqlite)
701        ("startup-notification" ,startup-notification)
702        ("unzip" ,unzip)
703        ("zip" ,zip)
704        ("zlib" ,zlib)))
705     (native-inputs
706       ;; Icecat 60 checkes for rust>=1.24
707      `(("rust" ,rust-1.24)
708        ("cargo" ,rust-1.24 "cargo")
709        ("llvm" ,llvm-3.9.1)
710        ("clang" ,clang-3.9.1)
711        ("perl" ,perl)
712        ("python" ,python-2) ; Python 3 not supported
713        ("python2-pysqlite" ,python2-pysqlite)
714        ("yasm" ,yasm)
715        ("pkg-config" ,pkg-config)
716        ("autoconf" ,autoconf-2.13)
717        ("which" ,which)))
718     (arguments
719      `(#:tests? #f          ; no check target
720        #:out-of-source? #t  ; must be built outside of the source directory
722        ;; XXX: There are RUNPATH issues such as
723        ;; $prefix/lib/icecat-31.6.0/plugin-container NEEDing libmozalloc.so,
724        ;; which is not in its RUNPATH, but they appear to be harmless in
725        ;; practice somehow.  See <http://hydra.gnu.org/build/378133>.
726        #:validate-runpath? #f
728        #:configure-flags `("--enable-default-toolkit=cairo-gtk3"
730                            "--with-distribution-id=org.gnu"
732                            "--enable-startup-notification"
733                            "--enable-pulseaudio"
735                            "--disable-tests"
736                            "--disable-updater"
737                            "--disable-crashreporter"
738                            "--disable-maintenance-service"
739                            "--disable-eme"
740                            "--disable-gconf"
742                            ;; Building with debugging symbols takes ~5GiB, so
743                            ;; disable it.
744                            "--disable-debug"
745                            "--disable-debug-symbols"
747                            ;; Clang is needed to build Stylo, Mozilla's new
748                            ;; CSS engine.  We must specify the clang paths
749                            ;; manually, because otherwise the Mozilla build
750                            ;; system looks in the directories returned by
751                            ;; llvm-config --bindir and llvm-config --libdir,
752                            ;; which return paths in the llvm package where
753                            ;; clang is not found.
754                            ,(string-append "--with-clang-path="
755                                            (assoc-ref %build-inputs "clang")
756                                            "/bin/clang")
757                            ,(string-append "--with-libclang-path="
758                                            (assoc-ref %build-inputs "clang")
759                                            "/lib")
761                            ;; Hack to work around missing
762                            ;; "unofficial" branding in icecat.
763                            "--enable-official-branding"
765                            ;; Avoid bundled libraries.
766                            "--with-system-zlib"
767                            "--with-system-bz2"
768                            "--with-system-jpeg"        ; must be libjpeg-turbo
769                            "--with-system-libevent"
770                            "--with-system-ogg"
771                            "--with-system-vorbis"
772                            ;; "--with-system-theora" ; wants theora-1.2, not yet released
773                            "--with-system-libvpx"
774                            "--with-system-icu"
775                            
776                            ;; See <https://bugs.gnu.org/32833>
777                            ;;   and related comments in the 'snippet' above.
778                            ;; UNBUNDLE-ME! "--with-system-nspr"
779                            ;; UNBUNDLE-ME! "--with-system-nss"
780                            
781                            "--with-system-harfbuzz"
782                            "--with-system-graphite2"
783                            "--enable-system-pixman"
784                            "--enable-system-ffi"
785                            "--enable-system-hunspell"
786                            "--enable-system-sqlite"
788                            ;; Fails with "--with-system-png won't work because
789                            ;; the system's libpng doesn't have APNG support".
790                            ;; According to
791                            ;; http://sourceforge.net/projects/libpng-apng/ ,
792                            ;; "the Animated Portable Network Graphics (APNG)
793                            ;; is an unofficial extension of the Portable
794                            ;; Network Graphics (PNG) format";
795                            ;; we probably do not wish to support it.
796                            ;; "--with-system-png"
797                            )
799        #:imported-modules ,%cargo-utils-modules ;for `generate-checksums'
801        #:modules ((ice-9 ftw)
802                   (ice-9 rdelim)
803                   (ice-9 match)
804                   ,@%gnu-build-system-modules)
805        #:phases
806        (modify-phases %standard-phases
807          (add-after
808           'unpack 'ensure-no-mtimes-pre-1980
809           (lambda _
810             ;; Without this, the 'source/test/addons/packed.xpi' and
811             ;; 'source/test/addons/simple-prefs.xpi' targets fail while trying
812             ;; to create zip archives.
813             (let ((early-1980 315619200)) ; 1980-01-02 UTC
814               (ftw "." (lambda (file stat flag)
815                          (unless (<= early-1980 (stat:mtime stat))
816                            (utime file early-1980 early-1980))
817                          #t))
818               #t)))
819          (add-after
820           'unpack 'link-libxul-with-libraries
821           (lambda _
822             ;; libxul.so dynamically opens libraries, so here we explicitly
823             ;; link them into libxul.so instead.
824             ;;
825             ;; TODO: It might be preferable to patch in absolute file names in
826             ;; calls to dlopen or PR_LoadLibrary, but that didn't seem to
827             ;; work.  More investigation is needed.
828             (substitute* "toolkit/library/moz.build"
829               (("^# This library needs to be last" all)
830                (string-append "OS_LIBS += [
831     'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5',
832     'avcodec', 'avutil', 'pulse' ]\n\n"
833                               all)))
834             #t))
835          (replace 'bootstrap
836            (lambda _
837              (invoke "sh" "-c" "autoconf old-configure.in > old-configure")))
838          (add-after 'patch-source-shebangs 'patch-cargo-checksums
839            (lambda _
840              (use-modules (guix build cargo-utils))
841              (let ((null-file "/dev/null")
842                    (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 null-file)))
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                                       (getenv "CPLUS_INCLUDE_PATH"))))))
870          (replace
871           'configure
872           ;; configure does not work followed by both "SHELL=..." and
873           ;; "CONFIG_SHELL=..."; set environment variables instead
874           (lambda* (#:key outputs configure-flags #:allow-other-keys)
875             (let* ((out (assoc-ref outputs "out"))
876                    (bash (which "bash"))
877                    (abs-srcdir (getcwd))
878                    (srcdir (string-append "../" (basename abs-srcdir)))
879                    (flags `(,(string-append "--prefix=" out)
880                             ,(string-append "--with-l10n-base="
881                                             abs-srcdir "/l10n")
882                             ,@configure-flags)))
883               (setenv "SHELL" bash)
884               (setenv "CONFIG_SHELL" bash)
885               (setenv "AUTOCONF" (which "autoconf")) ; must be autoconf-2.13
886               (setenv "CC" "gcc")  ; apparently needed when Stylo is enabled
887               (mkdir "../build")
888               (chdir "../build")
889               (format #t "build directory: ~s~%" (getcwd))
890               (format #t "configure flags: ~s~%" flags)
891               (apply invoke bash
892                      (string-append srcdir "/configure")
893                      flags))))
894          (add-before 'configure 'install-desktop-entry
895            (lambda* (#:key outputs #:allow-other-keys)
896              ;; Install the '.desktop' file.
897              (define (swallow-%%-directives input output)
898                ;; Interpret '%%ifdef' directives found in the '.desktop' file.
899                (let loop ((state 'top))
900                  (match (read-line input 'concat)
901                    ((? eof-object?)
902                     #t)
903                    ((? string? line)
904                     (cond ((string-prefix? "%%ifdef" line)
905                            (loop 'ifdef))
906                           ((string-prefix? "%%else" line)
907                            (loop 'else))
908                           ((string-prefix? "%%endif" line)
909                            (loop 'top))
910                           (else
911                            (case state
912                              ((top else)
913                               (display line output)
914                               (loop state))
915                              (else
916                               (loop state)))))))))
918              (let* ((out (assoc-ref outputs "out"))
919                     (applications (string-append out "/share/applications")))
920                (call-with-input-file "debian/icecat.desktop.in"
921                  (lambda (input)
922                    (call-with-output-file "debian/icecat.desktop"
923                      (lambda (output)
924                        (swallow-%%-directives input output)))))
926                (substitute* "debian/icecat.desktop"
927                  (("@MOZ_DISPLAY_NAME@")
928                   "GNU IceCat")
929                  (("^Exec=@MOZ_APP_NAME@")
930                   (string-append "Exec=" out "/bin/icecat"))
931                  (("@MOZ_APP_NAME@")
932                   "icecat"))
933                (install-file "debian/icecat.desktop" applications)
934                #t)))
935          (add-after 'install-desktop-entry 'install-icons
936            (lambda* (#:key outputs #:allow-other-keys)
937              (let ((out (assoc-ref outputs "out")))
938                (with-directory-excursion "browser/branding/official"
939                  (for-each
940                   (lambda (file)
941                     (let* ((size (string-filter char-numeric? file))
942                            (icons (string-append out "/share/icons/hicolor/"
943                                                  size "x" size "/apps")))
944                       (mkdir-p icons)
945                       (copy-file file (string-append icons "/icecat.png"))))
946                   '("default16.png" "default22.png" "default24.png"
947                     "default32.png" "default48.png" "content/icon64.png"
948                     "mozicon128.png" "default256.png"))
949                  #t))))
950          ;; This fixes the file chooser crash that happens with GTK 3.
951          (add-after 'install 'wrap-program
952            (lambda* (#:key inputs outputs #:allow-other-keys)
953              (let* ((out (assoc-ref outputs "out"))
954                     (lib (string-append out "/lib"))
955                     (gtk (assoc-ref inputs "gtk+"))
956                     (gtk-share (string-append gtk "/share")))
957                (wrap-program (car (find-files lib "^icecat$"))
958                  `("XDG_DATA_DIRS" ":" prefix (,gtk-share)))
959                #t))))))
960     (home-page "https://www.gnu.org/software/gnuzilla/")
961     (synopsis "Entirely free browser derived from Mozilla Firefox")
962     (description
963      "IceCat is the GNU version of the Firefox browser.  It is entirely free
964 software, which does not recommend non-free plugins and addons.  It also
965 features built-in privacy-protecting features.")
966     (license license:mpl2.0)     ;and others, see toolkit/content/license.html
967     (properties
968      `((ftp-directory . "/gnu/gnuzilla")
969        (cpe-name . "firefox_esr")
970        (cpe-version . ,(first (string-split version #\-)))))))
972 (define-public conkeror
973   ;; The Conkeror web browser relied on XULRunner, which IceCat > 50 no longer
974   ;; provides.  See <http://conkeror.org> for the original web page.
975   (deprecated-package "conkeror" icecat))