forked from redhat-developer/dotnet-regular-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime-id
executable file
·56 lines (45 loc) · 1.09 KB
/
runtime-id
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
#!/usr/bin/env bash
# This is a script called by multiple tests to find the runtime id of
# the current platform.
set -euo pipefail
function usage() {
echo "usage: $0 [--portable]"
echo ""
echo "Shows the runtime id of the current OS distribution, or general OS (with the --portable flag)"
}
source /etc/os-release
declare -A archmap
archmap=(
["aarch64"]="arm64"
["amd64"]="x64"
["armv8l"]="arm"
["i686"]="x86"
["i386"]="x86"
["x86_64"]="x64"
["s390x"]="s390x"
["ppc64le"]="ppc64le"
)
arch=${archmap["$(uname -m)"]}
portable_rid=0
while [[ $# -gt 0 ]]; do
arg=$1
shift
case "$arg" in
--portable) portable_rid=1 ;;
*) usage; exit 1 ;;
esac
done
if [[ ${portable_rid} == 1 ]]; then
if (ldd --version 2>&1 || true) | grep -q musl ; then
echo "linux-musl-${arch}"
else
echo "linux-${arch}"
fi
else
case "${ID}" in
# Remove the minor version
alpine|ol|rhel|rocky) rid_version=${VERSION_ID%.*} ;;
*) rid_version=${VERSION_ID} ;;
esac
echo "${ID}.${rid_version}-${arch}"
fi