1

I'm currently using cfx xpi to package my add-on to a .xpi file, as instructed here in the Add-on SDK Development Guide.

I would now like to build my code on a machine where the Add-on SDK is not present, which means no Python, and no cfx. Is it possible to do this, preferably from the command line?

I've tried simply zipping up the MyAddon folder to MyAddon.zip, and then renaming it to MyAddon.xpi, but when I try to install it on Firefox, I get the error message "This add-on could not be installed because it appears to be corrupt."

Any and all help appreciated.

BeneGal
  • 180
  • 1
  • 11

2 Answers2

3

Currently, you need the cfx tool to build add-ons if you want to use the Addon SDK. The build process includes mapping dependencies, adding in the bootstrap.js file for restartless addons, and a few files to make it loadable via Firefox. Just zipping it and calling it a xpi won't do the trick.

The Addon-SDK team is looking at options to make the same directory structure that you use for development able to be loaded directly into Firefox, removing the build step: Proposal

I worked on a JS-only builder addon during the SDK work week a few weeks ago that involves an addon essentially building and installing another addon. You can probably pull out components of that and node-ify them if you can run node on your build server. What -is- available on that other machine? What are you trying to accomplish that this set up is necessary, with a machine that doesn't even have python installed?

jsantell
  • 1,268
  • 8
  • 10
  • We have dedicated machines in work for building, and we're generally not allowed to request any special setups or installations. I think that assuming Python would not be installed was a mistake. Thanks for your definitive answer though, knowing I'll definitely need cfx, I'll add the sdk code to the delivery and work from there. – BeneGal Oct 11 '13 at 01:03
  • We would really like to not require CFX (so that the development directory is the same thing that would be installed), but that's still a ways off. Why do you need to build it on those machines, can't you just pass around the built xpi? – jsantell Oct 11 '13 at 03:24
0

OK I figured out how to manually create .xpi Firefox extensions after about an hour of frustrating trial and error.

The file structure that Firefox creates for all .xpi when you run cfx run is this:

myfirefoxaddonname.zip
   -> bootstrap.js
   -> defaults
         -> preferences
                 -> prefs.js NOTE: Empty by default
   -> harness-options.json
   -> resources
         -> myfirefoxaddonname
                  -> data
                          -> your stuff (CSS, JS, etc.) goes here
                  -> lib
                          -> main.js
                  -> test
   -> package.json
   -> install.rdf
   -> locales.json  NOTE: has one line by default: {"locales": []}
   -> locale NOTE: Empty by default

Some of these files/folders are unnecessary (e.g. the test folder), but I've included because that's the default format Firefox .xpi add-ons require.

The way I found this out was by running cfx xpi, then navigating to the created .xpi file, renaming it a .zip, and unzipping it to see its contents.

user2415992
  • 481
  • 7
  • 22