the.noonings wrote:
A note of caution.
Let us suppose that the user has more than one application that has been
built by par. The top level cache directory, $ENV{TEMP} plus "\par-$USER",
holds a \cache-" plus the SHA1 hash of the executable for each. Attempting
to remove the said entire top level cache dir in the uninstall routine of
one would remove the caches of the others, too. Not desirable. We need to
delete only the cache for the application which we are trying to delete.
No, I don't know how to do that.
I'm not certain I understand the issue you're raising.
Is it that (while only remotely possible) multiple, different
applications could generate the same SHA1 hash ?
If so, then the issue isn't terribly severe...PAR/pp startup
will just regenerate the directory structure the next
time the colliding application is executed. (I spose
if the colliding app(s) were running as servers or some
such, things might get nasty, except that Windows
would bark before then about trying to delete files that
were in use.)
All in all, it seems like a low likelihood risk I'm willing to assume.
And the better news is I've figgered out how to do this (with Inno Setup)
(also includes bits for generating the cache at install time):
First, add some special options to the main perl script you're
going to exe'ize:
#
# this argument runs us during uninstall to
# generate a simple batch file to cleanup
# the temp directories
#
if ($ARGV[0] && ($ARGV[0] eq '-c')) {
my $path = $ARGV[1];
my $parpath = $ENV{PAR_TEMP};
exit(0) unless ($parpath && -e $parpath);
open(OUTF, ">$path\\mycleanup.bat") || exit(0);
print OUTF "rmdir /S /Q $parpath\n";
close OUTF;
exit(0)
}
#
# a simple argument used during install to get PAR to extract
# the executable without doing anything, so later
# executions startup faster
#
exit(0) if ($ARGV[0] && ($ARGV[0] eq '-i'));
(The option flags are up to you of course)
Then in your Inno setup script:
[Run]
Filename: "{app}\MyPerlApp.exe"; Parameters: "-i"
Filename: "{app}\MyPerlApp.exe"; Description: "{cm:LaunchProgram,MyPerlApp}"; Flags:
nowait postinstall
[UninstallRun]
Filename: "{app}\MyPerlApp.exe"; Parameters: "-c ""{app}"""
Filename: "{app}\mycleanup.bat"
[UninstallDelete]
Type: files; Name: "{app}\mycleanup.bat"
(again, you'll need to adjust to your specific needs)
On install, it starts up the newly installed app, just to generate the
cached version.
On uninstall, it generates the cleanup batch file, then runs it, then
deletes it.
Took a tall frosty homebrew to figger it out, but its actually pretty
painless.
Regards,
Dean Arnold
Presicient Corp.