Mac OS X .pkg installer: check for target folder before installing

If the target folder exists, let the user know and give up. (This
seems safer than trying to delete the folder, since there might be
other files in the folder than the original files, and the installer
doesn't currently keep a list of installed files.)

original commit: 2e327d78866c598430a83632a7dde215bbfd4397
This commit is contained in:
Matthew Flatt 2014-10-24 07:00:14 -06:00
parent ad6ac7fe28
commit 1521fd2b8e

View File

@ -22,9 +22,9 @@
(define (gen-install-script install-dest)
(~a "#!/bin/sh\n"
"echo \"" (regexp-replace* #rx"\""
"echo \"" (regexp-replace* #rx"[\"$]"
install-dest
"\"'\"'\"")
"\"'\\0'\"")
"\"/bin > /etc/paths.d/racket\n"))
(define (make-pkg human-name src-dir pkg-name readme sign-identity)
@ -106,6 +106,29 @@
(attribute #f #f 'alignment "topleft")
(attribute #f #f 'scaling "none"))
null)
(element #f #f
'installation-check
(list (attribute #f #f 'script "check_exists_already()"))
null)
(element #f #f
'script
null
(list
(cdata #f #f
@~a{
function check_exists_already () {
if (system.files.fileExistsAtPath(@|(~s install-dest)|)) {
my.result.type = "Fatal";
my.result.title = "Folder Exists Already";
my.result.message = ("Cannot install because a "
+ @|(~s (~s human-name))|
+ " folder"
+ " already exists in the Applications folder."
+ " Please remove it and try again.");
return false;
}
return true;
}})))
(element-content e))]))]))
(call-with-output-file*
pkg-xml