-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
silkworm_compat_check.sh
executable file
·91 lines (79 loc) · 2 KB
/
silkworm_compat_check.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
set -e
set -u
set -o pipefail
OS_RELEASE_PATH=/etc/os-release
function glibc_version {
cmd="ldd --version"
$cmd | head -1 | awk '{ print $NF }'
}
function glibcpp_version {
link_path=$(/sbin/ldconfig -p | grep libstdc++ | awk '{ print $NF }' | head -1)
if [[ ! -L "$link_path" ]]
then
echo "0"
else
file_name=$(readlink "$link_path")
echo "${file_name##*.}"
fi
}
function version_major {
IFS='.' read -a components <<< "$1"
echo "${components[0]}"
}
function version_minor {
IFS='.' read -a components <<< "$1"
echo "${components[1]}"
}
case $(uname -s) in
Linux)
if [[ ! -f "$OS_RELEASE_PATH" ]]
then
echo "not supported Linux without $OS_RELEASE_PATH"
exit 2
fi
# The os-release file does not require any variables to be set
# so we define these two to avoid 'unbound variable' errors.
ID=""
VERSION_ID=""
source "$OS_RELEASE_PATH"
if [[ -n "$ID" ]] && [[ -n "$VERSION_ID" ]]
then
version=$(version_major "$VERSION_ID")
case "$ID" in
"debian")
if (( version < 12 ))
then
echo "not supported Linux version: $ID $VERSION_ID"
exit 3
fi
;;
"ubuntu")
if (( version < 22 ))
then
echo "not supported Linux version: $ID $VERSION_ID"
exit 3
fi
;;
esac
fi
version=$(version_minor "$(glibc_version)")
if (( version < 34 ))
then
echo "not supported glibc version: $version"
exit 4
fi
version=$(glibcpp_version)
if (( version < 30 ))
then
echo "not supported glibcpp version: $version"
exit 5
fi
;;
Darwin)
;;
*)
echo "unsupported OS"
exit 1
;;
esac