-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-verify-software.sh
More file actions
executable file
·75 lines (61 loc) · 1.94 KB
/
dev-verify-software.sh
File metadata and controls
executable file
·75 lines (61 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /bin/bash
set -e
# Software
software=("node" "java" "xcode-select" "adb" "pod" "xcodebuild")
# Version numbers (inclusive)
node=("22.0.0" "22.999.0")
java=("17.0.0" "17.999.0")
pod=("1.16.0")
xcodebuild=("16.2")
success() {
echo -e "✅ $1"
}
failures=0
error() {
echo -e "❌ $1"
((failures += 1))
}
semver_lte() {
printf '%s\n' "$1" "$2" | sort -C -V
}
for software in "${software[@]}"; do
if command -v "$software" &> /dev/null; then
if [[ "$(declare -p "$software" 2> /dev/null)" =~ "declare -a" ]]; then
version_output=$("$software" --version 2> /dev/null || true)
version_output="$version_output"$'\n'$("$software" -version 2> /dev/null || true)
semver=$(echo "$version_output" | grep -Eo '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n 1)
if [[ -z $semver ]]; then
error "Could not parse the version from command \`$software --version\`. Please check the installation."
else
version_failures=0
min_version="${software}[0]"
max_version="${software}[1]"
# Check for min and max version
if [[ -n "${!min_version}" ]] && ! semver_lte "${!min_version}" "$semver"; then
((version_failures += 1))
fi
if [[ -n "${!max_version}" ]] && ! semver_lte "$semver" "${!max_version}"; then
((version_failures += 1))
fi
# Output message if there are failures
if [[ $version_failures -ne 0 ]]; then
error_string="$software version $semver is not supported. Please install $software version "
[[ -n "${!min_version}" ]] && error_string+=">= ${!min_version}"
[[ -n "${!min_version}" ]] && [[ -n "${!max_version}" ]] && error_string+=" and "
[[ -n "${!max_version}" ]] && error_string+="<= ${!max_version}"
error "$error_string."
else
success "$software version $semver is installed."
fi
fi
else
success "$software is installed."
fi
else
error "$software is not installed."
fi
done
if [[ $failures -ne 0 ]]; then
error "Please check your environment setup."
exit 1
fi