packagesdev/packages

installer prevent downgrade packages but it still execute pre/post install

iradization opened this issue · 3 comments

Hi,

I've built a package using Packages. when I double click the application whereas newer version of the package is already installed, than the installer skip the downgrade process due to the following reason.

2023-02-22 20:19:11+02 my-Mac installd[744]: PackageKit: Skipping component “com.myapp.mycompany” (22.9.0-2209.0.0-*) because the version 23.2.3559-2302.3559.11638-* is already installed at /Applications/myapp.app.

However, I still see that the preinstall and postinstall script being executed.

Perhaps there's a way to either enable the downgrade, or disable it completely, so I won't get this partial install scenario.

Is there a way I can get indication that the installer has skipped the file copying of the target pkg, from within the post/pre install scripts (so I can handle it properly) ?

Perhaps there's a way to either enable the downgrade

Yes: http://s.sudre.free.fr/Software/documentation/Packages/en_2017/Package_Payload.html#4

Is there a way I can get indication that the installer has skipped the file copying of the target pkg, from within the post/pre install scripts (so I can handle it properly) ?

Nope. This happens at the payload level. Not at the package level. If there are some things to run specifically when the bundle is installed, I would suggest trying with a pre- or post-installation script attached to the bundle itself.

http://s.sudre.free.fr/Software/documentation/Packages/en_2017/Package_Payload.html#5

Thanks for the valuable inputs !

So I guess that if I'll mark the package as downgrade-able, I can still fail the installation in the preinstall script if package version is older that what's already installed.

However, I couldn't find a way to grab the version number from the pkg file at the preinstall stage (the only way I found is to extract the file and parse the plist file). Perhaps there's an easier way ?

I've found out about a file distribution.xml where I can write javascript function to compare versions (I can put the pkg version hard-coded, and lookup the current installation version from the plist file). Perhaps Packages supports integration with distribution.xml ?

Thanks

So I guess that if I'll mark the package as downgrade-able, I can still fail the installation in the preinstall script if package version is older that what's already installed.

I don't remember trying to fail a pre- or post-installation script of a bundle. So I don't know the result at this time.

However, I couldn't find a way to grab the version number from the pkg file at the preinstall stage (the only way I found is to extract the file and parse the plist file). Perhaps there's an easier way ?

I guess this can be done by using a script to build the package. This way you can update your pre-installation script with the version and not have to look for it.

I've found out about a file distribution.xml where I can write javascript function to compare versions (I can put the pkg version hard-coded, and lookup the current installation version from the plist file). Perhaps Packages supports integration with distribution.xml ?

You can not use an external distribution file because Packages builds one.

A solution could be to have a specific package in the distribution for this app bundle and then attach a Requirement to the choice for this package (Project > Presentation > Installation Types - Requirements inspector).