How to package two firefox extensions at once

First, background on why you might need to do this. Feel free to skip down to the technical details.

I’m working on the AddArt firefox extension with some folks at the Eyebeam labs. Our extension replaces advertisements with artwork. To do this, we piggyback on the functionality of the excellent Ad Block Plus extension. We benignly inject code into ABP so that when it blocks an advertisement our code kicks in and puts in art. Our code is useless without ABP, so we have to make sure that when folks install us, they also get ABP. We wanted to save folks time and give them a one click install of our extension and the extension we depend on.

The details:

I didn’t find the simple instructions provided on Multiple Item Packaging to be simple enough, so here’s the skinny.

  1. Put the n xpi files that you want to package together in an empty directory.
  2. Create a file called install.rdf with the following contents:
    1. an <em:type>32</em:type>
    2. an <em:targetApplication> that has a minVersion and a maxVersion that are valid for all of the xpi files you are installing.
    3. an <em:id> element
  3. zip them all and rename the .zip to .xpi
  4. That is all.

It is not tricky unless you are overcomplicating it. Firefox or Thunderbird or whatever just uses the install.rdf to note that this is a multiple item install xpi file and then installs every package inside of the xpi.

Here’s what our install.rdf looks like. Feel free to sub out the appropriate min and max versions for your needs and change the id and name values. Otherwise you don’t need to actually do anything.

<?xml version=”1.0″?>
<RDF:RDF xmlns:em=”http://www.mozilla.org/2004/em-rdf#”
xmlns:NC=”http://home.netscape.com/NC-rdf#”
xmlns:RDF=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”>
<RDF:Description RDF:about=”rdf:#$hFzg+”
em:id=”{ec8030f7-c20a-464f-9b0e-13a3a9e97384}”
em:minVersion=”2.0″
em:maxVersion=”3.1″ />
<RDF:Description RDF:about=”urn:mozilla:install-manifest”
em:id=”blahblah@add-art.org”
em:name=”add-artpackage”>
<em:targetApplication RDF:resource=”rdf:#$hFzg+”/>
<em:type>32</em:type>
</RDF:Description>
</RDF:RDF>

But wait, there's more

  • Just kidding, nothing's related to this.

Leave a Reply

Your email address will not be published. Required fields are marked *