OSX .pkg installer sometimes does not install .app file
Asked Answered
S

3

18

My Java application has a launcher which is a .app and a helper app which is bundled with it.

I am trying to make .pkg installer with a background image using the following commands:

pkgbuild --root "./Temp"  --identifier "com.company.id" --install-location "/Applications" --sign "signature" "temp.pkg"
productbuild  --package-path "temp.pkg" --distribution "./Distribution.xml" --package-path "./Temp" --resources "./Resources" --sign "installer signature"  "$FINAL_PKG"

When I look in the directory at ./Temp both of the .app folders are there and when I deconstruct the .pkg with:

pkgutil --expand "temp.pkg" "temp"

I see the .app folders but sometimes one of the .app folders do not show up when it is installed from the pkg. They always seem to show up the first time it is installed, but on machines where the application is installed and deleted many times (like on test and development machines) one of the .app folders will eventually not show up. I am wondering what could be going on here?

Initially we had the helper app inside a separate directory as the main app and in this case, the helper app would sometimes not get installed but the main app always would be. Next, we tried putting the helper app inside of the main app and then this worked the first time but the next time I tried to to install from the installer the main app wasn't there!

Sateen answered 9/10, 2013 at 22:24 Comment(0)
A
24

I have had roughly the same problem. It appears that the OS X installer uses information about already installed packages and application bundles in order to decide where and if to install new packages. As a result, sometimes my installer did not install any files whatsoever, and sometimes it just overwrote the .app bundle in my build tree. Not necessarily the one used to build the installer, but any .app bundle that OS X had found. In order to get the installer to install the files properly I had to do two things:

  1. Tell OS X to forget about the installed package

    sudo pkgutil --forget <package id> Not sure if this is needed for you nor in my case, but it is probably a good idea anyway.

  2. Delete all existing .app bundles for the app. If I didn't do this, the existing app bundle was overwritten on install instead of the app being placed in /Applications. Maybe there is a way to prevent this while building the installer package, but I haven't found it.

If you can you should probably try to make your application self contained so that users can install it by just drag and dropping it into /Applications. Of course, this only works if you don't need to install anything outside of your .app bundle.

Adnate answered 23/10, 2013 at 9:13 Comment(1)
After 2 days of trying and searching, I found that there was a .app file in some other folder. I just deleted that file and ran the installer, and everything works fine.What
L
7

If you don't want to (or can't expect other users to) hunt down and delete all existing copies of the app as described by villintehaspam, or just really need the app not to be relocated, you can provide a Component Property List file with BundleIsRelocatable set to false.

An easy way to create a valid version of the plist file is with pkgbuild --analyze; then you can edit the one property and use the file. E.g.:

pkgbuild --root myapp.root --analyze myapp.plist
/usr/libexec/PlistBuddy -c 'set :Dict:BundleIsRelocatable false' myapp.plist
pkgbuild --root myapp.root --component-plist myapp.plist [...other options...] myapp.pkg
Lanoralanose answered 26/10, 2016 at 23:35 Comment(3)
pkgbuild Component plist format certainly changed because the PlistBuddy command you use do not work anymore. I have to use /usr/libexec/PlistBuddy -c 'set :0:BundleIsRelocatable false' myapp.plist in order to make installer actually install my app to the /Applications folder.Multinuclear
Wow. I was totally misreading those debug lines and was stuck trying to figure out where installer was writing files. The line about BundleIsRelocatable is what did it. Thank you!Bayou
If you don't want to install PlistBuddy there is a built in plutil to modify property lists --> plutil -replace BundleIsRelocatable -bool NO Info.plistWhitby
W
0

After 2 days of trying and searching, I found that there was a .app file in some other folder. I just deleted that file and ran the installer, and everything works fine.

What answered 11/6 at 4:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.