On Mar 30, 2017, at 1:09 PM, Stephen Kay <
email@hidden> wrote:
My installation puts a folder inside /Applications that holds the .app and
some other support files (sorry, it's old). Within that folder, there is
another folder that holds a pdf Help File.
The structure is like this (note spaces in names):
/Applications/My App Folder/My App.app
/Applications/My App Folder/Help Folder/Help File 3.3.pdf
So if you install the new version on top of an older version, all files
having the same names get replaced except for the Help File which has a
version number at the end of it. So the user can end up with several older
help files.
If the older version was installed using a .pkg, then `installer` (even when called by `Installer.app`) should be cleaning away any files that were explicitly in the older version[1], but not explicitly in the newer version. This does not take any files created in any installer scripts into account, nor anything like data, cache, or preferences files created in the use of an app. But for most cases this should just be taken care of for you.
If you are just switching to a /pkg from something else (e.g. Mindvision Installer) then you are on your own. This also applies if you are changing the package id.
So I wanted to have the post-install script that is attached to my .app
bundle delete any older Help Files.
In testing this, this WORKS to delete an older file (if it exists, and if
not, who cares):
rm -rf "$2/../Help Folder/Help 3.2.pdf"
But I had gotten the impression that you should use sudo and the current
user for everything, as shown in most of the examples I've seen here.
If you are installing into /Applications, then things should already be running as root (well… with root permissions), and that is the appropriate user for anything in /Applications.
If I try this, it doesn't work:
/usr/bin/su $USER -c "/usr/bin/rm -rf \"$2/../Help Folder/Help 3.2.pdf\""
I must have something wrong with the quoting, I tried it without quotes,
numerous variations of quoting and escaping etc., but I can't see it. Or
there's something I'm misunderstanding about the examples I've seen.