summaryrefslogtreecommitdiffstats
path: root/.github/os_detect.sh
diff options
context:
space:
mode:
Diffstat (limited to '.github/os_detect.sh')
-rw-r--r--.github/os_detect.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/.github/os_detect.sh b/.github/os_detect.sh
new file mode 100644
index 0000000..ee9c145
--- /dev/null
+++ b/.github/os_detect.sh
@@ -0,0 +1,18 @@
1#!/bin/sh -e
2# workaround for really bare-bones Archlinux containers:
3if [ -x "$(command -v pacman)" ]; then
4 pacman --noconfirm -Sy
5 pacman --noconfirm -S grep gawk sed
6fi
7
8os_release_file=
9if [ -s "/etc/os-release" ]; then
10 os_release_file="/etc/os-release"
11elif [ -s "/usr/lib/os-release" ]; then
12 os_release_file="/usr/lib/os-release"
13else
14 echo >&2 "Cannot find an os-release file ..."
15 return 1
16fi
17export distro_id=$(grep '^ID=' $os_release_file|awk -F = '{print $2}'|sed 's/\"//g')
18export platform_id=$(grep '^PLATFORM_ID=' /etc/os-release|awk -F = '{print $2}'|sed 's/\"//g'| cut -d":" -f2)