unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Ian Eure <ian@retrospec.tv>
To: 71121@debbugs.gnu.org
Cc: Ian Eure <ian@retrospec.tv>
Subject: [bug#71121] [PATCH 2/3] gnu: librewolf: Rebuild source tarball
Date: Wed, 22 May 2024 07:59:55 -0700	[thread overview]
Message-ID: <20240522145956.31218-2-ian@retrospec.tv> (raw)
In-Reply-To: <20240522145956.31218-1-ian@retrospec.tv>

* gnu/packages/librewolf.scm (librewolf): This patch removes an intermediate
step in the build chain.  The upstream source tarball is created with an
automated build process, where Firefox sources are fetched, patched, and
repacked.  Rather than download the output of that process, as the package has
been, it’s now replicated within the build process, similar to how IceCat
works.

Change-Id: I0f1c2a10252cbbff9b3b3140f6ea3a594df0c97b
---
 gnu/packages/librewolf.scm | 120 +++++++++++++++++++++++++++++++++----
 1 file changed, 108 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/librewolf.scm b/gnu/packages/librewolf.scm
index fa83857c96..bb8bc8a283 100644
--- a/gnu/packages/librewolf.scm
+++ b/gnu/packages/librewolf.scm
@@ -40,10 +40,12 @@
 
 
 (define-module (gnu packages librewolf)
+  #:use-module ((srfi srfi-1) #:hide (zip))
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system cargo)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix gexp)
   #:use-module (guix packages)
@@ -62,6 +64,7 @@ (define-module (gnu packages librewolf)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
+  #:use-module (gnu packages gnuzilla)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages hunspell)
   #:use-module (gnu packages icu4c)
@@ -81,6 +84,7 @@ (define-module (gnu packages librewolf)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages rust)
   #:use-module (gnu packages rust-apps)
   #:use-module (gnu packages speech)
@@ -89,6 +93,109 @@ (define-module (gnu packages librewolf)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xorg))
 
+(define (firefox-source-origin version hash)
+  (origin
+    (method url-fetch)
+    (uri (string-append
+          "https://ftp.mozilla.org/pub/firefox/releases/"
+          version "/source/" "firefox-" version
+          ".source.tar.xz"))
+    (sha256 (base32 hash))))
+
+(define (librewolf-source-origin version hash)
+  (origin
+    (method git-fetch)
+    (uri (git-reference
+          (url "https://codeberg.org/librewolf/source.git")
+          (commit version)
+          (recursive? #t)))
+    (file-name (git-file-name "librewolf-source" version))
+    (sha256 (base32 hash))))
+
+(define computed-origin-method (@@ (guix packages) computed-origin-method))
+
+(define librewolf-source
+  (let* ((ff-src (firefox-source-origin "125.0.2" "16gpd6n52lshvkkha41z7xicggj64dw0qhr5gd07bcxsc4rmdl39"))
+         (version "125.0.2-1")
+         (lw-src (librewolf-source-origin version "17i36s2ny1pv3cz44w0gz48fy4vjfw6vp9jk21j62f5d3dl726x8")))
+
+    (origin
+      (method computed-origin-method)
+      (file-name (string-append "librewolf-" version ".source.tar.gz"))
+      (sha256 #f)
+      (uri
+       (delay
+         (with-imported-modules '((guix build utils))
+           #~(begin
+               (use-modules (guix build utils))
+               (set-path-environment-variable
+                "PATH" '("bin")
+                (list #+python
+                      #+(canonical-package bash)
+                      #+(canonical-package gnu-make)
+                      #+(canonical-package coreutils)
+                      #+(canonical-package findutils)
+                      #+(canonical-package patch)
+                      #+(canonical-package xz)
+                      #+(canonical-package sed)
+                      #+(canonical-package grep)
+                      #+(canonical-package gzip)
+                      #+(canonical-package tar)))
+               (set-path-environment-variable
+                "PYTHONPATH"
+                (list #+(format #f "lib/python~a/site-packages"
+                                (version-major+minor
+                                 (package-version python))))
+                '#+(cons python-jsonschema
+                         (map second
+                              (package-transitive-propagated-inputs
+                               python-jsonschema))))
+
+               ;; Copy LibreWolf source into the build directory and make
+               ;; everything writable.
+               (copy-recursively #+lw-src ".")
+               (for-each make-file-writable (find-files "."))
+
+               ;; Patch Makefile to use the upstream source instead of downloading.
+               (substitute* '("Makefile")
+                 (("^ff_source_tarball:=.*")
+                  (string-append "ff_source_tarball:=" #+ff-src)))
+
+               ;; Stage locales
+               (begin
+                 (format #t "Staging locales...~%")
+                 (force-output)
+                 (mkdir "l10n-staging")
+                 (with-directory-excursion "l10n-staging"
+                   (for-each
+                    (lambda (locale-dir)
+                      (let ((locale
+                             (string-drop (basename locale-dir)
+                                          (+ 32  ; length of hash
+                                             (string-length "-mozilla-locale-")))))
+                        (format #t "  ~a~%" locale)
+                        (force-output)
+                        (copy-recursively locale-dir locale
+                                          #:log (%make-void-port "w"))
+                        (for-each make-file-writable (find-files locale))
+                        (with-directory-excursion locale
+                          (when (file-exists? ".hgtags")
+                            (delete-file ".hgtags")))))
+                    '#+all-mozilla-locales)))
+
+               ;; Patch build script to use staged locales.
+               (begin
+                 (substitute* '("scripts/generate-locales.sh")
+                   (("wget") "# wget")
+                   (("unzip") "# unzip")
+                   (("mv browser/locales/l10n/\\$1-\\*/")
+                    "mv ../l10n-staging/$1/")))
+
+               ;; Run the build script
+               (invoke "make" "all")
+               (copy-file (string-append "librewolf-" #$version ".source.tar.gz")
+                          #$output))))))))
+
 ;; Define the versions of rust needed to build librewolf, trying to match
 ;; upstream.  See the file taskcluster/ci/toolchain/rust.yml at
 ;; https://searchfox.org under the particular firefox release, like
@@ -104,18 +211,7 @@ (define-public librewolf
   (package
     (name "librewolf")
     (version "125.0.2-1")
-    (source
-     (origin
-       (method url-fetch)
-
-       (uri (string-append "https://gitlab.com/api/v4/projects/32320088/"
-                           "packages/generic/librewolf-source/"
-                           version
-                           "/librewolf-"
-                           version
-                           ".source.tar.gz"))
-       (sha256
-        (base32 "09qzdaq9l01in9h4q14vyinjvvffycha2iyjqj5p4dd5jh6q5zma"))))
+    (source librewolf-source)
     (build-system gnu-build-system)
     (arguments
      (list
-- 
2.41.0





  reply	other threads:[~2024-05-22 15:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-22 14:53 [bug#71121] [PATCH 0/3] Update LibreWolf to 126.0-1 [security fixes] Ian Eure
2024-05-22 14:59 ` [bug#71121] [PATCH 1/3] gnu: all-mozilla-locales: Add Santali locale; make public Ian Eure
2024-05-22 14:59   ` Ian Eure [this message]
2024-05-30  1:30     ` [bug#71121] [PATCH 2/3] gnu: librewolf: Rebuild source tarball Maxim Cournoyer
2024-05-30  1:48       ` Ian Eure
2024-05-30 12:54         ` Maxim Cournoyer
2024-06-01 16:30           ` Ian Eure
2024-05-22 14:59   ` [bug#71121] [PATCH 3/3] gnu: librewolf: Update to 126.0-1 Ian Eure
2024-05-30 22:39 ` [bug#71121] [PATCH v2 1/3] gnu: all-mozilla-locales: Add Santali locale; make public Ian Eure
2024-05-30 22:39   ` [bug#71121] [PATCH v2 2/3] gnu: librewolf: Rebuild source tarball Ian Eure
2024-05-30 22:39   ` [bug#71121] [PATCH v2 3/3] gnu: librewolf: Update to 126.0-1 Ian Eure
2024-06-01 11:33     ` bug#71121: " Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240522145956.31218-2-ian@retrospec.tv \
    --to=ian@retrospec.tv \
    --cc=71121@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).