||<tablestyle="float:right; font-size: 0.9em; width:30%; background:#F1F1ED; background-repeat: no-repeat; background-position:  98% 0.5ex; margin: 0 0 1em 1em; padding: 0.5em;"><<TableOfContents>>||

= Prerequisites =
 * a Launchpad account
 * Ubuntu with these packages installed: build-essential firefox-3.5 xulrunner-dev mozilla-devscripts cdbs debhelper devscripts bzr
 * create a working directory where you want to practice this tutorial
 * cd into that directory and branch the ubufox upstream source, which we will used as an example
 {{{
bzr branch http://bazaar.launchpad.net/~asac/ubufox/main ubufox.upstream}}}
 * branch the package template provided in the firefox-extensions launchpad projects bzr repo
 {{{
bzr branch http://bazaar.launchpad.net/~mozillateam/firefox-extensions/XPI.TEMPLATE}}}
 
= Packaging =
== Before you package an extension ==
 * add the extension you are looking at to the appropriate table on https://wiki.ubuntu.com/MozillaTeam/Extensions/List and fill content into the columns
 * check the extension license for main, universe suitability. Below a list of good licenses. for other licenses, ask on #ubuntu-mozillateam (freenode)
  * MPL/GPL/LGPL - tri-license: this is the preferred license
  * GPL
  * LGPL
  * MPL
  * MIT
  * 2 or 3-clause BSD

== Packaging Procedure ==
 * For most extensions, use the packaging template that makes use of mozilla-devscripts. You can get the template from bzr:
 {{{
bzr branch http://bazaar.launchpad.net/~mozillateam/firefox-extensions/XPI.TEMPLATE}}}
 * create an upstream branch in the firefox-extensions project on launchpad. Be sure to check for a license file. In case there's none, contact upstream. For projects that distribute sources with a build-system/build-command this should be an import of the release you want to package
 {{{
cd directory-with-upstream-sources
bzr init
bzr add .
bzr commit -m "* import of upstream source (vVERSION.INFO)"
bzr push bzr+ssh://$LAUNCHPAD_ID@bazaar.launchpad.net/~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.upstream }}}
 * create a packaging branch derived from the upstream branch you just imported
 {{{
bzr branch http://bazaar.launchpad.net/~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.upstream $EXTENSIONNAME.ubuntu}}}
 * create the debian directory based on the debian directory in XPI.TEMPLATE in your package branch
 {{{
cd $EXTENSIONNAME.ubuntu
cp -r ../XPI.TEMPLATE/debian debian}}}
 * edit the debian/control, debian/rules and debian/copyright appropriately
  * the debian/rules template gives some brief comments on what variables you can use to tweak the build
  * please make sure that lines in Description in debian/control, and in debian/copyright are not longer than 80 characters.
 * add the new debian/ files to bzr
 {{{
bzr add debian/
}}}
 * commit and push your packaging branch
 {{{
bzr commit -m "* initial packaging based on XPI.TEMPLATE
 * ... (describe your changes here
"
bzr push bzr+ssh://$LAUNCHPAD_ID@bazaar.launchpad.net/~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.ubuntu}}}

== Build a test package locally ==
 * you can just cd to the {{{$EXTENSIONNAME.ubuntu}}} directory and use debuild -b
 * alternatively, you can use bzr builddeb (you need bzr-builddeb package installed). Details on how to do this are beyond this page.
 * If everything is ok, request a review and/or sponsorship, as described below.

= Preparing an update =
== Preparing an update for current development release ==
 * Branch your upstream branch, add new upstream release and push back.
 {{{
bzr branch lp:~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.upstream
rm -rf $EXTENSIONNAME.upstream/*
cp -r new-upstream-sources/* $EXTENSIONNAME.upstream/
cd $EXTENSIONNAME.upstream
bzr add .
bzr commit -m " * New upstream release v$NEW_UPSTREAM_VERSION"
bzr push lp:~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.upstream}}}
 * Branch your ubuntu branch.
 {{{
bzr branch lp:~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.ubuntu
cd $EXTENSIONNAME.ubuntu}}}
 * In case your extension was released to Ubuntu archive, merge it with ~ubuntu-dev's branch.
 {{{
bzr merge lp:~ubuntu-dev/firefox-extensions/$EXTENSIONNAME.ubuntu}}}
 * Merge it with upstream branch, in order to get new upstream release.
 {{{
bzr merge lp:~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.upstream}}}
 * Add a new changelog entry, that will have UNRELEASED for distribution. Add one change "open tree for development". Commit these changes.
 {{{
cd $EXTENSIONNAME.upstream
dch -v $NEW_UPSTREAM_VERSION-0ubuntu1 -DUNRELEASED "open tree for development"
bzr commit -m " * open tree for development"}}}
 * Adjust packaging if it's needed. Don't forget to add your changes to the changelog. You are encouraged to make small commits with commit notes at this step. The commit described in the next step should only show removed entry in changelog, and updated release distribution.
 {{{
...do something and add to changelog...
bzr commit -m " * Did something"}}}
 * Once you're satisfied, update the changelog with release distribution and remove "open tree for development" entry. Commit your changes and push to your ubuntu branch.
 {{{
dch -r
bzr commit -m " * RELEASE v$NEW_UPSTREAM_VERSION to $CURRENT_DEVELOPMENT_DISTRIBUTION"
bzr push lp:~$LAUNCHPAD_ID/firefox-extensions/$EXTENSIONNAME.ubuntu}}}
 * Follow the procedure described in Request review and/or sponsorship.
== Backporting ==
 * For backports, follow the usual procedure described on [[UbuntuBackports|backports page]].

= Request review and/or sponsorship =
 * before you request sponsorship/review, please ensure that you have added your extension to https://wiki.ubuntu.com/MozillaTeam/Extensions/List
 * if your extension is already in ubuntu archive, please file a bug with a subject "REVIEW/SPONSOR: please review and sponsor XXX" and subscribe the mozillateam
  * remember to state clearly the bzr branches you created
 * if this is a new package, just file a similar bug against the firefox-extensions launchpad project (https://bugs.launchpad.net/firefox-extensions/+filebug)

= Questions =
 * don't hesitate to ask for help on #ubuntu-mozillateam (irc.freenode.net) or join the mozillateam mailing list (ubuntu-mozillateam@lists.ubuntu.com)

''Happy Package Hacking!!''

----
[[CategoryMozillaTeam]]