productbuild path ignored on install
Asked Answered
C

2

7

I have an OSX application built with Qt. It is codesigned, packaged up to fit macstore and has been approved by apple and it is ready for sale in the mac store.

Though after installing it, it is installed into the location where it was residing during the packaging process instead of /Applications.

Alternatively I'm creating a .dmg package of the file, which I can install into /Applications.

At the end of the build procedure I'm running these commands:

codesign --force --deep --verify MyApp.app/ --entitlements ${INSTDIR}/Entitlements.plist -s "3rd Party Mac Developer Application: Company Name"
productbuild --component MyApp.app /Applications --sign "3rd Party Mac Developer Installer: Company Name" MyApp.pkg

The result of which is the pkg, which I'm attempting to install via installer:

$ sudo installer -store -pkg MyApp.pkg -target /
installer: Note: running installer as an admin user (instead of root) gives better Mac App Store fidelity
installer: MyApp.pkg has valid signature for submission: 3rd Party Mac Developer Installer: Company Name (key)
installer: Installation Check: Passed
installer: Volume Check: Passed
installer: Bundle com.CompanyName.MyApp will be relocated to /Users/peti/dev/build/bin/Mac/release/MyApp.app
installer: Starting install
installer: Install 0.0% complete
installer: Install 17.1% complete
installer: Install 96.4% complete
installer: Install 100.0% complete
installer: Finished install

Right after productbuild the relocation was saying /Applications, but it didn't install it there!! On a subsequent run it will say the incorrect path. I've also tried installing from different locations.

I've also tried installing the app from Mac Store which does the same... It goes into the incorrect path.

I've used:

pkgutil --expand

To extract the package. PackageInfo file says this:

<pkg-info overwrite-permissions="true" relocatable="false" identifier="com.CompanyName.MyApp" postinstall-action="none" version="3.0.0" format-version="2" generator-version="InstallCmds-502 (14F1605)" install-location="/Applications" auth="root" preserve-xattr="true">

Any ideas what could be going wrong? I've tried to google for solutions, but no luck. Where could this incorrect path be stored? I don't see the path embedded into any file before productbuild. Is productbuild doing something weird?

Crossbreed answered 19/4, 2016 at 4:16 Comment(12)
.dmg is a disk image, not a package, but you can certainly store a .pkg on it.Wenda
@I'L'I I understand that, what I don't understand is why the place of packaging has anything to do with the installation path.Crossbreed
If you mean the places where files are when building it, then it's because it uses that to determine where to install it to.Wenda
@I'L'I Hmm, why? As stated above I'm explicitly saying productbuild that installation destination is /Applications. Can you elaborate on that?Crossbreed
There are multple reasons, most common -- permissions, the build path, and the installer cache usually. Something that often works is to move your .app into the /Applications directory, then in terminal cd /Applications and execute the productbuild command. After that move the .app and created .pkg out of there (if the pkg was saved there) and then try running the installer.Wenda
I was afraid that you'll say that :) That's what I was keeping as a backup plan.Crossbreed
What permissions shall I leave for the app in /Applications ? Same as an example: drwxr-xr-x+ 3 root wheel 102 Apr 13 2015 TextEdit.app/Crossbreed
You shouldn't need to modify the permissions of the .app. Usually the default is drwxr-xr-x user staff (my system uses that). If the app launches after it installs then you should be good to go I would think :) Some of my applications in /Applications do have root wheel set though too. All installer packages require authorization from the user before installing anyway, so it's essentially up to you. Since you're creating an AppStore app I would archive and have it just install in /Applications, then run productbuild.Wenda
errr, I guess you're using Qt though... so forget the last sentence.Wenda
Why is that? Is this the reason why I'm having this with codesign: ` bundle format is ambiguous (could be app or framework)` Why is this working when I'm not in /Applications ?Crossbreed
Try building your app then do mv MyApp.app /Applications. Trying to cp -r an app bundle will likely screw things up.Wenda
Ahh! Very smart. Yes I've experienced the copy annoyance! When I move it to a /Applications the signing and productbuild works. Now to the fun part. I've tried installing it from a mac store on another machine. The location of install was straight into /Applications! It seems that when I've tried to install it from Mac store it was putting it into a location where it was installed before... Or something. Do you know if it is doing something like this?Crossbreed
C
5

Finally I think I have an explanation.

It installs correctly on every other machine, except our build machine. What the reason appears to be is that after you execute the named MyApp.app from anywhere on the filesystem osx remembers that path. So when you are trying to install it next time around (update?) it will update the application on the known path.

An even weirder scenario is that when you have two "installations" of the application (two copies) and you are trying to install it again, it will install it alternating between the two instances! Smells like a bug, that Apple is never going to fix.

Thanks for the help @l'L'l. If you could explain me this behaviour that would be a plus.

Crossbreed answered 21/4, 2016 at 2:2 Comment(0)
Q
1

I also ran into this, and the only way i found to get around it, was using an intermediate pkgbuild step using a component-plist file (components.plist) in the process.

The command below asumes a directory called Applications containing the built product (application) to be present in the current directory, as well as the file components.plist. It writes the results to ApplicationPackage.pkg.

$ > pkgbuild --root ./Applications --component-plist ./components.plist --identifier "com.company.app.pkg" --install-location /Application ApplicationPackage.pkg

This is then followed by the productbuild step.

Key is actually the BundleIsRelocatable-key in components.plist with value false.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>BundleHasStrictIdentifier</key>
        <true/>
        <key>BundleIsRelocatable</key>
        <false/>
        <key>BundleIsVersionChecked</key>
        <true/>
        <key>BundleOverwriteAction</key>
        <string>upgrade</string>
        <key>RootRelativeBundlePath</key>
        <string>AppBundle.app</string>
    </dict>
</array>
</plist>
Quadri answered 19/3, 2018 at 22:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.