JAR/XPI Firefox Extension Build Shell Script

I recently started work on a firefox extension, but this time I’m working on a mac rather than a pc. Below is a sample shell script for automatically building the JAR and XPI files.:

#!/bin/bash
mkdir build
mkdir build/chrome
cd chrome
zip -r formsaver.jar .
cd ..
cp chrome/formsaver.jar build/chrome/formsaver.jar
rm chrome/formsaver.jar
cp -R defaults build/
cp install.rdf build/install.rdf
cd build
zip -r formsaver.xpi .
mv formsaver.xpi ../formsaver.xpi
cd ..
rm -rf build
echo -n extension build successful

Here is a sample file for automatically building on windows (batch script):

Note: This requires that you have 7zip installed.

set x=%cd%
md build\chrome
md build\defaults\preferences
cd chrome
"C:\Program Files\7-Zip\7z.exe" a -tzip "%x%.jar" * -r -mx=0
move "%x%.jar" ..\build\chrome
cd ..
copy defaults\preferences\formsaver.js build\defaults\preferences
copy install.* build
cd build
"C:\Program Files\7-Zip\7z.exe" a -tzip "%x%.xpi" * -r -mx=9
move "%x%.xpi" ..\
cd ..
rd build /s/q