[gimp-macos-build/wip/lukaso/tests] Another attempt



commit 93bde03a5118f86dab777d7553b656321ab63b2a
Author: Lukas Oberhuber <lukaso gmail com>
Date:   Sun Oct 17 22:48:44 2021 +0100

    Another attempt

 package/create-dmg/create-dmg | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/package/create-dmg/create-dmg b/package/create-dmg/create-dmg
index ca5dcc6..f570342 100755
--- a/package/create-dmg/create-dmg
+++ b/package/create-dmg/create-dmg
@@ -349,11 +349,25 @@ EOS
        fi
 }
 
+# convenience function to run a command as the current user
+# usage:
+#   runAsUser command arguments...
+runAsUser() {
+  if [ "$currentUser" != "loginwindow" ]; then
+    launchctl asuser "$uid" sudo -u "$currentUser" "$@"
+  else
+    echo "no user logged in"
+    # uncomment the exit command
+    # to make the function exit with an error when no user is logged in
+    exit 1
+  fi
+}
+
 if [ $SKIP_JENKINS -eq 0 ]; then
        applescript_source | sed -e "s/WINX/$WINX/g" -e "s/WINY/$WINY/g" -e "s/WINW/$WINW/g" -e 
"s/WINH/$WINH/g" -e "s/BACKGROUND_CLAUSE/$BACKGROUND_CLAUSE/g" -e 
"s/REPOSITION_HIDDEN_FILES_CLAUSE/$REPOSITION_HIDDEN_FILES_CLAUSE/g" -e "s/ICON_SIZE/$ICON_SIZE/g" -e 
"s/TEXT_SIZE/$TEXT_SIZE/g" | perl -pe  "s/POSITION_CLAUSE/$POSITION_CLAUSE/g" | perl -pe 
"s/QL_CLAUSE/$QL_CLAUSE/g" | perl -pe "s/APPLICATION_CLAUSE/$APPLICATION_CLAUSE/g" | perl -pe 
"s/HIDING_CLAUSE/$HIDING_CLAUSE/" >"$APPLESCRIPT"
        sleep 2 # pause to workaround occasional "Can’t get disk" (-1728) issues
        echo "Running Applescript: /usr/bin/osascript \"${APPLESCRIPT}\" \"${VOLUME_NAME}\""
-       (/usr/bin/osascript "${APPLESCRIPT}" "${VOLUME_NAME}" || if [[ "$?" -ne 0 ]]; then echo "Failed 
running AppleScript"; hdiutil detach "${DEV_NAME}"; exit 64; fi)
+       (runAsUser /usr/bin/osascript "${APPLESCRIPT}" "${VOLUME_NAME}" || if [[ "$?" -ne 0 ]]; then echo 
"Failed running AppleScript"; hdiutil detach "${DEV_NAME}"; exit 64; fi)
        echo "Done running the applescript..."
        sleep 4
        rm "$APPLESCRIPT"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]