From 1521fd2b8ec6f42137e8ca8a56b91c927397639d Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 24 Oct 2014 07:00:14 -0600 Subject: [PATCH] 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 --- .../distro-build-client/installer-pkg.rkt | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/pkgs/distro-build-pkgs/distro-build-client/installer-pkg.rkt b/pkgs/distro-build-pkgs/distro-build-client/installer-pkg.rkt index 423def7..231f94c 100644 --- a/pkgs/distro-build-pkgs/distro-build-client/installer-pkg.rkt +++ b/pkgs/distro-build-pkgs/distro-build-client/installer-pkg.rkt @@ -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