Enable RHEL6 and CentOS 6 RID detection in build
authorJan Vorlicek <janvorli@microsoft.com>
Mon, 31 Jul 2017 15:49:25 +0000 (15:49 +0000)
committerJan Vorlicek <janvorli@microsoft.com>
Mon, 31 Jul 2017 19:05:57 +0000 (21:05 +0200)
This change adds RHEL6 and CentOS 6 RID detection to src/corehost/build.sh.
These distros don't have the /etc/os-release file and so we need to use another
source - the /etc/redhat-release file.
It is an exact copy of the same change merged in for CoreCLR.

Commit migrated from https://github.com/dotnet/core-setup/commit/6ae626fa9ce15b828eea1af9a92055c43ad8cb30

src/installer/corehost/build.sh

index da6c3d0..5b368d2 100755 (executable)
@@ -14,35 +14,38 @@ init_rid_plat()
         else
             if [ -e $ROOTFS_DIR/etc/os-release ]; then
                 source $ROOTFS_DIR/etc/os-release
-                export __rid_plat="$ID.$VERSION_ID"
+                __rid_plat="$ID.$VERSION_ID"
             fi
             echo "__rid_plat is $__rid_plat"
         fi
     else
+        __rid_plat=""
         if [ -e /etc/os-release ]; then
             source /etc/os-release
-
             if [[ "$ID" == "rhel" && $VERSION_ID = 7* ]]; then
-                export __rid_plat="rhel.7"
+                __rid_plat="rhel.7"
             elif [[ "$ID" == "centos" && "$VERSION_ID" = "7" ]]; then
-                export __rid_plat="rhel.7"
+                __rid_plat="rhel.7"
             else
-                export __rid_plat="$ID.$VERSION_ID"
+                __rid_plat="$ID.$VERSION_ID"
+            fi
+        elif [ -e /etc/redhat-release ]; then
+            local redhatRelease=$(</etc/redhat-release)
+            if [[ $redhatRelease == "CentOS release 6."* || $redhatRelease == "Red Hat Enterprise Linux Server release 6."* ]]; then
+               __rid_plat="rhel.6"
             fi
-        else
-            export __rid_plat=
         fi
     fi
 
     if [ "$(uname -s)" == "Darwin" ]; then
-        export __rid_plat=osx.10.12
+        __rid_plat=osx.10.12
     fi
 
     if [ $__linkPortable == 1 ]; then
         if [ "$(uname -s)" == "Darwin" ]; then
-            export __rid_plat="osx"
+            __rid_plat="osx"
         else
-            export __rid_plat="linux"
+            __rid_plat="linux"
         fi
     fi
 }