Fix RID extraction in packages and test build for Alpine (#14656)
authorJan Vorlicek <janvorli@microsoft.com>
Mon, 23 Oct 2017 21:03:23 +0000 (23:03 +0200)
committerGitHub <noreply@github.com>
Mon, 23 Oct 2017 21:03:23 +0000 (23:03 +0200)
* Fix RID extraction in packages and test build for Alpine

The host RID extraction in build-packages.sh and build-test.sh
was not matching the one in build.sh

* Reflect feedback

build-packages.sh
build-test.sh

index 9b929715e9f75ca84f054baac9f46857bf93c38f..48213860907e75931ee45da306ae48cd8c6ce780 100755 (executable)
@@ -16,6 +16,10 @@ initHostDistroRid()
     if [ "$__HostOS" == "Linux" ]; then
         if [ -e /etc/os-release ]; then
             source /etc/os-release
+            if [[ $ID == "alpine" ]]; then
+                # remove the last version digit
+                VERSION_ID=${VERSION_ID%.*}
+            fi
             __HostDistroRid="$ID.$VERSION_ID-$__Arch"
         elif [ -e /etc/redhat-release ]; then
             local redhatRelease=$(</etc/redhat-release)
@@ -24,9 +28,13 @@ initHostDistroRid()
             fi
         fi
     fi
+    if [ "$__HostOS" == "FreeBSD" ]; then
+        __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
+        __HostDistroRid="freebsd.$__freebsd_version-$__Arch"
+    fi
 
     if [ "$__HostDistroRid" == "" ]; then
-        echo "WARNING: Can not determine runtime id for current distro."
+        echo "WARNING: Cannot determine runtime id for current distro."
     fi
 }
 
index 48d9a1f604af4be73e09130e31cb8928110e0522..e560faf3f5f43242afb60972e3a21c85b58902c9 100755 (executable)
@@ -2,15 +2,30 @@
 
 initHostDistroRid()
 {
+    __HostDistroRid=""
     if [ "$__HostOS" == "Linux" ]; then
-        if [ ! -e /etc/os-release ]; then
-            echo "WARNING: Can not determine runtime id for current distro."
-            __HostDistroRid=""
-        else
+        if [ -e /etc/os-release ]; then
             source /etc/os-release
+            if [[ $ID == "alpine" ]]; then
+                # remove the last version digit
+                VERSION_ID=${VERSION_ID%.*}
+            fi
             __HostDistroRid="$ID.$VERSION_ID-$__HostArch"
+        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
+               __HostDistroRid="rhel.6-$__HostArch"
+            fi
         fi
     fi
+    if [ "$__HostOS" == "FreeBSD" ]; then
+        __freebsd_version=`sysctl -n kern.osrelease | cut -f1 -d'.'`
+        __HostDistroRid="freebsd.$__freebsd_version-$__HostArch"
+    fi
+
+    if [ "$__HostDistroRid" == "" ]; then
+        echo "WARNING: Cannot determine runtime id for current distro."
+    fi
 }
 
 initTargetDistroRid()