;;; packages - package definitions for infotropique OS ;;; Copyright (C) 2017, 2018 ng0 ;;; ;;; This program is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU Affero General Public License as ;;; published by the Free Software Foundation, either version 3 of the ;;; License, or (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU Affero General Public License for more details. ;;; ;;; You should have received a copy of the GNU Affero General Public License ;;; along with this program. If not, see . ;; Part of this module were originally based on the gnu/packages/gnuzilla.scm file ;; from GNU Guix which is covered by the GPL3 license. Consult the file for the ;; list of contributors. (define-module (www torbrowser torbrowser) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix git-download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (gnu packages) #:use-module (gnu packages gnuzilla) #:use-module (gnu packages rust) #:use-module ((srfi srfi-1) #:hide (zip)) #:use-module (ice-9 match) #:use-module (srfi srfi-26) #:use-module (guix utils) #:use-module (gnu packages autotools) #:use-module (gnu packages base) #:use-module (gnu packages databases) #:use-module (gnu packages glib) #:use-module (gnu packages gtk) #:use-module (gnu packages gnome) #:use-module (guix base16) #:use-module (gnu packages libcanberra) #:use-module (gnu packages cups) #:use-module (gnu packages kerberos) #:use-module (gnu packages linux) #:use-module (gnu packages llvm) #:use-module (gnu packages perl) #:use-module (gnu packages pkg-config) #:use-module (gnu packages compression) #:use-module (gnu packages fontutils) #:use-module (gnu packages libevent) #:use-module (gnu packages libreoffice) ;for hunspell #:use-module (gnu packages image) #:use-module (gnu packages libffi) #:use-module (gnu packages pulseaudio) #:use-module (gnu packages python) #:use-module (gnu packages xorg) #:use-module (gnu packages gl) #:use-module (gnu packages assembly) #:use-module (gnu packages icu4c) #:use-module (gnu packages video) #:use-module (gnu packages xdisorg) #:use-module (gnu packages readline)) (define-public tor-browser-data (package (name "tor-browser-data") (version "7.5") (source (origin (method url-fetch) (uri (list (string-append "https://dist.torproject.org/torbrowser/" version "/tor-browser-linux64-" version "_en-US.tar.xz") (string-append "https://archive.torproject.org/tor-package-archive/torbrowser/" version "/tor-browser-linux64-" version "_en-US.tar.xz"))) (file-name (string-append name "-" version ".tar.xz")) (sha256 (base32 "1ia8qv5hj7zrrli5d9qf65s3rlrls0whrx3q96lw63x2gn05nwv7")) (modules '((guix build utils))) (snippet '(begin (use-modules (ice-9 ftw)) ;; Delete .pyc files, typically present in icecat source tarballs (for-each delete-file (find-files "." "\\.pyc$")) ;; Delete obj-* directories, sometimes present in icecat tarballs (for-each delete-file-recursively (scandir "." (lambda (name) (string-prefix? "obj-" name)))) #t)))) (build-system trivial-build-system) (native-inputs `(("tar" ,tar) ("xz" ,xz))) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let ((out (assoc-ref %outputs "out")) (source (assoc-ref %build-inputs "source")) (tar (string-append (assoc-ref %build-inputs "tar") "/bin/tar")) (xz-path (string-append (assoc-ref %build-inputs "xz") "/bin"))) (setenv "PATH" xz-path) (mkdir out) (invoke tar "xvf" source "-C" out "--strip=3"))))) (home-page "https://www.torproject.org/projects/torbrowser.html") (synopsis "Data files for Tor Browser") (description "Torbrowser-data provides the data files required by the Tor Browser package.") (license license:mpl2.0))) ;and others (define-public tor-browser (package (name "tor-browser") (version "7.5") (source (origin (method git-fetch) (uri (git-reference (url "https://git.torproject.org/tor-browser.git") (commit "tor-browser-52.6.0esr-7.5-2-build1"))) (file-name (string-append name "-" version "-checkout")) (sha256 (base32 "0253aqyjawsjyp493g98y7jxp4ixid4lx4xxdrg2x8qp4n2425hd")) (modules '((guix build utils))) (snippet '(begin (use-modules (ice-9 ftw)) ;; Delete .pyc files, typically present in icecat source tarballs (for-each delete-file (find-files "." "\\.pyc$")) ;; Delete obj-* directories, sometimes present in icecat tarballs (for-each delete-file-recursively (scandir "." (lambda (name) (string-prefix? "obj-" name)))) #t)))) (build-system gnu-build-system) (inputs `(("alsa-lib" ,alsa-lib) ("bzip2" ,bzip2) ("cairo" ,cairo) ("cups" ,cups) ("dbus-glib" ,dbus-glib) ("gdk-pixbuf" ,gdk-pixbuf) ("glib" ,glib) ("gtk+" ,gtk+) ("gtk+-2" ,gtk+-2) ("graphite2" ,graphite2) ("pango" ,pango) ("freetype" ,freetype) ("harfbuzz" ,harfbuzz) ("hunspell" ,hunspell) ("libcanberra" ,libcanberra) ("libgnome" ,libgnome) ("libjpeg-turbo" ,libjpeg-turbo) ("libxft" ,libxft) ("libevent" ,libevent-2.0) ("libxinerama" ,libxinerama) ("libxscrnsaver" ,libxscrnsaver) ("libxcomposite" ,libxcomposite) ("libxt" ,libxt) ("libffi" ,libffi) ("ffmpeg" ,ffmpeg) ("libvpx" ,libvpx) ("icu4c" ,icu4c) ("pixman" ,pixman) ("pulseaudio" ,pulseaudio) ("mesa" ,mesa) ("mit-krb5" ,mit-krb5) ("nspr" ,nspr) ("nss" ,nss) ("sqlite" ,sqlite) ("startup-notification" ,startup-notification) ("tor-browser-data" ,tor-browser-data) ("unzip" ,unzip) ("zip" ,zip) ("zlib" ,zlib))) (native-inputs `(("perl" ,perl) ("python" ,python-2) ; Python 3 not supported ("python2-pysqlite" ,python2-pysqlite) ("yasm" ,yasm) ("pkg-config" ,pkg-config) ("autoconf" ,autoconf-2.13) ("which" ,which))) (arguments `(#:tests? #f ; no check target #:out-of-source? #t ; must be built outside of the source directory ;; XXX: There are RUNPATH issues such as ;; $prefix/lib/icecat-31.6.0/plugin-container NEEDing libmozalloc.so, ;; which is not in its RUNPATH, but they appear to be harmless in ;; practice somehow. See . #:validate-runpath? #f #:make-flags (list "-f" "client.mk" "realbuild") #:modules ((ice-9 ftw) (ice-9 rdelim) (ice-9 match) ,@%gnu-build-system-modules) #:phases (modify-phases %standard-phases (add-after 'unpack 'ensure-no-mtimes-pre-1980 (lambda _ ;; Without this, the 'source/test/addons/packed.xpi' and ;; 'source/test/addons/simple-prefs.xpi' targets fail while trying ;; to create zip archives. (let ((early-2000 946684800)) ; 2000-01-01 UTC (ftw "." (lambda (file stat flag) (unless (<= early-2000 (stat:mtime stat)) (utime file early-2000 early-2000)) #t)) #t))) (add-after 'unpack 'keep-codebase-the-same (lambda _ (substitute* "browser/branding/aurora/configure.sh" (("MOZ_DEV_EDITION=1") "")) (substitute* "browser/installer/Makefile.in" (("^MOZ_PKG_FATAL_WARNINGS = 1") "MOZ_PKG_FATAL_WARNINGS = 0")) #t)) ;; (add-before 'configure 'autoconf ;; (lambda _ ;; (invoke "autoreconf" "old-configure.in"))) ;; (add-after ;; 'unpack 'use-skia-by-default ;; (lambda _ ;; ;; Use the bundled Skia library by default, since IceCat appears ;; ;; to be far more stable when using it than when using our system ;; ;; Cairo. ;; (let ((out (open "browser/app/profile/firefox.js" ;; (logior O_WRONLY O_APPEND)))) ;; (format out "~%// Use Skia by default~%") ;; (format out "pref(~s, ~s);~%" "gfx.canvas.azure.backends" "skia") ;; (format out "pref(~s, ~s);~%" "gfx.content.azure.backends" "skia") ;; (close-port out)) ;; #t)) ;; (add-after ;; 'unpack 'arrange-to-link-libxul-with-libraries-it-might-dlopen ;; (lambda _ ;; ;; libxul.so dynamically opens libraries, so here we explicitly ;; ;; link them into libxul.so instead. ;; ;; ;; ;; TODO: It might be preferable to patch in absolute file names in ;; ;; calls to dlopen or PR_LoadLibrary, but that didn't seem to ;; ;; work. More investigation is needed. ;; (substitute* "toolkit/library/moz.build" ;; (("^# This library needs to be last" all) ;; (string-append "OS_LIBS += [ ;; 'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5', ;; 'avcodec', 'avutil', 'pulse' ]\n\n" ;; all))) ;; #t)) (replace 'configure (lambda* (#:key outputs configure-flags #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (bash (which "bash")) (abs-srcdir (getcwd)) (srcdir (string-append "../" (basename abs-srcdir))) (flags `(,(string-append "--prefix=" out) ,@configure-flags)) (mozconfig (string-append (getcwd) "/.mozconfig"))) (chmod mozconfig #o755) (setenv "SHELL" bash) (setenv "AUTOCONF" (string-append (assoc-ref %build-inputs "autoconf") "/bin/autoconf")) (setenv "CONFIG_SHELL" bash) (setenv "BUILD_OBJ_DIR" (string-append (getcwd) "/ff")) (setenv "QA_CONFIGURE_OPTIONS" ".*") (setenv "MOZBUILD_STATE_PATH" (string-append (getcwd) "/mach_state")) (setenv "MOZCONFIG" (string-append (getcwd) "/.mozconfig")) (setenv "MOZ_NOSPAM" "1") ;; (setenv "builddir" (string-append (getcwd) "/build")) ;; (mkdir-p (getenv "MOZBUILD_STATE_PATH")) ;;(mkdir-p (string-append (getcwd) "/builddir")) (with-output-to-file mozconfig (lambda () (display (string-append ". $topsrcdir/browser/config/mozconfig\n" ;;"mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-@CONFIG_GUESS@\n" "mk_add_options MOZ_OBJDIR=" (getenv "BUILD_OBJ_DIR") "\n" "mk_add_options MOZ_APP_DISPLAYNAME=\"Tor Browser\"\n" "mk_add_options XARGS=" (which "xargs") "\n" "mk_add_options MOZILLA_OFFICIAL=1\n" "mk_add_options BUILD_OFFICIAL=1\n" "ac_add_options --enable-extensions=default\n" ;;"ac_add_options --enable-optimize\n" ;;#ac_add_options --disable-optimize "ac_add_options --enable-official-branding\n" ;; # Let's support GTK2 for ESR52 "ac_add_options --enable-default-toolkit=cairo-gtk2\n" ;; ---- poncho didn't have those 2: ;;"ac_add_options --enable-signmar\n" ;;"ac_add_options --enable-verify-mar\n" ;; ---- "ac_add_options --disable-strip\n" "ac_add_options --disable-install-strip\n" "ac_add_options --disable-tests\n" ;; "ac_add_options --disable-debug\n" ;; ac_add_options --disable-maintenance-service ;; ac_add_options --disable-crashreporter "ac_add_options --disable-webrtc\n" "ac_add_options --disable-eme\n" "ac_add_options --with-app-name=torbrowser\n" "ac_add_options --with-app-basename=torbrowser\n" "ac_add_options --with-tor-browser-version=7.5\n" "ac_add_options --disable-tor-browser-update\n" ;;"ac_add_options --enable-tor-browser-data-outside-app-dir\n" ;; "ac_add_options --enable-default-toolkit=cairo-gtk3\n" "ac_add_options --enable-gio\n" "ac_add_options --enable-startup-notification\n" "ac_add_options --enable-pulseaudio\n" "ac_add_options --disable-gconf\n" "ac_add_options --disable-gnomeui\n" "ac_add_options --disable-maintenance-service\n" "ac_add_options --disable-updater\n" "ac_add_options --disable-necko-wifi\n" ;;"ac_add_options --enable-safe-browsing\n" "ac_add_options --disable-crashreporter\n" ;; Until 55 ESR we can disable this: "ac_add_options --disable-rust\n" ;; Building with debugging symbols takes ~5GiB, so ;; disable it. "ac_add_options --disable-debug\n" "ac_add_options --disable-debug-symbols\n" ;;"ac_add_options --enable-pie\n" ;; Avoid bundled libraries. "ac_add_options --with-system-zlib\n" "ac_add_options --with-system-bz2\n" "ac_add_options --with-system-jpeg\n" ; must be libjpeg-turbo "ac_add_options --with-system-libevent\n" "ac_add_options --with-system-libvpx\n" "ac_add_options --with-system-icu\n" "ac_add_options --with-system-nspr\n" "ac_add_options --with-system-nss\n" ;;"--with-system-harfbuzz" ;;"--with-system-graphite2" "ac_add_options --enable-system-pixman\n" "ac_add_options --enable-system-cairo\n" "ac_add_options --enable-system-ffi\n" "ac_add_options --enable-system-hunspell\n" "ac_add_options --enable-system-sqlite\n")))) (display (getcwd)) (newline) (display "make -f client.mk configure") (invoke "make" "--file=client.mk" "configure")))) ;; (replace 'build ;; (lambda _ ;; (chdir "build") ;; (display (getcwd)) ;; (display (string-append (getcwd) "..")) ;; (invoke "../source/mach" "--file=../source/client.mk" "build") ;; #t)) ;; (add-after 'install 'run-check ;; (lambda* (#:key outputs #:allow-other-keys) ;; (let ((out (assoc-ref outputs "out"))) ;; (invoke (string-append out "/bin/firefox" " --version"))))) (add-after 'install-desktop-entry 'install-icons (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (with-directory-excursion "../firefox-52.6.0esr/browser/branding/aurora" (for-each (lambda (file) (let* ((size (string-filter char-numeric? file)) (icons (string-append out "/share/icons/hicolor/" size "x" size "/apps"))) (mkdir-p icons) (copy-file file (string-append icons "/aurora.png")))) '("default16.png" "default32.png" "default48.png" "content/icon64.png" "mozicon128.png")))))) ;; This fixes the file chooser crash that happens with GTK 3. (add-after 'install 'wrap-program (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (lib (string-append out "/lib")) (gtk (assoc-ref inputs "gtk+")) (gtk-share (string-append gtk "/share"))) (wrap-program (car (find-files lib "^firefox$")) `("XDG_DATA_DIRS" ":" prefix (,gtk-share)))))) (add-after 'build 'install-desktop-entry (lambda* (#:key outputs #:allow-other-keys) ;; Add .desktop files for the 2 variants and the symlink (let* ((out (assoc-ref outputs "out")) (prefs (string-append out "/lib/firefox-52.6.0/browser/" "defaults/preferences/"))) (mkdir-p prefs) (with-output-to-file (string-append prefs "vendor.js") (lambda _ (format #t "// Disable default browser checking.~@ pref(\"browser.shell.checkDefaultBrowser\", false);~@ // Don't disable our bundled extensions in the application directory~@ pref(\"extensions.autoDisableScopes\", 11);~@ pref(\"extensions.shownSelectionUI\", true);~@ // Disable Signature Verification~@ pref(\"xpinstall.signatures.required\", false);~%" out)))) #t))))) (native-search-paths (list (search-path-specification (variable "MOZ_PLUGIN_PATH") (files (list (string-append "lib/mozilla/plugins")))))) (home-page "https://mozilla.org/en-US/firefox/") (synopsis "Web browser built from Firefox ESR source tree") (description "Web browser built from Firefox ESR source tree.") (license license:mpl2.0))) ;and others, see toolkit/content/license.html