Wednesday, August 29, 2007

What's in an OS X Package (.pkg) file?

I recently had occasion to figure out how packages work on OS X. This isn't an extensive treatise on the subject, and I didn't bother to look for any docs. This is just some poking around I did in the Finder and mostly in Terminal.

The original motivation was that I wanted to uninstall a package that I'd installed. The package file is Subversion-1.4.4.pkg. The first thing I learned is that packages are another case where a directory (aka folder) shows up as a single file in the Finder. You can see the contents in the Finder by control-clicking on the package file and selecting Show Package Contents. The Finder opens up a new window (just like any other folder).

All I see in my package is a folder called Contents. Within that folder, is a file called Archive.pax.gz, which is a compressed pax archive. Pax is an archive program like tar and cpio. (Actually, it's an experiment on genetic engineering - in order to "solve" the tar vs. cpio wars, they merged the two and called it pax, Latin for peace.) The pax archive was subsequently compressed with gzip - hence the gz extension.

Too see what's in the archive, we need to decompress it and get pax to print a listing of the contents. I did this as follows, although there are other ways to skin this cat:

cd /tmp
gzip -d < Subversion-1.4.4.pkg/Contents/Archive.pax.gz | pax -v

(Pax contains an option to do decompression, but I'm too old fashion.) Note that I redirect the compressed archive into gzip. I did this because I wanted to leave the archive compressed. I could have decompressed the archive and then ran pax on that, but I wanted to leave the entire package unharmed. The first bit of the output looks like:

-rwxr-xr-x 1 root wheel 1664424 Jun 22 23:57 ./usr/local/bin/svnadmin
-rwxr-xr-x 1 root wheel 1571744 Jun 22 23:57 ./usr/local/bin/svndumpfilter
-rwxr-xr-x 1 root wheel 1664612 Jun 22 23:57 ./usr/local/bin/svnlook

So, we can see that these are the files that got installed (in /usr/local). One nice thing to note is that the path names are all relative - they begin with "./" rather than just "/". This means the files can be installed anywhere - change into a directory, extract the archive, and the files will show up in a directory called usr/local below your current directory.

How can I use all of this to uninstall these files? Again, there are many ways to skin the cat, but here's what I did. I extracted the archive to /tmp. ("I thought you wanted to remove the files. Why are you extracting them again?" Patience, my friend.)

cd /tmp
gzip -d < Subversion-1.4.4.pkg/Contents/Archive.pax.gz | pax -r

This creates all of the files, but under /tmp - e.g., /tmp/usr/local/bin/svnadmin. I can now use find to get me a list of just the files:

find usr -type f -print > /tmp/fff

I then looked through the file names in /tmp/fff, and they made sense, so I removed them all.

sudo rm -i `cat /tmp/fff`

The sudo command was needed because the files were not owned by my user ID. The package installer asked for the administrator password and installed the files owned by root (as I recall). Of course, I could have avoiding "installing" the files in /tmp by running the output of pax -v through some awk or perl, but the archive was small, and I knew the options to find off the top of my head - I would have had to look up some awk or perl, since I don't use them that often any more.


P.S. This post almost never was: Blogger mangled the fonts repeatedly, and I almost gave up on it. Stupid JavaScript HTML editors!

Wednesday, August 22, 2007

Everything I Know About Business I Learned from My Mama

Everything I Know About Business I Learned from My Mama by Tim Knox is nominally a business book. However, it is certainly not your typical business book. The author doesn't tell you what corporate structure (e.g., LLC vs. S-Corp) is best, how to keep the books, or how to manage a Fortune 500 company. Rather, this is a bigger picture view of going into business for yourself. Tim Knox is all about entrepreneurship.

Although this book isn't really a how-to manual with lots of nuts-and-bolts details. It would be a really good book for someone who is thinking of going into business for himself. It even begins with a bunch of reasons why someone shouldn't go into business. If after reading the book, someone still wanted to go into business, he should probably read a few more books before jumping in. (The E-Myth Revisited: Why Most Small Businesses Don't Work and What to Do About It is next on my list to read.)

The book is pretty short and humorous, and the chapters are nice little bite-sized chunks. Here's an attempt as his sense of humor: this would be a great book to keep next to the toilet - each chapter is about one visit long. (I have a special place in my heart for books like that.) I suspect the book was easy for Tim to write since he's been writing newspaper articles for some time. I can easily imagine that many of the chapters are extensions of articles he wrote for the paper, bless his heart.

One minor nit I could pick with the title is that there isn't all that much mention of stuff his mama told him. Rather, there's a fair amount of common sense that one's mother might impart.

I bought this book because I've been listening to Tim on Dan Miller's radio show - see Dan is a career coach and wrote the book 48 Days to the Work You Love. The two of them spend a lot of time telling people to quit jobs they hate and move towards work they love. The radio show recently ended, and they've switched to an Internet format. The radio shows and the new Internet shows are available as podcasts.


Roomba Rants

I recently started using my (comparatively old) Roomba again, and I've been reminded of my chief complaint about Roomba: it gets dirty and needs to be cleaned.

Our house is a regular petting zoo, so stuff accumulates pretty quickly. This fills up the bin, which isn't so bad because emptying the bin is quick and easy. But the human hair and pet fur fowls the brush, and that takes some serious effort to clean. I suppose the Roomba for pets (which appears to be discontinued) addresses this with a brush that is comparatively easy to clean.

And then last night I discovered a new place to clean: the side sweeper brush. That thing was totally fowled (not surprising considering I just discovered that I needed to clean it - "read all the words"), and it took me 10 to 15 minutes with my pocket knife and tweezers.

I find it ironic that a cleaning tool requires a non-trivial amount of cleaning. Perhaps if I kept up with regular vacuuming, Roomba wouldn't get so overwhelmed by crap.

Finally, the reason I'm just getting back to using Roomba is that I just got a new battery after killing the old one some time ago. It turns out managing batteries with Roomba is a bit different than other devices I've used. Typically, I run devices down and recharge them. If I don't have an immediate use, I'd leave the device uncharged. Well, Roomba keeps discharging the battery even if it's not in use. And if you do that to a battery that's already low, it deeply discharges the battery - definitely not A Good Thing. I noticed the discharging thing: sometimes when I'd charge the battery and not use Roomba immediately, the battery would be low when I went to use it. So, Roomba prefers being left on the charger, even if you're not using it, which is something I tend to avoid with other devices. Anyway, the result was that I only got ~50 cycles out of the original battery - not good. The recording on Roomba's tech support tells you if you're not using the unit anytime soon, you should take the battery out. Fortunately, it's easy to install and remove the battery - e.g., no screws required.

Don't get me wrong: Roomba is still fun to use, and I did just put down more money for a new battery. So, I will continue to use it. It's just not as carefree and easy as I'd like to see it.


Friday, August 17, 2007

New iMac

Even though I was wishing for a Core2 Mini, when it was (finally) released (somewhat silently), I opted instead for one of the new iMacs, and I'm loving it.

My original plan was to get a Mini and use a KVM along with the PC boat-anchor that I keep around for a client. However, after using a KVM for a while with other PCs, I realized that KVMs can be kinda hokey. For example, my KVM makes a keyboard look generic - i.e., it hides any special keys. Also, although I have a cool 22" Viewsonic LCD, it's not as nice as an Apple display.

I opted for the 20" 2.4Ghz model with the stock 1GB of memory. I was very pleased to see how easy it will be to upgrade the memory when I get a few extra dollars. The 24" was pretty tempting (the price is quite reasonable), but I figured if I ever need a larger display, I can use the external video connected to my (somewhat inferior) Viewsonic for a ~40" display experience.

The CPU is hella fast, although I admit I'm comparing it to an 800 Mhz G4 iMac which was significantly taxes (~20% CPU) running Firefox and Gmail. To date, the only time I'm maxed out the two cores was converting audio files into MP3 with iTunes. My Internet is still only 128K ISDN, which makes for slow Gmail, but Steve Jobs can't be expected to fix that.

The new, thin keyboard is something that cannot be appreciated in a store standing over it. You have to sit in front of it with a real chair in a real working position to appreciate the nice ergonomics. My one gripe is that my thumb drive is too fat to fit in the USB sockets.

And finally, the Apple educational discount and promotions were sweet. After the rebates, I'll have a free Nano and printer, both of which I gave to the wife - score!

Anyway, Joe Bob says, 5 stars (on a scale of 4) - check it out!