You may have been given a package provided by some vendor, and they didn't package things quite to your standards. Perhaps they're installing setuid root executable programs with world-writable permissions all over your system, or they have problematic post flight scripts which try to modify the dock or open up a web page.
Having an Apple Installer.app package is nice, but it's not much good if you can't easily deploy it to a large number of hosts. I generally go about fixing poor quality packages using the following methods.
To fix misbehaving scripts, I generally just dive right in and hack the script itself. If you right click on the package and "Show Package Contents" you can dive into the Resources folder and directly modify the preflight, post-flight, pre-upgrade, and post-upgrade scripts as you see fit. Apple has a Knowledge Base article on the subject:
Software Delivery Guide.
To fix file permissions, I manually unpack the package archive, change any permissions that are wrong, and then re-package everything.
- Unpack the archive
-
mkdir /tmp/RootFileSystem/
-
cd /tmp/RootFileSystem/
-
sudo pax -z -pe -r -f /Volumes/foobar/Foobar-1.2.3-4.pkg/Contents/Archive.pax.gz
- Open PackageMaker.app (Distributed with Xcode Tools.)
- Re-use the bundle identifier and version from the source package:
/Volumes/foobar/Foobar-1.2.3-4.pkg/Contents/Info.plist
- You can optionally overwrite permissions when installing the package
- Ensure your permissions match the system default permissions on folders like /, /Library, /Applications, etc...
- To check what the system default permissions shoudl be, look at the owner, group, and file mode in the bill of materials file from the BaseSystem package:
lsbom /Library/Receipts/BaseSystem.pkg/Contents/Archive.bom | less
- Finally, repackage your cleaned up RootFilesystem by building your Package Maker project.
- Bundle the resulting package into a DMG (Optional):
-
hdiutil create -srcFolder /tmp/Foobar.pkg /home/archive/osx/pkgs/apps/Foobar-1.0.0-1.dmg
This procedure allows you to verify (lsbom) and manually modify (pax + Package Maker) packages that don't meet your requirements.