From dd2af4a40e9e1ec68c26a1694cbbeac34900e338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Tue, 1 Feb 2022 00:13:51 +0100 Subject: [PATCH 1/2] Create checkInstallomator.sh This script will check certain labels. It's meant to check all (or most) of Installomator, to see if the code is working. We need labels that are representative for alle the functionality in the script. (Bug-fix for LSMinimumSystemVersion is needed for some of these to work) --- utils/checkInstallomator.sh | 107 ++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100755 utils/checkInstallomator.sh diff --git a/utils/checkInstallomator.sh b/utils/checkInstallomator.sh new file mode 100755 index 0000000..ff3bce7 --- /dev/null +++ b/utils/checkInstallomator.sh @@ -0,0 +1,107 @@ +#!/bin/zsh + +export PATH=/usr/bin:/bin:/usr/sbin:/sbin + +# Check Installomator with various labels in various modes +# 2022 Søren Theilgaard (@theilgaard) + +# This script will use various labels to check if Installomator is working as it is supposed to do + +# To check this script use these labels: +# desktoppr dbeaverce brave microsoftteams whatsapp citrixworkspace aircall devonthink + + +# MARK: Constants +allLabels=( dbeaverce signal brave inkscape devonthink microsoftteams applenyfonts sketch sqlpropostgres desktoppr marathon) + +# dbeaverse: dmg without appNewVersion +# signal: dmg with appNewVersion +# brave: dmg with appNewVersion from versionKey +# inkscape: dmg with appCustomVersion +# adobecreativeclouddesktop: dmg with appNewVersion and installerTool +# devonthink: appInDmgInZip +# microsoftteams: pkg with appNewVersion from packageID +# applenyfonts: pkgInDmg from Apple with packageID and no appNewVersion +# sketch: zip with appNewVersion +# sqlpropostgres: zip without appNewVersion +# desktoppr: pkg from github with packageID +# marathon: dmg from github with archiveName + + +#setup some folders +script_dir=$(dirname ${0:A}) +repo_dir=$(dirname $script_dir) +build_dir="$repo_dir/build" +destination_file="$build_dir/Installomator.sh" +fragments_dir="$repo_dir/fragments" +labels_dir="$fragments_dir/labels" + +# MARK: Script +# Check minimal macOS requirement +if [[ $(sw_vers -buildVersion ) < "18" ]]; then + echo "Installomator requires at least macOS 10.14 Mojave." + exit 98 +fi + +currentUser=$(stat -f "%Su" /dev/console) + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[1;34m' +NC='\033[0m' # No Color +countWarning=0 +countError=0 + +for label in $allLabels; do + cmd_output=$( $repo_dir/assemble.sh $label DEBUG=2 INSTALL=force IGNORE_APP_STORE_APPS=yes BLOCKING_PROCESS_ACTION=ignore ) + #echo "$cmd_output" + no_appNewVersion=$( echo $cmd_output | grep -ic "Latest version not specified." ) + echo "No appNewVersion: $no_appNewVersion (1 for no)" + latest_appNewVersion=$( echo $cmd_output | grep -i "Latest version of " | sed -E 's/.* is ([0-9.]*),*.*$/\1/g' ) + echo "Latest vesion: $latest_appNewVersion" + github_label=$( echo $cmd_output | grep -ci "Downloading https://github.com" ) + echo "github: $github_label (1 for true)" + downloaded_version=$( echo $cmd_output | grep -ioE "Downloaded (package.*version|version of.*is) [0-9.]*" | grep -v "is the same as installed" | sed -E 's/.* (is|version) ([0-9.]*).*/\2/g' ) + echo "Downloaded version: $downloaded_version" + exit_status=$( echo $cmd_output | grep exit | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' ) + echo "Exit: $exit_status" + if [[ ${exit_status} -eq 0 ]] ; then + if [[ $no_appNewVersion -eq 1 ]]; then + echo "${GREEN}$label works fine, but no appNewVersion.${NC}" + elif [[ $latest_appNewVersion == $downloaded_version && $github_label -eq 0 ]]; then + echo "${GREEN}$label works fine, with version $latest_appNewVersion.${NC}" + elif [[ $github_label -eq 1 ]]; then + echo "${GREEN}$label works fine, with GitHub version $latest_appNewVersion.${NC}" + elif [[ $latest_appNewVersion != $downloaded_version && $github_label -eq 0 ]]; then + echo "${YELLOW}$label has version warning, with latest $latest_appNewVersion not matching downloaded $downloaded_version.${NC}" + ((countWarning++)) + echo "$cmd_output" + else + echo "${RED}$label NOT WORKING:${NC}" + ((countError++)) + errorLabels+=( "$label" ) + echo "$cmd_output" + fi + else + echo "${RED}$label NOT WORKING:${NC}" + ((countError++)) + errorLabels+=( "$label" ) + echo "$cmd_output" + fi +done + +echo +if [[ countWarning -gt 0 ]]; then + echo "${YELLOW}Warnings counted: $countWarning${NC}" + echo "${YELLOW}${warningLabels}${NC}" +else + echo "${GREEN}No warnings detected!${NC}" +fi +if [[ countError -gt 0 ]]; then + echo "${RED}ERRORS counted: $countError${NC}" +else + echo "${GREEN}No errors detected!${NC}" +fi + +echo "Done!" From 9416700da294c3dce44d9ee34cff57b4b0c06ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Theilgaard?= Date: Tue, 1 Feb 2022 09:12:50 +0100 Subject: [PATCH 2/2] Update checkInstallomator.sh More description on what to test --- utils/checkInstallomator.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/checkInstallomator.sh b/utils/checkInstallomator.sh index ff3bce7..570efe7 100755 --- a/utils/checkInstallomator.sh +++ b/utils/checkInstallomator.sh @@ -14,11 +14,14 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin # MARK: Constants allLabels=( dbeaverce signal brave inkscape devonthink microsoftteams applenyfonts sketch sqlpropostgres desktoppr marathon) -# dbeaverse: dmg without appNewVersion +## Testing for combinations of these +# Label types: dmg, pkg, zip, tbz, pkgInDmg, pkgInZip, appInDmgInZip +# Label fields: packageID, appNewVersion, versionKey, appCustomVersion(){}, archiveName, appName, pkgName + +# dbeaverse: dmg without appNewVersion and does not have LSMinimumSystemVersion in Info.plist # signal: dmg with appNewVersion # brave: dmg with appNewVersion from versionKey # inkscape: dmg with appCustomVersion -# adobecreativeclouddesktop: dmg with appNewVersion and installerTool # devonthink: appInDmgInZip # microsoftteams: pkg with appNewVersion from packageID # applenyfonts: pkgInDmg from Apple with packageID and no appNewVersion @@ -27,6 +30,10 @@ allLabels=( dbeaverce signal brave inkscape devonthink microsoftteams applenyfon # desktoppr: pkg from github with packageID # marathon: dmg from github with archiveName +# Label types not possible to test in DEBUG mode: updateronly +# Label fields not possible to test in DEBUG mode: targetDir, blockingProcesses, updateTool, updateToolRunAsCurrentUser, installerTool, CLIInstaller, CLIArguments +# adobecreativeclouddesktop: dmg with appNewVersion and installerTool, CLIInstaller, CLIArguments + #setup some folders script_dir=$(dirname ${0:A})