February 25, 2011

Endianess, Thy art Sneaky

I took delivery of my Linksys WUSB600N V2 today and was very excited to get my G4 Mac Mini online. The many online sources suggests all I need to do is change a few values in an Info.plist. However as it turns out, that wasn't enough. In order for me to get it working, I had to change the values, but also write the new values in hexadecimal format. This is because even though 0x0079 translates to 121, that is only true for a little endian system. Likewise, 0x1737 also only translates to 5943 under a small endian system. Since OS X running on PPC is a big endian system, unless you write out the exact byte values using hexadecimal notation it isn't going to work.

So, for the record: Linksys WUSB600N V2 runs just fine on OS X 10.5.8 running on G4. It does 5GHz and successfully authenticates with my airport express, which the Monoprice USB 2.0 Wireless N it replaced didn't.

Cheers,
Steve

Tabbing in Vim With Tab Autocompletion

I use vim with a tab autocompletion macro, and sometimes I really do want to insert a tab character and autocompletion gets in the way.

Today I found out that if I hold down shift and hit tab, a tab is inserted and tab autocompletion doesn't get triggered. Prior to this I have been adding a space then hitting tab, which leaves ugly little space-tab sequences in my files.

Hope this helps some one out there.

Cheers,
Steve

February 21, 2011

Broken OS X Installers and How to Fix Them

The installers Ralink provides for some of their chipsets, like the RT2770 does something retarded: they attempt to unload a kext in a pre-install script, and when it fails the script fails and the entire install fails.

This means on a new machine, or one that never had the kext installed, you can't install their driver.

Fail.

It used to be that pkg installers were just directories, and fixing something like this is easy: find the offending line and comment it out. But OS X 10.5 onwards introduced flat pkgs. These don't give up their secrets so easily.

An article on cnet tipped me off to pkgutil, a program that is installed by default. It lets you expand a flat pkg into a directory, and more importantly, allows to repackage it as a flat pkg after you have excised the cause of your troubles. This last step is important because a flat pkg when unpacked has a different directory structure to a "normal" pkg and thus can not simply be open'd.

Here is what I did to fix Ralink's installer:

  1. pkgutil --expand installer.pkg ~/Desktop/installer-expanded.pkg
  2. cd ~/Desktop/installer-expanded.pkg/installroot.pkg/Scripts/
  3. vim preinstall #alternatively, for ppl unfamilar with vim:
    1. open .
    2. right click on preinstall, open in TextEdit.app
  4. comment out the offending line which is trying to remove the kext
  5. save and exit your editor
  6. cd ~/Desktop
  7. pkgutil --flatten installer-expanded.pkg installer.pkg
  8. open ./installer.pkg

Cheers,
Steve