diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 03:32:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 03:32:49 +0000 |
commit | 8053187731ae8e3eb368d8360989cf5fd6eed9f7 (patch) | |
tree | 32bada84ff5d7460cdf3934fcbdbe770d6afe4cd /ci/utils.inc.sh | |
parent | Initial commit. (diff) | |
download | rnp-8053187731ae8e3eb368d8360989cf5fd6eed9f7.tar.xz rnp-8053187731ae8e3eb368d8360989cf5fd6eed9f7.zip |
Adding upstream version 0.17.0.upstream/0.17.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ci/utils.inc.sh')
-rw-r--r-- | ci/utils.inc.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ci/utils.inc.sh b/ci/utils.inc.sh new file mode 100644 index 0000000..618df78 --- /dev/null +++ b/ci/utils.inc.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Derived from: https://gist.github.com/marcusandre/4b88c2428220ea255b83 +get_os() { + local ostype + ostype=$(<<< "$OSTYPE" tr '[:upper:]' '[:lower:]') + if [ -z "$ostype" ]; then + ostype=$(uname | tr '[:upper:]' '[:lower:]') + fi + + case $ostype in + freebsd*) echo "freebsd" ;; + netbsd*) echo "netbsd" ;; + openbsd*) echo "openbsd" ;; + darwin*) echo "macos" ;; + linux*) echo "linux" ;; + cygwin*) echo "cygwin" ;; + msys*) echo "msys" ;; + mingw*) echo "win" ;; + *) echo "unknown"; exit 1 ;; + esac +} + +get_linux_dist() { + if [[ -f /etc/os-release ]]; then + sh -c '. /etc/os-release && echo $ID' + elif type lsb_release >/dev/null 2>&1; then + lsb_release -si | tr '[:upper:]' '[:lower:]' + fi +} + +# If target does not exist, create symlink from source to target. +ensure_symlink_to_target() { + local from="${1:?Missing source}" + local to="${2:?Missing target}" + + if [[ -e "${from}" && ! -e "${to}" ]]; then + if ! sudo ln -s "${from}" "${to}" + then + >&2 echo "Error: ${to} still not available after symlink. Aborting." + exit 1 + fi + fi +} |