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

Modernize RID detection in buildvars-setup.sh #4588

Merged
merged 1 commit into from
Sep 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions buildscripts/buildvars-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,29 @@ 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_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
get_current_linux_rid() {
# Construct RID for current distro

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
elif [[ $ID == "ubuntu" ]]; then
rid=$ID.$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 +141,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