Using pkgutil To Adjust Flat Packages

“I love it when companies break away from the standard pkg practices.”

– No one ever

When you run into an installer that is doing something you don’t expect or recommend we get to put on our Mac admin spelunking hat to dive into the depths of the installer to see what’s going on.  There are some handy tools that make this easier already bundled in the OS.  Those are: pkgutil and installer.  There are also good 3rd party apps like Pacifist and Suspicious Package that I use for examining installers as well.  For this exercise I didn’t need those.

I ran into an issue with the Fiery E-22C driver installer from EFI launching an app mid-install to offer to setup printers.

Not Helpful

That’s great for home users with a Fiery front end (who doesn’t have a Fiery at home?) but not for deploying in the enterprise.  The only way to get the drivers to install at this point was to click the link in the bottom left of the app window.  Not ideal. I tried many ways to bypass the “wizard” app as the installer existed but even when attempting a CLI install it would launch the app when a user was logged and the install would totally fail if no user was logged in.

One thing going for us at this point is the pkg is a flat package. Running the following will extract the pkg to better examine it:

pkgutil --expand ~/Desktop/Fiery\ Printer\ Driver.pkg ~/Desktop/fieryprinterdrivers

Navigating to ~/Desktop/fieryprinterdrivers shows us the expanded package contents:

Expanded Package

 Right click on the “FieryPrinterDriverInstaller.pkg” and choose “Show Package Contents”:

Show package contents

After digging around the piece that needed adjustments was the postinstall.  There was a system version check in there to launch the “wizard” if the OS was 10.5 or older.  If 10.5 or older it would just install the drivers.  That’s what I wanted on my new shiny OS!

#Pkg installs driver and exits in 10.5 since no Wizard is supported below 10.6
if [ "$MAJOR" = "10" ] && [ "$MINOR" = "5" ]
then
 logger "Postinstall Script: Checking for previous driver and printers with FSU and performing system cleanup"
 /bin/sh /tmp/efi_wiz_fsu_delete && logger "Postinstall Script: FSU done"
 sudo rm -f /tmp/efi_wiz_fsu_delete
 logger "Postinstall Script: Installing driver only for 10.5" && sudo installer -pkg /tmp/Fiery\ Printer\ Driver\ Installer.app/Contents/Resources/User\ Software/OSX/Printer\ Driver/OSX\ installer.pkg -target / && exit 0
fi

Further down if the OS was > 10.5 it would launch the “wizard” which is what I didn’t want.  To fix this install postinstall script all I needed to do was remove the OS Minor version check to make it just install the drivers if the OS Major version is 10.  I can handle deploying the drivers to the appropriate OS so I’m not worried about using their logic.

From:
if [ "$MAJOR" = "10" ] && [ "$MINOR" = "5" ]
to 
if [ "$MAJOR" = "10" ]

Once the postflight file is adjusted we can flatten the package back up again by running:

pkgutil --flatten ~/Desktop/fieryprinterdrivers/ ~/Desktop/Fiery\ Printers\ Driver\ Fixed.pkg

 And now I have a new package “Fiery Printers Driver Fixed.pkg” that’s deployable, won’t launch the wizard, and will install the drivers.

fixed pkg is a pkg

Advertisements
Tagged ,

One thought on “Using pkgutil To Adjust Flat Packages

  1. […] If desired, you can use pkgutil to expand the QuickAdd package, edit the postinstall script, then re-flatten the QuickAdd package. Expanding and re-flattening removes any package signing, so re-signing the package may be […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: