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.
This commit is contained in:
Hilton Chain 2024-12-11 23:30:12 +08:00
parent 5a7e61a0a5
commit 4fe0608a5c
No known key found for this signature in database
GPG key ID: ACC66D09CA528292
3 changed files with 80 additions and 1 deletions

View file

@ -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

View file

@ -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,

View file

@ -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<nsIFile> 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);