View Full Version : Mozilla update script?
shreddies
02-04-2002, 11:16 AM
Hi there,
I enjoy getting daily Mozilla builds to keep right up to date with the browser, so I thought of writing a shell script to get and install the latest whenever run, I came up with the following..
cd ~/Downloads
wget ftp://ftp.mozilla.org/pub/mozilla/nightly/latest/mozilla-macosX-trunk.smi.bin
open -a '/Applications/StuffIt Lite 6.5.1/StuffIt Expander.app' mozilla-macosX-trunk.smi.bin
open -a '/Applications/Utilities/Disk Copy.app/' ~/Downloads/mozilla-macosX-trunk.smi
mv /Applications/Mozilla/ ~/.Trash/
cp -r /Volumes/Mozilla\ for\ MacOS\ X/Mozilla/ /Applications/
However the resulant copy of mozilla is useless as the cp command does not include the resource fork.
Can anyone think of a better way to do this?
shreddies
Benad
02-04-2002, 11:20 AM
CpMac is in the developer tools in /Developer/Tools. It is similar in use to cp.
- Benad
shreddies
02-04-2002, 01:03 PM
Thanks for that :)
My shell script is coming along (see below) however the script errors because it tries to mount the .smi file before stuffit has created it.
Is there a way to expand macbinary files and mount images from the command line? Or maybe tell disk copy to wait?
Also, i'm having trouble unmounting the image once done, can anyone offer any advice?
Thanks
shreddies
---SHELL SCRIPT---
#!/bin/sh
#Variables
downloads=~/Downloads
devtools=/Developer/Tools/
# test the folders for read
[ -r "$devtools" ] || { echo "Can not read $devtools" ; exit 1; }
[ -r "$downloads" ] || { echo "Can not read $downloads" ; exit 1; }
#Move to the Downloads folder
cd $downloads
#Get the latest moz build
wget ftp://ftp.mozilla.org/pub/mozilla/nightly/latest/mozilla-macosX-trunk.smi.bin
#expand it
open -a '/Applications/StuffIt Lite 6.5.1/StuffIt Expander.app' $downloads/mozilla-macosX-trunk.smi.bin
#mount the image
open -a '/Applications/Utilities/Disk Copy.app' $downloads/mozilla-macosX-trunk.smi
#Put the old one in the bin
mv /Applications/Mozilla/ ~/.Trash/
#Copy the new version into apps, using cpmac
cd $devtools
./CpMac -r -mac /Volumes/Mozilla\ for\ MacOS\ X/Mozilla/ /Applications/
#If they're still kicking about get rid of the source files
if [ -e "$downloads/mozilla-macosX-trunk.smi.bin" ]; then
rm $downloads/mozilla-macosX-trunk.smi.bin
fi
if [ -e "$downloads/mozilla-macosX-trunk.smi" ]; then
rm $downloads/mozilla-macosX-trunk.smi
fi
#exit
exit 0
Benad
02-04-2002, 05:31 PM
My shell script is coming along (see below) however the script errors because it tries to mount the .smi file before stuffit has created it.
It might not be the best solution, but you can tell stuffit expander to mount itself the image when it's done decompressing.
At any rate, just put something like perl -e 'sleep 20'
Also, i'm having trouble unmounting the image once done, can anyone offer any advice?
I tried "umount" but it doesn't work, even as root. Maybe you can do that from an AppleScript.
- Benad
Phil Cryer
02-20-2002, 10:32 AM
Glad to see others with the same idea. We started a similar script a few months back, and it's moving along. It's called getmoz, and part of the original idea of it was to make it as crossplatform as possible. It is written in sh, so it *should* work within any *nix environment. We need help to certify that it does work within OS X, so any help is appreciated. Obviously it runs in Linux, but we're currently working on certifying it for Sun, AIX and want to add OS X to that list. You can find the details and the program here: http://getmoz.mozdev.org (http://getmoz.mozdev.org/)
Check the variables at the beginning of the script and change at least this one to reflect your file:
MOZ_TARBALL_NAME='mozilla-i686-pc-linux-gnu.tar.gz'
We'll probably rename that var in order to better reflect the filename, since OS X doesn't use a tarball! Also, be sure the download/install directories matches your structure.
We are working on a complete rewrite with many improvements, and should have it ready soon. If interested, I'll announce it here as well. Additionally, if you have any ideas to contribute or want to join the cause we'd love to hear from you. Future goals call for the script to become an installable XPI so that it will work with all versions of Mozilla.
As for the above question, we deal with the directory issue by querying the existing Moz install for a build number, then renaming that directory with the build number tacked on to the end. (eg- the 'old' Moz directory becomes mozilla-2002020814) We define this with the following code:
# Define the MOZ_OLD_BUILD_ID variable and display the installed Mozilla build number
if MOZ_OLD_BUILD_ID=`$MOZ_INSTALL_PATH/mozilla -v | cut -d' ' -f10`
then echo "Mozilla installation found. Build ID: $MOZ_OLD_BUILD_ID"
fi
after that it's a simple 'mv mozilla mozilla-$MOZ_OLD_BUILD_ID' command to have the old directory renamed and archived. The new install is moved over, so that any old shortcuts will work, the plugins are copied over from the old install and it's done. The current download is missing some of our newer features, but should be a good start for compatability. There are many more features on the new release, but I'll save that for another post.
Phil
This is my script. It downloads it, decodes the mac binary file, converts the smi to a dmg, mounts the image, deletes the old Mozilla.app and copies the new one to /Applications
I have been using a similar one for many days now without issues. Changing of path to Expander should be the only tweak, also the path to CpMac is unique to my install, so that needs changing, also could use ditto -rsrcFork instead of CpMac.
#! /bin/sh
echo "Begin Mozilla download: `date`" | tee -a /var/tmp/console.log
echo "Changing to download folder" | tee -a /var/tmp/console.log
cd $HOME
echo "Downloading Mozilla: `date`" | tee -a /var/tmp/console.log
/usr/bin/curl -O ftp://207.200.81.212/pub/mozilla/nightly/latest/mozilla-macosX-trunk.smi.bin
if [ -f mozilla-macosX-trunk.smi.bin ]
then
echo "Decoding Mozilla: `date`" | tee -a /var/tmp/console.log
/usr/bin/open -a "Applications/Stuffit Deluxe 6.5/StuffIt Expander.app" mozilla-macosX-trunk.smi.bin
sleep 10
echo "Converting Mozilla SMI: `date`" | tee -a /var/tmp/console.log
/usr/bin/hdiutil convert -format UDZO -o temp.dmg mozilla-macosX-trunk.smi
/bin/rm mozilla-macosX-trunk.smi
/bin/mv temp.dmg mozilla-macosX-trunk.dmg
echo "Mounting Mozilla DMG: `date`" | tee -a /var/tmp/console.log
thedisk=`/usr/bin/hdid mozilla-macosX-trunk.dmg | awk '{print $1}'`
echo "Copying Mozilla Application: `date`" | tee -a /var/tmp/console.log
rm -rf /Applications/Mozilla.app
/usr/local/sbin/CpMac -r "/Volumes/Mozilla for MacOS X/Mozilla/Mozilla.app" /Applications/
echo "Ejecting Mozilla DMG: `date`" | tee -a /var/tmp/console.log
/usr/bin/hdiutil eject $thedisk
echo "End Mozilla download: `date`" | tee -a /var/tmp/console.log
fi
Phil Cryer
02-25-2002, 11:26 AM
I'm looking into how my script can 'autodetect' which OS it's on. If I use the output from 'uname' I can make this work and then it will know which file to download, how to extract it and so on. Can someone running Mac OS X show me the output of running 'uname' (without switches) on the command line? So far I have:
OS=Linux
uname output=Linux
OS=Sun Solaris
uname output=SunOS
OS=AIX
uname output=AIX
Thanks
Phil
Benad
02-25-2002, 11:46 AM
'Darwin'
- Benad
shreddies
03-02-2002, 06:08 AM
Great script 'THEM' Im now getting a new mozilla every day ;) Using the ideas form THEM's scipt and others I'm trying to create the ultimate mozilla script but I'm stuck with one thing, how to query mozilla for it's version from the command line? -v doesn't work on OS X and I can't find the string anywhere within the .app, ideas?
Benad
03-02-2002, 09:26 AM
Try searching in Mozilla.app/Contents/MacOS. There *must* be a file in there that contains the version number... :)
- Benad
shreddies
03-02-2002, 11:00 AM
Doing a search within the .app reveals the "0.9.8+" string a few places but never the build ID :(
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.