gnu: icecat: Modernize package definition.

* gnu/packages/gnuzilla.scm (icecat)[inputs, native-inputs]: Use new style.
[configure-flags, phases]: Use gexps.
This commit is contained in:
Maxim Cournoyer 2022-05-12 16:13:10 -04:00
parent a3605b59c6
commit 7aa0e310fa
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -904,93 +904,94 @@ (define-public icecat
(source icecat-source) (source icecat-source)
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs (inputs
`(("alsa-lib" ,alsa-lib) (list alsa-lib
("bzip2" ,bzip2) bzip2
("cups" ,cups) cups
("dbus-glib" ,dbus-glib) dbus-glib
("gdk-pixbuf" ,gdk-pixbuf) gdk-pixbuf
("glib" ,glib) glib
("gtk+" ,gtk+) gtk+
("gtk+-2" ,gtk+-2) gtk+-2
;; UNBUNDLE-ME! ("graphite2" ,graphite2) ;; UNBUNDLE-ME! graphite2
("cairo" ,cairo) cairo
("pango" ,pango) pango
("freetype" ,freetype) freetype
("font-dejavu" ,font-dejavu) font-dejavu
;; UNBUNDLE-ME! ("harfbuzz" ,harfbuzz) ;; UNBUNDLE-ME! harfbuzz
("libcanberra" ,libcanberra) libcanberra
("libgnome" ,libgnome) libgnome
("libjpeg-turbo" ,libjpeg-turbo) libjpeg-turbo
("libpng-apng" ,libpng-apng) libpng-apng
;; UNBUNDLE-ME! ("libogg" ,libogg) ;; UNBUNDLE-ME! libogg
;; UNBUNDLE-ME! ("libtheora" ,libtheora) ; wants theora-1.2, not yet released ;; UNBUNDLE-ME! libtheora ; wants theora-1.2, not yet released
;; UNBUNDLE-ME! ("libvorbis" ,libvorbis) ;; UNBUNDLE-ME! libvorbis
("libxft" ,libxft) libxft
("libevent" ,libevent) libevent
("libxinerama" ,libxinerama) libxinerama
("libxscrnsaver" ,libxscrnsaver) libxscrnsaver
("libxcomposite" ,libxcomposite) libxcomposite
("libxt" ,libxt) libxt
("libffi" ,libffi) libffi
("ffmpeg" ,ffmpeg) ffmpeg
("libvpx" ,libvpx) libvpx
("icu4c" ,icu4c) icu4c
("pixman" ,pixman) pixman
("pulseaudio" ,pulseaudio) pulseaudio
("mesa" ,mesa) mesa
("pciutils" ,pciutils) pciutils
("mit-krb5" ,mit-krb5) mit-krb5
("hunspell" ,hunspell) hunspell
("libnotify" ,libnotify) libnotify
;; See <https://bugs.gnu.org/32833> ;; See <https://bugs.gnu.org/32833>
;; and related comments in the 'remove-bundled-libraries' phase. ;; and related comments in the 'remove-bundled-libraries' phase.
;; UNBUNDLE-ME! ("nspr" ,nspr) ;; UNBUNDLE-ME! nspr
;; UNBUNDLE-ME! ("nss" ,nss) ;; UNBUNDLE-ME! nss
("shared-mime-info" ,shared-mime-info) shared-mime-info
("sqlite" ,sqlite) sqlite
("eudev" ,eudev) eudev
("unzip" ,unzip) unzip
("zip" ,zip) zip
("zlib" ,zlib))) zlib))
(native-inputs (native-inputs
;; The following patches are specific to the Guix packaging of IceCat, ;; The following patches are specific to the Guix packaging of IceCat,
;; and therefore we prefer to leave them out of 'source', which should be ;; and therefore we prefer to leave them out of 'source', which should be
;; a tarball suitable for compilation on any system that IceCat supports. ;; a tarball suitable for compilation on any system that IceCat supports.
;; (Bug fixes and security fixes, however, should go in 'source'). ;; (Bug fixes and security fixes, however, should go in 'source').
`(;; XXX TODO: Adapt these patches to IceCat 91. (list
;; XXX TODO: Adapt these patches to IceCat 91.
;; ("icecat-avoid-bundled-libraries.patch" ;; ("icecat-avoid-bundled-libraries.patch"
;; ,(search-patch "icecat-avoid-bundled-libraries.patch")) ;; ,(search-patch "icecat-avoid-bundled-libraries.patch"))
;; ("icecat-use-system-graphite2+harfbuzz.patch" ;; ("icecat-use-system-graphite2+harfbuzz.patch"
;; ,(search-patch "icecat-use-system-graphite2+harfbuzz.patch")) ;; ,(search-patch "icecat-use-system-graphite2+harfbuzz.patch"))
;; ("icecat-use-system-media-libs.patch" ;; ("icecat-use-system-media-libs.patch"
;; ,(search-patch "icecat-use-system-media-libs.patch")) ;; ,(search-patch "icecat-use-system-media-libs.patch"))
rust
("patch" ,(canonical-package patch)) `(,rust "cargo")
rust-cbindgen-0.19
("rust" ,rust) llvm-11
("cargo" ,rust "cargo") clang-11
("rust-cbindgen" ,rust-cbindgen-0.19) perl
("llvm" ,llvm-11) node
("clang" ,clang-11) python-wrapper
("perl" ,perl) yasm
("node" ,node) nasm ; XXX FIXME: only needed on x86_64 and i686
("python" ,python-wrapper) pkg-config
("yasm" ,yasm) m4
("nasm" ,nasm) ; XXX FIXME: only needed on x86_64 and i686 which))
("pkg-config" ,pkg-config)
("m4" ,m4)
("which" ,which)))
(arguments (arguments
`(#:tests? #f ;not worth the cost (list
#:tests? #f ;not worth the cost
;; Some dynamic lib was determined at runtime, so rpath check may fail. ;; Some dynamic lib was determined at runtime, so rpath check may fail.
#:validate-runpath? #f #:validate-runpath? #f
#:configure-flags `("--enable-application=browser" #:configure-flags
#~(list
"--enable-application=browser"
"--with-distribution-id=org.gnu" "--with-distribution-id=org.gnu"
"--enable-geckodriver" "--enable-geckodriver"
;; Do not require addons in the global app or ;; Do not require addons in the global app or system directories to
;; system directories to be signed by Mozilla. ;; be signed by Mozilla.
"--with-unsigned-addon-scopes=app,system" "--with-unsigned-addon-scopes=app,system"
"--allow-addon-sideload" "--allow-addon-sideload"
@ -1001,8 +1002,7 @@ (define-public icecat
"--disable-crashreporter" "--disable-crashreporter"
"--disable-eme" "--disable-eme"
;; Building with debugging symbols takes ~5GiB, so ;; Building with debugging symbols takes ~5GiB, so disable it.
;; disable it.
"--disable-debug" "--disable-debug"
"--disable-debug-symbols" "--disable-debug-symbols"
@ -1012,22 +1012,18 @@ (define-public icecat
"--enable-strip" "--enable-strip"
"--disable-elf-hack" "--disable-elf-hack"
;; Clang is needed to build Stylo, Mozilla's new ;; Clang is needed to build Stylo, Mozilla's new CSS engine. We must
;; CSS engine. We must specify the clang paths ;; specify the clang paths manually, because otherwise the Mozilla
;; manually, because otherwise the Mozilla build ;; build system looks in the directories returned by llvm-config
;; system looks in the directories returned by ;; --bindir and llvm-config --libdir, which return paths in the llvm
;; llvm-config --bindir and llvm-config --libdir, ;; package where clang is not found.
;; which return paths in the llvm package where (string-append "--with-clang-path="
;; clang is not found. (search-input-file %build-inputs "bin/clang"))
,(string-append "--with-clang-path=" (string-append "--with-libclang-path="
(assoc-ref %build-inputs "clang") (dirname (search-input-file %build-inputs
"/bin/clang") "lib/libclang.so")))
,(string-append "--with-libclang-path="
(assoc-ref %build-inputs "clang")
"/lib")
;; Hack to work around missing ;; Hack to work around missing "unofficial" branding in icecat.
;; "unofficial" branding in icecat.
"--enable-official-branding" "--enable-official-branding"
;; Avoid bundled libraries. ;; Avoid bundled libraries.
@ -1055,9 +1051,9 @@ (define-public icecat
;; UNBUNDLE-ME! "--enable-system-sqlite" ;; UNBUNDLE-ME! "--enable-system-sqlite"
) )
#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums' #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
#:modules ((ice-9 ftw) #:modules `((ice-9 ftw)
(ice-9 match) (ice-9 match)
(srfi srfi-1) (srfi srfi-1)
(srfi srfi-26) (srfi srfi-26)
@ -1067,12 +1063,10 @@ (define-public icecat
(guix build gremlin) (guix build gremlin)
,@%gnu-build-system-modules) ,@%gnu-build-system-modules)
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'apply-guix-specific-patches (add-after 'unpack 'apply-guix-specific-patches
(lambda* (#:key inputs native-inputs #:allow-other-keys) (lambda* (#:key inputs native-inputs #:allow-other-keys)
(let ((patch (string-append (assoc-ref (or native-inputs inputs) (let ((patch (search-input-file inputs "bin/patch")))
"patch")
"/bin/patch")))
(for-each (match-lambda (for-each (match-lambda
((label . file) ((label . file)
(when (and (string-prefix? "icecat-" label) (when (and (string-prefix? "icecat-" label)
@ -1132,12 +1126,10 @@ (define-public icecat
)))) ))))
(add-after 'remove-bundled-libraries 'fix-ffmpeg-runtime-linker (add-after 'remove-bundled-libraries 'fix-ffmpeg-runtime-linker
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let* ((ffmpeg (assoc-ref inputs "ffmpeg"))
(libavcodec (string-append ffmpeg "/lib/libavcodec.so")))
;; Arrange to load libavcodec.so by its absolute file name. ;; Arrange to load libavcodec.so by its absolute file name.
(substitute* "dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp" (substitute* "dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp"
(("libavcodec\\.so") (("libavcodec\\.so")
libavcodec))))) (search-input-file inputs "lib/libavcodec.so")))))
(add-after 'fix-ffmpeg-runtime-linker 'build-sandbox-whitelist (add-after 'fix-ffmpeg-runtime-linker 'build-sandbox-whitelist
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(define (runpath-of lib) (define (runpath-of lib)
@ -1202,10 +1194,9 @@ (define (runpaths-of-input label)
;; configure does not work followed by both "SHELL=..." and ;; configure does not work followed by both "SHELL=..." and
;; "CONFIG_SHELL=..."; set environment variables instead ;; "CONFIG_SHELL=..."; set environment variables instead
(lambda* (#:key outputs configure-flags #:allow-other-keys) (lambda* (#:key outputs configure-flags #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((bash (which "bash"))
(bash (which "bash"))
(abs-srcdir (getcwd)) (abs-srcdir (getcwd))
(flags `(,(string-append "--prefix=" out) (flags `(,(string-append "--prefix=" #$output)
,(string-append "--with-l10n-base=" ,(string-append "--with-l10n-base="
abs-srcdir "/l10n") abs-srcdir "/l10n")
,@configure-flags))) ,@configure-flags)))
@ -1217,20 +1208,19 @@ (define (runpaths-of-input label)
(setenv "CC" "clang") (setenv "CC" "clang")
(setenv "CXX" "clang++") (setenv "CXX" "clang++")
(setenv "LDFLAGS" (string-append "-Wl,-rpath=" (setenv "LDFLAGS" (string-append "-Wl,-rpath="
(assoc-ref outputs "out") #$output "/lib/icecat"))
"/lib/icecat"))
(setenv "MACH_USE_SYSTEM_PYTHON" "1") (setenv "MACH_USE_SYSTEM_PYTHON" "1")
(setenv "MOZ_NOSPAM" "1") (setenv "MOZ_NOSPAM" "1")
(setenv "MOZ_BUILD_DATE" ,%icecat-build-id) ; avoid timestamp (setenv "MOZ_BUILD_DATE" #$%icecat-build-id) ; avoid timestamp
(format #t "build directory: ~s~%" (getcwd)) (format #t "build directory: ~s~%" (getcwd))
(format #t "configure flags: ~s~%" flags) (format #t "configure flags: ~s~%" flags)
(call-with-output-file "mozconfig" (call-with-output-file "mozconfig"
(lambda (out) (lambda (port)
(for-each (lambda (flag) (for-each (lambda (flag)
(format out "ac_add_options ~a\n" flag)) (format port "ac_add_options ~a\n" flag))
flags))) flags)))
(invoke "./mach" "configure")))) (invoke "./mach" "configure"))))
@ -1264,16 +1254,14 @@ (define (runpaths-of-input label)
;; reason. Use 'find-files' to avoid having to deal with the ;; reason. Use 'find-files' to avoid having to deal with the
;; system/architecture-specific file name. ;; system/architecture-specific file name.
(install-file (first (find-files "." "geckodriver")) (install-file (first (find-files "." "geckodriver"))
(string-append (assoc-ref outputs "out") "/bin")))) (string-append #$output "/bin"))))
(add-after 'install 'wrap-program (add-after 'install 'wrap-program
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((lib (string-append #$output "/lib"))
(lib (string-append out "/lib")) (gtk #$(this-package-input "gtk+"))
(gtk (assoc-ref inputs "gtk+"))
(gtk-share (string-append gtk "/share")) (gtk-share (string-append gtk "/share"))
(ld-libs (map (lambda (label) (ld-libs '#$(map (lambda (label)
(string-append (assoc-ref inputs label) (file-append (this-package-input label) "/lib"))
"/lib"))
'("libpng-apng" '("libpng-apng"
"libxscrnsaver" "libxscrnsaver"
"mesa" "mesa"
@ -1291,32 +1279,30 @@ (define (runpaths-of-input label)
;; `("MOZ_ENABLE_WAYLAND" = ("1")) ;; `("MOZ_ENABLE_WAYLAND" = ("1"))
`("LD_LIBRARY_PATH" prefix ,ld-libs))))) `("LD_LIBRARY_PATH" prefix ,ld-libs)))))
(add-after 'wrap-program 'install-desktop-entry (add-after 'wrap-program 'install-desktop-entry
(lambda* (#:key outputs #:allow-other-keys) (lambda _
;; Install the '.desktop' file. ;; Install the '.desktop' file.
(let* ((desktop-file "taskcluster/docker/icecat-snap/icecat.desktop") (let* ((desktop-file "taskcluster/docker/icecat-snap/icecat.desktop")
(out (assoc-ref outputs "out")) (applications (string-append #$output "/share/applications")))
(applications (string-append out "/share/applications")))
(substitute* desktop-file (substitute* desktop-file
(("^Exec=icecat") (string-append "Exec=" out "/bin/icecat")) (("^Exec=icecat") (string-append "Exec=" #$output "/bin/icecat"))
(("IceCat") "GNU IceCat") (("IceCat") "GNU IceCat")
(("Icon=.*") "Icon=icecat\n") (("Icon=.*") "Icon=icecat\n")
(("NewWindow") "new-window") (("NewWindow") "new-window")
(("NewPrivateWindow") "new-private-window")) (("NewPrivateWindow") "new-private-window"))
(install-file desktop-file applications)))) (install-file desktop-file applications))))
(add-after 'install-desktop-entry 'install-icons (add-after 'install-desktop-entry 'install-icons
(lambda* (#:key outputs #:allow-other-keys) (lambda _
(let ((out (assoc-ref outputs "out")))
(with-directory-excursion "browser/branding/official" (with-directory-excursion "browser/branding/official"
(for-each (for-each
(lambda (file) (lambda (file)
(let* ((size (string-filter char-numeric? file)) (let* ((size (string-filter char-numeric? file))
(icons (string-append out "/share/icons/hicolor/" (icons (string-append #$output "/share/icons/hicolor/"
size "x" size "/apps"))) size "x" size "/apps")))
(mkdir-p icons) (mkdir-p icons)
(copy-file file (string-append icons "/icecat.png")))) (copy-file file (string-append icons "/icecat.png"))))
'("default16.png" "default22.png" "default24.png" '("default16.png" "default22.png" "default24.png"
"default32.png" "default48.png" "content/icon64.png" "default32.png" "default48.png" "content/icon64.png"
"mozicon128.png" "default256.png"))))))))) "mozicon128.png" "default256.png"))))))))
(home-page "https://www.gnu.org/software/gnuzilla/") (home-page "https://www.gnu.org/software/gnuzilla/")
(synopsis "Entirely free browser derived from Mozilla Firefox") (synopsis "Entirely free browser derived from Mozilla Firefox")
(description (description