0

I have a Mac OS X flat package that runs a postinstall script. I would like to know in the script if it's a new install or an upgrade. Bundle-style packages have pre and postupgrade scripts but I can't use a bundle package.

I've dumped out the environment variables in the script and I've dumped the arguments to the script itself and none of these seem to indicate if it's an upgrade or install. I can tell that Installer knows because the Installer Log indicates install or upgrade. I just don't know how to tell from the postinstall script.

Dustin
  • 388
  • 1
  • 9

2 Answers2

0

If it's your package, why don't you check for signs that you're already on the machine? Either leave some marker that will tell you that you've already been installed or check if your old files are present on the disk before deployment?

Mahmoud Al-Qudsi
  • 28,357
  • 12
  • 85
  • 125
  • This is what I ended up doing. In my preinstall script I'm using pkgutil to see if my package is installed and creating a flag file which my postinstall script then checks for to tell if it was an upgrade or not. – Dustin May 10 '12 at 15:35
0

If your package is installed for the first time Installer will call postinstall script but if it is upgraded, it should call postupgrade script.

More information here in the What About script section.

Kevin MOLCARD
  • 2,168
  • 3
  • 22
  • 35
  • Flat packages (as mentioned in the question) support only **preinstall** and **postinstall** scripts. Reference: [Installer Package Scripting](https://macadmins.psu.edu/files/2019/07/psumac2019-345-Installer-Package-Scripting-Making-your-deployments-easier-one-at-a-time.pdf) – MikeOnline Jul 29 '22 at 02:10