From 5c3d7b1df5301ac960bcd585e0ebd921dbde3ee7 Mon Sep 17 00:00:00 2001 From: D3vil0p3r Date: May 06 2025 23:31:36 +0000 Subject: [PATCH 1/2] Add guidelines for packaging Mozilla Firefox extensions --- diff --git a/guidelines/modules/ROOT/pages/FirefoxExtensions.adoc b/guidelines/modules/ROOT/pages/FirefoxExtensions.adoc new file mode 100644 index 0000000..d860eb7 --- /dev/null +++ b/guidelines/modules/ROOT/pages/FirefoxExtensions.adoc @@ -0,0 +1,152 @@ += Packaging Mozilla Firefox Extensions +:page-authors: Your Name +:page-date: 2025-05-07 +:page-tags: packaging, firefox, extensions, rpm + +This guide explains how to properly package Mozilla Firefox extensions for Fedora. It includes the required `spec` file structure, metadata, and instructions for handling extension IDs in `manifest.json`. + +== General Guidelines + +To package a Firefox extension: + +1. Use the standard Firefox system extensions directory: ++ +[source,rpm] +---- +%global moz_extensions %{_datadir}/mozilla/extensions +%global firefox_app_id {ec8030f7-c20a-464f-9b0e-13a3a9e97384} +%global firefox_inst_dir %{moz_extensions}/%{firefox_app_id} +---- + +2. Assign a unique ID for the extension: ++ +[source,rpm] +---- +%global src_ext_id foxyproxy@eric.h.jung +---- + +3. Include the `.xpi` file as a source and install it in `%install`. + +4. Add AppStream metadata for integration with GNOME Software or other frontends. + +5. Require the `mozilla-filesystem` package and set `BuildArch: noarch`. + +== Example: Packaging an Extension Without Modification + +This example demonstrates a minimal spec for an extension that already contains a valid ID. + +[source,rpm] +---- +Name: mozilla-foxyproxy +Version: 9.2 +Release: %{autorelease} +Summary: Easy to use advanced Proxy Management tool for everyone. + +License: GPL-2.0-or-later +URL: https://getfoxyproxy.org/ +Source0: https://addons.mozilla.org/firefox/downloads/file/4472757/foxyproxy_standard-%{version}.xpi +Source1: mozilla-foxyproxy.metainfo.xml + +Requires: mozilla-filesystem +BuildArch: noarch + +%if 0%{?fedora} || 0%{?rhel} >= 7 +BuildRequires: libappstream-glib +%endif + +%description +Easy to use advanced Proxy Management tool for everyone. + +%prep +%setup -q -c + +%build + +%install +install -Dpm644 %{SOURCE0} %{buildroot}%{firefox_inst_dir}/%{src_ext_id}.xpi +install -Dpm644 %{SOURCE1} %{buildroot}%{_metainfodir}/%{name}.metainfo.xml +appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/%{name}.metainfo.xml + +%files +%{firefox_inst_dir}/%{src_ext_id}.xpi +%if 0%{?fedora} || 0%{?rhel} >= 7 +%{_metainfodir}/%{name}.metainfo.xml +%endif + +%changelog +%autochangelog +---- + +== AppStream Metadata + +Create an `.xml` metadata file with a matching name. Example: + +[source,xml] +---- + + + mozilla-foxyproxy + org.mozilla.firefox.desktop + FoxyProxy + Easy to use advanced Proxy Management tool for everyone. + https://getfoxyproxy.org/ + CC0-1.0 + GPL-2.0 + you@example.com + +---- + +== Handling Missing Extension ID + +Firefox extensions must declare a valid ID in their `manifest.json` file under the `browser_specific_settings.gecko.id` key. If the ID is missing, Firefox will not load the extension from the system directory. + +If the upstream `.xpi` lacks this field, patch it manually. Here's how. + +=== Example: Patching the Extension + +[source,rpm] +---- +Patch0: manifest.patch +---- + +Unpack and patch the extension during `%prep`, then repackage: + +[source,rpm] +---- +%prep +%setup -c +%autopatch + +%build +zip -qr ./cookie_quick_manager-%{version}.xpi * +---- + +Continue installation as normal. + +== Example Patch for `manifest.json` + +[source,diff] +---- +--- a/manifest.json ++++ b/manifest.json +@@ -27,5 +27,11 @@ + "options_ui": { + "page": "options.html", + "open_in_tab": true ++ }, ++ "browser_specific_settings": { ++ "gecko": { ++ "id": "cookiequickmanager@ysard", ++ "strict_min_version": "60.0" ++ } + } +} +---- + +== Final Notes + +* Always verify the extension works after installation. +* Ensure the ID is unique and consistent with the filename. +* Validate your AppStream metadata using `appstream-util validate-relax`. + +For more details, refer to Fedora Packaging Guidelines or reach out on the Fedora devel mailing list. From f6abcd666251a91a446c8910c8fe60c8f4b47c41 Mon Sep 17 00:00:00 2001 From: D3vil0p3r Date: May 09 2025 17:33:27 +0000 Subject: [PATCH 2/2] Fix text --- diff --git a/guidelines/modules/ROOT/pages/FirefoxExtensions.adoc b/guidelines/modules/ROOT/pages/FirefoxExtensions.adoc index d860eb7..a7133be 100644 --- a/guidelines/modules/ROOT/pages/FirefoxExtensions.adoc +++ b/guidelines/modules/ROOT/pages/FirefoxExtensions.adoc @@ -18,7 +18,7 @@ To package a Firefox extension: %global firefox_inst_dir %{moz_extensions}/%{firefox_app_id} ---- -2. Assign a unique ID for the extension: +2. Assign the extension ID. Its value can be retrieved from the `manifest.json` file inside the `.xpi` archive: + [source,rpm] ----