5

I have my product installer working nicely using pkgbuild and productbuild. However, now I am trying to figure out how to make my installer also function as an uninstaller. I am able to display an uninstall choice for the user by modifying my distribution.xml file, like this:

<choices-outline>
    <line choice="install"/>
    <line choice="uninstall"/>
</choices-outline>
<choice id="install" visible="true" title="Install" description="Installation description goes here">
    <pkg-ref id="com.prosc.RemoteExecution.install.pkg">#installer.pkg</pkg-ref>
</choice>
<choice id="uninstall" visible="true" title="Uninstall" description="Uninstaller description goes here" start_selected="false">
    <pkg-ref id="com.prosc.RemoteExecution.uninstall.pkg">#installer.pkg</pkg-ref>
</choice>

But when they pick uninstall, I need my postinstall script to somehow know which choice they picked. I don't see any way for the postinstall script to know this - there's nothing in the environment variables to indicate this, nor is it contained in the parameters that are passed to my script.

It occurred to me that I could write a separate uninstall package, with its own separate postinstall script, and then include that as a component with my overall product, but that just seems like a lot of extra setup work.

What if there were minor behavior differences based on the install choices that a user makes? Do I need to make a separate package component for each choice?

Is there a good solution for this that doesn't require an extra component package, or should I just make separate component packages for install / uninstall?

Jesse Barnum
  • 5,619
  • 4
  • 34
  • 59
  • 1
    Now I'm discovering that I can't change the conclusion message conditionally based on a user choice, which means I probably need an entirely different double-clickable uninstaller, which a conclusion message saying "The software was successfully uninstalled." It seems pretty lame that I can't customize the conclusion message on the fly. – Jesse Barnum Mar 15 '13 at 13:50
  • Has anyone figured out how to make uninstaller? – Jurica Krizanic Nov 28 '13 at 13:52
  • We created a separate uninstaller package, and that is working. I never did figure out how to combine install and uninstall functionality in the same package using the Apple installer. – Jesse Barnum Nov 28 '13 at 13:54
  • You used productbuild tool? Do you execute a shell script in uninstaller? – Jurica Krizanic Nov 28 '13 at 14:29
  • 1
    It's been a while, but yes, I think so. – Jesse Barnum Nov 28 '13 at 16:07
  • Hi, I know it's been a long while, but did you find any suitable solution to your problem to combine both apps in on a single package ? I'm using `productbuild` to create my installer, and I'd like to add uninstaller as well. – Zohar81 Sep 11 '16 at 05:48
  • No, I didn't. We ship a separate uninstaller bundle. – Jesse Barnum Sep 11 '16 at 13:32
  • @JesseBarnum The problem with a seperate uninstaller is the title bar and the button is "Install" instead of "Uninstall". Is it possible to change that? https://stackoverflow.com/questions/49643409/osx-pkg-uninstaller-is-it-possible-to-change-the-install-text-in-the-title-b – quanta Apr 18 '18 at 09:49
  • @quanta No I have not solved that problem – Jesse Barnum Apr 18 '18 at 14:23

0 Answers0