[Title] support multi linux distribution
authorHyoun Jiil <jiil.hyoun@samsung.com>
Thu, 27 Jun 2013 07:58:31 +0000 (16:58 +0900)
committerHyoun Jiil <jiil.hyoun@samsung.com>
Thu, 27 Jun 2013 07:58:31 +0000 (16:58 +0900)
[Type] Enhancement
[Module] Toolchain /
[Priority] Major
[Jira#]
[Redmine#] 9756
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: Id58805791784943079bd4bbedf1f27c8c3da4101

build-cli
build-svr
pkg-build
pkg-clean
pkg-cli
src/common/utils.rb

index b166552..494d209 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -53,8 +53,14 @@ end
 
 # check HOST OS
 if not Utils.check_host_OS() then
-       puts "Error: Your host OS is not supported!"
-       exit 1
+
+       if Utils.is_linux_like_os Utils::HOST_OS then
+               Utils.set_default_linux_host_os
+               puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+       else
+               puts "Error: Your host OS is not supported!"
+               exit 1
+       end
 end
 
 def query( ip, port, sym )
index 85718a3..db67cba 100755 (executable)
--- a/build-svr
+++ b/build-svr
@@ -46,8 +46,14 @@ end
 
 # check HOST OS
 if not Utils.check_host_OS() then
-       puts "Error: Your host OS is not supported!"
-       exit 1
+
+       if Utils.is_linux_like_os Utils::HOST_OS then
+               Utils.set_default_linux_host_os
+               puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+       else
+               puts "Error: Your host OS is not supported!"
+               exit 1
+       end
 end
 
 begin
index dbfad26..4f9dad7 100755 (executable)
--- a/pkg-build
+++ b/pkg-build
@@ -47,8 +47,14 @@ end
 
 # check HOST OS
 if not Utils.check_host_OS() then
-       puts "Error: Your host OS is not supported!"
-       exit 1
+
+       if Utils.is_linux_like_os Utils::HOST_OS then
+               Utils.set_default_linux_host_os
+               puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+       else
+               puts "Error: Your host OS is not supported!"
+               exit 1
+       end
 end
 
 # if "--os" is not specified, use host os type
index 6a6cbb4..acb105d 100755 (executable)
--- a/pkg-clean
+++ b/pkg-clean
@@ -48,8 +48,14 @@ option = parse
 
 # check HOST OS
 if not Utils.check_host_OS() then
-       puts "Error: Your host OS is not supported!"
-       exit 1
+
+       if Utils.is_linux_like_os Utils::HOST_OS then
+               Utils.set_default_linux_host_os
+               puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+       else
+               puts "Error: Your host OS is not supported!"
+               exit 1
+       end
 end
 
 begin
diff --git a/pkg-cli b/pkg-cli
index 7e9ecee..6c39e90 100755 (executable)
--- a/pkg-cli
+++ b/pkg-cli
@@ -53,8 +53,14 @@ end
 
 # check HOST OS
 if not Utils.check_host_OS() then
-       puts "Error: Your host OS is not supported!"
-       exit 1
+
+       if Utils.is_linux_like_os Utils::HOST_OS then
+               Utils.set_default_linux_host_os
+               puts "Warning: Your host OS is not supported!\nWe assume your host OS as #{Utils::HOST_OS} !!!"
+       else
+               puts "Error: Your host OS is not supported!"
+               exit 1
+       end
 end
 #if "--os" is not specfied, use host os type
 if option[:os].nil? then
index 142ae9f..93e6f20 100644 (file)
@@ -38,16 +38,18 @@ class Utils
 
                case `uname -s`.strip
                when "Linux"
+                       arch = `getconf LONG_BIT`.strip
+                       arch = "unknown" if arch.length != 2
                        if File.exist? "/etc/debian_version" then
-                               arch = (`uname -i`.strip == "x86_64") ? "64" : "32"
                                os = "ubuntu-#{arch}"
                        elsif File.exist? "/etc/redhat-release" then
-                               os = "redhat-unknown"
+                               os = "redhat-#{arch}"
                        elsif File.exist? "/etc/SuSE-release" then
-                               arch = (`uname -i`.strip == "x86_64") ? "64" : "32"
                                os = "opensuse-#{arch}"
                        elsif File.exist? "/etc/mandrake-release" then
-                               os = "mandrake-unknown"
+                               os = "mandrake-#{arch}"
+                       else
+                               os = "unknownlinux-#{arch}"
                        end
                when "MINGW32_NT-5.1"
                        progfile_path = Utils.execute_shell_return("echo $PROGRAMFILES","windows")[0].strip
@@ -64,6 +66,9 @@ class Utils
                return os
        end
 
+       def Utils.set_default_linux_host_os()
+               HOST_OS.sub!(/.*-/,"ubuntu-")
+       end
 
        def Utils.check_host_OS()
                if Utils.get_all_OSs().include? HOST_OS then
@@ -75,7 +80,7 @@ class Utils
 
 
        def Utils.get_all_OSs()
-               return ["ubuntu-32","ubuntu-64","windows-32","windows-64","macos-64","opensuse-32", "opensuse-64"]
+               return ["ubuntu-32","ubuntu-64","windows-32","windows-64","macos-64"]
        end
 
 
@@ -432,8 +437,7 @@ class Utils
 
        # check if the os is unix-like
        def Utils.is_unix_like_os(os_name)
-               if os_name.start_with? "ubuntu-" or
-                       os_name.start_with? "opensuse-" or
+               if Utils.is_linux_like_os os_name or
                        os_name.start_with?"macos-" then
                        return true
                else
@@ -445,7 +449,10 @@ class Utils
        # check if the os is linux-like
        def Utils.is_linux_like_os(os_name)
                if os_name.start_with? "ubuntu-" or
-                       os_name.start_with? "opensuse-" then
+                       os_name.start_with? "redhat-" or
+                       os_name.start_with? "opensuse-" or
+                       os_name.start_with? "mandrake-" or
+                       os_name.start_with? "unknownlinux-" then
                        return true
                else
                        return false
@@ -464,11 +471,11 @@ class Utils
 
 
        def Utils.get_os_category(os_name)
-               if os_name.start_with? "ubuntu-" or os_name.start_with? "opensuse-" then
+               if is_linux_like_os os_name then
                        return "linux"
-               elsif os_name.start_with?"macos-" then
+               elsif is_macos_like_os os_name then
                        return "macos"
-               elsif os_name.start_with? "windows-" then
+               elsif is_windows_like_os os_name then
                        return "windows"
                else
                        return os_name