I know there are some paid GUI tools that let you do this, but I'm not interested in those.
Currently, I'm doing this:
gzcat Contents/Archive.pax.gz | pax -r
However, there are some pkg files that are now xar archives and I need pkgutil to extract them. And there's probably other permutations of pkg spec that I'm not aware of.
Bottom line is that I can always find some way to manually get the stuff out of the pkg, but I'd like a one-shot solution that would do this automatically without worrying about the specific pkg implementation, say:
unpkg CrappyPackage.pkg
Does such a thing exist?
Perhaps the most foolproof way is to use the system installer itself but that seems to always need a full system drive as its target. Would be really useful if you could do something along the lines of:
installer -pkg CrappyPackage.pkg -target SomeEmptySandbox.dmg
I know there is this question: How can I open a .pkg file manually? However, all the offered solutions there are pretty manual and I'm doing those right now anyways.
pkgutil --expand thepackage.pkg destination
xar -xf package.pkg