Fix: OS name detection error by build scripts 55/4355/3
authorAbdul Halim <abdul.halim@intel.com>
Fri, 11 Dec 2015 11:54:13 +0000 (11:54 +0000)
committerMaryam Tahhan <maryam.tahhan@intel.com>
Mon, 14 Dec 2015 10:05:11 +0000 (10:05 +0000)
There is a problem detecting OS specific scripts dir if NAME variable in
/etc/os-release contains a multi-word string (e.g NAME="CentOS Linux").
To fix this we get first part of the NAME string (i.e "CentOS") for
simplicity and look for version specific scripts dir within that.

Change-Id: Ic840788875e9b486b20608a9b9e523cbd4530e31
Signed-off-by: Abdul Halim <abdul.halim@intel.com>
Reviewed-by: Maryam Tahhan <maryam.tahhan@intel.com>
Reviewed-by: Al Morton <acmorton@att.com>
Reviewed-by: Brian Castelli <Brian.Castelli@spirent.com>
systems/build_base_machine.sh

index 95f3876..c64f7bb 100755 (executable)
@@ -37,6 +37,9 @@ function die() {
 # Detect OS name and version from systemd based os-release file
 . /etc/os-release
 
+# Get OS name (the First word from $NAME in /etc/os-release)
+OS_NAME=`echo "$NAME" | cut -d ' ' -f1`
+
 # check if root
 if [ "$UID" -ne "$ROOT_UID" ]
 then
@@ -45,11 +48,11 @@ then
 fi
 
 # If there is version specific dir available then set distro_dir to that
-if [ -d "$NAME/$VERSION_ID" ]; then
-    distro_dir="$NAME/$VERSION_ID"
+if [ -d "$OS_NAME/$VERSION_ID" ]; then
+    distro_dir="$OS_NAME/$VERSION_ID"
 else
     # Fallback - Default distro_dir = OS name
-    distro_dir="$NAME"
+    distro_dir="$OS_NAME"
 fi
 
 # build base system using OS specific scripts