Building and Packaging FireFox Extensions on OS X
source link: http://www.mikechambers.com/blog/2004/11/28/building-and-packaging-firefox-extensions-on-os-x/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Building and Packaging FireFox Extensions on OS X
Sunday, November 28, 2004
I have been learning how to build FireFox extensions on OS X. Actually doing a build and packaging it to install and test the extension is a little involved (you have to create multiple jar files and and an xpi file). Luckily there are a couple of scripts available that basically automate this process:
I am running on OS X so I was using the Bash / Linux script. However, this needed a few tweaks to get it to work correctly. Basically, I had to fix some path errors, and also get it to not package the mac .DS_Store folders.
Here is the updated script, which is based on the script found here.
#!/bin/bash
# build.sh: build JAR and XPI files from source
# based on Nathan Yergler's build script
# Modified to work on OS X by Mike Chambers (http://www.mikechambers.com)
#### editable items (none of these can be blank)
APP_NAME=helloworld # short-name, jar and xpi files name.
HAS_DEFAULTS=0 # whether the ext. provides default values for user prefs etc.
HAS_COMPONENTS=0 # whether the ext. includes any components
HAS_LOCALE=0 # package APP_NAME.jar/locale/ ?
HAS_SKIN=1 # package APP_NAME.jar/skin/ ?
KEEP_JAR=1 # leave the jar when done?
ROOT_FILES="license.txt install.rdf install.js" # put these files in root of xpi
#### editable items end
TMP_DIR=build.tmp
#uncomment to debug
#set -x
# remove any left-over files
rm $APP_NAME.jar
rm $APP_NAME.xpi
rm -rf $TMP_DIR
# create xpi directory layout and populate it
mkdir $TMP_DIR
mkdir $TMP_DIR/chrome
if [ $HAS_COMPONENTS = 1 ]; then
mkdir $TMP_DIR/components
cp components/* $TMP_DIR/components
fi
if [ $HAS_DEFAULTS = 1 ]; then
DEFAULT_FILES="`find ./defaults -path '*DS_Store*' -prune -o -type f -print | grep -v \~`"
cp --parents $DEFAULT_FILES $TMP_DIR
fi
# Copy other files to the root of future XPI.
cp $ROOT_FILES $TMP_DIR
# generate the JAR file, excluding .DS_Store and temporary files
zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find content -path '*DS_Store*' -prune -o -type f -print | grep -v \~`
if [ $HAS_LOCALE = 1 ]; then
zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find locale -path '*DS_Store*' -prune -o -type f -print | grep -v \~`
fi
if [ $HAS_SKIN = 1 ]; then
zip -0 -r $TMP_DIR/chrome/$APP_NAME.jar `find skin -path '*DS_Store*' -prune -o -type f -print | grep -v \~`
fi
# generate the XPI file
cd $TMP_DIR
zip -r ../$APP_NAME.xpi *
cd ..
if [ $KEEP_JAR = 1 ]; then
# save the jar file
mv $TMP_DIR/chrome/$APP_NAME.jar .
fi
# remove the working files
rm -rf $TMP_DIR
In order to use this, you need to set up the directory structure in a specific way. Using the HelloWorld extension from this tutorial (highly recommended), the directory structure would look like this:
You can download the files and directory structure from here.
Notice that the build.sh file is in the same directory as the install.rdf. In order to build the extension, edit the parameters at the top of the build.sh file (at a minimum set the APP_NAME variable to match your extension name), and then just run it from the terminal. If it doesn’t run, make sure that it is set to be executable by running the following command:
chmod 755 ./build.sh
from the terminal.
Thanks to everyone in the Mozilla Extension forum for helping me out, roachfiend.com for a great extension tutorial, and to whoever wrote the Linux / Bash package script that the OS X script was based on.
Recommend
-
160
With the release of Firefox Quantum on November 14, 2017, we officially entered a WebExtensions-only world for add-on development. While that event was certainly the
-
48
It’s that time of year again where we endeavor to improve ourselves, to wash away poor habits of the past and improve our lot in life. Yet most of us fall short of our yearly resolution goals. Why? Maybe we just haven’t found the right Firefox ext...
-
100
-
86
Firefox Quantum continues to make news as Mozilla incorporates even more innovative technology into the platform. The development team behind the WebExtensions architecture is no ...
-
72
Seeking great new extensions for the Firefox Quantum Extensions Challenge! Between March 15 and April 15, 2018, use Firefox Developer Edition to create extensions that make full use of available ...
-
51
The results are in for the Firefox Quantum Extensions Challenge! We were thrilled to see so many creative, helpful, and delightful submission entries. https://blog.mozilla.org/addons/files/2018/05/submission_showcase.mp4 ...
-
55
Last week Firefox 62 moved into the Beta channel. This version has fewer additions and changes to the WebExtensions API than the last several releases. ...
-
6
Misadventures in Python Packaging: Optional C Extensions July 19, 2018 17:58 / peewee
-
6
Teaching packaging by building a Python package By PyBites Team on 25 March 2023 Listen here
-
8
Manufacturing, Packaging & Materials Building Better Bridges In Advanced Packaging
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK