From 4fe0608a5cc44e3f368dab98709d0ab4392a37ed Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Wed, 11 Dec 2024 23:30:12 +0800 Subject: [PATCH] nongnu: firefox-esr: Support Guix icecat browser extensions. * nongnu/packages/patches/firefox-esr-compare-paths.patch: New file. * nongnu/packages/patches/firefox-esr-use-system-wide-dir.patch: New file. * nongnu/packages/mozilla.scm (firefox-esr)[source]: Add them. [arguments]<#:configure-flags>: Allow unsigned system addons. [native-search-paths]: Add ICECAT_SYSTEM_DIR. --- nongnu/packages/mozilla.scm | 20 +++++++++- .../patches/firefox-esr-compare-paths.patch | 23 +++++++++++ .../firefox-esr-use-system-wide-dir.patch | 38 +++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 nongnu/packages/patches/firefox-esr-compare-paths.patch create mode 100644 nongnu/packages/patches/firefox-esr-use-system-wide-dir.patch diff --git a/nongnu/packages/mozilla.scm b/nongnu/packages/mozilla.scm index e46d6d1..d6bc572 100644 --- a/nongnu/packages/mozilla.scm +++ b/nongnu/packages/mozilla.scm @@ -98,7 +98,15 @@ (uri (string-append "https://archive.mozilla.org/pub/firefox/releases/" version "/source/firefox-" version ".source.tar.xz")) (sha256 - (base32 "1awl0yhcv693q23p6zw9rw40gicpp6pakbx616qsl5w85d2arijz")))) + (base32 "1awl0yhcv693q23p6zw9rw40gicpp6pakbx616qsl5w85d2arijz")) + (patches + (map (lambda (patch) + (search-path + (map (cut string-append <> "/nongnu/packages/patches") + %load-path) + patch)) + '("firefox-esr-compare-paths.patch" + "firefox-esr-use-system-wide-dir.patch"))))) (build-system gnu-build-system) (arguments (list @@ -130,6 +138,11 @@ "--with-distribution-id=org.nonguix" "--disable-official-branding" + ;; Do not require addons in the global app or system directories to + ;; be signed by Mozilla. + "--allow-addon-sideload" + "--with-unsigned-addon-scopes=app,system" + ;; Features "--disable-tests" "--disable-updater" @@ -482,6 +495,11 @@ rust-cbindgen-0.26 which yasm)) + (native-search-paths + (list (search-path-specification + (variable "ICECAT_SYSTEM_DIR") + (separator #f) ;single entry + (files '("lib/icecat"))))) (home-page "https://mozilla.org/firefox/") (synopsis "Trademarkless version of Firefox") (description diff --git a/nongnu/packages/patches/firefox-esr-compare-paths.patch b/nongnu/packages/patches/firefox-esr-compare-paths.patch new file mode 100644 index 0000000..dd113c7 --- /dev/null +++ b/nongnu/packages/patches/firefox-esr-compare-paths.patch @@ -0,0 +1,23 @@ +See comment in gnu/build/icecat-extension.scm. + +diff --git a/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs b/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs +index 0b885f6..0bbfbee 100644 +--- a/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs ++++ b/toolkit/mozapps/extensions/internal/XPIDatabase.sys.mjs +@@ -3607,6 +3607,7 @@ export const XPIDatabaseReconcile = { + if ( + newAddon || + oldAddon.updateDate != xpiState.mtime || ++ oldAddon.path != xpiState.path || + (aUpdateCompatibility && this.isAppBundledLocation(installLocation)) + ) { + newAddon = this.updateMetadata( +@@ -3615,8 +3616,6 @@ export const XPIDatabaseReconcile = { + xpiState, + newAddon + ); +- } else if (oldAddon.path != xpiState.path) { +- newAddon = this.updatePath(installLocation, oldAddon, xpiState); + } else if (aUpdateCompatibility || aSchemaChange) { + newAddon = this.updateCompatibility( + installLocation, diff --git a/nongnu/packages/patches/firefox-esr-use-system-wide-dir.patch b/nongnu/packages/patches/firefox-esr-use-system-wide-dir.patch new file mode 100644 index 0000000..67a1709 --- /dev/null +++ b/nongnu/packages/patches/firefox-esr-use-system-wide-dir.patch @@ -0,0 +1,38 @@ +Replace "/usr/lib/mozilla" (the system-wide directory for extensions and +native manifests) with "$ICECAT_SYSTEM_DIR". + +diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp +index d3af49b495..4beef0aa7e 100644 +--- a/toolkit/xre/nsXREDirProvider.cpp ++++ b/toolkit/xre/nsXREDirProvider.cpp +@@ -296,24 +296,12 @@ nsresult nsXREDirProvider::GetBackgroundTasksProfilesRootDir( + static nsresult GetSystemParentDirectory(nsIFile** aFile) { + nsresult rv; + nsCOMPtr localDir; +-# if defined(XP_MACOSX) +- rv = GetOSXFolderType(kOnSystemDisk, kApplicationSupportFolderType, +- getter_AddRefs(localDir)); +- if (NS_SUCCEEDED(rv)) { +- rv = localDir->AppendNative("Mozilla"_ns); +- } +-# else +- constexpr auto dirname = +-# ifdef HAVE_USR_LIB64_DIR +- "/usr/lib64/mozilla"_ns +-# elif defined(__OpenBSD__) || defined(__FreeBSD__) +- "/usr/local/lib/mozilla"_ns +-# else +- "/usr/lib/mozilla"_ns +-# endif +- ; +- rv = NS_NewNativeLocalFile(dirname, false, getter_AddRefs(localDir)); +-# endif ++ ++ const char* systemParentDir = getenv("ICECAT_SYSTEM_DIR"); ++ if (!systemParentDir || !*systemParentDir) return NS_ERROR_FAILURE; ++ ++ rv = NS_NewNativeLocalFile(nsDependentCString(systemParentDir), false, ++ getter_AddRefs(localDir)); + + if (NS_SUCCEEDED(rv)) { + localDir.forget(aFile);