Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Modernize RID detection in buildvars-setup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Sep 21, 2017
1 parent 2394767 commit d3b2347
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions buildscripts/buildvars-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,27 @@ check_native_prereqs()
hash clang-$__ClangMajorVersion.$__ClangMinorVersion 2>/dev/null || hash clang$__ClangMajorVersion$__ClangMinorVersion 2>/dev/null || hash clang 2>/dev/null || { echo >&2 "Please install clang before running this script"; exit 1; }
}

get_current_linux_rid() {
# Construct RID for current distro

get_current_linux_distro() {
# Detect Distro
if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then
if [ "$(cat /etc/*-release | grep -cim1 16.04)" -eq 1 ]; then
echo "ubuntu.16.04"
return 0
rid=linux

if [ -e /etc/os-release ]; then
source /etc/os-release
if [[ $ID == "alpine" ]]; then
# remove the last version digit
VERSION_ID=${VERSION_ID%.*}
rid=alpine.$VERSION_ID
fi

echo "ubuntu.14.04"
return 0
elif [ -e /etc/redhat-release ]; then
redhatRelease=$(</etc/redhat-release)
if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
rid=rhel.6
fi
fi

# Cannot determine Linux distribution, assuming Ubuntu 14.04.
echo "ubuntu.14.04"
return 0
echo $rid
}


Expand Down Expand Up @@ -134,7 +139,7 @@ case $OSName in

Linux)
export __BuildOS=Linux
export __NugetRuntimeId=$(get_current_linux_distro)-x64
export __NugetRuntimeId=$(get_current_linux_rid)-$__HostArch
;;

NetBSD)
Expand Down

0 comments on commit d3b2347

Please sign in to comment.