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.


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