Add guidelines for packaging Mozilla Firefox extensions #1462

Open
noctua wants to merge 2 commits from my-firefox-extension-docs into main
First-time contributor

Added guidelines to package Mozilla Firefox extensions.

Added guidelines to package Mozilla Firefox extensions.
Owner

How does a packager determine what the gecko id should be?

How does a packager determine what the gecko id should be?
Author
First-time contributor

It is in the manifest.json file in the field id. If the field id does not exist, as reported in this PR content, the extension cannot work.

It is in the `manifest.json` file in the field `id`. If the field `id` does not exist, as reported in this PR content, the extension cannot work.
Owner

So this will be in that file, and that file will exist, in every extension?

So this will be in that file, and that file will exist, in every extension?
Author
First-time contributor

yes. Manifest file is mandatory for each extension.

yes. Manifest file is mandatory for each extension.
Owner

Ok, thank you!

Ok, thank you!
Author
First-time contributor

rebased onto 6e208c155d

rebased onto 6e208c155d7fa34013b363c5497323cf553c0b01
Owner

One significant problem I see with this is that it's just not OK to just take the .xpi file from upstream and copy it over and be done, just as it's not acceptable to copy an upstream compiled binary into _bindir. We don't know what's in there; it could have minimized javascript sources or the output of something that compilers to javascript. In fact, I'd argue that even if there wasn't anything but a single javascript file in there, we still shouldn't be shipping the upstream .xpi file.

One of the best-packaged extensions is mozilla-ublock-origin. That spec is way more complicated: it lists out all of the bundled javascript libraries, it invokes the upstream source build script and it recreates all of the .wasm files. I expect that most extensions would be simpler but that the common case is that there is still something bundled or something that needs building.

One significant problem I see with this is that it's just not OK to just take the .xpi file from upstream and copy it over and be done, just as it's not acceptable to copy an upstream compiled binary into _bindir. We don't know what's in there; it could have minimized javascript sources or the output of something that compilers to javascript. In fact, I'd argue that even if there wasn't anything but a single javascript file in there, we still shouldn't be shipping the upstream .xpi file. One of the best-packaged extensions is mozilla-ublock-origin. That spec is way more complicated: it lists out all of the bundled javascript libraries, it invokes the upstream source build script and it recreates all of the .wasm files. I expect that most extensions would be simpler but that the common case is that there is still something bundled or something that needs building.
Author
First-time contributor

If you are concerned about security, I think that the best option should be still to get the .xpi file directly from Mozilla store, because the AMO team actually performs security checks.

uBlock Origin can be packaged in that manner because it is a particular case (give a look to the source repository) and usually, the most of extensions don't have that structure. I think the most generic way is the one described in the proposed PR.

If you are concerned about security, I think that the best option should be still to get the .xpi file directly from Mozilla store, because the AMO team actually performs security checks. uBlock Origin can be packaged in that manner because it is a particular case (give a look to the source repository) and usually, the most of extensions don't have that structure. I think the most generic way is the one described in the proposed PR.
Member

Guidelines already require that code be rebuilt from source. Even if there isn't anything to be rebuilt, I would expect that the .xpi at least be unpacked and repacked (as in the missing ID example) so that the contents can be verified.

Guidelines already require that code be rebuilt from source. Even if there isn't anything to be rebuilt, I would expect that the .xpi at least be unpacked and repacked (as in the missing ID example) so that the contents can be verified.
Member

This .xpi file should be built from source like any other artifact. See for example mozilla-noscript or mozilla-privacy-badger.

This `.xpi` file should be built from source like any other artifact. See for example [mozilla-noscript](https://src.fedoraproject.org/rpms/mozilla-noscript/blob/rawhide/f/mozilla-noscript.spec) or [mozilla-privacy-badger](https://src.fedoraproject.org/rpms/mozilla-privacy-badger/blob/rawhide/f/mozilla-privacy-badger.spec).
Author
First-time contributor

Yes. I need to change the source and point to their git source repository.

Yes. I need to change the source and point to their git source repository.
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin my-firefox-extension-docs:my-firefox-extension-docs
git switch my-firefox-extension-docs

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff my-firefox-extension-docs
git switch my-firefox-extension-docs
git rebase main
git switch main
git merge --ff-only my-firefox-extension-docs
git switch my-firefox-extension-docs
git rebase main
git switch main
git merge --no-ff my-firefox-extension-docs
git switch main
git merge --squash my-firefox-extension-docs
git switch main
git merge --ff-only my-firefox-extension-docs
git switch main
git merge my-firefox-extension-docs
git push origin main
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
packaging/guidelines!1462
No description provided.