{ "versions": [ { "version": "11.0", "queries": { "exists": "SELECT 1 FROM apps WHERE bundle_identifier = 'com.macility.popchar3';", "patched": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps WHERE bundle_identifier = 'com.macility.popchar3' AND version_compare(bundle_short_version, '11.0') < 0);", "open": "SELECT 1 WHERE NOT EXISTS (SELECT 1 FROM apps a JOIN processes p ON p.path = concat(a.path, '/Contents/MacOS/', a.bundle_executable) WHERE a.bundle_identifier = 'com.macility.popchar3' AND a.bundle_executable != '');" }, "installer_url": "https://storage.ergonis.com/apps/production/popchar/archive/PopChar_110.zip", "install_script_ref": "a3a87a4e", "uninstall_script_ref": "07636a5c", "sha256": "ef47095bd1f8aac4419f10d23ed071b9b8475bb13322cc9c1ca91f54461002b7", "default_categories": [ "Utilities" ] } ], "refs": { "07636a5c": "#!/bin/bash\n\n# variables\nAPPDIR=\"/Applications/\"\nLOGGED_IN_USER=$(scutil <<< \"show State:/Users/ConsoleUser\" | awk '/Name :/ { print $3 }')\n# functions\n\napp_process_running() {\n local bundle_id=\"$1\" app\n while IFS= read -r app; do\n grep -qixF -- \"$bundle_id\" <<< \"$(defaults read \"$app/Contents/Info\" CFBundleIdentifier 2>/dev/null)\" && return 0\n done < <(ps -axo comm= | sed -n 's|^ *\\(.*\\.app\\)/Contents/MacOS/.*|\\1|p' | sort -u)\n return 1\n}\n\n\nquit_application() {\n local bundle_id=\"$1\"\n local timeout_duration=10\n\n local app_running\n app_running=$(osascript -e 'on run argv' -e 'return application id (item 1 of argv) is running' -e 'end run' -- \"$bundle_id\" 2>/dev/null)\n if [[ \"$app_running\" != \"true\" ]]; then\n return\n fi\n\n local console_user\n console_user=$(stat -f \"%Su\" /dev/console)\n if [[ -z \"$console_user\" || \"$console_user\" == \"root\" || \"$console_user\" == \"loginwindow\" ]]; then\n echo \"Not logged into a non-root GUI; skipping quitting application ID '$bundle_id'.\"\n return\n fi\n\n echo \"Quitting application '$bundle_id'...\"\n\n local quit_success=false still_running quit_error\n SECONDS=0\n while (( SECONDS < timeout_duration )); do\n quit_error=$(osascript -e 'on run argv' -e 'tell application id (item 1 of argv) to quit' -e 'end run' -- \"$bundle_id\" 2>&1 >/dev/null)\n if [[ \"$quit_error\" == *\"(-600)\" ]] && ! app_process_running \"$bundle_id\"; then\n echo \"Application '$bundle_id' isn't running.\"\n quit_success=true\n break\n fi\n sleep 1\n if still_running=$(osascript -e 'on run argv' -e 'return application id (item 1 of argv) is running' -e 'end run' -- \"$bundle_id\" 2>/dev/null) && [[ \"$still_running\" == \"false\" ]]; then\n echo \"Application '$bundle_id' quit successfully.\"\n quit_success=true\n break\n fi\n done\n\n if [[ \"$quit_success\" = false ]]; then\n echo \"Application '$bundle_id' did not quit.\"\n return 1\n fi\n}\n\n\nremove_system_path() {\n local target=\"$1\"\n local parent name rel top expected\n parent=\"$(dirname \"$target\")\"\n name=\"$(basename \"$target\")\"\n rel=\"${parent#/}\"\n top=\"/${rel%%/*}\"\n expected=\"$(cd -P \"$top\" 2>/dev/null && pwd -P)${parent#\"$top\"}\"\n\n (\n cd -P \"$parent\" 2>/dev/null || exit 1\n if [[ \"$(pwd -P)\" != \"$expected\" ]]; then\n echo \"Skipped $target: a folder in its path is a symlink.\"\n exit 0\n fi\n rm -rf \"./$name\"\n ) || echo \"Failed to remove $target.\"\n}\n\ntrash() {\n local logged_in_user=\"$1\"\n local target_file=\"$2\"\n local timestamp=\"$(date +%Y-%m-%d-%s)\"\n local rand=\"$(jot -r 1 0 99999)\"\n local trash=\"\"\n\n # Paths in the user's home are moved to their Trash as the user: the user\n # controls those paths and ~/.Trash, so as root the move could be redirected\n # into a root-only directory. Other paths are deleted as root by\n # remove_system_path. At the login window there's no user Trash, so home\n # paths are skipped. Removal is best-effort and never fails the uninstall.\n if [[ \"$target_file\" == ~* ]]; then\n if [[ -z \"$logged_in_user\" || \"$logged_in_user\" == \"root\" || \"$logged_in_user\" == \"loginwindow\" ]]; then\n echo \"Not logged into a non-root GUI; skipping $target_file.\"\n return\n fi\n # replace ~ with /Users/$logged_in_user\n target_file=\"/Users/$logged_in_user${target_file:1}\"\n trash=\"/Users/$logged_in_user/.Trash\"\n fi\n\n # If the target contains glob characters, expand it and remove each match.\n if [[ \"$target_file\" == *[*?[]* ]]; then\n local file file_name\n local matched=false\n local i=0\n # compgen -G expands the (quoted) pattern itself, so paths containing\n # spaces glob correctly; reading line by line keeps each match intact.\n while IFS= read -r file; do\n [[ -n \"$file\" ]] || continue\n [[ -e \"$file\" || -L \"$file\" ]] || continue\n matched=true\n i=$((i + 1))\n file_name=\"$(basename \"$file\")\"\n echo \"removing $file.\"\n if [[ -z \"$trash\" ]]; then\n remove_system_path \"$file\"\n else\n # The per-match counter keeps matches that share a basename from\n # overwriting each other in the trash.\n sudo -u \"$logged_in_user\" mv -f \"$file\" \"$trash/${file_name}_${timestamp}_${rand}_${i}\" || echo \"Failed to move $file to the Trash.\"\n fi\n done < <(compgen -G \"$target_file\" 2>/dev/null)\n if [[ \"$matched\" == false ]]; then\n echo \"$target_file doesn't exist.\"\n fi\n return\n fi\n\n local file_name=\"$(basename \"${target_file}\")\"\n\n if [[ -e \"$target_file\" ]]; then\n echo \"removing $target_file.\"\n if [[ -z \"$trash\" ]]; then\n remove_system_path \"$target_file\"\n else\n sudo -u \"$logged_in_user\" mv -f \"$target_file\" \"$trash/${file_name}_${timestamp}_${rand}\" || echo \"Failed to move $target_file to the Trash.\"\n fi\n else\n echo \"$target_file doesn't exist.\"\n fi\n}\n\nquit_application 'com.macility.popchar3' || exit 1\nsudo rm -rf \"$APPDIR/PopChar.app\"\ntrash \"$LOGGED_IN_USER\" '~/Library/Application Support/PopChar'\ntrash \"$LOGGED_IN_USER\" '~/Library/Caches/com.macility.popchar3'\ntrash \"$LOGGED_IN_USER\" '~/Library/HTTPStorages/com.macility.popchar3'\ntrash \"$LOGGED_IN_USER\" '~/Library/Preferences/com.macility.popchar3.plist'\n", "a3a87a4e": "#!/bin/bash\n\n# variables\nAPPDIR=\"/Applications/\"\nTMPDIR=$(dirname \"$(realpath \"$INSTALLER_PATH\")\")\n# functions\n\napp_process_running() {\n local bundle_id=\"$1\" app\n while IFS= read -r app; do\n grep -qixF -- \"$bundle_id\" <<< \"$(defaults read \"$app/Contents/Info\" CFBundleIdentifier 2>/dev/null)\" && return 0\n done < <(ps -axo comm= | sed -n 's|^ *\\(.*\\.app\\)/Contents/MacOS/.*|\\1|p' | sort -u)\n return 1\n}\n\n\nquit_and_track_application() {\n local bundle_id=\"$1\"\n local var_name=\"APP_WAS_RUNNING_${bundle_id//[^[:alnum:]_]/_}\"\n local timeout_duration=10\n\n local app_running\n app_running=$(osascript -e 'on run argv' -e 'return application id (item 1 of argv) is running' -e 'end run' -- \"$bundle_id\" 2>/dev/null)\n if [[ \"$app_running\" != \"true\" ]]; then\n eval \"export $var_name=0\"\n return\n fi\n\n local console_user\n console_user=$(stat -f \"%Su\" /dev/console)\n if [[ -z \"$console_user\" || \"$console_user\" == \"root\" || \"$console_user\" == \"loginwindow\" ]]; then\n echo \"Not logged into a non-root GUI; skipping quitting application ID '$bundle_id'.\"\n eval \"export $var_name=0\"\n return\n fi\n\n eval \"export $var_name=1\"\n echo \"Application '$bundle_id' was running; will relaunch after installation.\"\n\n echo \"Quitting application '$bundle_id'...\"\n\n local quit_success=false quit_sent=false still_running quit_error\n SECONDS=0\n while (( SECONDS < timeout_duration )); do\n quit_error=$(osascript -e 'on run argv' -e 'tell application id (item 1 of argv) to quit' -e 'end run' -- \"$bundle_id\" 2>&1 >/dev/null)\n if [[ \"$quit_error\" == *\"(-600)\" ]] && ! app_process_running \"$bundle_id\"; then\n if [[ \"$quit_sent\" == false ]]; then\n eval \"export $var_name=0\"\n echo \"Application '$bundle_id' isn't running; it won't be relaunched.\"\n else\n echo \"Application '$bundle_id' quit successfully.\"\n fi\n quit_success=true\n break\n fi\n quit_sent=true\n sleep 1\n if still_running=$(osascript -e 'on run argv' -e 'return application id (item 1 of argv) is running' -e 'end run' -- \"$bundle_id\" 2>/dev/null) && [[ \"$still_running\" == \"false\" ]]; then\n echo \"Application '$bundle_id' quit successfully.\"\n quit_success=true\n break\n fi\n done\n\n if [[ \"$quit_success\" = false ]]; then\n echo \"Application '$bundle_id' did not quit.\"\n return 1\n fi\n}\n\n\nrelaunch_application() {\n local bundle_id=\"$1\"\n local var_name=\"APP_WAS_RUNNING_${bundle_id//[^[:alnum:]_]/_}\"\n local was_running\n\n # Check if the app was running before installation\n eval \"was_running=\\$$var_name\"\n if [[ \"$was_running\" != \"1\" ]]; then\n return\n fi\n\n local console_user\n console_user=$(stat -f \"%Su\" /dev/console)\n if [[ -z \"$console_user\" || \"$console_user\" == \"root\" || \"$console_user\" == \"loginwindow\" ]]; then\n echo \"Not logged into a non-root GUI; skipping relaunching application ID '$bundle_id'.\"\n return\n fi\n\n echo \"Relaunching application '$bundle_id'...\"\n\n # Launch the app in the logged-in user's GUI session. Apps launched by root\n # won't register with the user's Dock/GUI, so run 'open' as the console user.\n # Use 'launchctl asuser' to bootstrap into the console user's Mach namespace\n # and GUI session — 'sudo -u' alone doesn't do this, which can cause\n # LSOpenURLsWithRole() failures even when 'open' exits 0.\n local open_status=0\n if [[ $EUID -eq 0 ]]; then\n local console_uid\n console_uid=$(id -u \"$console_user\")\n /bin/launchctl asuser \"$console_uid\" sudo -u \"$console_user\" open -b \"$bundle_id\" >/dev/null 2>&1 || open_status=$?\n else\n open -b \"$bundle_id\" >/dev/null 2>&1 || open_status=$?\n fi\n\n if [[ $open_status -eq 0 ]]; then\n echo \"Application '$bundle_id' relaunched successfully.\"\n else\n echo \"Failed to relaunch application '$bundle_id'.\"\n fi\n}\n\n\n# extract contents\nMOUNT_POINT=$(mktemp -d /tmp/dmg_mount_XXXXXX)\nyes | hdiutil attach -plist -nobrowse -readonly -mountpoint \"$MOUNT_POINT\" \"$INSTALLER_PATH\" || exit 1\nif ! sudo cp -R \"$MOUNT_POINT\"/* \"$TMPDIR\"; then\n\thdiutil detach \"$MOUNT_POINT\" || { sleep 2; hdiutil detach \"$MOUNT_POINT\"; } || hdiutil detach -force \"$MOUNT_POINT\" || true\n\texit 1\nfi\nhdiutil detach \"$MOUNT_POINT\" || { sleep 2; hdiutil detach \"$MOUNT_POINT\"; } || hdiutil detach -force \"$MOUNT_POINT\" || true\n# copy to the applications folder\nquit_and_track_application 'com.macility.popchar3' || exit 1\nif [ -d \"$APPDIR/PopChar.app\" ]; then\n\tsudo mv \"$APPDIR/PopChar.app\" \"$TMPDIR/PopChar.app.bkp\" || exit $?\nfi\nif ! sudo cp -R \"$TMPDIR/PopChar.app\" \"$APPDIR\"; then\n\t# remove the partial copy so a failed install isn't inventoried as the new\n\t# version, then restore the previous version if there was one\n\tsudo rm -rf \"$APPDIR/PopChar.app\"\n\tif [ -d \"$TMPDIR/PopChar.app.bkp\" ]; then\n\t\tsudo mv \"$TMPDIR/PopChar.app.bkp\" \"$APPDIR/PopChar.app\"\n\tfi\n\texit 1\nfi\nrelaunch_application 'com.macility.popchar3'\n" } }