Align a function and improve checking in checkLabels

Will now also go through labels with warnings in the, to figure out if the label works. Many warnings are about version checking, so those will be verified now.
This commit is contained in:
Søren Theilgaard
2022-02-04 11:59:51 +01:00
parent 378b166164
commit 08e9e63422
2 changed files with 60 additions and 28 deletions

View File

@@ -48,6 +48,12 @@ fragments_dir="$repo_dir/fragments"
labels_dir="$fragments_dir/labels"
# MARK: Script
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
NC='\033[0m' # No Color
# Check minimal macOS requirement
if [[ $(sw_vers -buildVersion ) < "18" ]]; then
echo "Installomator requires at least macOS 10.14 Mojave."
@@ -59,28 +65,24 @@ echo "Version: $($repo_dir/assemble.sh version)"
echo "\nRemember to follow log in another terminal window (for the REAL tests):"
echo "tail -f /var/log/Installomator.log\n"
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
warningLabels="" # variable for labels with warnings
errorLabels="" # variable for labels with errors
countWarning=0
countError=0
mostWorkAndCheck() {
checkCmd_output() {
no_appNewVersion=$( echo $cmd_output | grep -ic "Latest version not specified." )
echo "No appNewVersion: $no_appNewVersion (1 for no)"
#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 version: $latest_appNewVersion"
#echo "Latest version: $latest_appNewVersion"
github_label=$( echo $cmd_output | grep -ci "Downloading https://github.com" )
echo "GitHub: $github_label (1 for true)"
#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"
#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"
#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}"
@@ -91,6 +93,7 @@ mostWorkAndCheck() {
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++))
warningLabels+=( "$label" )
echo "$cmd_output"
else
echo "${RED}$label NOT WORKING:${NC}"
@@ -99,7 +102,7 @@ mostWorkAndCheck() {
echo "$cmd_output"
fi
else
echo "${RED}$label NOT WORKING:${NC}"
echo "${RED}$label FAILED with exit code ${exit_status}:${NC}"
((countError++))
errorLabels+=( "$label" )
echo "$cmd_output"
@@ -115,7 +118,7 @@ for label in $allLabels; do
echo "Label $label: $label_name"
cmd_output=$( $repo_dir/assemble.sh $label DEBUG=2 INSTALL=force IGNORE_APP_STORE_APPS=yes BLOCKING_PROCESS_ACTION=ignore )
#echo "$cmd_output"
mostWorkAndCheck
checkCmd_output
echo
fi
done
@@ -142,7 +145,7 @@ for labelArg in $allLabelsArg; do
#echo "$cmd_output"
argument_variables=$( echo $cmd_output | grep -i "setting variable from argument" | sed -E 's/.*setting variable from argument (.*)$/\1/g')
echo $argument_variables
mostWorkAndCheck
checkCmd_output
echo
fi
done
@@ -156,6 +159,7 @@ else
fi
if [[ countError -gt 0 ]]; then
echo "${RED}ERRORS counted: $countError${NC}"
echo "${YELLOW}${errorLabels}${NC}"
else
echo "${GREEN}No errors detected!${NC}"
fi

View File

@@ -89,6 +89,42 @@ arch () {
echo $fixedArch
}
checkCmd_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 version: $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++))
warningLabels+=( "$label" )
echo "$cmd_output"
else
echo "${RED}$label NOT WORKING:${NC}"
((countError++))
errorLabels+=( "$label" )
echo "$cmd_output"
fi
else
echo "${RED}$label FAILED with exit code ${exit_status}:${NC}"
((countError++))
errorLabels+=( "$label" )
echo "$cmd_output"
fi
}
# MARK: Script
RED='\033[0;31m'
@@ -215,22 +251,14 @@ for fixedArch in i386 arm64; do
echo "${RED}-> !! ERROR in downloadURL${NC}"
labelError=1
fi
if [[ $labelWarning != 0 ]]; then; echo "${YELLOW}########## Warning in label: $label${NC}"; ((countWarning++)); warningLabels+=( "$label" ); fi
if [[ $labelError != 0 ]]; then
if [[ $labelError != 0 || $labelWarning != 0 ]]; then
echo "${RED}########## ERROR in label: $label${NC}"
echo "Testing using Installomator"
exit_status=$( . $repo_dir/assemble.sh $label DEBUG=2 INSTALL=force IGNORE_APP_STORE_APPS=yes BLOCKING_PROCESS_ACTION=ignore | grep exit | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' )
if [[ ${exit_status} -eq 0 ]] ; then
echo "${GREEN}$label works fine!${NC}"
#errorLabels=("${(@)errorLabels:#$errorLabel}")
else
echo "${RED}$label NOT WORKING!${NC}"
((countError++))
errorLabels+=( "$label" )
fi
#exit_status=$( . $repo_dir/assemble.sh $label DEBUG=2 INSTALL=force IGNORE_APP_STORE_APPS=yes BLOCKING_PROCESS_ACTION=ignore | grep exit | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' )
cmd_output=$( $repo_dir/assemble.sh $label DEBUG=2 INSTALL=force IGNORE_APP_STORE_APPS=yes BLOCKING_PROCESS_ACTION=ignore )
#echo "$cmd_output"
checkCmd_output
fi
if (($archLabels[(Ie)$label])); then
secondRoundLabels+=( "$label" )
fi