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

10,467

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.

Share:
10,467
Admin
Author by

Admin

Updated on June 15, 2022

Comments

  • Admin
    Admin almost 2 years

    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

  • Gerrit
    Gerrit over 6 years
    When using these parameters on my machine the home installation is not the first choice enabled and is not chosen by default. Is there a way to set the home installation as default?
  • souch
    souch over 6 years
    After using the answer above for some times now: the OSX installer seems bugged. In my case, if I disable system wide install : (enable_localSystem="false" enable_anywhere="false" enable_currentUserHome="true"), sometimes (not always!), the installer still choose automatically system install (and bypass the install location panel). So my answer is not working in real world.
  • denis.gz
    denis.gz about 6 years
    Well, installing packages to the user's home actually IS WORKING, and there is no reason to discourage it. Provided that the package is allowed to install in user's home directory, the command line to do it is as follows: bash-3.2$ installer -package file.pkg -target CurrentUserHomeDirectory There is no need to set anything in --install-location option, the default value is fine. The only critical stuff is to include <domains enable_currentUserHome="true"/> in distribution template, and use the magic CurrentUserHomeDirectory target in installer command line.
  • catlan
    catlan about 6 years
    This was writing five major OS versions ago. And I haven't done any testing on these version. Anyhow, just because it worked once, I wouldn't trust it. Based on 'Fool me once, shame on you; fool me twice, shame on me'
  • Bemipefe
    Bemipefe almost 4 years
    @souch I have the exact same problem and I set these three parameter like you. I don't understand why sometimes macOS asks for admin password even if I specified that the application must be installed in the user home. Maybe it has to do with the signature of the package or to the notarization status of the package. Did you find a solution for this in the meantime ?
  • souch
    souch almost 4 years
    We found no clean solution. Our app is signed and notarized (the .app and the .pkg), follow the OSX file guidelines (e.g.: .dylib in Contents\Frameworks ...). Still the installer sometime choose randomly what it wants. At the postinst script, if the installer choosed the wrong choice, if needed, we copy the .app to /Applications and chown it to the current user.
  • Bemipefe
    Bemipefe almost 4 years
    In my case I want to allow also non-admin users to install and use my app so I want to completely get rid of the credential panel prompt. For some reasons the "standard installation" on disk is sometime automatically selected even if enable_localSystem="false" .