mirror of
https://github.com/mtan93/Installomator.git
synced 2026-03-08 05:31:53 +00:00
Update checkLabels.sh
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||||||
|
|
||||||
# Check Installomator labels from fragments
|
# Check Installomator labels from fragments
|
||||||
# 2021 Søren Theilgaard (@theilgaard)
|
# 2021-2022 Søren Theilgaard (@theilgaard)
|
||||||
|
|
||||||
# This script will test labels and check if download link is active, and if version is defined.
|
# This script will test labels and check if download link is active, and if version is defined.
|
||||||
# If labels are written to the script only those will be tested.
|
# If labels are written to the script only those will be tested.
|
||||||
@@ -132,158 +132,127 @@ countError=0
|
|||||||
|
|
||||||
# Loop through the 2 architectures
|
# Loop through the 2 architectures
|
||||||
for fixedArch in i386 arm64; do
|
for fixedArch in i386 arm64; do
|
||||||
echo "${BLUE}Architecture: $fixedArch${NC}"
|
echo "${BLUE}Architecture: $fixedArch${NC}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Loop through all labels
|
# Loop through all labels
|
||||||
for label in $allLabels; do
|
for label in $allLabels; do
|
||||||
echo "########## $label"
|
echo "########## $label"
|
||||||
labelWarning=0; labelError=0; expectedExtension=""; URLextension=""
|
labelWarning=0; labelError=0; expectedExtension=""; URLextension=""
|
||||||
name=""; type=""; downloadURL=""; curlOptions=""; appNewVersion=""; expectedTeamID=""; blockingProcesses=""; updateTool=""; updateToolArguments=""; archiveName=""
|
name=""; type=""; downloadURL=""; curlOptions=""; appNewVersion=""; expectedTeamID=""; blockingProcesses=""; updateTool=""; updateToolArguments=""; archiveName=""
|
||||||
|
|
||||||
#caseLabel
|
#caseLabel
|
||||||
if cat "${labels_dir}/${label}.sh" | grep -v -E '^[a-z0-9\_-]*(\)|\|\\)$' | grep -v ";;" > checkLabelCurrent.sh; then
|
if cat "${labels_dir}/${label}.sh" | grep -v -E '^[a-z0-9\_-]*(\)|\|\\)$' | grep -v ";;" > checkLabelCurrent.sh; then
|
||||||
source checkLabelCurrent.sh
|
source checkLabelCurrent.sh
|
||||||
|
|
||||||
echo "Name: $name"
|
echo "Name: $name"
|
||||||
echo "Download URL: $downloadURL"
|
echo "Download URL: $downloadURL"
|
||||||
echo "Type: $type"
|
echo "Type: $type"
|
||||||
case $type in
|
case $type in
|
||||||
dmg|pkg|zip|tbz)
|
dmg|pkg|zip|tbz)
|
||||||
expectedExtension="$type"
|
expectedExtension="$type"
|
||||||
;;
|
;;
|
||||||
pkgInDmg)
|
pkgInDmg)
|
||||||
expectedExtension="dmg"
|
expectedExtension="dmg"
|
||||||
;;
|
;;
|
||||||
*InZip)
|
*InZip)
|
||||||
expectedExtension="zip"
|
expectedExtension="zip"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Cannot handle type $type"
|
echo "Cannot handle type $type"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if [[ "$appNewVersion" == "" ]] ; then
|
if [[ "$appNewVersion" == "" ]] ; then
|
||||||
echo "No appNewVersion!"
|
echo "No appNewVersion!"
|
||||||
else
|
|
||||||
if [[ $( echo "$appNewVersion" | grep -i "[0-9.]" ) == "" || $appNewVersion == "" ]]; then
|
|
||||||
echo "${RED}-> !! ERROR in appNewVersion${NC}"
|
|
||||||
labelError=1
|
|
||||||
else
|
else
|
||||||
if [[ $appNewVersion != $( echo "$appNewVersion" | sed -E 's/[^0-9]*([0-9.]*)[^0-9]*/\1/g' ) ]]; then
|
if [[ $( echo "$appNewVersion" | grep -i "[0-9.]" ) == "" || $appNewVersion == "" ]]; then
|
||||||
echo "${YELLOW}Warning: Version contain not only numbers and dots.${NC}"
|
echo "${RED}-> !! ERROR in appNewVersion${NC}"
|
||||||
labelWarning=1
|
labelError=1
|
||||||
|
else
|
||||||
|
if [[ $appNewVersion != $( echo "$appNewVersion" | sed -E 's/[^0-9]*([0-9.]*)[^0-9]*/\1/g' ) ]]; then
|
||||||
|
echo "${YELLOW}Warning: Version contain not only numbers and dots.${NC}"
|
||||||
|
labelWarning=1
|
||||||
|
fi
|
||||||
|
echo "Version: $appNewVersion" ;
|
||||||
fi
|
fi
|
||||||
echo "Version: $appNewVersion" ;
|
|
||||||
fi
|
fi
|
||||||
fi
|
if curl -sfL ${curlOptions} --output /dev/null -r 0-0 "$downloadURL" ; then
|
||||||
if curl -sfL ${curlOptions} --output /dev/null -r 0-0 "$downloadURL" ; then
|
echo "${GREEN}OK: downloadURL works OK${NC}"
|
||||||
echo "${GREEN}OK: downloadURL works OK${NC}"
|
if [[ $(echo "$downloadURL" | sed -E 's/.*\.([a-zA-Z]*)\s*/\1/g' ) == "${expectedExtension}" ]]; then
|
||||||
if [[ $(echo "$downloadURL" | sed -E 's/.*\.([a-zA-Z]*)\s*/\1/g' ) == "${expectedExtension}" ]]; then
|
echo "${GREEN}OK: download extension MATCH on ${expectedExtension}${NC}"
|
||||||
echo "${GREEN}OK: download extension MATCH on ${expectedExtension}${NC}"
|
else
|
||||||
else
|
if [[ $(echo "$downloadURL" | grep -io "github.com") != "github.com" ]]; then
|
||||||
if [[ $(echo "$downloadURL" | grep -io "github.com") != "github.com" ]]; then
|
URLheader=$( curl -fsIL "$downloadURL" )
|
||||||
URLheader=$( curl -fsIL "$downloadURL" )
|
if [[ "${URLheader}" != "" ]]; then
|
||||||
if [[ "${URLheader}" != "" ]]; then
|
URLlocation=$( echo "${URLheader}" | grep -i "^location" )
|
||||||
URLlocation=$( echo "${URLheader}" | grep -i "^location" )
|
URLfilename=$( echo "${URLheader}" | grep -i "filename=" )
|
||||||
URLfilename=$( echo "${URLheader}" | grep -i "filename=" )
|
if [[ "${URLlocation}" != "" ]]; then
|
||||||
if [[ "${URLlocation}" != "" ]]; then
|
URLextension=$( echo "${URLlocation}" | tail -1 | sed -E 's/.*\.([a-zA-Z]*)\s*/\1/g' | tr -d '\r\n' )
|
||||||
URLextension=$( echo "${URLlocation}" | tail -1 | sed -E 's/.*\.([a-zA-Z]*)\s*/\1/g' | tr -d '\r\n' )
|
else
|
||||||
|
URLextension=$( echo "${URLfilename}" | tail -1 | sed -E 's/.*\.([a-zA-Z]*)\s*/\1/g' | tr -d '\r\n' )
|
||||||
|
fi
|
||||||
|
URLextension=${${URLextension:l}%%\?*}
|
||||||
|
if [[ "${URLextension}" == "${expectedExtension}" ]]; then
|
||||||
|
echo "${GREEN}OK: download extension MATCH on ${URLextension}${NC}"
|
||||||
|
else
|
||||||
|
echo "${RED}-> !! ERROR in download extension, expected ${expectedExtension}, but got ${URLextension}.${NC}"
|
||||||
|
labelError=1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
URLextension=$( echo "${URLfilename}" | tail -1 | sed -E 's/.*\.([a-zA-Z]*)\s*/\1/g' | tr -d '\r\n' )
|
echo "no header provided from server."
|
||||||
fi
|
fi
|
||||||
URLextension=${${URLextension:l}%%\?*}
|
else
|
||||||
if [[ "${URLextension}" == "${expectedExtension}" ]]; then
|
githubPart="$(echo "$downloadURL" | cut -d "/" -f4-6)"
|
||||||
echo "${GREEN}OK: download extension MATCH on ${URLextension}${NC}"
|
if [[ "$(curl -fsL "$downloadURL" | grep -io "${githubPart}.*\.${expectedExtension}")" != "" ]]; then
|
||||||
|
echo "${GREEN}OK: download extension MATCH on ${expectedExtension}${NC}"
|
||||||
else
|
else
|
||||||
echo "${RED}-> !! ERROR in download extension, expected ${expectedExtension}, but got ${URLextension}.${NC}"
|
echo "${RED}-> !! ERROR in download extension, expected ${expectedExtension}, but it was wrong${NC}"
|
||||||
labelError=1
|
labelError=1
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "no header provided from server."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
githubPart="$(echo "$downloadURL" | cut -d "/" -f4-6)"
|
|
||||||
if [[ "$(curl -fsL "$downloadURL" | grep -io "${githubPart}.*\.${expectedExtension}")" != "" ]]; then
|
|
||||||
echo "${GREEN}OK: download extension MATCH on ${expectedExtension}${NC}"
|
|
||||||
else
|
|
||||||
echo "${RED}-> !! ERROR in download extension, expected ${expectedExtension}, but it was wrong${NC}"
|
|
||||||
labelError=1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (($archLabels[(Ie)$label])); then
|
||||||
|
secondRoundLabels+=( "$label" )
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "${RED}-> !! ERROR in downloadURL${NC}"
|
echo "Label: ${label} is not it's own file in Labels-folder. Skipping"
|
||||||
labelError=1
|
|
||||||
fi
|
|
||||||
if [[ $labelWarning != 0 ]]; then; echo "${YELLOW}########## Warning in label: $label${NC}"; ((countWarning++)); warningLabels+=( "$label" ); fi
|
|
||||||
if [[ $labelError != 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
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (($archLabels[(Ie)$label])); then
|
|
||||||
secondRoundLabels+=( "$label" )
|
|
||||||
fi
|
fi
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
if [[ $fixedArch == i386 ]] ; then
|
||||||
|
errorLabelsi386=( ${=errorLabels} )
|
||||||
else
|
else
|
||||||
echo "Label: ${label} is not it's own file in Labels-folder. Skipping"
|
errorLabelsarm64=( ${=errorLabels} )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
errorLabels=""
|
||||||
|
allLabels=( ${=secondRoundLabels} )
|
||||||
|
archLabels=()
|
||||||
echo
|
echo
|
||||||
done
|
done
|
||||||
# check errorLabels using Installomator
|
|
||||||
#echo "Testing – $errorLabels – using Installomator"
|
|
||||||
#if [[ countError > 0 ]]; then
|
|
||||||
# allLabels=( ${=errorLabels} )
|
|
||||||
# for errorLabel in $errorLabels; do
|
|
||||||
# exit_status=$( . $repo_dir/assemble.sh $errorLabel DEBUG=2 INSTALL=force | grep exit | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' )
|
|
||||||
# if [[ ${exit_status} -eq 0 ]] ; then
|
|
||||||
# echo "$errorLabel works fine"
|
|
||||||
# errorLabels=("${(@)errorLabels:#$errorLabel}")
|
|
||||||
# ((countError--))
|
|
||||||
# fi
|
|
||||||
# done
|
|
||||||
#fi
|
|
||||||
if [[ $fixedArch == i386 ]] ; then
|
|
||||||
errorLabelsi386=( ${=errorLabels} )
|
|
||||||
else
|
|
||||||
errorLabelsarm64=( ${=errorLabels} )
|
|
||||||
fi
|
|
||||||
#eval errorLabels${fixedArch}="${errorLabels}"
|
|
||||||
errorLabels=""
|
|
||||||
allLabels=( ${=secondRoundLabels} )
|
|
||||||
archLabels=()
|
|
||||||
echo
|
|
||||||
done
|
|
||||||
#errorLabels${fixedArch}=(${=errorLabels})
|
|
||||||
# check errorLabels using Installomator
|
|
||||||
#echo "Testing – $errorLabels – using Installomator"
|
|
||||||
#if [[ countError > 0 ]]; then
|
|
||||||
# allLabels=( ${=errorLabels} )
|
|
||||||
# for errorLabel in $errorLabels; do
|
|
||||||
# exit_status=$( . $repo_dir/assemble.sh $errorLabel DEBUG=2 INSTALL=force | grep exit | tail -1 | sed -E 's/.*exit code ([0-9]).*/\1/g' )
|
|
||||||
# if [[ ${exit_status} -eq 0 ]] ; then
|
|
||||||
# echo "$errorLabel works fine"
|
|
||||||
# errorLabels=("${(@)errorLabels:#$errorLabel}")
|
|
||||||
# ((countError--))
|
|
||||||
# fi
|
|
||||||
# done
|
|
||||||
#fi
|
|
||||||
#errorLabels2=( ${=errorLabels} )
|
|
||||||
|
|
||||||
rm checkLabelCurrent.sh
|
rm checkLabelCurrent.sh
|
||||||
|
|
||||||
#${SELFLOCATION}/Installomator.sh version
|
|
||||||
#echo
|
|
||||||
|
|
||||||
if [[ countWarning -gt 0 ]]; then
|
if [[ countWarning -gt 0 ]]; then
|
||||||
echo "${YELLOW}Warnings counted: $countWarning${NC}"
|
echo "${YELLOW}Warnings counted: $countWarning${NC}"
|
||||||
echo "${YELLOW}${warningLabels}${NC}"
|
echo "${YELLOW}${warningLabels}${NC}"
|
||||||
|
|||||||
Reference in New Issue
Block a user