acdbe5ca3714f6fd9b45b25a496dc69ab19b3e8a
[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, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2016, 2017, 2018, 2019, 2021 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, 2018 Nikita <nikita@n0.is>
10 ;;; Copyright © 2017, 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2018, 2020 Ricardo Wurmus <rekado@elephly.net>
12 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
13 ;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
14 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
15 ;;; Copyright © 2019, 2020 Adrian Malacoda <malacoda@monarch-pass.net>
16 ;;; Copyright © 2020, 2021, 2022 Jonathan Brielmaier <jonathan.brielmaier@web.de>
17 ;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org>
18 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
19 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
20 ;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
21 ;;; Copyright © 2021 Baptiste Strazzul <bstrazzull@hotmail.fr>
22 ;;;
23 ;;; This file is part of GNU Guix.
24 ;;;
25 ;;; GNU Guix is free software; you can redistribute it and/or modify it
26 ;;; under the terms of the GNU General Public License as published by
27 ;;; the Free Software Foundation; either version 3 of the License, or (at
28 ;;; your option) any later version.
29 ;;;
30 ;;; GNU Guix is distributed in the hope that it will be useful, but
31 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
32 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 ;;; GNU General Public License for more details.
34 ;;;
35 ;;; You should have received a copy of the GNU General Public License
36 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
37
38 (define-module (gnu packages gnuzilla)
39 #:use-module ((srfi srfi-1) #:hide (zip))
40 #:use-module (ice-9 format)
41 #:use-module (ice-9 match)
42 #:use-module (gnu packages)
43 #:use-module ((guix licenses) #:prefix license:)
44 #:use-module (guix packages)
45 #:use-module (guix download)
46 #:use-module (guix git-download)
47 #:use-module (guix hg-download)
48 #:use-module (guix gexp)
49 #:use-module (guix store)
50 #:use-module (guix modules)
51 #:use-module (guix monads)
52 #:use-module (guix utils)
53 #:use-module (guix build-system gnu)
54 #:use-module (guix build-system cargo)
55 #:use-module (guix build-system trivial)
56 #:use-module (gnu packages admin)
57 #:use-module (gnu packages audio)
58 #:use-module (gnu packages autotools)
59 #:use-module (gnu packages m4)
60 #:use-module (gnu packages base)
61 #:use-module (gnu packages bash)
62 #:use-module (gnu packages databases)
63 #:use-module (gnu packages glib)
64 #:use-module (gnu packages gtk)
65 #:use-module (gnu packages gnome)
66 #:use-module (gnu packages libcanberra)
67 #:use-module (gnu packages cups)
68 #:use-module (gnu packages kerberos)
69 #:use-module (gnu packages linux)
70 #:use-module (gnu packages perl)
71 #:use-module (gnu packages pkg-config)
72 #:use-module (gnu packages compression)
73 #:use-module (gnu packages fontutils)
74 #:use-module (gnu packages fonts)
75 #:use-module (gnu packages hunspell)
76 #:use-module (gnu packages libevent)
77 #:use-module (gnu packages image)
78 #:use-module (gnu packages libffi)
79 #:use-module (gnu packages pulseaudio)
80 #:use-module (gnu packages python)
81 #:use-module (gnu packages python-xyz)
82 #:use-module (gnu packages node)
83 #:use-module (gnu packages xorg)
84 #:use-module (gnu packages gl)
85 #:use-module (gnu packages pciutils)
86 #:use-module (gnu packages assembly)
87 #:use-module (gnu packages rust)
88 #:use-module (gnu packages rust-apps)
89 #:use-module (gnu packages llvm)
90 #:use-module (gnu packages nss)
91 #:use-module (gnu packages icu4c)
92 #:use-module (gnu packages video)
93 #:use-module (gnu packages xiph)
94 #:use-module (gnu packages xdisorg)
95 #:use-module (gnu packages readline)
96 #:use-module (gnu packages sqlite)
97 #:autoload (json parser) (json->scm))
98
99 (define-public mozjs
100 (package
101 (name "mozjs")
102 (version "102.2.0")
103 (source (origin
104 (method url-fetch)
105 ;; TODO: Switch to IceCat source once available on ftp.gnu.org.
106 (uri (string-append "https://ftp.mozilla.org/pub/firefox"
107 "/releases/" version "esr/source/firefox-"
108 version "esr.source.tar.xz"))
109 (sha256
110 (base32
111 "1zwpgis7py1bf8p88pz3mpai6a02qrdb8ww2fa9kxxdl9b8r2k81"))))
112 (build-system gnu-build-system)
113 (arguments
114 (list
115 #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
116 #:modules `((guix build cargo-utils)
117 ,@%gnu-build-system-modules)
118 #:test-target "check-jstests"
119 #:configure-flags
120 #~(list
121 ;; Disable debugging symbols to save space.
122 "--disable-debug"
123 "--disable-debug-symbols"
124 ;; This is important because without it gjs will segfault during the
125 ;; configure phase. With jemalloc only the standalone mozjs console
126 ;; will work.
127 "--disable-jemalloc"
128 "--enable-tests"
129 "--enable-hardening"
130 "--enable-optimize"
131 "--enable-release"
132 "--enable-readline"
133 "--enable-shared-js"
134 "--with-system-icu"
135 "--with-system-nspr"
136 "--with-system-zlib"
137 "--with-intl-api")
138 #:phases
139 #~(modify-phases %standard-phases
140 (add-after 'patch-source-shebangs 'patch-cargo-checksums
141 (lambda _
142 (let ((null-hash
143 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
144 (for-each (lambda (file)
145 (format #t "patching checksums in ~a~%" file)
146 (substitute* file
147 (("^checksum = \".*\"")
148 (string-append "checksum = \"" null-hash "\""))))
149 (find-files "." "Cargo\\.lock$"))
150 (for-each generate-all-checksums
151 '("js" "third_party/rust")))))
152 (replace 'configure
153 (lambda* (#:key configure-flags #:allow-other-keys)
154 ;; The configure script does not accept environment variables as
155 ;; arguments. It also must be run from a different directory,
156 ;; but not the root directory either.
157 (mkdir "run-configure-from-here")
158 (chdir "run-configure-from-here")
159 (setenv "SHELL" (which "sh"))
160 (setenv "CONFIG_SHELL" (which "sh"))
161 (setenv "AUTOCONF" (which "autoconf"))
162 (apply invoke "python" "../configure.py"
163 "--enable-project=js"
164 (string-append "--prefix=" #$output)
165 configure-flags)))
166 (add-before 'check 'adjust-tests
167 (lambda _
168 (with-directory-excursion "../js/src/tests"
169 (substitute* "shell/os.js"
170 ;; FIXME: Why does the killed process have an exit status?
171 ((".*killed process should not have exitStatus.*")
172 ""))
173
174 ;; The test suite expects a lightly patched ICU. Disable tests
175 ;; that do not work with the system version. See
176 ;; "intl/icu-patches" for clues.
177
178 ;; See <https://unicode-org.atlassian.net/browse/ICU-20992> and
179 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=1636984> and
180 ;; related patch for why this is failing.
181 (delete-file "non262/Intl/DateTimeFormat/\
182 fractional-second-digits-append-item.js")
183 ;; FIXME: got "0 \u251CAM/PM: noon\u2524", expected "0 (AM/PM: noon)"
184 (delete-file "non262/Intl/DateTimeFormat/day-period-hour-cycle.js")
185 ;; FIXME: got "en-US-posix", expected "en-US-POSIX".
186 (delete-file "non262/Intl/available-locales-supported.js")
187 ;; FIXME: got "en-US", expected "en-US-POSIX"
188 (delete-file "non262/Intl/available-locales-resolved.js"))))
189 (add-before 'check 'pre-check
190 (lambda _
191 (setenv "JSTESTS_EXTRA_ARGS"
192 (string-join
193 (list
194 ;; Do not run tests marked as "random".
195 "--exclude-random"
196 ;; Exclude web platform tests.
197 "--wpt=disabled"
198 ;; Respect the daemons configured number of jobs.
199 (string-append "--worker-count="
200 (number->string (parallel-job-count)))))))))))
201 (native-inputs
202 (list autoconf
203 llvm ;for llvm-objdump
204 m4
205 perl
206 pkg-config
207 python-wrapper
208 rust
209 `(,rust "cargo")))
210 (inputs
211 (list icu4c-71 readline zlib))
212 (propagated-inputs
213 (list nspr)) ; in the Requires.private field of mozjs-*.pc
214 (home-page
215 "https://spidermonkey.dev/")
216 (synopsis "Mozilla JavaScript engine")
217 (description "SpiderMonkey is Mozilla's JavaScript engine written
218 in C/C++.")
219 (license license:mpl2.0))) ; and others for some files
220
221 (define-public mozjs-91
222 (package
223 (inherit mozjs)
224 (version "91.13.0")
225 (source (origin
226 (method url-fetch)
227 (uri (string-append "https://ftp.mozilla.org/pub/firefox"
228 "/releases/" version "esr/source/firefox-"
229 version "esr.source.tar.xz"))
230 (sha256
231 (base32
232 "0qh7j960wdp5zcfqhkj8ki47spp9i9ms12xx0v0kxvmmw36jpgjk"))))
233 (arguments
234 (substitute-keyword-arguments (package-arguments mozjs)
235 ((#:phases phases)
236 #~(modify-phases #$phases
237 (add-before 'check 'disable-timezone-tests
238 (lambda _
239 (with-directory-excursion "../js/src/tests"
240 ;; FIXME: Assertion failed: got "2021a", expected "2021a3"?
241 (delete-file "non262/Intl/DateTimeFormat/timeZone_version.js")
242 ;; XXX: Delete all tests that test time zone functionality,
243 ;; because the test suite uses /etc/localtime to figure out
244 ;; the offset from the hardware clock, which does not work
245 ;; in the build container. See <tests/non262/Date/shell.js>.
246 (delete-file-recursively "non262/Date")
247 (delete-file
248 "non262/Intl/DateTimeFormat/tz-environment-variable.js"))))))))
249 (inputs (modify-inputs (package-inputs mozjs)
250 (replace "icu4c" icu4c)))))
251
252 (define-public mozjs-78
253 (package
254 (inherit mozjs)
255 (name "mozjs")
256 (version "78.15.0")
257 (source (origin
258 (method url-fetch)
259 (uri (string-append "https://archive.mozilla.org/pub/firefox"
260 "/releases/" version "esr/source/firefox-"
261 version "esr.source.tar.xz"))
262 (sha256
263 (base32
264 "0l91cxdc5v9fps79ckb1kid4gw6v5qng1jd9zvaacwaiv628shx4"))))
265 (build-system gnu-build-system)
266 (arguments
267 (substitute-keyword-arguments (package-arguments mozjs)
268 ((#:phases phases)
269 #~(modify-phases #$phases
270 (replace 'configure
271 (lambda* (#:key configure-flags #:allow-other-keys)
272 ;; The configure script does not accept environment variables as
273 ;; arguments. It also must be run from a different directory,
274 ;; but not the root directory either.
275 (mkdir "run-configure-from-here")
276 (chdir "run-configure-from-here")
277 (setenv "SHELL" (which "sh"))
278 (setenv "CONFIG_SHELL" (which "sh"))
279 (setenv "AUTOCONF" (which "autoconf"))
280 (apply invoke "../js/src/configure"
281 (cons (string-append "--prefix=" #$output)
282 configure-flags))))
283 (replace 'adjust-tests
284 (lambda _
285 (with-directory-excursion "../js/src/tests"
286 ;; The test suite expects a lightly patched ICU 67. Since
287 ;; Guix is about to switch to ICU 68, massage the tests to
288 ;; work with that instead of patching ICU. Try removing this
289 ;; phase for newer versions of mozjs.
290
291 ;; These tests look up locale names and expects to get
292 ;; "GB" instead of "UK".
293 (substitute* "non262/Intl/DisplayNames/language.js"
294 (("Traditionell, GB")
295 "Traditionell, UK"))
296 (substitute* "non262/Intl/DisplayNames/region.js"
297 (("\"GB\": \"GB\"")
298 "\"GB\": \"UK\""))
299
300 ;; XXX: Some localized time formats have changed, and
301 ;; substitution fails for accented characters, even though
302 ;; it works in the REPL(?). Just delete these for now.
303 (delete-file "non262/Intl/Date/toLocaleString_timeZone.js")
304 (delete-file "non262/Intl/Date/toLocaleDateString_timeZone.js")
305
306 ;; Similarly, these get an unexpected "A" suffix when looking
307 ;; up a time in the "ar-MA-u-ca-islamicc" locale, which is
308 ;; tricky to substitute.
309 (delete-file "non262/Intl/DateTimeFormat/format_timeZone.js")
310 (delete-file "non262/Intl/DateTimeFormat/format.js")
311
312 ;; This file compares a generated list of ICU locale names
313 ;; with actual lookups. Some have changed slightly, i.e.
314 ;; daf-Latn-ZZ -> daf-Latn-CI, so drop it for simplicity.
315 (delete-file "non262/Intl/Locale/likely-subtags-generated.js"))))
316 (replace 'pre-check
317 (lambda _
318 (with-directory-excursion "../js/src/tests"
319 (substitute* "shell/os.js"
320 ;; FIXME: Why does the killed process have an exit status?
321 ((".*killed process should not have exitStatus.*")
322 ""))
323
324 ;; XXX: Delete all tests that test time zone functionality,
325 ;; because the test suite uses /etc/localtime to figure out
326 ;; the offset from the hardware clock, which does not work
327 ;; in the build container. See <tests/non262/Date/shell.js>.
328 (delete-file-recursively "non262/Date")
329 (delete-file "non262/Intl/DateTimeFormat/tz-environment-variable.js")
330
331 (setenv "JSTESTS_EXTRA_ARGS"
332 (string-join
333 (list
334 ;; Do not run tests marked as "random".
335 "--exclude-random"
336 ;; Exclude web platform tests.
337 "--wpt=disabled"
338 ;; Respect the daemons configured number of jobs.
339 (string-append "--worker-count="
340 (number->string
341 (parallel-job-count)))))))))))))
342 (native-inputs
343 (list autoconf-2.13
344 automake
345 llvm ;for llvm-objdump
346 perl
347 pkg-config
348 python-3
349 rust
350 `(,rust "cargo")))
351 (inputs
352 (list icu4c readline zlib))))
353
354 \f
355 ;;;
356 ;;; Localization helper procedures.
357 ;;;
358 (define mozilla-compare-locales
359 (origin
360 (method hg-fetch)
361 (uri (hg-reference
362 (url "https://hg.mozilla.org/l10n/compare-locales/")
363 (changeset "RELEASE_8_1_0")))
364 (file-name "mozilla-compare-locales")
365 (sha256 (base32 "00bpkaqf2ng1nn9ajyb5mli0jq58q5fm2n3yy90jy0hp4q2gbs50"))))
366
367 (define (mozilla-locale locale changeset hash-string)
368 (origin
369 (method hg-fetch)
370 (uri (hg-reference
371 (url (string-append "https://hg.mozilla.org/l10n-central/"
372 locale))
373 (changeset changeset)))
374 (file-name (string-append "mozilla-locale-" locale))
375 (sha256 (base32 hash-string))))
376
377 (define-syntax-rule (mozilla-locales (hash-string changeset locale) ...)
378 (list (mozilla-locale locale changeset hash-string)
379 ...))
380
381 (define (update-mozilla-locales changesets.json)
382 "Output a new list of Mozilla locales, to update the ALL-MOZILLA-LOCALES
383 variable defined below. It requires guile-json to be installed."
384 (match (call-with-input-file changesets.json json->scm)
385 (((lang ("revision" . revision) platforms pin) ...)
386 (let ((data (reverse (map (lambda (rev lang)
387 `(,(list->string (make-list 40 #\0))
388 ,(string-take rev 12) ,lang))
389 revision lang))))
390 (format #t "~{~s~%~}" data)
391 data))))
392
393 (define all-mozilla-locales
394 (mozilla-locales
395 ;; sha256 changeset locale
396 ;;---------------------------------------------------------------------------
397 ("1s59ihmj8x6z0ssq4xav689jb5azrpdnay8csgjm1b9pw7wmvcli" "a6940ae1a02f" "ach")
398 ("1cqixlk9f8p63jz20wzsvnfb7xa82ba725gzdydlwz2axgp09c26" "4e2c7d1ddbed" "af")
399 ("19r1yhmfxqasyslc8gr9as5w1scscz1xr8iqy9zi4b90fdjzs0ac" "06897e40a7ea" "an")
400 ("0nfknb1p03j9fgmkwlm1mzdyh10g0l33x34ab39kc072apziyv0n" "9272819b09e2" "ar")
401 ("11qqblqfffbmkdr5b6mxzq02i8rj1hjq3iy6xv5i5xxy311b3vpb" "f706d22e6910" "ast")
402 ("0q2p1a437qr2nshdd4934qkv2sblmykiwzir149c8p9m5sjk0dyw" "f5c2a9800add" "az")
403 ("0gxxm3lv18kj0922bw0g897azc4nkrszm5irgwdkgmkbyr97li83" "98ba7d51484f" "be")
404 ("10vrbbaabjns824ndya6c09znm815pak2xpvqgjydl3r5qvacx65" "5c79c77311cd" "bg")
405 ("1il7yyifx5xzj0v2lna315mppl5pk1vi4m9r66hdz1lzc485m1wp" "c80c87ef7193" "bn")
406 ("1p1ig4v9pczzrnnxzr20r61g7xk85k5lgnxhzgn1rx518p85xrkm" "6a1bcb9851b2" "br")
407 ("08q33bk9kdvbyc4ib58bsn2b67ki3d2yzskkf5r2n5zlglblksa2" "939779cb58d6" "bs")
408 ("1bdkywrqah85fh8kfnz163qnc02ffx0a4vlnx5pq1wg9j4f1gznf" "9a45ccf144f1" "ca")
409 ("0hhmp5dzc0rssykl0b2n9h0vfy4svwhxmhpsr3rcfpbg2s0r5h6l" "4f60e18fc248" "ca-valencia")
410 ("18phbl9raqsbys9wa8z0gq0h0pw3b55v6ngn67r4373lfc0s9cxv" "b4ef404c7de8" "cak")
411 ("0147qyw1y97mgqhkb46wblxv61lq2mvvm5n5ihwf49l5cyizi0jg" "f56ef18f05df" "cs")
412 ("08sbhnsxndlsaijnxndc367qcbrzb29m7bpkcawinz9fg6mz3573" "4f9d92f04f5e" "cy")
413 ("09cm5kk1sh2a6ws1fj185jrknhfa6n4bhj7nfnr4lsk339n0kvv9" "902503567e30" "da")
414 ("0r630bki5d4ylicq6lzh6s2mvsq225933szswmm0sap507rj75cm" "6000baf7a412" "de")
415 ("0749qjsfv3rn94rnci3ydgndw27qlr3w3w97kfwma2gmsf3m3r0p" "4a948952d1f4" "dsb")
416 ("0yc64i7mpxhs4qlyyh59i2aiz0vpap0bn8slcsk8b71wd1d7cy5m" "153a16a13733" "el")
417 ("0d4m5ji6ii10yap8y24cxx3fr60ba1jqi10hy3j1cq6ni7hzavga" "7ce17ae529ac" "en-CA")
418 ("12jzqcfbgdhfm8f2gqp15bdnin62li07jwicjc8ynn4cl9a19xiz" "a25d9eea7c23" "en-GB")
419 ("0gbb8hfc5yvjah63mapjxm53wxrf98srbrbg43b9g734zfi4n8y5" "4ed3471dad5d" "eo")
420 ("19lw7zmqx2irjmv5y6r7nncp6nysn06abf10n3dzj5nzgays6sln" "853fe7acb415" "es-AR")
421 ("0rq4pa380b77rkv6dq7sqx8a8i33jk3vs5rgcl8fv7slqvsw23kd" "921b67bf27a5" "es-CL")
422 ("1dyxzab9hln5spch66wmfagfzmfdiaxgpq7qlzvdfg98wkqdj25n" "c9a210ea496c" "es-ES")
423 ("1gwpmfl37wxl7rynqswgj41liljflgxydvljd4zdhk3jzqn605fb" "ddd35183d81c" "es-MX")
424 ("0c3blniddklapifnjbz03f2frw24jjgwgwn6swl5mwm2z0y6wa9f" "82d23ffaa7d3" "et")
425 ("05mq2df6n6fr8m5m2xwl0f6n1q3zgjrnk465ldx1nfr9agrhd36c" "13975626d549" "eu")
426 ("1l1jyqqiy551903j6yzh9ayg1pf26q2hr9h3jj4l51xzp7x4ms2q" "039e1fdb7c71" "fa")
427 ("091l05y9sggxznv0y11b9zy5qf146p0hb5faw4ix7yn5p5kca2f5" "7bd3722d82de" "ff")
428 ("1lllwjvmbl5dx44fcvsqg08fbflkc8dx5as9n6nf4xlkzydx6izm" "39808e88c9d1" "fi")
429 ("10ha955vvyf5vbciricm72kplj9j0s00g2333lmg46jiwi7aviiv" "426d373db6a7" "fr")
430 ("11zdfk8jvdy1k9z1q162cwapplcbz35l3dq4mv45brdin3v0x8kr" "96cd93d18389" "fy-NL")
431 ("1l5xr25gmssyachwmfprlnp2v2xj4b0hp8gxrf7fi5bvv9c2fynb" "de3daf7d3f9d" "ga-IE")
432 ("06h9ijfsn1cgz5fvxxbisk7fvqhgsw99id92575hgyg1p8xb1n69" "f04aea656d9e" "gd")
433 ("19913i5n8yyfhz9j21krlk7wqsyy89vggxc1m1swv94y2ix8rpaj" "1b8cdb87bf69" "gl")
434 ("0k5x31bfl2l0r9b5dkn03frm1gd8n6igai7ch2f1kj0skflynwww" "82df570c4241" "gn")
435 ("03rygnj9xhfvykark7dls117kwhid13ghvrsqiial0vp8m7ymx79" "e2e41d7beaa5" "gu-IN")
436 ("0vyraplj1x7b5im15anhzdaq03k2gqfyybgklrd4f9ry6msh5jhx" "de724e943805" "he")
437 ("1zqps586jrgxpf7xx2l3qw3ch3fr31r9a25y861fpxrpvh7ygw7g" "898598e1a5c6" "hi-IN")
438 ("0czq68l3qdhdc0mgazlrh8x83a6d5qrjwgjv8xvsmmzi7h68ww0l" "2711d1515af0" "hr")
439 ("1wwvrnm38gk2rnw4vmcranh8hk61gjcj9292pck3ckiv6mq7kd4s" "03e02f3d0676" "hsb")
440 ("0yvgdxlbyhhg3lk43hxx9gx66rcm7gaj02zzzx5zni8dhvlk2v6m" "d423ada9dc00" "hu")
441 ("1kjm7bg4990jhfbxwc38r4lqm2fbcxc82nc2d4qkqwikr4aah4b9" "06836af0bd6e" "hy-AM")
442 ("1dla7r3snvagb7m985xxqyi7gl498cr5xsz8msw0zpg6xmi05rlx" "299bd950d538" "ia")
443 ("0w8w9xn93akir7nqcp5iwr3kqvba5gbirg7gmzlzg7mgrhw8pcsa" "dee087477b99" "id")
444 ("10iakv1c1d20ihxg1s7c3zc1zfw18vr2kspcw7bk5k02rmrffgcn" "320095d063ed" "is")
445 ("1xn5pa3rc7l6k2migm3c0dx71q1hk7mjls045xpv9cy8gvirnj94" "4722680fb5bf" "it")
446 ("0va9zfj3wqh1yvbgh3x808yvdyxkg780vazjg887wbxpfk1n6hxa" "cb3cfe294621" "ja")
447 ("0qvjc3fhk6jg2c3g6mymmnslg1rkkxmv9gi3whf2bc5mzfgyc5zw" "7efe92bd7780" "ja-JP-mac")
448 ("0zfiwwz0axbd219ar32c7a6b8h816sf04ajx6jl74s5kyij79y82" "4c1fe3a18da9" "ka")
449 ("1aiik4758r5df76q2a132y5fjdjrsxshjylk7irwsr7yy0c7f63g" "acdf76048aa0" "kab")
450 ("0icxh4sgv6m1yykycb9d9c43k3r6w02f9c6jr04wm8hvqq5icfl5" "9b418ff7936b" "kk")
451 ("1cqlhggf46lr7w399k7qb7a1hc56f32w1dy26i2racpppzza5plc" "9771ada0b5f8" "km")
452 ("0p04irnb7x7y37m6lz388x9dynn8rnk000avpp296barajnhs5i8" "645aa37a2112" "kn")
453 ("1lbc1fxr5i0ccymlsd8axz3633cqggg5k8ak5yqwi704g7kvv9g2" "1cd68952d119" "ko")
454 ("11b55bxg73zqfdn5gy9nn5imab2mv0hxr603whggp7vymllgb7kb" "26bb83959bfe" "lij")
455 ("15jsijm6d26i0105gz0f7sh2yh2v4pmw4j95cwkdrb1d8m935jlz" "b9829891f153" "lt")
456 ("0liwwv13fgyw97nizhsyy53xrbf8jks5ics7qkkxfccawjrg5rlb" "e5f09d03d959" "lv")
457 ("0w420yf3hdnl7dp9mn9ghc20cq79k24fn9adn3syk723ppl6mkb0" "7884845e94f3" "mk")
458 ("13wkr7rgqsv9w3d9w7k8lnxdzgfixsq4bmc27zsyc770l6062ml6" "030db7412202" "mr")
459 ("06nsadcnxx0ssdp67x47dj9crihn1ycgd5mwvn5m7lkb97r4ch9f" "40a7703e875c" "ms")
460 ("0mlnjdzck6dp9p59ajj3sr63r36fn0qi8r9scrqrqcisgfclw9sg" "daca40056531" "my")
461 ("0z1hgx9d5i9w20f9k9azzng1y3lmm5d6hdjkj7rf6r5710bhhzh5" "664bd049e105" "nb-NO")
462 ("1466qvrs13g2iix1k35cknb2pia9b66li2ncvdyqf0jsd92z9k8x" "eaa6ae781ba0" "ne-NP")
463 ("0jgmz2lkzj0aspd9mabygzic6li5s2b25y0r6vjg8mv3jm5pi86j" "5ef8f1c9739e" "nl")
464 ("1m46x0h20vdfbzjxlz0ac43dbaq40xnyldr2yzbf7pk5di9pzxa6" "f08e15466d5d" "nn-NO")
465 ("0r3zvihqh6iya3z1qm7if0m3zfgf81s9qp7x7qc701h2q357wkgf" "6712c0e12ec2" "oc")
466 ("102j89jm28c223yhhkrj76xxj4kmy58hcs2r0jn15xa1qkqv1fdk" "8f36cc819e00" "pa-IN")
467 ("1j9za6s0i46abn8dsrlkpck3qxxw35rhfcg1xs1vp8sc4ckg8qwi" "c3b0c1c02b94" "pl")
468 ("1k9lbsvckpwl4xax8kxp5yxsfkspq2mhqm77jh5nl9aw88dsn55b" "cc32bf9630fe" "pt-BR")
469 ("0f0jyvbn2sa5m66wqdzh4607g4gd0270xq37ipd9ls52b4764bd8" "5478d7242086" "pt-PT")
470 ("19znkkialh1d4np7qcp80xkagrf1j2xah2s1xxzsh854p3d30zs7" "dd934a76fb01" "rm")
471 ("1xn26r8g8zzkb5myfgmnjbk8k4i0brkvbrvnhp7k5nkrnsin25di" "d57ab3dee73d" "ro")
472 ("04rhkxlmpp5pyzw85ldbfkmiigqr2p9y5cbns5dqs6sz1633ccxp" "7aea98f33a20" "ru")
473 ("1zzkkxl7ayxh5gx9snyvp5czflsvi77hp48li613h3c2fii4n9qk" "7c986f4b5044" "sco")
474 ("1219i0ghhqj3s1i0rm68jjkvivh6y40938wav7z4ifck527sq6r1" "bc9e55d4e3ea" "si")
475 ("05i5p3n3a6hgl6rf10yjs4vag7y3rn2jwgxsddcdcqiv6405zn81" "8814afd7f67e" "sk")
476 ("1wcqdbm1py1ldq6cj2g201m715nql79r6szr71jvrxacb711c62a" "20013dc06e96" "sl")
477 ("0g2izkaa4ipwgwyhy77ciyrxxpf4pxzj9mjqvxriy5prmkhm3zjs" "d86d5d2b6eef" "son")
478 ("1cc99m6srjg8698dkc3il70crby0mdv43v3ijwy069k4w50hyjjg" "49bb5fae5d9b" "sq")
479 ("13kfssq4fhq9mb36as6sxiaffl17qyg1wdw8kpz3ilqm86bsjrgl" "d6a0ab79b06f" "sr")
480 ("1wx9snbm0431q97i0q0nv4wbsqcv9nhllwfr88crlp7bfj5w8czw" "4bab04993da3" "sv-SE")
481 ("0laglkfl8ml0ip5vmm3z2q790hgwax9gfqwq3wm68a2nnsyck8fw" "4b3316c4aa48" "szl")
482 ("15pnlic4q7m48y0mc5yh8w5yscjwzx0mmfrbj3f2b9jxxa44nx4h" "48c7aab86db8" "ta")
483 ("16qar5y0wns75ryi8bfv7yln3mjsyn7qi4345zcniz3ydgkczh46" "7bbb3dac8f47" "te")
484 ("112g7x8h0qz16r5faam386x4a0rgwd4zy02d5agmg9m0kbficdfx" "009fd0852454" "th")
485 ("1l80kh9byqxnz5vkz357rb39g4y9sgn9pr0v29ywp6d009img1qg" "dad9caecd7a9" "tl")
486 ("1nalvjlxxsa9wldhhdb93bgfc7dl084xayh7i7mgg93yjgrym93x" "0c48082d37cd" "tr")
487 ("0wkxqcfgsra2ljws28kiwajv73w9aa8drsc4fqlg9krbicnjl2n8" "f6d105faedcc" "trs")
488 ("18jf4ysrfv3635fyxc1vwr970dr2r05bl3h8v599pwp2g7jzyjpm" "e1011388a55e" "uk")
489 ("1ihmksjsz54yii23qda5iv8cxrj9144afy75hzhvfi6m182kj4h8" "c4e927eab511" "ur")
490 ("0d42dhfa2vcw24wsvwf95pw20np0pz8c0is6p4307n981n8s207y" "7063df917cb3" "uz")
491 ("04khnkrg8css55hyna01jqay9c2ppxk5znbx2zj9i25knhvvx1lq" "1753054e6ab8" "vi")
492 ("0fi5kxn78xp7s15svkqlf4748j4pzxh941nm52n6kbbrhyi3qcqn" "93bc595dc32e" "xh")
493 ("0jg676vd37wqgzjnm0yynj7xrvm6fsgdwg296h78wnyc33zc4ads" "edd4e468bc31" "zh-CN")
494 ("1y4wldm3z95mfjlficp994jyqg0lj07wi35b79dy1s8ljy3jilil" "0bad1f7d2b2d" "zh-TW")))
495
496 ;; XXXX: Workaround 'snippet' limitations.
497 (define computed-origin-method (@@ (guix packages) computed-origin-method))
498
499 (define %icecat-base-version "102.8.0")
500 (define %icecat-version (string-append %icecat-base-version "-guix0-preview1"))
501 (define %icecat-build-id "20230214000000") ;must be of the form YYYYMMDDhhmmss
502
503 ;; 'icecat-source' is a "computed" origin that generates an IceCat tarball
504 ;; from the corresponding upstream Firefox ESR tarball, using the 'makeicecat'
505 ;; script from the upstream IceCat project.
506 (define icecat-source
507 (let* ((major-version (first (string-split %icecat-base-version #\.)))
508 (minor-version (second (string-split %icecat-base-version #\.)))
509 (sub-version (third (string-split %icecat-base-version #\.)))
510
511 (upstream-firefox-version (string-append %icecat-base-version "esr"))
512 (upstream-firefox-source
513 (origin
514 (method url-fetch)
515 (uri (string-append
516 "https://ftp.mozilla.org/pub/firefox/releases/"
517 upstream-firefox-version "/source/"
518 "firefox-" upstream-firefox-version ".source.tar.xz"))
519 (sha256
520 (base32
521 "0j6afrgfsmd0adbbmffw4p1f2hznpck9d36z3bsjx36f7cjgdy27"))))
522
523 ;; The upstream-icecat-base-version may be older than the
524 ;; %icecat-base-version.
525 (upstream-icecat-base-version "102.8.0")
526 (gnuzilla-commit "f23f8b609ef4afcc7d8ac5fa795093f1c403f8da")
527 (gnuzilla-source
528 (origin
529 (method git-fetch)
530 (uri (git-reference
531 (url "git://git.savannah.gnu.org/gnuzilla.git")
532 (commit gnuzilla-commit)))
533 (file-name (git-file-name "gnuzilla"
534 ;;upstream-icecat-base-version
535 (string-take gnuzilla-commit 8)))
536 (sha256
537 (base32
538 "1zvvgjvsj7k8753f7xmpmkq35dqzyik95943hzl84v2j5mnahhj4"))))
539
540 ;; 'search-patch' returns either a valid file name or #f, so wrap it
541 ;; in 'assume-valid-file-name' to avoid 'local-file' warnings.
542 (makeicecat-patch
543 (local-file (assume-valid-file-name
544 (search-patch "icecat-makeicecat.patch")))))
545
546 (origin
547 (method computed-origin-method)
548 (file-name (string-append "icecat-" %icecat-version ".tar.xz"))
549 (sha256 #f)
550 (uri
551 (delay
552 (with-imported-modules '((guix build utils))
553 #~(begin
554 (use-modules (guix build utils))
555 (let ((firefox-dir
556 (string-append "firefox-" #$%icecat-base-version))
557 (icecat-dir
558 (string-append "icecat-" #$%icecat-version)))
559
560 (set-path-environment-variable
561 "PATH" '("bin")
562 (list #+python
563 #+(canonical-package bash)
564 #+(canonical-package coreutils)
565 #+(canonical-package findutils)
566 #+(canonical-package patch)
567 #+(canonical-package xz)
568 #+(canonical-package sed)
569 #+(canonical-package grep)
570 #+(canonical-package bzip2)
571 #+(canonical-package gzip)
572 #+(canonical-package tar)))
573
574 (set-path-environment-variable
575 "PYTHONPATH"
576 (list #+(format #f "lib/python~a/site-packages"
577 (version-major+minor
578 (package-version python))))
579 '#+(cons python-jsonschema
580 (map second
581 (package-transitive-propagated-inputs
582 python-jsonschema))))
583
584 ;; Needed by the 'makeicecat' script.
585 (setenv "RENAME_CMD" "rename")
586
587 ;; We copy the gnuzilla source directory because it is
588 ;; read-only in 'gnuzilla-source', and the makeicecat script
589 ;; uses "cp -a" to copy parts of it and assumes that the
590 ;; copies will be writable.
591 (copy-recursively #+gnuzilla-source "/tmp/gnuzilla"
592 #:log (%make-void-port "w"))
593
594 (with-directory-excursion "/tmp/gnuzilla"
595 (make-file-writable "makeicecat")
596 (invoke "patch" "--force" "--no-backup-if-mismatch"
597 "-p1" "--input" #+makeicecat-patch)
598 (patch-shebang "makeicecat")
599 (substitute* "makeicecat"
600 (("^readonly FFMAJOR=(.*)" all ffmajor)
601 (unless (string=? #$major-version
602 (string-trim-both ffmajor))
603 ;; The makeicecat script cannot be expected to work
604 ;; properly on a different version of Firefox, even if
605 ;; no errors occur during execution.
606 (error "makeicecat major version mismatch"))
607 (string-append "readonly FFMAJOR=" #$major-version "\n"))
608 (("^readonly FFMINOR=.*")
609 (string-append "readonly FFMINOR=" #$minor-version "\n"))
610 (("^readonly FFSUB=.*")
611 (string-append "readonly FFSUB=" #$sub-version "\n"))
612 (("^readonly DATADIR=.*")
613 "readonly DATADIR=/tmp/gnuzilla/data\n")
614 (("^readonly SOURCEDIR=.*")
615 (string-append "readonly SOURCEDIR=" icecat-dir "\n"))
616 (("/bin/sed")
617 #+(file-append (canonical-package sed) "/bin/sed"))))
618
619 (format #t "Unpacking upstream firefox tarball...~%")
620 (force-output)
621 (invoke "tar" "xf" #+upstream-firefox-source)
622 (rename-file firefox-dir icecat-dir)
623
624 (with-directory-excursion icecat-dir
625 (format #t "Populating l10n directory...~%")
626 (force-output)
627 (mkdir "l10n")
628 (with-directory-excursion "l10n"
629 (for-each
630 (lambda (locale-dir)
631 (let ((locale
632 (string-drop (basename locale-dir)
633 (+ 32 ; length of hash
634 (string-length "-mozilla-locale-")))))
635 (format #t " ~a~%" locale)
636 (force-output)
637 (copy-recursively locale-dir locale
638 #:log (%make-void-port "w"))
639 (for-each make-file-writable (find-files locale))
640 (with-directory-excursion locale
641 (when (file-exists? ".hgtags")
642 (delete-file ".hgtags"))
643 (mkdir-p "browser/chrome/browser/preferences")
644 (call-with-output-file
645 "browser/chrome/browser/preferences/advanced-scripts.dtd"
646 (lambda (port) #f)))))
647 '#+all-mozilla-locales)
648 (copy-recursively #+mozilla-compare-locales
649 "compare-locales"
650 #:log (%make-void-port "w"))
651 (delete-file "compare-locales/.gitignore")
652 (delete-file "compare-locales/.hgignore")
653 (delete-file "compare-locales/.hgtags")))
654
655 (format #t "Running makeicecat script...~%")
656 (force-output)
657 (invoke "bash" "/tmp/gnuzilla/makeicecat")
658
659 (format #t "Packing IceCat source tarball...~%")
660 (force-output)
661 (setenv "XZ_DEFAULTS" (string-join (%xz-parallel-args)))
662 (invoke "tar" "cfa" #$output
663 ;; Avoid non-determinism in the archive. We set the
664 ;; mtime of files in the archive to early 1980 because
665 ;; the build process fails if the mtime of source
666 ;; files is pre-1980, due to the creation of zip
667 ;; archives.
668 "--mtime=@315619200" ; 1980-01-02 UTC
669 "--owner=root:0"
670 "--group=root:0"
671 "--sort=name"
672 icecat-dir)))))))))
673
674 (define-public icecat-minimal
675 (package
676 (name "icecat-minimal")
677 (version %icecat-version)
678 (source icecat-source)
679 (build-system gnu-build-system)
680 (inputs
681 (list alsa-lib
682 bzip2
683 cups
684 dbus-glib
685 gdk-pixbuf
686 glib
687 gtk+
688 ;; UNBUNDLE-ME! graphite2
689 cairo
690 pango
691 freetype
692 font-dejavu
693 ;; UNBUNDLE-ME! harfbuzz
694 libcanberra
695 libgnome
696 libjpeg-turbo
697 libpng-apng
698 ;; UNBUNDLE-ME! libogg
699 ;; UNBUNDLE-ME! libtheora ; wants theora-1.2, not yet released
700 ;; UNBUNDLE-ME! libvorbis
701 libxft
702 libevent
703 libxinerama
704 libxscrnsaver
705 libxcomposite
706 libxt
707 libffi
708 ffmpeg
709 libvpx
710 icu4c-71 ; TODO: Change to 'icu4c' when its version is >= 71.
711 pixman
712 pulseaudio
713 mesa
714 pciutils
715 mit-krb5
716 hunspell
717 libnotify
718 ;; See <https://bugs.gnu.org/32833>
719 ;; and related comments in the 'remove-bundled-libraries' phase.
720 ;; UNBUNDLE-ME! nspr
721 ;; UNBUNDLE-ME! nss
722 shared-mime-info
723 sqlite
724 eudev
725 unzip
726 zip
727 zlib))
728 (native-inputs
729 ;; The following patches are specific to the Guix packaging of IceCat,
730 ;; and therefore we prefer to leave them out of 'source', which should be
731 ;; a tarball suitable for compilation on any system that IceCat supports.
732 ;; (Bug fixes and security fixes, however, should go in 'source').
733 (list
734 ;; XXX TODO: Adapt these patches to IceCat 102.
735 ;; ("icecat-avoid-bundled-libraries.patch"
736 ;; ,(search-patch "icecat-avoid-bundled-libraries.patch"))
737 ;; ("icecat-use-system-graphite2+harfbuzz.patch"
738 ;; ,(search-patch "icecat-use-system-graphite2+harfbuzz.patch"))
739 ;; ("icecat-use-system-media-libs.patch"
740 ;; ,(search-patch "icecat-use-system-media-libs.patch"))
741 rust
742 `(,rust "cargo")
743 rust-cbindgen-0.23
744 llvm
745 clang
746 perl
747 node
748 python-wrapper
749 yasm
750 nasm ; XXX FIXME: only needed on x86_64 and i686
751 pkg-config
752 m4
753 which))
754 (arguments
755 (list
756 #:tests? #f ;not worth the cost
757
758 ;; Some dynamic lib was determined at runtime, so rpath check may fail.
759 #:validate-runpath? #f
760
761 #:configure-flags
762 #~(list
763 "--enable-application=browser"
764 "--with-distribution-id=org.gnu"
765 "--enable-geckodriver"
766 ;; Do not require addons in the global app or system directories to
767 ;; be signed by Mozilla.
768 "--with-unsigned-addon-scopes=app,system"
769 "--allow-addon-sideload"
770
771 "--enable-pulseaudio"
772
773 "--disable-tests"
774 "--disable-updater"
775 "--disable-crashreporter"
776 "--disable-eme"
777
778 ;; Building with debugging symbols takes ~5GiB, so disable it.
779 "--disable-debug"
780 "--disable-debug-symbols"
781
782 "--enable-rust-simd"
783 "--enable-release"
784 "--enable-optimize"
785 "--enable-strip"
786 "--disable-elf-hack"
787
788 ;; Clang is needed to build Stylo, Mozilla's new CSS engine. We must
789 ;; specify the clang paths manually, because otherwise the Mozilla
790 ;; build system looks in the directories returned by llvm-config
791 ;; --bindir and llvm-config --libdir, which return paths in the llvm
792 ;; package where clang is not found.
793 (string-append "--with-clang-path="
794 (search-input-file %build-inputs "bin/clang"))
795 (string-append "--with-libclang-path="
796 (dirname (search-input-file %build-inputs
797 "lib/libclang.so")))
798
799 ;; Hack to work around missing "unofficial" branding in icecat.
800 "--enable-official-branding"
801
802 ;; TODO: Add support for wasm sandboxed libraries.
803 "--without-wasm-sandboxed-libraries"
804
805 ;; Avoid bundled libraries.
806 "--with-system-jpeg" ;must be libjpeg-turbo
807 "--with-system-png" ;must be libpng-apng
808 "--with-system-zlib"
809 ;; UNBUNDLE-ME! "--with-system-bz2"
810 ;; UNBUNDLE-ME! "--with-system-libevent"
811 ;; UNBUNDLE-ME! "--with-system-ogg"
812 ;; UNBUNDLE-ME! "--with-system-vorbis"
813 ;; UNBUNDLE-ME! "--with-system-theora" ; wants theora-1.2, not yet released
814 ;; UNBUNDLE-ME! "--with-system-libvpx"
815 "--with-system-icu"
816
817 ;; See <https://bugs.gnu.org/32833>
818 ;; and related comments in the
819 ;; 'remove-bundled-libraries' phase below.
820 ;; UNBUNDLE-ME! "--with-system-nspr"
821 ;; UNBUNDLE-ME! "--with-system-nss"
822
823 ;; UNBUNDLE-ME! "--with-system-harfbuzz"
824 ;; UNBUNDLE-ME! "--with-system-graphite2"
825 "--enable-system-pixman"
826 "--enable-system-ffi"
827 ;; UNBUNDLE-ME! "--enable-system-sqlite"
828 )
829
830 #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
831
832 #:modules `((ice-9 ftw)
833 (ice-9 match)
834 (srfi srfi-1)
835 (srfi srfi-26)
836 (rnrs bytevectors)
837 (rnrs io ports)
838 (guix elf)
839 (guix build gremlin)
840 ,@%gnu-build-system-modules)
841 #:phases
842 #~(modify-phases %standard-phases
843 (add-after 'unpack 'apply-guix-specific-patches
844 (lambda* (#:key inputs native-inputs #:allow-other-keys)
845 (let ((patch (search-input-file inputs "bin/patch")))
846 (for-each (match-lambda
847 ((label . file)
848 (when (and (string-prefix? "icecat-" label)
849 (string-suffix? ".patch" label))
850 (format #t "applying '~a'...~%" file)
851 (invoke patch "--force" "--no-backup-if-mismatch"
852 "-p1" "--input" file))))
853 (or native-inputs inputs)))))
854 (add-after 'apply-guix-specific-patches 'remove-bundled-libraries
855 (lambda _
856 ;; Remove bundled libraries that we don't use, since they may
857 ;; contain unpatched security flaws, they waste disk space and
858 ;; memory, and may cause confusion.
859 (for-each (lambda (file)
860 (format #t "deleting '~a'...~%" file)
861 (delete-file-recursively file))
862 '( ;; FIXME: Removing the bundled icu breaks configure.
863 ;; * The bundled icu headers are used in some places.
864 ;; * The version number is taken from the bundled copy.
865 ;;"intl/icu"
866 ;;
867 ;; FIXME: A script from the bundled nspr is used.
868 ;;"nsprpub"
869 ;;
870 ;; FIXME: With the update to IceCat 60, using system NSS
871 ;; broke certificate validation. See
872 ;; <https://bugs.gnu.org/32833>. For now, we use
873 ;; the bundled NSPR and NSS. TODO: Investigate,
874 ;; and try to unbundle these libraries again.
875 ;; UNBUNDLE-ME! "security/nss"
876 ;;
877 ;; TODO: Use more system media libraries. See:
878 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
879 ;; * libtheora: esr60 wants v1.2, not yet released.
880 ;; * soundtouch: avoiding the bundled library would
881 ;; result in some loss of functionality. There's
882 ;; also an issue with exception handling
883 ;; configuration. It seems that this is needed in
884 ;; some moz.build:
885 ;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
886 ;; * libopus
887 ;; * speex
888 ;;
889 "modules/freetype2"
890 ;; "media/libjpeg" ; needed for now, because media/libjpeg/moz.build is referenced from config/external/moz.build
891 ;; UNBUNDLE-ME! "modules/zlib"
892 ;; UNBUNDLE-ME! "ipc/chromium/src/third_party/libevent"
893 ;; UNBUNDLE-ME! "media/libvpx"
894 ;; UNBUNDLE-ME! "media/libogg"
895 ;; UNBUNDLE-ME! "media/libvorbis"
896 ;; UNBUNDLE-ME! "media/libtheora" ; wants theora-1.2, not yet released
897 ;; UNBUNDLE-ME! "media/libtremor"
898 ;; UNBUNDLE-ME! "gfx/harfbuzz"
899 ;; UNBUNDLE-ME! "gfx/graphite2"
900 "js/src/ctypes/libffi"
901 ;; UNBUNDLE-ME! "db/sqlite3"
902 ))))
903 (add-after 'remove-bundled-libraries 'fix-ffmpeg-runtime-linker
904 (lambda* (#:key inputs #:allow-other-keys)
905 ;; Arrange to load libavcodec.so by its absolute file name.
906 (substitute* "dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp"
907 (("libavcodec\\.so")
908 (search-input-file inputs "lib/libavcodec.so")))))
909 (add-after 'fix-ffmpeg-runtime-linker 'build-sandbox-whitelist
910 (lambda* (#:key inputs #:allow-other-keys)
911 (define (runpath-of lib)
912 (call-with-input-file lib
913 (compose elf-dynamic-info-runpath
914 elf-dynamic-info
915 parse-elf
916 get-bytevector-all)))
917 (define (runpaths-of-input label)
918 (let* ((dir (string-append (assoc-ref inputs label) "/lib"))
919 (libs (find-files dir "\\.so$")))
920 (append-map runpath-of libs)))
921 ;; Populate the sandbox read-path whitelist as needed by ffmpeg.
922 (let* ((whitelist
923 (map (cut string-append <> "/")
924 (delete-duplicates
925 `(,(string-append (assoc-ref inputs "shared-mime-info")
926 "/share/mime")
927 ,(string-append (assoc-ref inputs "font-dejavu")
928 "/share/fonts")
929 "/run/current-system/profile/share/fonts"
930 ,@(append-map runpaths-of-input
931 '("mesa" "ffmpeg"))))))
932 (whitelist-string (string-join whitelist ","))
933 (port (open-file "browser/app/profile/icecat.js" "a")))
934 (format #t "setting 'security.sandbox.content.read_path_whitelist' to '~a'~%"
935 whitelist-string)
936 (format port "~%pref(\"security.sandbox.content.read_path_whitelist\", ~S);~%"
937 whitelist-string)
938 (close-output-port port))))
939 (add-after 'patch-source-shebangs 'patch-cargo-checksums
940 (lambda _
941 (use-modules (guix build cargo-utils))
942 (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
943 (for-each (lambda (file)
944 (format #t "patching checksums in ~a~%" file)
945 (substitute* file
946 (("^checksum = \".*\"")
947 (string-append "checksum = \"" null-hash "\""))))
948 (find-files "." "Cargo.lock$"))
949 (for-each generate-all-checksums
950 '("services"
951 "js"
952 "third_party/rust"
953 "dom/media"
954 "dom/webauthn"
955 "toolkit"
956 "gfx"
957 "storage"
958 "modules"
959 "xpcom/rust"
960 "media"
961 "mozglue/static/rust"
962 "netwerk"
963 "remote"
964 "intl"
965 "servo"
966 "security/manager/ssl"
967 "build")))))
968 (add-after 'patch-cargo-checksums 'remove-cargo-frozen-flag
969 (lambda _
970 ;; Remove --frozen flag from cargo invokation, otherwise it'll
971 ;; complain that it's not able to change Cargo.lock.
972 ;; https://bugzilla.mozilla.org/show_bug.cgi?id=1726373
973 (substitute* "build/RunCbindgen.py"
974 (("\"--frozen\",") ""))))
975 (delete 'bootstrap)
976 (replace 'configure
977 ;; configure does not work followed by both "SHELL=..." and
978 ;; "CONFIG_SHELL=..."; set environment variables instead
979 (lambda* (#:key outputs configure-flags #:allow-other-keys)
980 (let* ((bash (which "bash"))
981 (abs-srcdir (getcwd))
982 (flags `(,(string-append "--prefix=" #$output)
983 ,(string-append "--with-l10n-base="
984 abs-srcdir "/l10n")
985 ,@configure-flags)))
986 (setenv "SHELL" bash)
987 (setenv "CONFIG_SHELL" bash)
988
989 (setenv "AR" "llvm-ar")
990 (setenv "NM" "llvm-nm")
991 (setenv "CC" "clang")
992 (setenv "CXX" "clang++")
993 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
994 #$output "/lib/icecat"))
995
996 (setenv "MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE" "system")
997 (setenv "MOZ_BUILD_DATE" #$%icecat-build-id) ; avoid timestamp
998
999 ;; XXX TODO: Fix this to work on systems other than x86_64-linux.
1000 (setenv "GUIX_PYTHONPATH"
1001 (string-append (getcwd)
1002 "/obj-x86_64-pc-linux-gnu/_virtualenvs/build"))
1003
1004 (mkdir ".mozbuild")
1005 (setenv "MOZBUILD_STATE_PATH"
1006 (string-append (getcwd) "/.mozbuild"))
1007
1008 (format #t "build directory: ~s~%" (getcwd))
1009 (format #t "configure flags: ~s~%" flags)
1010
1011 (call-with-output-file "mozconfig"
1012 (lambda (port)
1013 (for-each (lambda (flag)
1014 (format port "ac_add_options ~a\n" flag))
1015 flags)))
1016
1017 (invoke "./mach" "configure"))))
1018 (replace 'build
1019 (lambda* (#:key (make-flags '()) (parallel-build? #t)
1020 #:allow-other-keys)
1021 (apply invoke "./mach" "build"
1022 ;; mach will use parallel build if possible by default
1023 `(,@(if parallel-build?
1024 '()
1025 '("-j1"))
1026 ,@make-flags))))
1027 (add-after 'build 'neutralise-store-references
1028 (lambda _
1029 ;; Mangle the store references to compilers & other build tools in
1030 ;; about:buildconfig, reducing IceCat's closure by 1 GiB on x86-64.
1031 (let* ((obj-dir (match (scandir "." (cut string-prefix? "obj-" <>))
1032 ((dir) dir)))
1033 (file (string-append
1034 obj-dir
1035 "/dist/bin/chrome/toolkit/content/global/buildconfig.html")))
1036 (substitute* file
1037 (("[0-9a-df-np-sv-z]{32}" hash)
1038 (string-append (string-take hash 8)
1039 "<!-- Guix: not a runtime dependency -->"
1040 (string-drop hash 8)))))))
1041 (replace 'install
1042 (lambda* (#:key outputs #:allow-other-keys)
1043 (invoke "./mach" "install")
1044 ;; The geckodriver binary is not installed by the above, for some
1045 ;; reason. Use 'find-files' to avoid having to deal with the
1046 ;; system/architecture-specific file name.
1047 (install-file (first (find-files "." "geckodriver"))
1048 (string-append #$output "/bin"))))
1049 (add-after 'install 'wrap-program
1050 (lambda* (#:key inputs #:allow-other-keys)
1051 (let* ((lib (string-append #$output "/lib"))
1052 (gtk #$(this-package-input "gtk+"))
1053 (gtk-share (string-append gtk "/share"))
1054 (ld-libs '#$(map (lambda (label)
1055 (file-append (this-package-input label) "/lib"))
1056 '("libpng-apng"
1057 "libxscrnsaver"
1058 "mesa"
1059 "pciutils"
1060 "mit-krb5"
1061 "eudev"
1062 "pulseaudio"
1063 ;; For the integration of native notifications
1064 "libnotify"))))
1065 (wrap-program (car (find-files lib "^icecat$"))
1066 `("XDG_DATA_DIRS" prefix (,gtk-share))
1067 ;; The following line is commented out because the icecat
1068 ;; package on guix has been observed to be unstable when
1069 ;; using wayland, and the bundled extensions stop working.
1070 ;; `("MOZ_ENABLE_WAYLAND" = ("1"))
1071 `("LD_LIBRARY_PATH" prefix ,ld-libs)))))
1072 (add-after 'wrap-program 'install-desktop-entry
1073 (lambda _
1074 ;; Install the '.desktop' file.
1075 (let* ((desktop-file "taskcluster/docker/icecat-snap/icecat.desktop")
1076 (applications (string-append #$output "/share/applications")))
1077 (substitute* desktop-file
1078 (("^Exec=icecat") (string-append "Exec=" #$output "/bin/icecat"))
1079 (("IceCat") "GNU IceCat")
1080 (("Icon=.*") "Icon=icecat\n")
1081 (("NewWindow") "new-window")
1082 (("NewPrivateWindow") "new-private-window")
1083 (("StartupNotify=true")
1084 "StartupNotify=true\nStartupWMClass=Navigator"))
1085 (install-file desktop-file applications))))
1086 (add-after 'install-desktop-entry 'install-icons
1087 (lambda _
1088 (with-directory-excursion "browser/branding/official"
1089 (for-each
1090 (lambda (file)
1091 (let* ((size (string-filter char-numeric? file))
1092 (icons (string-append #$output "/share/icons/hicolor/"
1093 size "x" size "/apps")))
1094 (mkdir-p icons)
1095 (copy-file file (string-append icons "/icecat.png"))))
1096 '("default16.png" "default22.png" "default24.png"
1097 "default32.png" "default48.png" "content/icon64.png"
1098 "mozicon128.png" "default256.png"))))))))
1099 (home-page "https://www.gnu.org/software/gnuzilla/")
1100 (synopsis "Entirely free browser derived from Mozilla Firefox")
1101 (description
1102 "IceCat is the GNU version of the Firefox browser. It is entirely free
1103 software, which does not recommend non-free plugins and addons. It also
1104 features built-in privacy-protecting features. This package also includes the
1105 @command{geckodriver} command, which can be useful for automated web
1106 testing.
1107
1108 WARNING: IceCat 102 has not yet been released by the upstream IceCat project.
1109 This is a preview release, and does not currently meet the privacy-respecting
1110 standards of the IceCat project.")
1111 (license license:mpl2.0) ;and others, see toolkit/content/license.html
1112 (properties
1113 `((ftp-directory . "/gnu/gnuzilla")
1114 (cpe-name . "firefox_esr")
1115 (cpe-version . ,(first (string-split version #\-)))))))
1116
1117 (define %icecat-locales
1118 '("ach" "af" "an" "ar" "ast" "az" "be" "bg" "bn" "br" "bs" "ca" "cak"
1119 "ca-valencia" "cs" "cy" "da" "de" "dsb" "el" "en-CA" "en-GB" "eo" "es-AR"
1120 "es-CL" "es-ES" "es-MX" "et" "eu" "fa" "ff" "fi" "fr" "fy-NL" "ga-IE" "gd"
1121 "gl" "gn" "gu-IN" "he" "hi-IN" "hr" "hsb" "hu" "hy-AM" "ia" "id" "is" "it"
1122 "ja" "ja-JP-mac" "ka" "kab" "kk" "km" "kn" "ko" "lij" "lt" "lv" "mk" "mr" "ms"
1123 "my" "nb-NO" "ne-NP" "nl" "nn-NO" "oc" "pa-IN" "pl" "pt-BR" "pt-PT" "rm" "ro"
1124 "ru" "sco" "si" "sk" "sl" "son" "sq" "sr" "sv-SE" "szl" "ta" "te" "th" "tl"
1125 "tr" "trs" "uk" "ur" "uz" "vi" "xh" "zh-CN" "zh-TW"))
1126
1127 (define %icedove-build-id "20230207000000") ;must be of the form YYYYMMDDhhmmss
1128 (define %icedove-version "102.7.2")
1129
1130 ;; Provides the "comm" folder which is inserted into the icecat source.
1131 ;; Avoids the duplication of Icecat's source tarball.
1132 (define thunderbird-comm-source
1133 (origin
1134 (method hg-fetch)
1135 (uri (hg-reference
1136 (url "https://hg.mozilla.org/releases/comm-esr102")
1137 (changeset "0f6deed0752b618055c34e06c268af3da9d1548d")))
1138 (file-name (string-append "thunderbird-" %icedove-version "-checkout"))
1139 (sha256
1140 (base32
1141 "071q0pcfvfpzx741ly1sl8anlmzx02h17w4ylfnrkwrpaclq3p6p"))))
1142
1143 (define (comm-source->locales+changeset source)
1144 "Given SOURCE, a checkout of the Thunderbird 'comm' component, return the
1145 list of languages supported as well as the currently used changeset."
1146 (match (update-mozilla-locales
1147 (string-append source "/mail/locales/l10n-changesets.json"))
1148 (((_ changeset locale) ...)
1149 (values locale (first changeset)))))
1150
1151 ;;; Generated with comm-source->locales+changeset.
1152 (define %icedove-locales
1153 '("af" "ar" "ast" "be" "bg" "br" "ca" "cak" "cs" "cy" "da" "de" "dsb" "el"
1154 "en-CA" "en-GB" "es-AR" "es-ES" "es-MX" "et" "eu" "fi" "fr" "fy-NL" "ga-IE"
1155 "gd" "gl" "he" "hr" "hsb" "hu" "hy-AM" "id" "is" "it" "ja" "ja-JP-mac" "ka"
1156 "kab" "kk" "ko" "lt" "lv" "ms" "nb-NO" "nl" "nn-NO" "pa-IN" "pl" "pt-BR"
1157 "pt-PT" "rm" "ro" "ru" "sk" "sl" "sq" "sr" "sv-SE" "th" "tr" "uk" "uz" "vi"
1158 "zh-CN" "zh-TW"))
1159
1160 ;;; To find out which changeset to use for the comm-l10n repo, use the
1161 ;;; 'comm-source->locales+changeset' procedure on the thunderbird-comm-source
1162 ;;; checkout directory. The complete localization data should be released as
1163 ;;; a tarball in the next release (see:
1164 ;;; https://bugzilla.mozilla.org/show_bug.cgi?id=1817086). When this tarball
1165 ;;; is available, it should replace the complete 'l10n' directory at the root
1166 ;;; of the IceCat source, instead of only the 'calendar', chat and mail
1167 ;;; directories that it provides.
1168 (define thunderbird-comm-l10n
1169 (let* ((changeset "5b6788295358")
1170 (version (git-version %icedove-version "0" changeset)))
1171 (origin
1172 (method hg-fetch)
1173 (uri (hg-reference
1174 (url "https://hg.mozilla.org/projects/comm-l10n")
1175 (changeset changeset)))
1176 (file-name (git-file-name "comm-l10n" version))
1177 (sha256
1178 (base32
1179 "1jrsmkscjjllcfawi3788vwm53wn25inbhdis5nk4vfpr7wk5ill")))))
1180
1181 (define icedove-source
1182 (let ((name (string-append "icedove-" %icedove-version)))
1183 (origin
1184 (method computed-origin-method)
1185 (file-name (string-append name ".tar.xz"))
1186 (sha256 #f)
1187 (uri
1188 (delay
1189 (with-imported-modules (source-module-closure '((guix build utils)))
1190 #~(begin
1191 (use-modules (guix build utils)
1192 (sxml simple))
1193
1194 (set-path-environment-variable
1195 "PATH" '("bin")
1196 (list #+(canonical-package tar)
1197 #+(canonical-package xz)))
1198
1199 ;; Extract the base Icecat tarball, renaming its top-level
1200 ;; directory.
1201 (invoke "tar" "--transform" (string-append "s,[^/]*," #$name ",")
1202 "-xf" #$icecat-source)
1203 (chdir #$name)
1204
1205 ;; Merge the Thunderdbird localization data.
1206 (copy-recursively #$thunderbird-comm-l10n "l10n")
1207
1208 ;; Add the Thunderbird-specific "comm" directory..
1209 (mkdir "comm")
1210 (copy-recursively #$thunderbird-comm-source "comm")
1211 (delete-file "sourcestamp.txt")
1212
1213 ;; Adjust the application name.
1214 (substitute* "comm/mail/confvars.sh"
1215 (("MOZ_APP_NAME=thunderbird")
1216 "MOZ_APP_NAME=icedove")
1217 (("MOZ_UPDATER=1")
1218 "MOZ_UPDATER=0"))
1219
1220 ;; Remove branding to comply with Mozilla's trademark policy
1221 (with-directory-excursion "comm/mail/branding/nightly"
1222 (delete-file "content/about-wordmark.svg")
1223 (call-with-output-file "content/about-wordmark.svg"
1224 (lambda (port)
1225 (sxml->xml '(svg (@ (xmlns "http://www.w3.org/2000/svg")
1226 (viewBox "0 0 789.1 90.78")
1227 (width "333")
1228 (height "48")
1229 (fill "#fff"))
1230 (text (@ (x "400") (y "70")
1231 (text-anchor "middle")
1232 (font-size "90"))
1233 "Icedove Daily"))
1234 port)))
1235 (substitute* '("locales/en-US/brand.properties"
1236 "locales/en-US/brand.ftl"
1237 "locales/en-US/brand.dtd"
1238 "configure.sh")
1239 (("Thunderbird") "Icedove")
1240 (("mozilla.org") "guix.gnu.org")))
1241 ;; Remove other mentions of Thunderbird in user-visible text.
1242 (with-directory-excursion "comm/mail/base/content"
1243 (substitute* '("overrides/app-license-name.html")
1244 (("Thunderbird") "Icedove")))
1245 (with-directory-excursion "comm/mail/components/"
1246 (substitute* '("MailGlue.jsm"
1247 "extensions/schemas/addressBook.json"
1248 "extensions/schemas/tabs.json"
1249 "extensions/schemas/cloudFile.json"
1250 "extensions/schemas/chrome_settings_overrides.json"
1251 "extensions/schemas/windows.json"
1252 "extensions/parent/ext-mail.js"
1253 "im/messages/mail/Info.plist"
1254 "enterprisepolicies/moz.build"
1255 "enterprisepolicies/helpers/moz.build"
1256 "enterprisepolicies/schemas/moz.build")
1257 (("Thunderbird") "Icedove")))
1258 (substitute* '("comm/mailnews/base/prefs/content/accountUtils.js"
1259 "comm/mail/base/content/customizeToolbar.js"
1260 "comm/suite/components/customizeToolbar.js")
1261 (("AppConstants.MOZ_APP_NAME (.)= \"thunderbird" _ e)
1262 (format #f "AppConstants.MOZ_APP_NAME ~a= \"icedove" e)))
1263
1264 ;; Override addon URLs and settings
1265 (substitute* "comm/mail/app/profile/all-thunderbird.js"
1266 (("(pref\\(\"extensions.webservice.discoverURL\").*" _ m)
1267 (string-append m ", \"https://directory.fsf.org/wiki/Icedove\");"))
1268 (("(pref\\(\"extensions.getAddons.search.url\").*" _ m)
1269 (string-append m ", \"https://guix.gnu.org/packages\");"))
1270 (("(pref\\(\"extensions.update.enabled\").*" _ m)
1271 (string-append m ", false);"))
1272 (("(pref\\(\"extensions.systemAddon.update.enabled\").*" _ m)
1273 (string-append m ", false);"))
1274 (("(pref\\(\"lightweightThemes.update.enabled\").*" _ m)
1275 (string-append m ", false);"))
1276
1277 ;; XXX: The autoDisableScopes is tweaked by the makeicecat
1278 ;; script, but it doesn't know about Thunderbird. This is
1279 ;; necessary to allow picking up the extensions found in the
1280 ;; system global application directory, such as the language
1281 ;; packs.
1282 (("\"extensions.autoDisableScopes\", 15")
1283 "\"extensions.autoDisableScopes\", 3")
1284
1285 ;; Set the default locale to that of the operating system.
1286 ((".*extensions.autoDisableScopes.*" anchor)
1287 (string-append anchor
1288 "pref(\"intl.locale.requested\", \"\");\n")))
1289
1290 ;; Step out of the directory and create the tarball.
1291 (chdir "..")
1292 (format #t "Packing Icedove source tarball...~%")
1293 (force-output)
1294 (setenv "XZ_DEFAULTS" (string-join (%xz-parallel-args)))
1295 (invoke "tar" "cfa" #$output
1296 "--mtime=@315619200" ;1980-01-02 UTC
1297 "--owner=root:0"
1298 "--group=root:0"
1299 "--sort=name"
1300 #$name))))))))
1301
1302 (define-public icedove-minimal
1303 (package
1304 (name "icedove-minimal")
1305 (version %icedove-version)
1306 (source icedove-source)
1307 (properties
1308 `((cpe-name . "thunderbird_esr")))
1309 (build-system gnu-build-system)
1310 (arguments
1311 (list
1312 #:tests? #f ;no check target
1313 #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
1314 #:modules `((guix build utils) ;find-files
1315 (sxml simple)
1316 (ice-9 regex)
1317 ,@%gnu-build-system-modules)
1318 #:phases
1319 #~(modify-phases %standard-phases
1320 (add-after 'patch-source-shebangs 'patch-cargo-checksums
1321 (lambda _
1322 (use-modules (guix build cargo-utils))
1323 (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934\
1324 ca495991b7852b855"))
1325 (for-each (lambda (file)
1326 (format #t "patching checksums in ~a~%" file)
1327 (substitute* file
1328 (("^checksum = \".*\"")
1329 (string-append "checksum = \"" null-hash "\""))))
1330 (find-files "." "Cargo.lock$"))
1331 (for-each generate-all-checksums
1332 '("third_party/rust"
1333 "toolkit/library/rust")))))
1334 (add-after 'patch-cargo-checksums 'remove-cargo-frozen-flag
1335 (lambda _
1336 ;; Remove --frozen flag from cargo invokation, otherwise it'll
1337 ;; complain that it's not able to change Cargo.lock.
1338 ;; https://bugzilla.mozilla.org/show_bug.cgi?id=1726373
1339 (substitute* "build/RunCbindgen.py"
1340 (("\"--frozen\",") ""))))
1341 ;; Fixes issue where each installation directory generates its own
1342 ;; profile (see:
1343 ;; https://trac.torproject.org/projects/tor/ticket/31457).
1344 (add-after 'patch-source-shebangs 'fix-profile-setting
1345 (lambda _
1346 (substitute* "comm/mail/moz.configure"
1347 (("MOZ_DEDICATED_PROFILES, True")
1348 "MOZ_DEDICATED_PROFILES, False"))))
1349 (add-after 'build 'neutralize-store-references
1350 (lambda _
1351 ;; Mangle the store references to compilers & other build tools in
1352 ;; about:buildconfig, reducing Icedove's closure significant.
1353 ;; The resulting files are saved in lib/thunderbird/omni.ja
1354 (substitute*
1355 ;; Use find because the path "obj-x86_64-pc-linux-gnu" contains
1356 ;; the architecture and the system -> more complicated.
1357 (find-files "." "buildconfig.html")
1358 (((format #f "(~a/)([0-9a-df-np-sv-z]{32})"
1359 (regexp-quote (%store-directory)))
1360 _ store hash)
1361 (string-append store
1362 (string-take hash 8)
1363 "<!-- Guix: not a runtime dependency -->"
1364 (string-drop hash 8))))))
1365 (delete 'bootstrap)
1366 (replace 'configure
1367 (lambda* (#:key native-inputs inputs configure-flags
1368 #:allow-other-keys)
1369 (let* ((bash (which "bash"))
1370 (abs-srcdir (getcwd))
1371 (srcdir (string-append "../" (basename abs-srcdir)))
1372 (flags `(,(string-append "--prefix=" #$output)
1373 ,@configure-flags))
1374 (mozconfig (string-append (getcwd) "/.mozconfig")))
1375 (setenv "SHELL" bash)
1376 (setenv "CONFIG_SHELL" bash)
1377 (setenv "QA_CONFIGURE_OPTIONS" ".*")
1378 (setenv "MOZBUILD_STATE_PATH"
1379 (string-append (getcwd) "/mach_state"))
1380 (setenv "MOZCONFIG"
1381 (string-append (getcwd) "/.mozconfig"))
1382
1383 (setenv "AR" "llvm-ar")
1384 (setenv "NM" "llvm-nm")
1385 (setenv "CC" "clang")
1386 (setenv "CXX" "clang++")
1387
1388 (setenv "MOZ_NOSPAM" "1")
1389 (setenv "MACH_USE_SYSTEM_PYTHON" "1")
1390 (setenv "PYTHON"
1391 (search-input-file inputs "/bin/python"))
1392 (setenv "MOZ_BUILD_DATE" #$%icedove-build-id) ; avoid timestamp
1393 (setenv "MOZ_APP_NAME" "icedove")
1394 (setenv "LDFLAGS" (string-append "-Wl,-rpath=" #$output
1395 "/lib/icedove"))
1396 (mkdir-p (string-append (getcwd) "/builddir"))
1397 (with-output-to-file mozconfig
1398 (lambda ()
1399 (display
1400 (string-append
1401 "ac_add_options --allow-addon-sideload\n"
1402 "ac_add_options --with-unsigned-addon-scopes=app,system\n"
1403 "ac_add_options --disable-crashreporter\n"
1404 "ac_add_options --disable-debug\n"
1405 "ac_add_options --disable-debug-symbols\n"
1406 "ac_add_options --disable-elf-hack\n"
1407 "ac_add_options --disable-jit\n"
1408 "ac_add_options --disable-necko-wifi\n"
1409 "ac_add_options --disable-official-branding\n"
1410 "ac_add_options --disable-tests\n"
1411 "ac_add_options --disable-updater\n"
1412 "ac_add_options --disable-webrtc\n"
1413 "ac_add_options --enable-application=comm/mail\n"
1414 "ac_add_options --enable-default-toolkit=\"cairo-gtk3\"\n"
1415 "ac_add_options --enable-optimize\n"
1416 "ac_add_options --enable-pulseaudio\n"
1417 "ac_add_options --enable-release\n"
1418 "ac_add_options --enable-strip\n"
1419 "ac_add_options --enable-system-ffi\n"
1420 "ac_add_options --enable-system-pixman\n"
1421 "ac_add_options --prefix=" #$output "\n"
1422 "ac_add_options --with-clang-path="
1423 (search-input-file (or native-inputs inputs)
1424 "bin/clang") "\n"
1425 "ac_add_options --with-distribution-id=org.gnu\n"
1426 "ac_add_options --with-libclang-path="
1427 #$(this-package-native-input "clang") "/lib\n"
1428 "ac_add_options --with-system-bz2\n"
1429 "ac_add_options --with-system-icu\n"
1430 "ac_add_options --with-system-jpeg\n"
1431 "ac_add_options --with-system-libevent\n"
1432 "ac_add_options --with-system-nspr\n"
1433 "ac_add_options --with-system-nss\n"
1434 "ac_add_options --with-system-zlib\n"
1435 "ac_add_options --without-wasm-sandboxed-libraries\n"
1436 "mk_add_options MOZ_MAKE_FLAGS=-j"
1437 (number->string (parallel-job-count)) "\n"))))
1438 (display (getcwd))
1439 (newline)
1440 (display "mach configure")
1441 (invoke "./mach" "configure"))))
1442 (replace 'build
1443 (lambda _ (invoke "./mach" "build")))
1444 (replace 'install
1445 (lambda _ (invoke "./mach" "install")))
1446 ;; Thunderbird doesn't provide any .desktop file.
1447 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1637575
1448 (add-after 'install 'install-desktop-file
1449 (lambda _
1450 (let ((apps (string-append #$output "/share/applications")))
1451 (mkdir-p apps)
1452 (with-output-to-file (string-append apps "/icedove.desktop")
1453 (lambda _
1454 (format #t
1455 "[Desktop Entry]~@
1456 Name=Icedove~@
1457 Exec=~a/bin/icedove~@
1458 Icon=icedove~@
1459 GenericName=Mail/News Client~@
1460 Categories=Network;Email;~@
1461 Terminal=false~@
1462 StartupNotify=true~@
1463 MimeType=x-scheme-handler/mailto;~@
1464 Type=Application~@
1465 Actions=ComposeMessage;~@
1466 [Desktop Action ComposeMessage]~@
1467 Name=Write new message~@
1468 Exec=~@*~a/bin/icedove -compose~%"
1469 #$output))))))
1470 (add-after 'install-desktop-file 'install-icons
1471 (lambda _
1472 (with-directory-excursion "browser/branding/official"
1473 (for-each
1474 (lambda (file)
1475 (let* ((size (string-filter char-numeric? file))
1476 (icons (string-append #$output "/share/icons/hicolor/"
1477 size "x" size "/apps")))
1478 (mkdir-p icons)
1479 (copy-file file (string-append icons "/icedove.png"))))
1480 '("default16.png" "default22.png" "default24.png"
1481 "default32.png" "default48.png" "content/icon64.png"
1482 "mozicon128.png" "default256.png")))))
1483 (add-after 'install 'wrap-program
1484 (lambda* (#:key inputs #:allow-other-keys)
1485 (let* ((lib (string-append #$output "/lib"))
1486 (gtk #$(this-package-input "gtk+"))
1487 (gtk-share (string-append gtk "/share"))
1488 (pulseaudio #$(this-package-input "pulseaudio"))
1489 (pulseaudio-lib (string-append pulseaudio "/lib"))
1490 (eudev #$(this-package-input "eudev"))
1491 (eudev-lib (string-append eudev "/lib")))
1492 (wrap-program (car (find-files lib "^icedove$"))
1493 `("XDG_DATA_DIRS" prefix (,gtk-share))
1494 `("LD_LIBRARY_PATH" prefix (,pulseaudio-lib ,eudev-lib)))))))))
1495 (inputs
1496 (list alsa-lib
1497 bzip2
1498 cairo
1499 cups
1500 dbus-glib
1501 ffmpeg
1502 freetype
1503 gdk-pixbuf
1504 glib
1505 gtk+
1506 gtk+-2
1507 hunspell
1508 icu4c-71
1509 libcanberra
1510 libevent
1511 libffi
1512 libgnome
1513 libjpeg-turbo
1514 libpng-apng
1515 libvpx
1516 libxcomposite
1517 libxft
1518 libxinerama
1519 libxscrnsaver
1520 libxt
1521 mesa
1522 mit-krb5
1523 nss-next
1524 pango
1525 pixman
1526 pulseaudio
1527 sqlite
1528 startup-notification
1529 eudev
1530 unzip
1531 zip
1532 zlib))
1533 (native-inputs
1534 (list `(,rust "cargo")
1535 clang
1536 llvm
1537 m4
1538 nasm
1539 node
1540 perl
1541 pkg-config
1542 python-wrapper
1543 rust
1544 rust-cbindgen-0.23
1545 which
1546 yasm))
1547 (home-page "https://www.thunderbird.net")
1548 (synopsis "Rebranded Mozilla Thunderbird email client")
1549 (description
1550 "This package provides an email client built based on Mozilla
1551 Thunderbird. It supports email, news feeds, chat, calendar and contacts.")
1552 (license license:mpl2.0)))
1553
1554 (define (make-l10n-package project version source locales)
1555 "Return a package for PROJECT, a symbol (either icecat or icedove), with
1556 their corresponding VERSION, SOURCE and LOCALES variables."
1557 (unless (member project '(icecat icedove))
1558 (error "only icecat or icedove components are currently supported"))
1559
1560 (let ((name (if (eq? 'icecat project)
1561 "IceCat"
1562 "Icedove")))
1563 (package
1564 (name (format #f "~a-l10n" project))
1565 (version version)
1566 (source source)
1567 (outputs (cons "out" locales))
1568 (build-system gnu-build-system)
1569 (arguments
1570 (list
1571 #:modules '((guix build gnu-build-system)
1572 (guix build utils)
1573 (ice-9 format)
1574 (ice-9 ftw)
1575 (srfi srfi-1)
1576 (srfi srfi-26))
1577 #:tests? #f ;no tests, this is data
1578 #:phases
1579 #~(modify-phases %standard-phases
1580 (delete 'bootstrap)
1581 (delete 'install)
1582 (replace 'configure
1583 (lambda _
1584 ;; The following configuration is inspired by guidance at
1585 ;; https://firefox-source-docs.mozilla.org/build/buildsystem/locales.html.
1586 (call-with-output-file ".mozconfig"
1587 (lambda (p)
1588 (format p "~{~a~%~}"
1589 (list (if (eq? 'icecat '#$project)
1590 "ac_add_options --enable-project=browser"
1591 "ac_add_options --enable-project=comm/mail")
1592 "ac_add_options --disable-compile-environment"
1593 (string-append
1594 "ac_add_options --with-l10n-base="
1595 (getcwd) "/l10n")
1596 ;; Hack, otherwise the build system throws:
1597 ;; 'RuntimeError: File "brand.dtd" not found'.
1598 "ac_add_options --enable-official-branding"
1599 "mk_add_options MOZ_OBJDIR=obj"))))
1600 (setenv "CONFIG_SHELL" (which "bash"))
1601 (setenv "MOZBUILD_STATE_PATH"
1602 (string-append (getcwd) "/mach_state"))
1603 (setenv "MOZCONFIG" (string-append (getcwd) "/.mozconfig"))
1604 (setenv "MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE" "system")
1605 (setenv "BUILD_BACKENDS" "FasterMake,RecursiveMake")))
1606 (replace 'build ;build and install data files
1607 (lambda* (#:key outputs #:allow-other-keys)
1608 (define (find-file dir name)
1609 (let ((files (find-files dir name)))
1610 (when (null? files)
1611 (error "could not find file in dir" name dir))
1612 (car files)))
1613
1614 (for-each
1615 (lambda (l)
1616 (let* ((out (assoc-ref outputs l))
1617 ;; The older lib/$project/distribution/extensions
1618 ;; directory is deprecated. Use the newer app-global
1619 ;; directory, which is lib/$project/extensions.
1620 (ext-dir-prefix
1621 (format
1622 #f "lib/~a/~:[~;browser/~]extensions"
1623 '#$project (eq? 'icecat '#$project)))
1624 (all-ext (string-append #$output "/" ext-dir-prefix))
1625 (ext-dir (string-append out "/" ext-dir-prefix))
1626 ;; XXX: Because Icedove doesn't have a makeicedove
1627 ;; script that substitutes all the Thunderbird
1628 ;; references to Icedove, the MOZ_LANGPACK_EID
1629 ;; defined in comm/mail/locales/Makefile.in uses
1630 ;; 'thunderbird' in its ID extension rather than
1631 ;; 'icedove'.
1632 (name (format #f "langpack-~a@~a.mozilla.org.xpi"
1633 l (if (eq? 'icedove '#$project)
1634 'thunderbird
1635 '#$project))))
1636 (format #t "processing locale `~a'...~%" l)
1637 (if (eq? 'icecat '#$project)
1638 ;; XXX: For some reasons, for IceCat, there are some
1639 ;; parsing errors that cause the build system to
1640 ;; return an unclean exit code; use system* to ignore
1641 ;; errors.
1642 (system* "./mach" "build" (string-append "langpack-" l))
1643 (invoke "./mach" "build" (string-append "langpack-" l)))
1644 (mkdir-p ext-dir)
1645 (let ((xpi (find-file "obj" (string-append
1646 "\\." l "\\.langpack\\.xpi$"))))
1647 (copy-file xpi (string-append ext-dir "/" name))
1648 ;; Symlink to the main output so that a user can
1649 ;; install all of the language packs at once.
1650 (mkdir-p all-ext)
1651 (symlink (string-append ext-dir "/" name)
1652 (string-append all-ext "/" name)))))
1653 (if (eq? 'icedove '#$project)
1654 '#$%icedove-locales
1655 '#$%icecat-locales)))))))
1656 (native-inputs
1657 (list m4
1658 perl
1659 python-wrapper
1660 node
1661 unzip))
1662 (home-page "https://www.mozilla.org/")
1663 (synopsis (string-append "Language localization data for " name))
1664 (description (string-append "This package contains the various language
1665 localization data files (language pack extensions) for " name ". The
1666 individual localization packages can be installed by using the output
1667 associated with their name."))
1668 (license license:mpl2.0))))
1669
1670 (define-public icecat-l10n
1671 (make-l10n-package 'icecat %icecat-version icecat-source %icecat-locales))
1672
1673 (define-public icedove-l10n
1674 (make-l10n-package 'icedove %icedove-version icedove-source %icedove-locales))
1675
1676 ;;; This hack exists because there's no way to configure extra extension
1677 ;;; search paths for IceCat or Icedove. The global extensions directory is
1678 ;;; constructed relatively to the executable file name.
1679 (define (make-mozilla-with-l10n project base l10n-package)
1680 "Return a package definition for PROJECT (a symbol such as 'icecat or
1681 'icedove) that combines the BASE package with L10N-PACKAGE."
1682
1683 (unless (member project '(icecat icedove))
1684 (error "only icecat or icedove components are currently supported"))
1685
1686 (let ((name (symbol->string project))
1687 (icecat? (eq? 'icecat project)))
1688 (package
1689 (inherit base)
1690 (name (symbol->string project))
1691 (build-system trivial-build-system)
1692 (arguments
1693 (list
1694 #:modules '((guix build union)
1695 (guix build utils))
1696 #:builder
1697 #~(begin
1698 (use-modules (guix build union)
1699 (guix build utils))
1700
1701 (union-build #$output (list #$base #$l10n-package)
1702 #:create-all-directories? #t)
1703
1704 (define* (expose name #:optional (proc copy-file)
1705 #:key (source #$base))
1706 (let ((dest (string-append #$output "/" name)))
1707 (mkdir-p (dirname dest))
1708 (proc (string-append source "/" name) dest)))
1709
1710 (let ((wrapper (string-append "lib/" #$name "/" #$name))
1711 (real-binary (string-append "lib/" #$name "/." #$name
1712 "-real"))
1713 (desktop-file (string-append "share/applications/"
1714 #$name ".desktop")))
1715 ;; Copy wrapper file.
1716 (delete-file (string-append #$output "/" wrapper))
1717 (expose wrapper)
1718
1719 ;; Recreate bin symlink.
1720 (delete-file (string-append #$output "/bin/" #$name))
1721 (symlink (string-append #$output "/" wrapper)
1722 (string-append #$output "/bin/" #$name))
1723
1724 ;; Copy actual binary.
1725 (delete-file (string-append #$output "/" real-binary))
1726 (expose real-binary)
1727
1728 ;; Copy desktop file.
1729 (delete-file (string-append #$output "/" desktop-file))
1730 (expose desktop-file)
1731
1732 ;; Adjust the references in the desktop file and wrapper.
1733 (substitute* (list (string-append #$output "/" desktop-file)
1734 (string-append #$output "/" wrapper))
1735 ((#$base) #$output)))))))))
1736
1737 (define-public icecat
1738 (make-mozilla-with-l10n 'icecat icecat-minimal icecat-l10n))
1739
1740 (define-public icedove
1741 (make-mozilla-with-l10n 'icedove icedove-minimal icedove-l10n))
1742
1743 (define-public icedove/wayland
1744 (package
1745 (inherit icedove)
1746 (name "icedove-wayland")
1747 (build-system trivial-build-system)
1748 (arguments
1749 (list
1750 #:modules '((guix build utils))
1751 #:builder
1752 #~(begin
1753 (use-modules (guix build utils))
1754 (let* ((exe (string-append #$output "/bin/icedove")))
1755 (mkdir-p (dirname exe))
1756 (call-with-output-file exe
1757 (lambda (port)
1758 (format port "#!~a
1759 MOZ_ENABLE_WAYLAND=1 exec ~a $@"
1760 #$(file-append bash-minimal "/bin/bash")
1761 #$(file-append icedove "/bin/icedove"))))
1762 (chmod exe #o555)
1763 ;; Provide the manual and .desktop file.
1764 (copy-recursively (string-append #$icedove "/share")
1765 (string-append #$output "/share"))
1766 (substitute* (string-append #$output
1767 "/share/applications/icedove.desktop")
1768 ((#$icedove) #$output))))))
1769 (native-inputs '())
1770 (inputs '())))
1771
1772 (define-public firefox-decrypt
1773 (package
1774 (name "firefox-decrypt")
1775 (version "0.7.0")
1776 (source (origin
1777 (method git-fetch)
1778 (uri (git-reference
1779 (url "https://github.com/Unode/firefox_decrypt")
1780 (commit version)))
1781 (file-name (git-file-name name version))
1782 (sha256
1783 (base32
1784 "17yyyxp47z4m8hnflcq34rc1y871515kr3f1y42j1l0yx3g0il07"))))
1785 (build-system trivial-build-system)
1786 (inputs
1787 (list nss python))
1788 (arguments
1789 `(#:modules ((guix build utils))
1790 #:builder
1791 (begin
1792 (use-modules (guix build utils))
1793 (setenv "PATH"
1794 (string-append
1795 (assoc-ref %build-inputs "python") "/bin"))
1796 (copy-file (string-append (assoc-ref %build-inputs "source")
1797 "/firefox_decrypt.py")
1798 "firefox_decrypt.py")
1799 (substitute* "firefox_decrypt.py"
1800 (("/usr/bin/env python") (which "python3"))
1801 (("libnss3.so") (string-append (assoc-ref %build-inputs "nss")
1802 "/lib/nss/libnss3.so")))
1803 (install-file "firefox_decrypt.py" (string-append %output "/bin"))
1804 #t)))
1805 (home-page "https://github.com/Unode/firefox_decrypt/")
1806 (synopsis "Tool to extract passwords from Mozilla profiles")
1807 (description "Firefox Decrypt is a tool to extract passwords from
1808 Mozilla (Firefox, Waterfox, Thunderbird, SeaMonkey) profiles.")
1809 (license license:gpl3+)))
1810
1811 (define-public lz4json
1812 (package
1813 (name "lz4json")
1814 (version "2")
1815 (source
1816 (origin
1817 (method git-fetch)
1818 (uri
1819 (git-reference
1820 (url "https://github.com/andikleen/lz4json")
1821 (commit (string-append "v" version))))
1822 (file-name (git-file-name name version))
1823 (sha256
1824 (base32 "1xxn8yzr6j8j6prmbj6mxspdczigarfiv3vlm9k70yxmky65ijh3"))))
1825 (build-system gnu-build-system)
1826 (native-inputs (list pkg-config))
1827 (inputs (list lz4))
1828 (arguments
1829 `(#:tests? #f ; no check target
1830 #:phases
1831 (modify-phases %standard-phases
1832 (delete 'configure) ; no configure script
1833 (replace 'install ; no install target
1834 (lambda* (#:key outputs #:allow-other-keys)
1835 (let* ((out (assoc-ref outputs "out"))
1836 (bin (string-append out "/bin"))
1837 (man (string-append out "/share/man/man1")))
1838 (install-file "lz4jsoncat" bin)
1839 (install-file "lz4jsoncat.1" man)))))
1840 #:make-flags `(,(string-append "CC=" ,(cc-for-target)))))
1841 (home-page "https://github.com/andikleen/lz4json")
1842 (synopsis "C decompress tool for mozilla lz4json format")
1843 (description
1844 "@code{lz4json} is a little utility to unpack lz4json files as generated
1845 by Firefox's bookmark backups and session restore. This is a different format
1846 from what the normal lz4 utility expects. The data is dumped to stdout.")
1847 (license license:bsd-2)))