How do you specify a default install location to $HOME with pkgbuild?

Owen Urkov picture Owen Urkov · Oct 12, 2012 · Viewed 9.9k times · Source

I'm in the process of porting our installer from PackageMaker to pkgbuild and am trying to make the default install location be the current user's home directory and still allow the user to install system wide.

In my distribution file I have enable_currentUserHome="true" and enable_localSystem="true" which correctly allows the user to "Install for all users of this computer" or "Install for me only". However, I'd like for "Install for me only" to be selected by default.

pkgbuild has a command line option for "--install-location" which the man page says specifies the default location, but there's no mention of how to specify the home directory. I've tried "~" and "$HOME" with no luck. Is there some macro I don't know about?

Does anyone know how to tell pkgbuild to install under the current user's home directory by default?

Thanks in advance!

-Owen

Answer

catlan picture catlan · Oct 21, 2012

pkgbuild generates the component package for you. Although a component package can be installed on its own, it is typically incorporated into a product archive. In the product archive you can set the install domain like localSystem and home.

For example pkgbuild --install-location /Application would install it as expected into /Application if the local system domain is chosen, or into $HOME/Application if the home installation is chosen.

That said, I highly discourage form using the Installer for home folder installation. It's just not working in the real world.

See my Known Issues and Workarounds section in Making OS X Installer Packages and also Installer Problems and Solutions.