Techno Barje

How to Setup a Mozilla Extension Update Server

I’ve shared in the previous post a command line version of Mccoy. Here is a new tutorial on how to use it!

Prerequisite

  • a HTTP server
  • Patched version of mccoy, with command line capabilities : mccoy.tar.gz
  • This start kit : mccoy-test.tar.gz which bundle a sample extension and one update.xml file
$ cd /one/of/your/htdocs/dir
$ wget http://blog.techno-barje.fr/public/mccoy.tar.gz
$ tar zxvf mccoy.tar.gz
$ wget http://blog.techno-barje.fr/public/mccoy-test.tar.gz
$ tar zxvf mccoy-test.tar.gz
$ cd mccoy-test/
$ ls
update.xml  workdir  xpis


Setup your XPI with valid update information

Create a new key in Mccoy

mccoy-test $ cd workdir/
workdir $ ls
chrome  chrome.manifest  install.rdf
workdir $ ../../mccoy -createKey myextensionkey
Creating key with name : myextensionkey
Public key : MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbV+ZGXs658dOm/+4YtT+VzT5JWzMFYiQ8155fnMkOJCina2yDEBq8Lvi5qF5SyoMDkqaYeO51LR+B4p1g7oWmBW9HbOz3eA9lD/AHUR1SHiJAX7RQq8v9sPSkYta+LyVrCMFgpTmhOWPUXOnwalmL7syGkXyjxHqHCYz+s3d22QIDAQAB
The key has been successfully created!

Remember the name of your key (if you forgot the name, you can later execute mccoy -listKeys)
Inject the public key in your extension

workdir $ ./mccoy -installKey install.rdf -key myextensionkey
Public key inserted!

This will set the updateKey attribute with the public key. (you can later retrieve the public key with mccoy -publicKey myextension)
Set the updateURL attribute of the install.rdf with the URL of the update.xml file located in mccoy-test/update.xml

workdir $ vi update.rdf

Build the first xpi

$ zip -r ../xpis/mccoy-test-0.1.xpi .

»» now install this XPI! This sample extension will just display an alert with message "Mccoy 0.1!"


Create a new version of your extension

Alter the sample extension alert message with something new

workdir $ vi chrome/content/firefoxOverlay.xul

Update the version number with 0.2

workdir $ vi install.rdf

Build the new xpi

workdir $ zip -r ../xpis/mccoy-test-0.2.xpi .

Update the update xml file

workdir $ cd ..
mccoy-test $ vi update.xml
### change version with 0.2
### change updatelink with mccoy-test-0.2.xpi
### change updatehash with result of sha1sum xpis/mccoy-test-0.2.xpi

Sign the update file with mccoy

mccoy-test $ ../mccoy/mccoy -signRDF update.xml -key myextensionkey
Sign < update.xml > with key < myextensionkey >
Sign addon : urn:mozilla:extension:mccoy-test@techno-barje.fr
File signed!

This will set the signature attribute with computed with your private key.


»» You can now force the update in your firefox, relaunch it and voilà!


Some tips for debugging

Enable this two about:config entries in order to get some message in JS console about update process :

extensions.logging.enabled = true
javascript.options.showInConsole = true

Comments