PDA

View Full Version : Shellscript problem with XPI file


Samji
11-02-2006, 12:59 PM
Hi, everyone.

I recently wrote a shellscript to zip up files for a Firefox extension into an XPI file using p7zip.

I had no problems up to a point, but the output I get is a Salamander.xpi file with an extra (unicode?) formatted character in the filename.

Here is the my shell script:


#!/bin/sh
# Build a Firefox XPI extension script

# (build.sh)

# ================================================== ==

# Set extension path, XPI and JAR filenames

extpath=/media/hda5/sams/programming/ffext/xPMvb
xpi=Salamander.xpi

jar=xpmr.jar

# ================================================== ==
clear
echo "Deleting old XPI file..."
rm $xpi
echo "Done."
echo
echo "Building JAR file..."
mkdir build
cd build
mkdir chrome
cd $extpath/chrome/
7z a -tzip $jar * -r -mx=0
echo "Done."
echo
echo "Moving JAR file..."
mv $jar -f $extpath/build/chrome/
echo "Done."
echo
echo "Copying additional required files..."
cp $extpath/chrome.manifest -f $extpath/build/
cp $extpath/install.rdf -f $extpath/build/
echo "Done."
echo
echo "Building new XPI file..."
cd $extpath/build/
7z a -tzip $xpi * -r -mx=9
echo "Done."
echo
echo "Moving new XPI file..."
mv $extpath/build/$xpi -f $extpath
echo "Done."
echo
echo "Clearing up..."
cd $extpath
rm -rf build
echo "Done."


Here is the output file I get with the extra character I don't want after the extension in the filename.

http://img162.imageshack.us/img162/3161/screenshotsalamanderxpiqb1.th.png (http://img162.imageshack.us/my.php?image=screenshotsalamanderxpiqb1.png)

Is there something wrong with one of my variables which is causing this problem?

Thanks in advance. ;)

rg3
11-02-2006, 02:07 PM
I don't see anything wrong. You should first try to see which character it is (ls -b comes to my mind) and retype the full script, maybe by copypasting it from your post. Some weird character might have ended up in one of the script lines and be invisible from the text editor, but visible once it has reached the filename.

And, apart from that, the zip command line tool is more widely available than p7zip. My two cents. :p

Edit: in theory, it could also be a bug in the way p7zip handles the file names internally, but that would be extremely weird.

Samji
11-02-2006, 02:45 PM
Thanks for your help. I tried pasting it back in and it worked fine. :)
I tried using zip, but I found my XPI is just over 2KB bigger - I get better compression with p7zip. (42.7KB with zip, compared to 40.3KB with 7z).

I have included the command line parameters to use for zip next to my 7z command though, so should I release my script properly, it will still be useful to people who don't want to use p7zip.


7z a -tzip $jar * -r -mx=0 # alernatively, use "zip -0 -v -r $jar *"
...
7z a -tzip $xpi * -r -mx=9 # alernatively, use "zip -9 -v -r $xpi *"