Automatic program updating via shell script
Posted by: Kevin Ballard in Mac OS X, ProgrammingBecause I kept releasing updates to Rendezvous Browser, I wanted to make it really easy to update my DMG and upload it to the server. To that end, I created a shell script that does exactly that. However, it took a while to get it just right because there were a few problems.
The biggest problem was that every time I updated my DMG and converted it to compressed format, the size would change. It would end up anywhere from 200-600kb. I think the problem was the Disk Image framework doesn’t know anything about HFS+, so space marked as unused by HFS+ but not actually deleted was still being stored in the disk image. The only way to fix this was to create a brand new disk image every time.
The problem with creating a brand new disk image was I had icon placement and a background image that I wanted to keep. However, this wouldn’t work when just copying a folder since the view options of the folder are stored in the .DSStore of the parent folder. A real pain. The only solution I could find was to create a DMG that I used as the source folder, since a volume root stores its view options in its own DSStore. Then I had to scrub the resulting DMG of all the extraneous files and information pertaining to the HFS+ format, otherwise the DMG would break if I tried to open it without the source DMG present since it had information on it pertaining to the source DMG. Luckily, hdiutil has a -scrub option that does exactly that.
After getting it all perfect, my resulting DMG size is 128k. A huge drop from what I was previously offering. And my shell script works great! I compile the app, open the terminal, and type updateRB and it automatically creates the new DMG and uploads it to the server. Additionally, I can supply a different name to use than what it defaults to, in case I want to upload a pre-release version without replacing the previous release. And lastly, I can provide a switch which prevents it from uploading, in case I want to have the resulting DMG without putting it on the server (granted, this option isn’t so useful now that the DMG size isn’t fluctuating wildly with each update).
It’s also pretty easy to adapt to any other program, since I keep the names and paths of everything in variables at the top of the script. Anybody interested in using it for their own program? You can download it here.
Entries (RSS)
March 5th, 2004 at 9:18 pm
It is interesting that you mentioned the problem with Disk Images and free disk space. If you turn on FileVault in Panther, it moves your home directory to an encrypted disk image file. While this is nice in that all files are encrypted automatically, it also means that every time you log off, it has to free disk space. If you could figure out how they’re doing this, you could avoid making a new disk image after each update.