Packaging a Firefox addon for Ubuntu

Submitted by olaf on 2016-03-25

My day to day machine is a Ubuntu LTS system. For easier administration, I have all Firefox addons installed as Ubuntu packages.

Today, the time had come again to update the Noscript addon. With Debian’s (or Ubuntu’s) mozilla-devscripts this is a straightforward task. The first step is to download the XPI package, which is version 2.9.0.10 at the time

wget https://addons.mozilla.org/firefox/downloads/latest/722/addon-722-latest.xpi

You then repackage the XPI to a .tar.gz archive and unpack it

xpi-repack -p xul-ext-noscript -u 2.9.0.10 addon-722-latest.xpi
tar xf xul-ext-noscript_2.6.9.31.orig.tar.gz
cd xul-ext-noscript-2.6.9.31

Where -p xul-ext-noscript denotes the addon package name and -u 2.9.0.10-0.1 the current version for a non-maintainer package.

A Debian package needs some files in the debian subdirectory, which is described in the Debian Policy Manual and also Debian New Maintainers’ Guide, e.g. Chapter 4 and Chapter 5. The changelog file is created with

DEBFULLNAME="John Smith" DEBEMAIL=john@example.com dch --create --package xul-ext-noscript --newversion 2.9.0.10-0.1 New upstream release

When updating an existing changelog, you omit --create and --package.

The compat file

echo 9 >debian/compat

The rules file, which can be kept very simple for Firefox addons, see CDBS/using xpi file

#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/mozilla-devscripts/xpi.mk

The control file is a bit more elaborate, but may have also a lot of defaults for Firefox addons, see debian/control

Source: xul-ext-noscript
Section: web
Priority: optional
Maintainer: John Smith <john@example.com>
Build-Depends: cdbs, debhelper (>= 9), mozilla-devscripts (>= 0.36)
Standards-Version: 3.9.4
Homepage: http://noscript.net/

Package: xul-ext-noscript
Architecture: all
Depends: ${misc:Depends} ${xpi:Depends}
Recommends: ${xpi:Recommends}
Provides: ${xpi:Provides}
Enhances: ${xpi:Enhances}
Description: Javascript/plugins permissions manager for Firefox
 This extension brings a powerful control over the way external scripts or
 embedded programs, such as Java or Flash, are loaded.
 .
 By blocking scripts and/or plugins, it improves security and disables annoying
 behaviours caused by malicious scripts.
 .
 When a script is blocked, you are notified, and you can unblock a site or a
 page, either temporarily or permanently. You can then set a whitelist of
 trusted sites based on url or on domain name.

A complete maintained package has more, of course, patches for example. See the “Debian Policy Manual” and “Debian New Maintainers’ Guide” for details.

For now this is sufficient, and we create the package with

dpkg-buildpackage -uc -us -sd -tc

Options -uc and -us prevent signing, which is unnecessary for a private package. That’s it, what remains is installing the package, so every Firefox user on the system can benefit

dpkg -i ../xul-ext-noscript_2.9.0.10-0.1_all.deb

Post a comment

All comments are held for moderation; Markdown and basic HTML formatting accepted. If you want to stay anonymous, leave name, e-mail and website empty.