From 9b6c337d7a5defe092ce57b573e8e35fc6cfb3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Mon, 21 Feb 2022 21:53:18 +0100 Subject: [PATCH] Improved logging for app copy with `ditto` And a few lines changed to `WARN`. --- fragments/functions.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fragments/functions.sh b/fragments/functions.sh index 0b10f05..251121d 100644 --- a/fragments/functions.sh +++ b/fragments/functions.sh @@ -486,7 +486,7 @@ installAppWithPath() { # $1: path to app to install in $targetDir # remove existing application if [ -e "$targetDir/$appName" ]; then - printlog "Removing existing $targetDir/$appName" DEBUG + printlog "Removing existing $targetDir/$appName" WARN deleteAppOut=$(rm -Rfv "$targetDir/$appName" 2>&1) tempName="$targetDir/$appName" tempNameLength=$((${#tempName} + 10)) @@ -497,16 +497,21 @@ installAppWithPath() { # $1: path to app to install in $targetDir # copy app to /Applications printlog "Copy $appPath to $targetDir" - if ! ditto "$appPath" "$targetDir/$appName"; then - cleanupAndExit 7 "Error while copying" ERROR + copyAppOut=$(ditto -v "$appPath" "$targetDir/$appName" 2>&1) + copyAppStatus=$(echo $?) + deduplicatelogs "$copyAppOut" + printlog "Debugging enabled, App copy output was:\n$logoutput" DEBUG + if [[ $appVerifyStatus -ne 0 ]] ; then + #if ! ditto "$appPath" "$targetDir/$appName"; then + cleanupAndExit 7 "Error while copying:\n$logoutput" ERROR fi # set ownership to current user if [[ "$currentUser" != "loginwindow" && $SYSTEMOWNER -ne 1 ]]; then - printlog "Changing owner to $currentUser" + printlog "Changing owner to $currentUser" WARN chown -R "$currentUser" "$targetDir/$appName" else - printlog "No user logged in or SYSTEMOWNER=1, setting owner to root:wheel" + printlog "No user logged in or SYSTEMOWNER=1, setting owner to root:wheel" WARN chown -R root:wheel "$targetDir/$appName" fi