[Title] indentation
authorjiil.hyoun <jiil.hyoun@samsung.com>
Wed, 17 Oct 2012 02:25:49 +0000 (11:25 +0900)
committerjiil.hyoun <jiil.hyoun@samsung.com>
Wed, 17 Oct 2012 02:25:49 +0000 (11:25 +0900)
[Type] Enhancement
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: If94e4326e402526f277d73c7778b1ed89f58ea0c

56 files changed:
build-cli
build-svr
pkg-build
pkg-clean
pkg-cli
pkg-svr
src/build_server/BinaryUploadProject.rb
src/build_server/BuildClientOptionParser.rb
src/build_server/BuildJob.rb
src/build_server/BuildServer.rb
src/build_server/BuildServerController.rb
src/build_server/BuildServerOptionParser.rb
src/build_server/CommonJob.rb
src/build_server/CommonProject.rb
src/build_server/DistributionManager.rb
src/build_server/GitBuildJob.rb
src/build_server/GitBuildProject.rb
src/build_server/JobClean.rb
src/build_server/JobLog.rb
src/build_server/JobManager.rb
src/build_server/MultiBuildJob.rb
src/build_server/PackageSync.rb
src/build_server/ProjectManager.rb
src/build_server/RegisterPackageJob.rb
src/build_server/RemoteBuildServer.rb
src/build_server/RemoteBuilder.rb
src/build_server/ReverseBuildChecker.rb
src/build_server/SocketJobRequestListener.rb
src/builder/Builder.rb
src/builder/CleanOptionParser.rb
src/builder/optionparser.rb
src/common/Action.rb
src/common/BuildComm.rb
src/common/FileTransferViaDirect.rb
src/common/FileTransferViaFTP.rb
src/common/PackageManifest.rb
src/common/ScheduledActionHandler.rb
src/common/Version.rb
src/common/dependency.rb
src/common/execute_with_log.rb
src/common/log.rb
src/common/mail.rb
src/common/package.rb
src/common/parser.rb
src/common/utils.rb
src/pkg_server/DistSync.rb
src/pkg_server/SocketRegisterListener.rb
src/pkg_server/client.rb
src/pkg_server/clientOptParser.rb
src/pkg_server/distribution.rb
src/pkg_server/downloader.rb
src/pkg_server/installer.rb
src/pkg_server/packageServer.rb
src/pkg_server/packageServerConfig.rb
src/pkg_server/packageServerLog.rb
src/pkg_server/serverOptParser.rb

index d7bc25cd803d59454bcc3aa429425b334d50d6c1..0054113004e86d2851170174170006231018a831 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -1,7 +1,7 @@
 #!/usr/bin/ruby
 
 =begin
+
  build-cli
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -39,12 +39,12 @@ require "FileTransferViaFTP"
 require "FileTransferViaDirect"
 
 
-#option parsing 
+#option parsing
 begin
-    option = option_parse
+       option = option_parse
 rescue => e
-    puts e.message
-    exit 0
+       puts e.message
+       exit 0
 end
 
 
@@ -68,7 +68,7 @@ end
 
 def query_system_info(ip, port)
        # HOST SYSTEM INFO
-    puts "* SYSTEM INFO *"
+       puts "* SYSTEM INFO *"
        data = query( ip, port, "SYSTEM")
        if data.nil? then exit 1 end
 
@@ -77,7 +77,7 @@ def query_system_info(ip, port)
        puts "MAX_WORKING_JOBS: #{result[1]}"
 
        # FTP INFO
-    puts "\n* FTP *"
+       puts "\n* FTP *"
        data = query(ip, port, "FTP")
        if data.nil? then exit 1 end
 
@@ -86,7 +86,7 @@ def query_system_info(ip, port)
        puts "FTP_USERNAME: #{result[1]}"
 
        # SUPPORTED OS INFO
-    puts "\n* SUPPORTED OS LIST *"
+       puts "\n* SUPPORTED OS LIST *"
        data = query(ip, port, "OS")
        if data.nil? then exit 1 end
 
@@ -95,7 +95,7 @@ def query_system_info(ip, port)
        end
 
        # Friend lists
-    puts "\n* FRIEND SERVER LIST (WAIT|WORK/MAX) jobs [transfer count] *"
+       puts "\n* FRIEND SERVER LIST (WAIT|WORK/MAX) jobs [transfer count] *"
        data = query(ip, port, "FRIEND")
        if data.nil? then exit 1 end
        i = 0
@@ -138,7 +138,7 @@ end
 
 # if "--os" is not specified, use pe
 if option[:os].nil? then 
-    option[:os] = "default"
+       option[:os] = "default"
 end
 
 if option[:domain].nil? then
@@ -149,44 +149,44 @@ end
 begin
        case option[:cmd] 
        when "build" 
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
                client = BuildCommClient.create( result[0], result[1], nil, 0 )
                if not client.nil? then
                        client.send "BUILD|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:noreverse]}|#{option[:dist]}"
-                       client.print_stream
+                               client.print_stream
                        client.terminate
                else
                        puts "Connection to server failed!"
                        exit 1
                end
        when "resolve"
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
                client = BuildCommClient.create( result[0], result[1], nil, 0 )
                if not client.nil? then
                        client.send "RESOLVE|GIT|#{option[:project]}|#{option[:passwd]}|#{option[:os]}|#{option[:async]}|#{option[:dist]}" 
-                       client.print_stream
+                               client.print_stream
                        client.terminate
                end
        when "query"
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
 
                query_system_info( result[0], result[1] )
                puts ""
@@ -195,51 +195,51 @@ begin
                query_job_list( result[0], result[1])
 
        when "query-system"
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
 
                query_system_info( result[0], result[1] )
 
        when "query-project"
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
 
                query_project_list( result[0], result[1])
 
        when "query-job"
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
 
                query_job_list( result[0], result[1] )
 
        when "cancel"
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
                if not option[:job].nil? then
                        client = BuildCommClient.create( result[0], result[1], nil, 0 )
                        if not client.nil? then
                                client.send "CANCEL|#{option[:job]}|#{option[:passwd]}"
-                               result1 = client.receive_data()
+                                       result1 = client.receive_data()
                                if result1.nil? then
                                        client.terminate
                                        exit(-1)
@@ -261,26 +261,26 @@ begin
                        exit(-1)
                end
 
-        result = Utils.parse_server_addr(option[:domain])
-        if result.nil? then
-            puts "Server address is incorrect. (#{option[:domain]})"
-            puts "Tune as following format."
-            puts " <ip>:<port>"
-            exit 1
-        end
+               result = Utils.parse_server_addr(option[:domain])
+               if result.nil? then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
                bs_ip = result[0]
                bs_port = result[1]
 
                if not option[:fdomain].nil? then
-               ftp_result = Utils.parse_ftpserver_url(option[:fdomain])
-               if ftp_result.nil? or ftp_result.length != 4 then
-               puts "FTP server url is incorrect. (#{option[:fdomain]})"
-               puts "Tune as following format."
-               puts " ftp://<usrename>:<passwd>@<address>"
-               exit 1
-               end
+                       ftp_result = Utils.parse_ftpserver_url(option[:fdomain])
+                       if ftp_result.nil? or ftp_result.length != 4 then
+                               puts "FTP server url is incorrect. (#{option[:fdomain]})"
+                               puts "Tune as following format."
+                               puts " ftp://<usrename>:<passwd>@<address>"
+                               exit 1
+                       end
                        ip = ftp_result[0]
-               port = ftp_result[1]
+                       port = ftp_result[1]
                        username = ftp_result[2]
                        passwd = ftp_result[3]
                        transporter = FileTransferFTP.new( nil, ip, port, username, passwd )
@@ -311,7 +311,7 @@ begin
                        exit(-1)
                end
                client.send("REGISTER|BINARY|#{File.basename(option[:package])}|#{option[:passwd]}|#{dock}|#{option[:dist]}")
-               client.print_stream
+                       client.print_stream
                client.terminate
 
        else
index 3e5a57c516cb716e49573f541bd8637de9d541a6..c839bf1344e407bba137b530db565b7c38b3fee6 100755 (executable)
--- a/build-svr
+++ b/build-svr
@@ -1,7 +1,7 @@
 #!/usr/bin/ruby
 
 =begin
+
  build-svr
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -36,7 +36,7 @@ require "log.rb"
 require "BuildServerOptionParser"
 require "BuildServerController"
 
-#option parsing 
+#option parsing
 begin
        option = option_parse
 rescue => e
@@ -53,42 +53,42 @@ end
 begin
        case option[:cmd]
        when "create"
-               ftpsvr_addr = nil; ftpsvr_port = nil; ftpsvr_username = nil; ftpsvr_passwd = nil
+               ftpsvr_addr = nil; ftpsvr_port = nil; ftpsvr_username = nil; ftpsvr_passwd = nil
                if not option[:fdomain].nil? then
-               ftp_result = Utils.parse_ftpserver_url(option[:fdomain])
-               if ftp_result.nil? or ftp_result.length != 4 then
-               puts "FTP server url is incorrect. (#{option[:fdomain]})"
-               puts "Tune as following format."
-               puts " ftp://<usrename>:<passwd>@<address>:<port>"
-               exit 1
-               end
-               ftpsvr_addr = ftp_result[0]
-               ftpsvr_port = ftp_result[1]
-               ftpsvr_username = ftp_result[2]
-               ftpsvr_passwd = ftp_result[3]
+                       ftp_result = Utils.parse_ftpserver_url(option[:fdomain])
+                       if ftp_result.nil? or ftp_result.length != 4 then
+                               puts "FTP server url is incorrect. (#{option[:fdomain]})"
+                               puts "Tune as following format."
+                               puts " ftp://<usrename>:<passwd>@<address>:<port>"
+                               exit 1
+                       end
+                       ftpsvr_addr = ftp_result[0]
+                       ftpsvr_port = ftp_result[1]
+                       ftpsvr_username = ftp_result[2]
+                       ftpsvr_passwd = ftp_result[3]
                end
                pkgsvr_url = pkgsvr_addr = pkgsvr_port = nil
                if not option[:domain].nil? and not option[:url].nil? then
-               svr_result = Utils.parse_server_addr(option[:domain])
-               if svr_result.nil? or svr_result.length != 2 then
-               puts "Server address is incorrect. (#{option[:domain]})"
-               puts "Tune as following format."
-               puts " <ip>:<port>"
-               exit 1
-               end
-               pkgsvr_url = option[:url]
-               pkgsvr_addr = svr_result[0]
-               pkgsvr_port = svr_result[1]
+                       svr_result = Utils.parse_server_addr(option[:domain])
+                       if svr_result.nil? or svr_result.length != 2 then
+                               puts "Server address is incorrect. (#{option[:domain]})"
+                               puts "Tune as following format."
+                               puts " <ip>:<port>"
+                               exit 1
+                       end
+                       pkgsvr_url = option[:url]
+                       pkgsvr_addr = svr_result[0]
+                       pkgsvr_port = svr_result[1]
                end
                BuildServerController.create_server( option[:name], Utils::WORKING_DIR, ftpsvr_addr, ftpsvr_port, ftpsvr_username, ftpsvr_passwd, pkgsvr_url, pkgsvr_addr, pkgsvr_port )
        when "remove"
-               BuildServerController.remove_server( option[:name] ) 
+               BuildServerController.remove_server( option[:name] )
        when "start"
                if( option[:child] ) then # Child Process
-                       BuildServerController.start_server( option[:name], option[:port] ) 
+                       BuildServerController.start_server( option[:name], option[:port] )
                else  # Parent Process
-                       # check server config 
-                       if not File.exist? "#{BuildServer::CONFIG_ROOT}/#{option[:name]}/server.cfg" 
+                       # check server config
+                       if not File.exist? "#{BuildServer::CONFIG_ROOT}/#{option[:name]}/server.cfg"
                                raise RuntimeError, "The server \"#{option[:name]}\" does not exist!"
                        end
 
@@ -107,7 +107,7 @@ begin
                                                log.info "Down Build Server."
                                                break
                                        elsif ($?.exitstatus == 99) then # DIBS UPGRADE
-                                               cmd = "#{File.dirname(__FILE__)}/upgrade -l #{File.dirname(__FILE__)} -S -t BUILDSERVER -n #{option[:name]} -p #{option[:port]}" 
+                                               cmd = "#{File.dirname(__FILE__)}/upgrade -l #{File.dirname(__FILE__)} -S -t BUILDSERVER -n #{option[:name]} -p #{option[:port]}"
                                                cmd = Utils.generate_shell_command(cmd)
                                                puts cmd
                                                Utils.spawn(cmd)
@@ -123,80 +123,80 @@ begin
                        end
                end
        when "stop"
-               BuildServerController.stop_server( option[:name] ) 
+               BuildServerController.stop_server( option[:name] )
 
        when "upgrade"
-               BuildServerController.upgrade_server( option[:name] ) 
+               BuildServerController.upgrade_server( option[:name] )
 
        when "add-svr"
-               svr_result = Utils.parse_server_addr(option[:domain])
-               if svr_result.nil? or svr_result.length != 2 then
-               puts "Server address is incorrect. Tune as following format."
-               puts " <ip>:<port>"
-               exit 1
-               end
-               pkgsvr_addr = svr_result[0]
-               pkgsvr_port = svr_result[1]
-               BuildServerController.add_remote_server( option[:name], pkgsvr_addr, pkgsvr_port ) 
+               svr_result = Utils.parse_server_addr(option[:domain])
+               if svr_result.nil? or svr_result.length != 2 then
+                       puts "Server address is incorrect. Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
+               pkgsvr_addr = svr_result[0]
+               pkgsvr_port = svr_result[1]
+               BuildServerController.add_remote_server( option[:name], pkgsvr_addr, pkgsvr_port )
 
        when "remove-svr"
                BuildServerController.remove_remote_server( option[:name], pkgsvr_addr, pkgsvr_port )
+
        when "add-os"
-               BuildServerController.add_target_os( option[:name], option[:os] ) 
+               BuildServerController.add_target_os( option[:name], option[:os] )
 
        when "remove-os"
-               BuildServerController.remove_target_os( option[:name], option[:os] ) 
+               BuildServerController.remove_target_os( option[:name], option[:os] )
 
        when "add-dist"
-               svr_result = Utils.parse_server_addr(option[:domain])
-               if svr_result.nil? or svr_result.length != 2 then
-               puts "Server address is incorrect. (#{option[:domain]})"
-               puts "Tune as following format."
-               puts " <ip>:<port>"
-               exit 1
-               end
-               pkgsvr_url = option[:url]
-               pkgsvr_addr = svr_result[0]
-               pkgsvr_port = svr_result[1]
-               BuildServerController.add_distribution( option[:name], option[:dist], pkgsvr_url, pkgsvr_addr, pkgsvr_port ) 
+               svr_result = Utils.parse_server_addr(option[:domain])
+               if svr_result.nil? or svr_result.length != 2 then
+                       puts "Server address is incorrect. (#{option[:domain]})"
+                       puts "Tune as following format."
+                       puts " <ip>:<port>"
+                       exit 1
+               end
+               pkgsvr_url = option[:url]
+               pkgsvr_addr = svr_result[0]
+               pkgsvr_port = svr_result[1]
+               BuildServerController.add_distribution( option[:name], option[:dist], pkgsvr_url, pkgsvr_addr, pkgsvr_port )
 
        when "remove-dist"
-               BuildServerController.remove_distribution( option[:name], option[:dist] ) 
+               BuildServerController.remove_distribution( option[:name], option[:dist] )
 
        when "add-sync"
-               BuildServerController.add_sync_package_server( option[:name], option[:url], option[:dist] ) 
+               BuildServerController.add_sync_package_server( option[:name], option[:url], option[:dist] )
 
        when "remove-sync"
-               BuildServerController.remove_sync_package_server( option[:name], option[:url], option[:dist] ) 
+               BuildServerController.remove_sync_package_server( option[:name], option[:url], option[:dist] )
 
        when "add-prj"
                if not option[:git].nil? then
-                       BuildServerController.add_project( option[:name], option[:pid], 
-                               option[:git], option[:branch], option[:remote], option[:passwd],
-                               option[:os], option[:dist] ) 
+                       BuildServerController.add_project( option[:name], option[:pid],
+                                                                                         option[:git], option[:branch], option[:remote], option[:passwd],
+                                                                                         option[:os], option[:dist] )
                else
-                       BuildServerController.add_binary_project( option[:name], option[:pid], 
-                               option[:package], option[:passwd], option[:os], option[:dist] ) 
+                       BuildServerController.add_binary_project( option[:name], option[:pid],
+                                                                                                        option[:package], option[:passwd], option[:os], option[:dist] )
                end
 
        when "remove-prj"
-               BuildServerController.remove_project( option[:name], option[:pid], option[:dist] ) 
+               BuildServerController.remove_project( option[:name], option[:pid], option[:dist] )
 
        when "fullbuild"
-               BuildServerController.build_all_projects( option[:name], option[:dist] ) 
+               BuildServerController.build_all_projects( option[:name], option[:dist] )
 
        when "register"
-               BuildServerController.register_package( option[:name], option[:package], option[:dist] ) 
+               BuildServerController.register_package( option[:name], option[:package], option[:dist] )
 
        when "query"
-               BuildServerController.query_server( option[:name] ) 
+               BuildServerController.query_server( option[:name] )
 
        when "set-attr"
-               BuildServerController.set_server_attribute( option[:name], option[:attr], option[:value] ) 
+               BuildServerController.set_server_attribute( option[:name], option[:attr], option[:value] )
 
        when "get-attr"
-               BuildServerController.get_server_attribute( option[:name], option[:attr] ) 
+               BuildServerController.get_server_attribute( option[:name], option[:attr] )
 
        else
                raise RuntimeError, "input option incorrect : #{option[:cmd]}"
index 39e788282a609b9a933689a4691fb8b8426a19df..dbfad2649b862d402e311cf04415cbbbddc2dd74 100755 (executable)
--- a/pkg-build
+++ b/pkg-build
@@ -1,7 +1,7 @@
-#!/usr/bin/ruby 
+#!/usr/bin/ruby
 
 =begin
+
  pkg-build
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -37,10 +37,10 @@ require "Builder"
 require "optionparser"
 
 begin
-    option = parse
+       option = parse
 rescue => e
-    puts e.message
-    exit 0
+       puts e.message
+       exit 0
 end
 
 #generate server when local package server is not set
@@ -57,38 +57,38 @@ if option[:os].nil? then
 end
 
 path = Dir.pwd
-if not File.exist? "package" then 
-    puts "current dirctory \"#{path}\" is not package root directory"
-    exit 1
-end 
+if not File.exist? "package" then
+       puts "current dirctory \"#{path}\" is not package root directory"
+       exit 1
+end
 
 # if url specified
 if not option[:url].nil? then
        begin
-       builder = Builder.get("default") 
+               builder = Builder.get("default")
                if builder.pkgserver_url != option[:url] then
                        puts "Package server URL has been changed! Creating new builder..."
-               builder = Builder.create("default", option[:url], nil, nil, nil)  
+                       builder = Builder.create("default", option[:url], nil, nil, nil)
                end
        rescue
                puts "Default builder does not exist! Creating new builder..."
-       builder = Builder.create("default", option[:url], nil, nil, nil)  
+               builder = Builder.create("default", option[:url], nil, nil, nil)
        end
 else # if url is not specified
-       begin 
-       builder = Builder.get("default")  
+       begin
+               builder = Builder.get("default")
        rescue
                puts "Default builder does not exist! Creating new builder..."
-       builder = Builder.create("default", "http://172.21.111.132/pkgserver/unstable",nil, nil, nil)  
+               builder = Builder.create("default", "http://172.21.111.132/pkgserver/unstable",nil, nil, nil)
        end
-end 
+end
 
 #build project
 if not builder.build( Utils::WORKING_DIR, option[:os], option[:clean], [], true) then
        puts "Build Failed!"
-    exit 1    
+       exit 1
 else
        puts "Build Succeeded!"
-    exit 0    
+       exit 0
 end
 
index 9315d88e7f272d719de772b525e942f60525ee82..6a6cbb405b91ebb3734ed7f0a2de54f7fa42c481 100755 (executable)
--- a/pkg-clean
+++ b/pkg-clean
@@ -1,7 +1,7 @@
-#!/usr/bin/ruby 
+#!/usr/bin/ruby
 
 =begin
+
  pkg-clean
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -37,10 +37,10 @@ require "Builder"
 require "CleanOptionParser"
 
 path = Dir.pwd
-if not File.exist? "package" then 
-    puts "current dirctory \"#{path}\" is not package root directory"
-    exit 1
-end 
+if not File.exist? "package" then
+       puts "current dirctory \"#{path}\" is not package root directory"
+       exit 1
+end
 
 option = parse
 
@@ -52,11 +52,11 @@ if not Utils.check_host_OS() then
        exit 1
 end
 
-begin 
-       builder = Builder.get("default")  
+begin
+       builder = Builder.get("default")
 rescue
        puts "Default builder does not exist! Creating new builder..."
-       builder = Builder.create("default", "http://172.21.111.132/pkgserver/unstable",nil)  
+       builder = Builder.create("default", "http://172.21.111.132/pkgserver/unstable",nil)
 end
 
 #build project
diff --git a/pkg-cli b/pkg-cli
index df9a164be1b629db3e45074d2b53e798538f7e53..2d3a0bf6b35473b77a64c5d1fa488877ca6f6eec 100755 (executable)
--- a/pkg-cli
+++ b/pkg-cli
@@ -1,7 +1,7 @@
 #!/usr/bin/ruby 
 
 =begin
+
  pkg-cli
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -47,7 +47,7 @@ begin
        option = option_parse
 rescue => e
        # if option parse error print help message
-    puts e.message
+       puts e.message
        exit 0
 end
 
@@ -63,98 +63,98 @@ end
 
 case option[:cmd] 
 when "update" then
-    client = Client.new( option[:url], nil, nil )
-    #client.update()
+       client = Client.new( option[:url], nil, nil )
+       #client.update()
 when "clean" then
-    client = Client.new( nil, option[:loc], nil )
-    client.clean(option[:f])
+       client = Client.new( nil, option[:loc], nil )
+       client.clean(option[:f])
 when "download" then
-    client = Client.new( option[:url], option[:loc], nil )
-    #if not option[:url].nil? then
-    #    client.update()
-    #end
+       client = Client.new( option[:url], option[:loc], nil )
+       #if not option[:url].nil? then
+       #    client.update()
+       #end
        file_loc = client.download( option[:pkg], option[:os], option[:t] )
 when "install" then
-    client = Client.new( option[:url], option[:loc], nil )
-    #if not option[:url].nil? then
-    #    client.update()
-    #end
-    client.install( option[:pkg], option[:os], option[:t], option[:f] ) 
+       client = Client.new( option[:url], option[:loc], nil )
+       #if not option[:url].nil? then
+       #    client.update()
+       #end
+       client.install( option[:pkg], option[:os], option[:t], option[:f] ) 
 when "install-file" then
-    client = Client.new( option[:url], option[:loc], nil )
+       client = Client.new( option[:url], option[:loc], nil )
        client.install_local_pkg( option[:pkg], option[:t], option[:f] ) 
 when "uninstall" then
-    client = Client.new( nil, option[:loc], nil )
-    client.uninstall( option[:pkg], option[:t] )
+       client = Client.new( nil, option[:loc], nil )
+       client.uninstall( option[:pkg], option[:t] )
 when "upgrade" then
-    client = Client.new( option[:url], option[:loc], nil )
-    #if not option[:url].nil? then
-    #    client.update()
-    #end
-    client.upgrade( option[:os], option[:t] )
+       client = Client.new( option[:url], option[:loc], nil )
+       #if not option[:url].nil? then
+       #    client.update()
+       #end
+       client.upgrade( option[:os], option[:t] )
 when "check-upgrade" then
-    client = Client.new( option[:url], option[:loc], nil )
-    #if not option[:url].nil? then
-    #   client.update()
+       client = Client.new( option[:url], option[:loc], nil )
+       #if not option[:url].nil? then
+       #   client.update()
        #end
-    client.check_upgrade( option[:os] )
+       client.check_upgrade( option[:os] )
 when "show-rpkg" then
-    client = Client.new( option[:url], nil, nil )
-    #if not option[:url].nil? then
-    #    client.update()
-    #end
+       client = Client.new( option[:url], nil, nil )
+       #if not option[:url].nil? then
+       #    client.update()
+       #end
        puts client.show_pkg_info( option[:pkg], option[:os] ) 
 when "list-rpkg" then
-    client = Client.new( option[:url], nil, nil )
-    #if not option[:url].nil? then
-    #    client.update()
-    #end
+       client = Client.new( option[:url], nil, nil )
+       #if not option[:url].nil? then
+       #    client.update()
+       #end
        result = client.show_pkg_list( option[:os] )
-    if not result.nil? and not result.empty? then
-        result.each do |i|
-            name = i[0].strip
-            version = i[1].strip
-            desc = i[2].strip
-            puts name + "  (" + version + ")"
-        end
-    end
+       if not result.nil? and not result.empty? then
+               result.each do |i|
+                       name = i[0].strip
+                       version = i[1].strip
+                       desc = i[2].strip
+                       puts name + "  (" + version + ")"
+               end
+       end
 when "show-lpkg" then
-    client = Client.new( nil, option[:loc], nil )
-    puts client.show_installed_pkg_info( option[:pkg] )
+       client = Client.new( nil, option[:loc], nil )
+       puts client.show_installed_pkg_info( option[:pkg] )
 when "list-lpkg" then
-    client = Client.new( nil, option[:loc], nil )
+       client = Client.new( nil, option[:loc], nil )
        result = client.show_installed_pkg_list()
-    if not result.nil? and not result.empty? then
-        result.each do |i|
-            name = i[0].strip
-            version = i[1].strip
-            desc = i[2].strip
-            puts name + "  (" + version + ")"
-        end
-    else 
-        puts "Info: There is no any package."
-    end
+       if not result.nil? and not result.empty? then
+               result.each do |i|
+                       name = i[0].strip
+                       version = i[1].strip
+                       desc = i[2].strip
+                       puts name + "  (" + version + ")"
+               end
+       else 
+               puts "Info: There is no any package."
+       end
 when "build-dep" then
-    client = Client.new( nil, nil, nil )
+       client = Client.new( nil, nil, nil )
        result = client.get_build_dependent_packages( option[:pkg], option[:os], true )
-    ret = ""
-    result.each do |i|
-        ret = ret + i + " --> "
-    end
-    ret = ret.strip
-    ret[-3..-1] = ""
-    puts ret
+       ret = ""
+       result.each do |i|
+               ret = ret + i + " --> "
+       end
+       ret = ret.strip
+       ret[-3..-1] = ""
+       puts ret
 when "install-dep" then
-    client = Client.new( nil, nil, nil )
+       client = Client.new( nil, nil, nil )
        result = client.get_install_dependent_packages( option[:pkg], option[:os], true, false )
-    ret = ""
-    result.each do |i|
-        ret = ret + i + " --> "
-    end
-    ret = ret.strip
-    ret[-3..-1] = ""
-    puts ret
+       ret = ""
+       result.each do |i|
+               ret = ret + i + " --> "
+       end
+       ret = ret.strip
+       ret[-3..-1] = ""
+       puts ret
 else
-    raise RuntimeError, "Input is incorrect : #{option[:cmd]}"
+       raise RuntimeError, "Input is incorrect : #{option[:cmd]}"
 end
 
diff --git a/pkg-svr b/pkg-svr
index 405b1850a7cb0d29093efbe603ae325f1b225628..99224012485bbb0e41577137fae5d0138f969073 100755 (executable)
--- a/pkg-svr
+++ b/pkg-svr
@@ -1,7 +1,7 @@
 #!/usr/bin/ruby 
 
 =begin
+
  pkg-svr
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
index 83994696a04359c98a58ea2dbc114420190a3159..2486d899dae2b4f2183fdbc63113999584812d68 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  BinaryUploadProject.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -47,9 +47,9 @@ class BinaryUploadProject < CommonProject
 
        # create new job
        def create_new_job( filename, dock = "0" )
-        new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
-        pkg_name = new_name.split(",")[0]
-        os = new_name.split(",")[2]
+               new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
+               pkg_name = new_name.split(",")[0]
+               os = new_name.split(",")[2]
 
                # check file name
                if @pkg_name != pkg_name then
@@ -86,7 +86,7 @@ class BinaryUploadProject < CommonProject
                #set up change log
                change_log = {}
                begin
-               change_log = Parser.read_changelog "#{pkginfo_dir}/changelog" if File.exist? "#{pkginfo_dir}/changelog"
+                       change_log = Parser.read_changelog "#{pkginfo_dir}/changelog" if File.exist? "#{pkginfo_dir}/changelog"
                rescue => e
                        @server.log.error( e.message, Log::LV_USER)
                        return nil
index 5aa74f7aa8c0b83b49ac375fad440a037a17e1a5..9fda538c94b7c56e516f8c8c9b9f352f7018ad48 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  BuildClientOptionParser.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -32,65 +32,65 @@ require 'utils'
 
 class BuildClientUsage
        BUILD="build-cli build -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>]" 
-    RESOLVE="build-cli resolve -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>]"    
-    QUERY="build-cli query -d <server address>"    
-    QUERY_SYSTEM="build-cli query-system -d <server address>"    
-    QUERY_PROJECT="build-cli query-project -d <server address>"    
-    QUERY_JOB="build-cli query-job -d <server address>"    
-    CANCEL="build-cli cancel -j <job number> -d <server address> [-w <password>]"    
-    REGISTER="build-cli register -P <package file> -d <server address>  [-t <ftp server url>] [-w <password>] [-D <distribution name>]"    
+       RESOLVE="build-cli resolve -N <project name> -d <server address> [-o <os>] [-w <password>] [--async] [-D <distribution name>]"    
+       QUERY="build-cli query -d <server address>"    
+       QUERY_SYSTEM="build-cli query-system -d <server address>"    
+       QUERY_PROJECT="build-cli query-project -d <server address>"    
+       QUERY_JOB="build-cli query-job -d <server address>"    
+       CANCEL="build-cli cancel -j <job number> -d <server address> [-w <password>]"    
+       REGISTER="build-cli register -P <package file> -d <server address>  [-t <ftp server url>] [-w <password>] [-D <distribution name>]"    
 end
 
 
 def option_error_check( options )
-    case options[:cmd]
-
-    when "build" then
-        if options[:project].nil? or options[:project].empty? or
-                options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::BUILD
-        end
-
-    when "resolve" then
-        if options[:project].nil? or options[:project].empty? or
-                options[:domain].nil?  or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::RESOLVE
-        end
-
-    when "query" then
-        if options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::QUERY
-        end                
-
-    when "query-system" then
-        if options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_SYSTEM
-        end                
-
-    when "query-project" then
-        if options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_PROJECT
-        end               
-    when "query-job" then
-        if options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_JOB
-        end                
-
-    when "cancel" then
-        if options[:job].nil? or options[:job].empty? or
-                options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::CANCEL
-        end
-    when "register" then
-        if options[:package].nil? or options[:package].empty? or
-            options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildClientUsage::REGISTER
-        end
-
-    else
-        raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
-    end
+       case options[:cmd]
+
+       when "build" then
+               if options[:project].nil? or options[:project].empty? or
+                       options[:domain].nil? or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::BUILD
+               end
+
+       when "resolve" then
+               if options[:project].nil? or options[:project].empty? or
+                       options[:domain].nil?  or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::RESOLVE
+               end
+
+       when "query" then
+               if options[:domain].nil? or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::QUERY
+               end                
+
+       when "query-system" then
+               if options[:domain].nil? or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_SYSTEM
+               end                
+
+       when "query-project" then
+               if options[:domain].nil? or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_PROJECT
+               end               
+
+       when "query-job" then
+               if options[:domain].nil? or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::QUERY_JOB
+               end                
+
+       when "cancel" then
+               if options[:job].nil? or options[:job].empty? or
+                       options[:domain].nil? or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::CANCEL
+               end
+       when "register" then
+               if options[:package].nil? or options[:package].empty? or
+                       options[:domain].nil? or options[:domain].empty? then
+                       raise ArgumentError, "Usage: " + BuildClientUsage::REGISTER
+               end
+
+       else
+               raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
+       end
 
        if ARGV.length > 1 then
                raise ArgumentError, "Unknown argument value : #{ARGV[1]}"
@@ -98,33 +98,33 @@ def option_error_check( options )
 end
 
 def option_parse
-    options = {}
-    banner = "Requiest service to build-server command-line tool." + "\n" \
-       + "\n" + "Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli (-h|-v)" + "\n" \
-       + "\n" + "Subcommands:" + "\n" \
-       + "\t" + "build         Build and create package." + "\n" \
-       + "\t" + "resolve       Request change to resolve-status for build-conflict." + "\n" \
-       + "\t" + "query         Query information about build-server." + "\n" \
-       + "\t" + "query-system  Query system information about build-server." + "\n" \
-       + "\t" + "query-project Query project information about build-server." + "\n" \
-       + "\t" + "query-job     Query job information about build-server." + "\n" \
-       + "\t" + "cancel        Cancel a building project." + "\n" \
-       + "\t" + "register      Register the package to the build-server." + "\n" \
-       + "\n" + "Subcommand usage:" + "\n" \
-       + "\t" + BuildClientUsage::BUILD + "\n" \
-       + "\t" + BuildClientUsage::RESOLVE + "\n" \
-       + "\t" + BuildClientUsage::QUERY + "\n" \
-       + "\t" + BuildClientUsage::QUERY_SYSTEM + "\n" \
-       + "\t" + BuildClientUsage::QUERY_PROJECT + "\n" \
-       + "\t" + BuildClientUsage::QUERY_JOB + "\n" \
-       + "\t" + BuildClientUsage::CANCEL + "\n" \
-       + "\t" + BuildClientUsage::REGISTER + "\n" \
-       + "\n" + "Options:" + "\n"
-
-    optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
-
-        # Set a banner, displayed at the top
-        # of the help screen.
+       options = {}
+       banner = "Requiest service to build-server command-line tool." + "\n" \
+               + "\n" + "Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli (-h|-v)" + "\n" \
+               + "\n" + "Subcommands:" + "\n" \
+               + "\t" + "build         Build and create package." + "\n" \
+               + "\t" + "resolve       Request change to resolve-status for build-conflict." + "\n" \
+               + "\t" + "query         Query information about build-server." + "\n" \
+               + "\t" + "query-system  Query system information about build-server." + "\n" \
+               + "\t" + "query-project Query project information about build-server." + "\n" \
+               + "\t" + "query-job     Query job information about build-server." + "\n" \
+               + "\t" + "cancel        Cancel a building project." + "\n" \
+               + "\t" + "register      Register the package to the build-server." + "\n" \
+               + "\n" + "Subcommand usage:" + "\n" \
+               + "\t" + BuildClientUsage::BUILD + "\n" \
+               + "\t" + BuildClientUsage::RESOLVE + "\n" \
+               + "\t" + BuildClientUsage::QUERY + "\n" \
+               + "\t" + BuildClientUsage::QUERY_SYSTEM + "\n" \
+               + "\t" + BuildClientUsage::QUERY_PROJECT + "\n" \
+               + "\t" + BuildClientUsage::QUERY_JOB + "\n" \
+               + "\t" + BuildClientUsage::CANCEL + "\n" \
+               + "\t" + BuildClientUsage::REGISTER + "\n" \
+               + "\n" + "Options:" + "\n"
+
+       optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
+
+               # Set a banner, displayed at the top
+               # of the help screen.
 
                opts.banner = banner 
 
@@ -132,88 +132,88 @@ def option_parse
                        if not Utils.multi_argument_test( project, "," ) then
                                raise ArgumentError, "Project variable parsing error : #{project}"
                        end
-            options[:project] = project
-        end
+                       options[:project] = project
+               end
 
-        options[:domain] = nil
+               options[:domain] = nil
                opts.on( '-d', '--address <server address>', 'build server address: 127.0.0.1:2224' ) do|domain|
-            options[:domain] = domain
-        end
-               
-        options[:os] = nil
-           opts.on( '-o', '--os <operating system>', 'target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64' ) do |os|
+                       options[:domain] = domain
+               end
+
+               options[:os] = nil
+               opts.on( '-o', '--os <operating system>', 'target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64' ) do |os|
                        if not Utils.multi_argument_test( os, "," ) then
                                raise ArgumentError, "OS variable parsing error : #{os}"
                        end
-            options[:os] = os
-        end
+                       options[:os] = os
+               end
 
-        options[:async] = "NO"
+               options[:async] = "NO"
                opts.on( '--async', 'asynchronous job' ) do
-            options[:async] = "YES"
+                       options[:async] = "YES"
                end
 
-        options[:noreverse] = "NO"
+               options[:noreverse] = "NO"
                opts.on( '--noreverse', 'do not check reverse build' ) do
-            options[:noreverse] = "YES"
-        end
-       
+                       options[:noreverse] = "YES"
+               end
+
                opts.on( '-j', '--job <job number>', 'job number' ) do|job|
-            options[:job] = job
-        end
+                       options[:job] = job
+               end
 
-        options[:passwd] = ""
+               options[:passwd] = ""
                opts.on( '-w', '--passwd <password>', 'password for managing project' ) do|passwd|
-            options[:passwd] = passwd
-        end
+                       options[:passwd] = passwd
+               end
 
                opts.on( '-P', '--pkg <package file>', 'package file path' ) do|package|
-            options[:package] = package.strip
-        end
+                       options[:package] = package.strip
+               end
 
                opts.on( '-D', '--dist <distribution name>', 'distribution name' ) do|dist|
-            options[:dist] = dist
-        end
+                       options[:dist] = dist
+               end
 
                opts.on( '-t', '--ftp <ftp server url>', 'ftp server url: ftp://dibsftp:dibsftp@127.0.0.1' ) do|domain|
-            options[:fdomain] = domain
-        end
+                       options[:fdomain] = domain
+               end
 
                opts.on( '-h', '--help', 'display help' ) do
-            opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse"}
+                       opts.help.split("\n").each {|op| puts op if not op.include? "--noreverse"}
                        exit
-        end
+               end
 
                opts.on( '-v', '--version', 'display version' ) do
-            puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
+                       puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
                        exit
-        end
-               
-    end
-    
+               end
+
+       end
+
        cmd = ARGV[0] 
 
-    if cmd.eql? "build" or cmd.eql? "resolve" or
-        cmd.eql? "query" or cmd.eql? "query-system" or
+       if cmd.eql? "build" or cmd.eql? "resolve" or
+               cmd.eql? "query" or cmd.eql? "query-system" or
                cmd.eql? "query-project" or cmd.eql? "query-job" or
                cmd.eql? "cancel" or
-        cmd.eql? "register" or
-        cmd =~ /(-v)|(--version)/ or        
-        cmd =~ /(help)|(-h)|(--help)/ then
+               cmd.eql? "register" or
+               cmd =~ /(-v)|(--version)/ or        
+               cmd =~ /(help)|(-h)|(--help)/ then
 
-        if cmd.eql? "help" then
+               if cmd.eql? "help" then
                        ARGV[0] = "-h" 
                end
 
-        options[:cmd] = ARGV[0]
-    else
-        raise ArgumentError, "Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli -h"
-    end
+               options[:cmd] = ARGV[0]
+       else
+               raise ArgumentError, "Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli -h"
+       end
+
+       optparse.parse!
 
-    optparse.parse!
+       option_error_check options
 
-    option_error_check options
-   
-    return options
+       return options
 end 
 
index e864d95d894d9befb6ed1fefaa7035efe25900a7..f14851f5a10fd80a4256b32232d325dab06e46af 100644 (file)
@@ -60,7 +60,7 @@ class BuildJob < CommonJob
                @type = "BUILD"
 
                @cancel_state = "NONE"
-        @resolve = false
+               @resolve = false
                @host_os = Utils::HOST_OS
                if not @server.distmgr.nil? then
                        @pkgsvr_url = @server.distmgr.get_distribution(project.dist_name).pkgsvr_url
@@ -90,8 +90,8 @@ class BuildJob < CommonJob
                @build_dep_prjs = nil # for cacnel pending job
 
                # for resolving build-break
-        @rev_fail_projects = [] # list of [project,os]
-        @rev_success_jobs = [] # list of job
+               @rev_fail_projects = [] # list of [project,os]
+               @rev_success_jobs = [] # list of job
 
                # remote build
                @remote_server = nil
@@ -177,7 +177,7 @@ class BuildJob < CommonJob
                @external_pkgs.push "#{@job_root}/external_pkgs/#{file_name}"
        end
 
-       
+
        #terminate
        def terminate()
                #do noting
@@ -206,7 +206,7 @@ class BuildJob < CommonJob
                        client = BuildCommClient.create( @remote_server.ip, @remote_server.port, @log )
                        if not client.nil? then
                                client.send "CANCEL|#{@remote_id}|#{self.get_project.passwd}"
-                               result1 = client.receive_data()
+                                       result1 = client.receive_data()
                                if result1.nil? then
                                        @log.info( "cancel operation failed [connection error] !!", Log::LV_USER)
                                else
@@ -233,8 +233,8 @@ class BuildJob < CommonJob
                                # and add it into rev_fail_project list if not exist
                                p_sub_jobs = @server.jobmgr.jobs.select do |j| 
                                        ( not j.pending_ancestor.nil? and 
-                                         "#{j.pending_ancestor.id}" == "#{@pending_ancestor.id}" and
-                                         j.is_build_dependent_project(@project, @os) ) 
+                                        "#{j.pending_ancestor.id}" == "#{@pending_ancestor.id}" and
+                                        j.is_build_dependent_project(@project, @os) ) 
                                end
                                p_sub_jobs.each do |d|
                                        @pending_ancestor.remove_rev_success_job(d)
@@ -302,7 +302,7 @@ class BuildJob < CommonJob
                        not (Version.new(@pkginfo.get_version()) == Version.new(o.pkginfo.get_version())) then
                        return false 
                end
-       
+
                # check compat os       
                @pkginfo.get_target_packages(@os).each do |p|
                        if not p.os_list.include?(o.os) then return false end
@@ -310,13 +310,13 @@ class BuildJob < CommonJob
 
                return true
        end
-                       
+
 
        def has_build_dependency?(other_job)
 
                if has_same_packages?(other_job) or
-                         does_depend_on?(other_job) or
-                         does_depended_by?(other_job) then
+                       does_depend_on?(other_job) or
+                       does_depended_by?(other_job) then
 
                        return true
                else
@@ -331,7 +331,7 @@ class BuildJob < CommonJob
                if get_distribution_name() != wjob.get_distribution_name() then
                        return false
                end
-               
+
                # same package must have same os
                if not @os.eql? wjob.os then
                        return false
@@ -352,7 +352,7 @@ class BuildJob < CommonJob
 
 
        def does_depend_on?( wjob )
+
                # must have same distribution
                if get_distribution_name() != wjob.get_distribution_name() then
                        return false
@@ -370,7 +370,7 @@ class BuildJob < CommonJob
                                end
                        end
                end
-               
+
                return false
        end
 
@@ -480,7 +480,7 @@ class BuildJob < CommonJob
                        prjs = @server.prjmgr.get_projects_from_pkgs(pkgs)
                        @build_dep_prjs = prjs
                end
-               
+
                return @build_dep_prjs
        end
 
@@ -538,7 +538,7 @@ class BuildJob < CommonJob
                @log.info( "Invoking a thread for building Job #{@id}", Log::LV_USER)
                if @status == "ERROR" then return end
                @log.info( "New Job #{@id} is started", Log::LV_USER)
-               
+
                # checking build dependency
                if not @is_remote_job and not @is_internal_job and
                        not check_build_dependency() then
@@ -569,7 +569,7 @@ class BuildJob < CommonJob
                elsif not @parent.nil? and not @is_rev_build_check_job then
                        copy_result_files(@parent.source_path)
                end
-               
+
                # INFO. don't change this string
                @log.info( "Job is completed!", Log::LV_USER)
                @status = "FINISHED"
@@ -705,16 +705,16 @@ class BuildJob < CommonJob
 
        # return pending job that wait for me
        def get_pending_ancestor_job()
-        @server.jobmgr.get_pending_jobs.each do |job|
+               @server.jobmgr.get_pending_jobs.each do |job|
                        # must have same distribution
                        if get_distribution_name() != job.get_distribution_name() then
                                next
                        end
-                       
-            if job.is_rev_fail_project(@project,@os) then
-                return job
-            end
-        end
+
+                       if job.is_rev_fail_project(@project,@os) then
+                               return job
+                       end
+               end
 
                return nil
        end
@@ -746,7 +746,7 @@ class BuildJob < CommonJob
                                        end
                                end
                                if compat_found then break end
-                               
+
                                # check other package already in package server
                                ver_svr = @pkgsvr_client.get_attr_from_pkg( p.package_name, o, "version")
                                if not ver_svr.nil? and p.version.eql? ver_svr then
@@ -777,7 +777,7 @@ class BuildJob < CommonJob
                        end
                else
                        builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
-                                "#{@buildroot_dir}", @server.build_cache_dir )
+                                                                        "#{@buildroot_dir}", @server.build_cache_dir )
                        if builder.nil?
                                @log.error( "Creating job builder failed", Log::LV_USER)
                                return false
@@ -787,7 +787,7 @@ class BuildJob < CommonJob
                        @log.info( " - Build Cache Path : #{@server.build_cache_dir}" )
                end
                @log.info( " - Log Path : #{@log.path}" )
-               
+
                # if sub job, install dependent packages of parent-pkgs and not clean
                use_clean = true
                local_pkgs = []
@@ -848,7 +848,7 @@ class BuildJob < CommonJob
                end
 
                # check reverse dependecy if not sub jobs
-       
+
                if not @no_reverse then
                        if not @is_rev_build_check_job and not @is_internal_job and
                                not ReverseBuildChecker.check( self, true ).empty? then
@@ -875,7 +875,7 @@ class BuildJob < CommonJob
                        end
                else
                        builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
-                                "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
+                                                                        "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
                        if builder.nil?
                                @log.error( "Creating job builder failed", Log::LV_USER)
                                return false
@@ -890,13 +890,13 @@ class BuildJob < CommonJob
                if @is_remote_job then
                        result = builder.build_job(self, [])
                else
-               result =  builder.build_job(self, true, [], false )
+                       result =  builder.build_job(self, true, [], false )
                end
-        if not result then
-            @log.error( "Building job failed", Log::LV_USER)
+               if not result then
+                       @log.error( "Building job failed", Log::LV_USER)
                        write_log_url()
-            return false
-        end
+                       return false
+               end
 
                # check reverse dependecy
                @rev_fail_projects = ReverseBuildChecker.check(self, false)
@@ -905,18 +905,18 @@ class BuildJob < CommonJob
                        return true
                end
 
-        # pending 
-        @status = "PENDING"
-        @log.info( "Entered the PENDING state ...", Log::LV_USER)
+               # pending 
+               @status = "PENDING"
+               @log.info( "Entered the PENDING state ...", Log::LV_USER)
                old_msg = ""
-        while @status == "PENDING"
+               while @status == "PENDING"
                        new_msg = @rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
                        if old_msg != new_msg then
-               @log.error( " * Waiting for building next projects: #{new_msg}", Log::LV_USER)
+                               @log.error( " * Waiting for building next projects: #{new_msg}", Log::LV_USER)
                                old_msg = new_msg
                        end
-            sleep 1
-        end 
+                       sleep 1
+               end 
 
                return true
        end
@@ -955,7 +955,7 @@ class BuildJob < CommonJob
                        end
                else
                        builder = Builder.create( "JB#{@id}", @pkgsvr_url, nil,
-                                "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
+                                                                        "#{@buildroot_dir}/#{@os}", @server.build_cache_dir )
                        if builder.nil?
                                @log.error( "Creating job builder failed", Log::LV_USER)
                                return false
@@ -1002,16 +1002,16 @@ class BuildJob < CommonJob
                end
 
                # update the status of pending job
-        @status = "PENDING"
-        @pending_ancestor.remove_rev_fail_project(@project, @os)
+               @status = "PENDING"
+               @pending_ancestor.remove_rev_fail_project(@project, @os)
                @pending_ancestor.rev_success_jobs.push self
                if @pending_ancestor.rev_fail_projects.empty? then
                        @pending_ancestor.status = "RESOLVED"
-            @pending_ancestor.rev_success_jobs.each do |job|
-                job.status = "RESOLVED"
-            end
-        else
-            @log.info( "Entered the PENDING state ...", Log::LV_USER)
+                       @pending_ancestor.rev_success_jobs.each do |job|
+                               job.status = "RESOLVED"
+                       end
+               else
+                       @log.info( "Entered the PENDING state ...", Log::LV_USER)
                        old_msg = ""
                        while @status == "PENDING"
                                new_msg = @pending_ancestor.rev_fail_projects.map {|p| "#{p[0].name}(#{p[1]})"}.join(", ")
@@ -1023,7 +1023,7 @@ class BuildJob < CommonJob
 
                                sleep 1
                        end
-        end
+               end
 
                return true
        end
@@ -1031,7 +1031,7 @@ class BuildJob < CommonJob
 
        def upload()
                @log.info( "Uploading ...", Log::LV_USER)
-       
+
                # get package path list
                binpkg_path_list = Dir.glob("#{@source_path}/*_*_#{@os}.zip")
 
@@ -1044,19 +1044,19 @@ class BuildJob < CommonJob
 
                        return false
                end
-       
+
                # update local
                @log.info( "Upload succeeded. Sync local pkg-server again...", Log::LV_USER)
                @pkgsvr_client.update
                @log.info("Snapshot: #{snapshot}", Log::LV_USER)
-       
+
                return true
        end
 
 
        def copy_result_files(dst_path)
                @log.info( "Copying result files to #{dst_path}", Log::LV_USER)
-       
+
                # get package path list
                binpkg_path_list = Dir.glob("#{@source_path}/*_*_#{@os}.zip")
 
@@ -1064,7 +1064,7 @@ class BuildJob < CommonJob
                        @log.info( " * #{file}", Log::LV_USER)
                        FileUtils.cp(file,"#{dst_path}/")
                end
-       
+
                return true
        end
 
@@ -1076,7 +1076,7 @@ class BuildJob < CommonJob
                @log.info( "Copying log to #{outgoing_dir}", Log::LV_USER)
                file = "#{@source_path}/../log"
                FileUtils.copy_file(file, "#{outgoing_dir}/remote_log")
-       
+
                # copy result files, if not reverse build       
                if not @is_rev_build_check_job then
                        return copy_result_files( outgoing_dir )
@@ -1137,7 +1137,7 @@ class BuildJob < CommonJob
 
                chained_deps = []
                chained_deps += deps
-       
+
                # if parent is multi build job, gether all install dependency of dependency.    
                if parent.type == "MULTIBUILD" then
                        begin
@@ -1200,5 +1200,5 @@ class BuildJob < CommonJob
                        dep_target_os = @os
                end
        end
-       
+
 end
index 16336b45209477a8443c645066d8b9cfd2cc36bb..b1471aaa38ca3aff3000da485002f615cd347d87 100644 (file)
@@ -96,10 +96,10 @@ class BuildServer
                @test_time=0 #test time in mili-seconds
                @password="0000"
                @keep_time=86400
-        @ftp_addr = ftpsvr_addr
-        @ftp_port = ftpsvr_port
-        @ftp_username = ftpsvr_username
-        @ftp_passwd = ftpsvr_passwd
+               @ftp_addr = ftpsvr_addr
+               @ftp_port = ftpsvr_port
+               @ftp_username = ftpsvr_username
+               @ftp_passwd = ftpsvr_passwd
                @cleaner=nil
                @prjmgr = ProjectManager.new(self)
                @distmgr = DistributionManager.new(self)
@@ -150,22 +150,22 @@ class BuildServer
                        @pkg_sync =  PackageServerSynchronizer.new(self)
                        @pkg_sync.start
                end
-       
+
                # main loop
                @log.info "Entering main loop..."
                begin
                        if @test_time > 0 then start_time = Time.now end
                        while( not @finish )
-            
+
                                # update friend server status
                                @friend_servers.each do |server|
                                        # update state
                                        server.update_state
                                end
-            
+
                                # handle jobs
                                @jobmgr.handle()
-            
+
                                # sleep
                                if @test_time > 0 then
                                        curr_time = Time.now
@@ -213,7 +213,7 @@ class BuildServer
 
        # add new remote friend server
        def add_remote_server( ip, port )
-       
+
                # if already exit, return false
                @friend_servers.each do |svr|
                        if svr.ip.eql? ip and svr.port == port then
@@ -245,7 +245,7 @@ class BuildServer
 
        # add new remote pkg server
        def add_sync_package_server( url, dist )
-       
+
                # if already exit, return false
                @remote_pkg_servers.each do |e|
                        if e[0] == url and e[1] == dist  then
@@ -261,7 +261,7 @@ class BuildServer
 
        # remove remote pkg server
        def remove_sync_package_server( url, dist )
-       
+
                # if already exit, return false
                @remote_pkg_servers.each do |e|
                        if e[0] == url and e[1] == dist  then
@@ -277,7 +277,7 @@ class BuildServer
        # add new target OS.
        # If already exist, return false , otherwise true
        def add_target_os( os_name )
-       
+
                # if already exit, return false
                @supported_os_list.each do |os|
                        if os.eql? os_name then
@@ -306,7 +306,7 @@ class BuildServer
        # get remote server     
        def get_available_server ( job )
                candidates = []
-               
+
                # calculate empty rooms
                # if sub job, his parent should be excluded
                local_empty_rooms = @jobmgr.get_number_of_empty_room
@@ -340,7 +340,7 @@ class BuildServer
 
                        # skip
                        if server == best_server then next end
-               
+
                        # compare remain rooms
                        empty_room = server.get_number_of_empty_room
                        if empty_room > max_empty_room then
@@ -348,7 +348,7 @@ class BuildServer
                                best_server = server
                        end
                end
-                
+
                return best_server
        end
 
@@ -370,7 +370,7 @@ class BuildServer
                return false
        end
 
-       
+
        # return available working slot
        def get_number_of_empty_room
                return @jobmgr.get_number_of_empty_room
@@ -414,107 +414,107 @@ class BuildServer
                        db.do "CREATE TABLE IF NOT EXISTS project_os(prj_id INTEGER, os_name VARCHAR(32))"
                        db.do "CREATE TABLE IF NOT EXISTS users(user_id INTEGER PRIMARY KEY AUTOINCREMENT, email VARCHAR(256), password VARCHAR(256), password_salt VARCHAR(256), user_name VARCHAR(256), group_id VARCHAR(256))"
                        db.do "CREATE TABLE IF NOT EXISTS groups(group_id INTEGER PRIMARY KEY AUTOINCREMENT, group_name VARCHAR(256))"
-               rescue DBI::DatabaseError => e
-                       puts "DB Creation failed!"
-                       puts e.errstr
-                       result = false
-               ensure
-                       db.disconnect if db
-               end
-               return result
-       end
-
-
-       # save
-       def save_db()
-
-               result = true
-               # distribution
-               @distmgr.save_db()
-
-               sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
-               begin
-                       # open DB
-                       db = DBI.connect(sqlite_db_file)
-
-                       # remote_build_servers
-                       db.do "DELETE FROM remote_build_servers"
-                       @friend_servers.each { |svr|
-                               db.do "INSERT INTO remote_build_servers (svr_addr) VALUES('#{svr.ip}:#{svr.port}')"
-                       }
-
-                       # sync_pkg_servers
-                       db.do "DELETE FROM sync_pkg_servers"
-                       @remote_pkg_servers.each { |svr|
-                               db.do "INSERT INTO sync_pkg_servers (pkgsvr_url,period,dist_name) VALUES('#{svr[0]}','#{@pkg_sync_period}','#{svr[1]}')"
-                       }
-
-                       # supported_os
-                       db.do "DELETE FROM supported_os"
-                       @supported_os_list.each { |os|
-                               db.do "INSERT INTO supported_os VALUES('#{os}')"
-                       }
-
-               rescue DBI::DatabaseError => e
-                       puts "DB update failed!"
-                       puts e.errstr
-                       result = false
-               ensure
-                       db.disconnect if db
-               end
-
-               return result
-       end
+                       rescue DBI::DatabaseError => e
+                               puts "DB Creation failed!"
+                               puts e.errstr
+                               result = false
+                       ensure
+                               db.disconnect if db
+                       end
+                       return result
+                       end
 
 
-       # load
-       def load_db()
+                       # save
+                       def save_db()
+
+                               result = true
+                               # distribution
+                               @distmgr.save_db()
+
+                               sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
+                               begin
+                                       # open DB
+                                       db = DBI.connect(sqlite_db_file)
+
+                                       # remote_build_servers
+                                       db.do "DELETE FROM remote_build_servers"
+                                       @friend_servers.each { |svr|
+                                               db.do "INSERT INTO remote_build_servers (svr_addr) VALUES('#{svr.ip}:#{svr.port}')"
+                                       }
+
+                                       # sync_pkg_servers
+                                       db.do "DELETE FROM sync_pkg_servers"
+                                       @remote_pkg_servers.each { |svr|
+                                               db.do "INSERT INTO sync_pkg_servers (pkgsvr_url,period,dist_name) VALUES('#{svr[0]}','#{@pkg_sync_period}','#{svr[1]}')"
+                                       }
+
+                                       # supported_os
+                                       db.do "DELETE FROM supported_os"
+                                       @supported_os_list.each { |os|
+                                               db.do "INSERT INTO supported_os VALUES('#{os}')"
+                                       }
+
+                                               rescue DBI::DatabaseError => e
+                                                       puts "DB update failed!"
+                                                       puts e.errstr
+                                                       result = false
+                                               ensure
+                                                       db.disconnect if db
+                                               end
+
+                                               return result
+                                       end
 
-               result = true
-               # distribution
-               @distmgr.load_db()
 
-               sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
-               begin
-                       # open DB
-                       db = DBI.connect(sqlite_db_file)
-                       #db.results_as_hash = true
-
-                       # remote_build_servers
-                       @friend_servers = []
-                       sth = db.execute "SELECT * FROM remote_build_servers"
-                       sth.fetch_hash { |row|
-                               add_remote_server(
-                                       row['svr_addr'].split(":")[0],
-                                       row['svr_addr'].split(":")[1].to_i)
-                       }
-                       sth.finish
-                       # sync_package_servers
-                       @remote_pkg_servers = []
-                       sth = db.execute "SELECT * FROM sync_pkg_servers"
-                       sth.fetch_hash { |row|
-                               add_sync_package_server( row['pkgsvr_url'], row['dist_name'] )
-                               @pkg_sync_period = row['period'].to_i
-                       }
-                       sth.finish
-
-                       # supported_os
-                       @supported_os_list = []
-                       sth = db.execute "SELECT * FROM supported_os"
-                       sth.fetch_hash { |row|
-                               add_target_os( row['name'] )
-                       }
-                       sth.finish
-               rescue DBI::DatabaseError => e
-                       puts "DB loading failed!"
-                       puts e.errstr
-                       result = false
-               ensure
-                       sth.finish if not sth.finished?
-                       db.disconnect if db
-               end
-               return result
-       end
+                                       # load
+                                       def load_db()
+
+                                               result = true
+                                               # distribution
+                                               @distmgr.load_db()
+
+                                               sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@id}/server.db"
+                                               begin
+                                                       # open DB
+                                                       db = DBI.connect(sqlite_db_file)
+                                                       #db.results_as_hash = true
+
+                                                       # remote_build_servers
+                                                       @friend_servers = []
+                                                       sth = db.execute "SELECT * FROM remote_build_servers"
+                                                       sth.fetch_hash { |row|
+                                                               add_remote_server(
+                                                                       row['svr_addr'].split(":")[0],
+                                                                       row['svr_addr'].split(":")[1].to_i)
+                                                       }
+                                                       sth.finish
+                                                       # sync_package_servers
+                                                       @remote_pkg_servers = []
+                                                       sth = db.execute "SELECT * FROM sync_pkg_servers"
+                                                       sth.fetch_hash { |row|
+                                                               add_sync_package_server( row['pkgsvr_url'], row['dist_name'] )
+                                                               @pkg_sync_period = row['period'].to_i
+                                                       }
+                                                       sth.finish
+
+                                                       # supported_os
+                                                       @supported_os_list = []
+                                                       sth = db.execute "SELECT * FROM supported_os"
+                                                       sth.fetch_hash { |row|
+                                                               add_target_os( row['name'] )
+                                                       }
+                                                       sth.finish
+                                               rescue DBI::DatabaseError => e
+                                                       puts "DB loading failed!"
+                                                       puts e.errstr
+                                                       result = false
+                                               ensure
+                                                       sth.finish if not sth.finished?
+                                                       db.disconnect if db
+                                               end
+                                               return result
+                                       end
 
-end
+                                               end
 
index 6ba375940c3f260863c0a16913a367a3608e212f..7098b4cdffebaaa2abc81a311f0b7985fcdba285 100644 (file)
@@ -55,7 +55,7 @@ class BuildServerController
                @@instance_map[id].jobmgr.max_working_jobs= 2
                @@instance_map[id].job_log_url=""
                @@instance_map[id].send_mail="NO"
-       
+
                # write config
                write_server_config( @@instance_map[id] )
 
@@ -114,7 +114,7 @@ class BuildServerController
        # start server
        def self.start_server( id, port = 2222 )
                server = get_server(id)
-       
+
                # write run port        
                server_dir = "#{BuildServer::CONFIG_ROOT}/#{server.id}"
                f = File.open( "#{server_dir}/run", "w" )
@@ -156,7 +156,7 @@ class BuildServerController
 
                # terminate     
                client.terminate
-       
+
                if not stop_ok then     
                        puts "Server stop failed!"
                end
@@ -193,7 +193,7 @@ class BuildServerController
 
                # terminate     
                client.terminate
-       
+
                if not upgrade_ok then  
                        puts "Server upgrade failed!"
                end
@@ -206,14 +206,14 @@ class BuildServerController
 
                server = get_server(id)
                server_dir = "#{BuildServer::CONFIG_ROOT}/#{id}"
-       
+
                if File.exist? "#{server_dir}/friends" then
                        File.open( "#{server_dir}/friends", "r" ) do |f|
                                f.each_line do |l|
                                        if l.split(",").count < 2 then next end
                                        ip = l.split(",")[0].strip
                                        port = l.split(",")[1].strip
-       
+
                                        client = BuildCommClient.create( ip, port )
                                        if client.nil? then
                                                puts "Friend Server #{ip}:#{port} is not running!"
@@ -234,10 +234,10 @@ class BuildServerController
                                                        upgrade_ok = true
                                                end
                                        end
-       
+
                                        # terminate     
                                        client.terminate
-       
+
                                        if upgrade_ok then      
                                                puts "Friend Server #{ip}:#{port} upgrade requested!"
                                        else
@@ -248,7 +248,7 @@ class BuildServerController
                else
                        puts "No Friend Server."
                end             
-               
+
                return true
        end
 
@@ -256,7 +256,7 @@ class BuildServerController
        # add friend server
        def self.add_remote_server( id, ip, port )
                server = get_server(id)
-               
+
                # add
                if server.add_remote_server( ip, port ) then
                        if server.save_db() then
@@ -276,7 +276,7 @@ class BuildServerController
        # remove friend server
        def self.remove_remote_server( id, ip, port )
                server = get_server(id)
-               
+
                # add
                if server.remove_remote_server( ip, port ) then
                        if server.save_db() then
@@ -303,7 +303,7 @@ class BuildServerController
 
                # get server
                server = get_server(id)
-               
+
                # add
                if server.add_target_os( os_name ) then
                        if server.save_db() then
@@ -324,7 +324,7 @@ class BuildServerController
        def self.remove_target_os( id, os_name )
                # get server
                server = get_server(id)
-               
+
                # add
                if server.remove_target_os( os_name ) then
                        if server.save_db() then
@@ -345,7 +345,7 @@ class BuildServerController
        def self.add_distribution( id, dist_name, pkgsvr_url, pkgsvr_ip, pkgsvr_port )
                # get server
                server = get_server(id)
-               
+
                # add
                if server.distmgr.add_distribution( dist_name, pkgsvr_url, pkgsvr_ip, pkgsvr_port ) then
                        if server.save_db() then
@@ -366,7 +366,7 @@ class BuildServerController
        def self.remove_distribution( id, dist_name )
                # get server
                server = get_server(id)
-               
+
                # remove
                if server.distmgr.remove_distribution( dist_name ) then
                        if server.save_db() then
@@ -386,7 +386,7 @@ class BuildServerController
        # add remote package server
        def self.add_sync_package_server(id, url, dist_name)
                server = get_server(id)
-       
+
                # check distribution    
                dist_name = check_distribution_name(dist_name, server)
                if dist_name.nil? then return false end 
@@ -445,10 +445,10 @@ class BuildServerController
 
        # add project
        def self.add_project( id, project_name, git_repos, git_branch, remote_server_id,
-                       passwd, os_string, dist_name )
+                                                passwd, os_string, dist_name )
                # get server
                server = get_server(id)
-       
+
                # get supported os for project. 
                # if not specified, all supported os of the server will be used
                if os_string.nil? or os_string.empty? then
@@ -495,7 +495,7 @@ class BuildServerController
        def self.add_binary_project( id, project_name, pkg_name, passwd, os_string, dist_name )
                # get server
                server = get_server(id)
-       
+
                # get supported os for project. 
                # if not specified, all supported os of the server will be used
                if os_string.nil? or os_string == "default" then
@@ -522,7 +522,7 @@ class BuildServerController
 
                # add
                result = server.prjmgr.add_binary_project( project_name, pkg_name, passwd,
-                       os_list, dist_name )
+                                                                                                 os_list, dist_name )
                if result then
                        puts "Adding project succeeded!"
                        return true
@@ -537,7 +537,7 @@ class BuildServerController
        def self.remove_project( id, project_name, dist_name )
                # get server
                server = get_server(id)
-       
+
                # check distribution    
                dist_name = check_distribution_name(dist_name, server)
                if dist_name.nil? then return false end 
@@ -591,7 +591,7 @@ class BuildServerController
 
                # terminate     
                client.terminate
-       
+
                if not fullbuild_ok then        
                        puts "Full build failed!"
                end
@@ -638,7 +638,7 @@ class BuildServerController
 
                # terminate     
                client.terminate
-       
+
                if not success then     
                        puts "Registering package failed!"
                end
@@ -709,8 +709,8 @@ class BuildServerController
                        server.keep_time = value.to_i
                when "FTP_ADDR"
                        server.ftp_addr = value
-        when "FTP_PORT"
-                       server.ftp_port = value
+               when "FTP_PORT"
+                       server.ftp_port = value
                when "FTP_USERNAME"
                        server.ftp_username = value
                when "FTP_PASSWD"
@@ -755,8 +755,8 @@ class BuildServerController
                        puts "#{server.keep_time}"
                when "FTP_ADDR"
                        puts server.ftp_addr
-        when "FTP_PORT"
-                       puts server.ftp_port
+               when "FTP_PORT"
+                       puts server.ftp_port
                when "FTP_USERNAME"
                        puts server.ftp_username
                when "FTP_PASSWD"
@@ -861,11 +861,11 @@ class BuildServerController
                                elsif l.start_with?("JOB_KEEP_TIME=")
                                        keep_time = l[idx,length].strip.to_i
                                elsif l.start_with?("FTP_URL=")
-                               ftp_result = Utils.parse_ftpserver_url(l[idx,length].strip)
-                               ftp_addr = ftp_result[0]
-                               ftp_port = ftp_result[1]
-                               ftp_username = ftp_result[2]
-                               ftp_passwd = ftp_result[3]
+                                       ftp_result = Utils.parse_ftpserver_url(l[idx,length].strip)
+                                       ftp_addr = ftp_result[0]
+                                       ftp_port = ftp_result[1]
+                                       ftp_username = ftp_result[2]
+                                       ftp_passwd = ftp_result[3]
                                elsif l.start_with?("PKG_SYNC_PERIOD=")
                                        pkg_sync_period = l[idx,length].strip.to_i
                                elsif l.start_with?("CHANGELOG_CHECK=")
@@ -889,7 +889,7 @@ class BuildServerController
 
                # set git binary path
                obj.git_bin_path = git_bin_path
-       
+
                # set git binary path
                obj.jobmgr.max_working_jobs = max_working_jobs
 
index 04b2f8eddabe5f80c6ddfb9394e32933486529fe..f8565dd5bbdaf23cf424f61c5f667716e1ee9fb2 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  BuildServerOptionParser.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -54,269 +54,269 @@ class BuildServerUsage
 end
 
 def option_error_check( options )
-    case options[:cmd]
-
-    when "create"
-        if options[:name].nil? or options[:name].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::CREATE
-        end            
-
-    when "remove"
-        if options[:name].nil? or options[:name].empty? then 
-            raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE
-        end
-
-    when "start"
-        if options[:name].nil? or options[:name].empty? or
-                options[:port].nil? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::START
-        end
-
-    when "stop"
-        if options[:name].nil? or options[:name].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::STOP
-        end
-
-    when "upgrade"
-        if options[:name].nil? or options[:name].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::UPGRADE
-        end
-
-    when "add-svr"
-        if options[:name].nil? or options[:name].empty? or 
+       case options[:cmd]
+
+       when "create"
+               if options[:name].nil? or options[:name].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::CREATE
+               end            
+
+       when "remove"
+               if options[:name].nil? or options[:name].empty? then 
+                       raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE
+               end
+
+       when "start"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:port].nil? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::START
+               end
+
+       when "stop"
+               if options[:name].nil? or options[:name].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::STOP
+               end
+
+       when "upgrade"
+               if options[:name].nil? or options[:name].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::UPGRADE
+               end
+
+       when "add-svr"
+               if options[:name].nil? or options[:name].empty? or 
                        (options[:domain].nil? or options[:domain].empty?) then
-            raise ArgumentError, "Usage: " + BuildServerUsage::ADD_SVR
-        end
+                       raise ArgumentError, "Usage: " + BuildServerUsage::ADD_SVR
+               end
 
-    when "remove-svr"
-        if options[:name].nil? or options[:name].empty? or
+       when "remove-svr"
+               if options[:name].nil? or options[:name].empty? or
                        (options[:domain].nil? or options[:domain].empty?) then
-            raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_SVR
-        end
-
-    when "add-os"
-        if options[:name].nil? or options[:name].empty? or
-            options[:os].nil? or options[:os].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::ADD_OS
-        end  
-
-    when "remove-os"
-        if options[:name].nil? or options[:name].empty? or
-            options[:os].nil? or options[:os].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_OS
-        end  
-
-    when "add-dist"
-        if options[:name].nil? or options[:name].empty? or
-            options[:dist].nil? or options[:dist].empty? or
-            options[:url].nil? or options[:url].empty? or
+                       raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_SVR
+               end
+
+       when "add-os"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:os].nil? or options[:os].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::ADD_OS
+               end  
+
+       when "remove-os"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:os].nil? or options[:os].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_OS
+               end  
+
+       when "add-dist"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:dist].nil? or options[:dist].empty? or
+                       options[:url].nil? or options[:url].empty? or
                        options[:domain].nil? or options[:domain].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::ADD_DIST
-        end  
-
-    when "remove-dist"
-        if options[:name].nil? or options[:name].empty? or
-            options[:dist].nil? or options[:dist].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_DIST
-        end  
-
-    when "add-sync"
-        if options[:name].nil? or options[:name].empty? or 
-                        (options[:url].nil? or options[:url].empty?) then
-            raise ArgumentError, "Usage: " + BuildServerUsage::ADD_SYNC
-        end
-
-    when "remove-sync"
-        if options[:name].nil? or options[:name].empty? or 
-                        (options[:url].nil? or options[:url].empty?) then
-            raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_SYNC
-        end
-
-    when "add-prj"
-        if options[:name].nil? or options[:name].empty? or
-            options[:pid].nil? or options[:pid].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::ADD_PRJ
-        end  
-
-    when "remove-prj"
-        if options[:name].nil? or options[:name].empty? or
-            options[:pid].nil? or options[:pid].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_PRJ
-        end  
-
-    when "fullbuild"
-        if options[:name].nil? or options[:name].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::FULLBUILD
-        end
-
-    when "register"
-        if options[:name].nil? or options[:name].empty? or
+                       raise ArgumentError, "Usage: " + BuildServerUsage::ADD_DIST
+               end  
+
+       when "remove-dist"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:dist].nil? or options[:dist].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_DIST
+               end  
+
+       when "add-sync"
+               if options[:name].nil? or options[:name].empty? or 
+                       (options[:url].nil? or options[:url].empty?) then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::ADD_SYNC
+               end
+
+       when "remove-sync"
+               if options[:name].nil? or options[:name].empty? or 
+                       (options[:url].nil? or options[:url].empty?) then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_SYNC
+               end
+
+       when "add-prj"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:pid].nil? or options[:pid].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::ADD_PRJ
+               end  
+
+       when "remove-prj"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:pid].nil? or options[:pid].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::REMOVE_PRJ
+               end  
+
+       when "fullbuild"
+               if options[:name].nil? or options[:name].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::FULLBUILD
+               end
+
+       when "register"
+               if options[:name].nil? or options[:name].empty? or
                        options[:package].nil? or options[:package].empty?  then
-            raise ArgumentError, "Usage: " + BuildServerUsage::REGISTER
-        end
-
-    when "query"
-        if options[:name].nil? or options[:name].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::QUERY
-        end
-
-    when "set-attr"
-        if options[:name].nil? or options[:name].empty? or
-               options[:attr].nil? or options[:attr].empty? or
-               options[:value].nil? or options[:value].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::SET_ATTR
-        end
-
-    when "get-attr"
-        if options[:name].nil? or options[:name].empty? or
-               options[:attr].nil? or options[:attr].empty? then
-            raise ArgumentError, "Usage: " + BuildServerUsage::SET_ATTR
-        end
-
-    else
-        raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
-    end            
+                       raise ArgumentError, "Usage: " + BuildServerUsage::REGISTER
+               end
+
+       when "query"
+               if options[:name].nil? or options[:name].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::QUERY
+               end
+
+       when "set-attr"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:attr].nil? or options[:attr].empty? or
+                       options[:value].nil? or options[:value].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::SET_ATTR
+               end
+
+       when "get-attr"
+               if options[:name].nil? or options[:name].empty? or
+                       options[:attr].nil? or options[:attr].empty? then
+                       raise ArgumentError, "Usage: " + BuildServerUsage::SET_ATTR
+               end
+
+       else
+               raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
+       end            
 end
 
 def option_parse 
-    options = {}
-    banner = "Build-server administer service command-line tool." + "\n" \
-       + "\n" + "Usage: build-svr <SUBCOMMAND> [OPTS] or build-svr (-h|-v)" + "\n" \
-       + "\n" + "Subcommands:" + "\n" \
-       + "\t" + "create        Create the build-server." + "\n" \
-       + "\t" + "remove        Remove the build-server." + "\n" \
-       + "\t" + "start         Start the build-server." + "\n" \
-       + "\t" + "stop          Stop the build-server." + "\n" \
-       + "\t" + "upgrade       Upgrade the build-server include friends." + "\n" \
-       + "\t" + "add-svr       Add remote build/package server for support multi-OS or distribute build job." + "\n" \
-       + "\t" + "remove-svr    Remove remote build/package server for support multi-OS or distribute build job." + "\n" \
-       + "\t" + "add-os        Add supported OS." + "\n" \
-       + "\t" + "remove-os     Remove supported OS." + "\n" \
-       + "\t" + "add-dist      Add distribution." + "\n" \
-       + "\t" + "remove-dist   Remove distribution." + "\n" \
-       + "\t" + "add-sync      Add package repository URL to synchronize with." + "\n" \
-       + "\t" + "remove-sync   Remove package repository URL." + "\n" \
-       + "\t" + "add-prj       Add project to build." + "\n" \
-       + "\t" + "remove-prj    Remove project." + "\n" \
-       + "\t" + "register      Register the package to the build-server." + "\n" \
-       + "\t" + "fullbuild     Build all your projects and upload them to package server." + "\n" \
-       + "\t" + "query         Show build server configuration." + "\n" \
-       + "\t" + "set-attr      Set build server atribute." + "\n" \
-       + "\t" + "get-attr      Get build server atribute." + "\n" \
-       + "\n" + "Subcommand usage:" + "\n" \
-        + "\t" + BuildServerUsage::CREATE + "\n" \
-        + "\t" + BuildServerUsage::REMOVE + "\n" \
-        + "\t" + BuildServerUsage::START + "\n" \
-        + "\t" + BuildServerUsage::STOP + "\n" \
-        + "\t" + BuildServerUsage::UPGRADE + "\n" \
-        + "\t" + BuildServerUsage::ADD_SVR + "\n" \
-        + "\t" + BuildServerUsage::REMOVE_SVR + "\n" \
-        + "\t" + BuildServerUsage::ADD_OS + "\n" \
-        + "\t" + BuildServerUsage::REMOVE_OS + "\n" \
-        + "\t" + BuildServerUsage::ADD_DIST + "\n" \
-        + "\t" + BuildServerUsage::REMOVE_DIST + "\n" \
-        + "\t" + BuildServerUsage::ADD_SYNC + "\n" \
-        + "\t" + BuildServerUsage::REMOVE_SYNC + "\n" \
-        + "\t" + BuildServerUsage::ADD_PRJ + "\n" \
-        + "\t" + BuildServerUsage::REMOVE_PRJ + "\n" \
-        + "\t" + BuildServerUsage::FULLBUILD + "\n" \
-        + "\t" + BuildServerUsage::REGISTER + "\n" \
-        + "\t" + BuildServerUsage::QUERY + "\n" \
-        + "\t" + BuildServerUsage::SET_ATTR + "\n" \
-        + "\t" + BuildServerUsage::GET_ATTR + "\n" \
-       + "\n" + "Options:" + "\n"
-
-    optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
-        # Set a banner, displayed at the top
-        # of the help screen.
+       options = {}
+       banner = "Build-server administer service command-line tool." + "\n" \
+               + "\n" + "Usage: build-svr <SUBCOMMAND> [OPTS] or build-svr (-h|-v)" + "\n" \
+               + "\n" + "Subcommands:" + "\n" \
+               + "\t" + "create        Create the build-server." + "\n" \
+               + "\t" + "remove        Remove the build-server." + "\n" \
+               + "\t" + "start         Start the build-server." + "\n" \
+               + "\t" + "stop          Stop the build-server." + "\n" \
+               + "\t" + "upgrade       Upgrade the build-server include friends." + "\n" \
+               + "\t" + "add-svr       Add remote build/package server for support multi-OS or distribute build job." + "\n" \
+               + "\t" + "remove-svr    Remove remote build/package server for support multi-OS or distribute build job." + "\n" \
+               + "\t" + "add-os        Add supported OS." + "\n" \
+               + "\t" + "remove-os     Remove supported OS." + "\n" \
+               + "\t" + "add-dist      Add distribution." + "\n" \
+               + "\t" + "remove-dist   Remove distribution." + "\n" \
+               + "\t" + "add-sync      Add package repository URL to synchronize with." + "\n" \
+               + "\t" + "remove-sync   Remove package repository URL." + "\n" \
+               + "\t" + "add-prj       Add project to build." + "\n" \
+               + "\t" + "remove-prj    Remove project." + "\n" \
+               + "\t" + "register      Register the package to the build-server." + "\n" \
+               + "\t" + "fullbuild     Build all your projects and upload them to package server." + "\n" \
+               + "\t" + "query         Show build server configuration." + "\n" \
+               + "\t" + "set-attr      Set build server atribute." + "\n" \
+               + "\t" + "get-attr      Get build server atribute." + "\n" \
+               + "\n" + "Subcommand usage:" + "\n" \
+               + "\t" + BuildServerUsage::CREATE + "\n" \
+               + "\t" + BuildServerUsage::REMOVE + "\n" \
+               + "\t" + BuildServerUsage::START + "\n" \
+               + "\t" + BuildServerUsage::STOP + "\n" \
+               + "\t" + BuildServerUsage::UPGRADE + "\n" \
+               + "\t" + BuildServerUsage::ADD_SVR + "\n" \
+               + "\t" + BuildServerUsage::REMOVE_SVR + "\n" \
+               + "\t" + BuildServerUsage::ADD_OS + "\n" \
+               + "\t" + BuildServerUsage::REMOVE_OS + "\n" \
+               + "\t" + BuildServerUsage::ADD_DIST + "\n" \
+               + "\t" + BuildServerUsage::REMOVE_DIST + "\n" \
+               + "\t" + BuildServerUsage::ADD_SYNC + "\n" \
+               + "\t" + BuildServerUsage::REMOVE_SYNC + "\n" \
+               + "\t" + BuildServerUsage::ADD_PRJ + "\n" \
+               + "\t" + BuildServerUsage::REMOVE_PRJ + "\n" \
+               + "\t" + BuildServerUsage::FULLBUILD + "\n" \
+               + "\t" + BuildServerUsage::REGISTER + "\n" \
+               + "\t" + BuildServerUsage::QUERY + "\n" \
+               + "\t" + BuildServerUsage::SET_ATTR + "\n" \
+               + "\t" + BuildServerUsage::GET_ATTR + "\n" \
+               + "\n" + "Options:" + "\n"
+
+       optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
+               # Set a banner, displayed at the top
+               # of the help screen.
 
                opts.banner = banner 
 
-        opts.on( '-n', '--name <server name>', 'build server name' ) do|name|
-            options[:name] = name 
-        end
-        
+               opts.on( '-n', '--name <server name>', 'build server name' ) do|name|
+                       options[:name] = name 
+               end
+
                opts.on( '-u', '--url <package server url>', 'package server url: http://127.0.0.1/dibs/unstable' ) do|url|
-            options[:url] = url 
-        end
+                       options[:url] = url 
+               end
 
                opts.on( '-d', '--address <server address>', 'server address: 127.0.0.1:2224' ) do|domain|
-            options[:domain] = domain
-        end
-               
-        options[:port] = 2222
+                       options[:domain] = domain
+               end
+
+               options[:port] = 2222
                opts.on( '-p', '--port <port>', 'server port number: 2224' ) do|port|
-            options[:port] = port.strip.to_i
-        end
+                       options[:port] = port.strip.to_i
+               end
 
                opts.on( '-P', '--pkg <package name/file>', 'package file path or name' ) do|package|
-            options[:package] = package.strip
-        end
+                       options[:package] = package.strip
+               end
 
-        options[:os] = nil
+               options[:os] = nil
                opts.on( '-o', '--os <target os list>', 'ex) ubuntu-32,windows-32' ) do|os|
                        if not Utils.multi_argument_test( os, "," ) then
                                raise ArgumentError, "OS variable parsing error : #{os}"
                        end
-            options[:os] = os
-        end
+                       options[:os] = os
+               end
 
                opts.on( '-N', '--pname <project name>', 'project name' ) do|pid|
-            options[:pid] = pid
-        end
+                       options[:pid] = pid
+               end
 
                opts.on( '-g', '--git <git repository>', 'git repository' ) do|git|
-            options[:git] = git
-        end
+                       options[:git] = git
+               end
 
                opts.on( '-b', '--branch <git branch>', 'git branch' ) do|branch|
-            options[:branch] = branch
-        end
+                       options[:branch] = branch
+               end
 
                #opts.on( '-r', '--remote <remote server id>', 'remote server id' ) do|remote|
-        #    options[:remote] = remote
-        #end
-        options[:dist] = ""
+               #    options[:remote] = remote
+               #end
+               options[:dist] = ""
                opts.on( '-D', '--dist <distribution name>', 'distribution name' ) do |dist|
-            options[:dist] = dist
+                       options[:dist] = dist
                end
 
 
-        options[:passwd] = ""
+               options[:passwd] = ""
                opts.on( '-w', '--passwd <password>', 'password for managing project' ) do|passwd|
-            options[:passwd] = passwd
-        end
+                       options[:passwd] = passwd
+               end
 
                opts.on( '-t', '--ftp <ftp server url>', 'ftp server url: ftp://dibsftp:dibsftp@127.0.0.1:1024' ) do|domain|
-            options[:fdomain] = domain
-        end
-               
+                       options[:fdomain] = domain
+               end
+
                opts.on( '-A', '--attr <attribute name>', 'attribute' ) do |attr|
-            options[:attr] = attr
+                       options[:attr] = attr
                end
 
                opts.on( '-V', '--value <value>', 'value' ) do |value|
-            options[:value] = value
+                       options[:value] = value
                end
 
                opts.on( '-h', '--help', 'display this information' ) do
-            opts.help.split("\n").each {|op| puts op if not op.include? "--CHILD"}
+                       opts.help.split("\n").each {|op| puts op if not op.include? "--CHILD"}
                        exit
-        end
+               end
 
                opts.on( '-v', '--version', 'display version' ) do
-            puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
+                       puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
                        exit
-        end
+               end
 
                opts.on( '-C', '--CHILD', 'child process' ) do
-            options[:child] = true
-        end
-               
-    end
-    
+                       options[:child] = true
+               end
+
+       end
+
        cmd = ARGV[0] 
-    if cmd.eql? "create" or cmd.eql? "remove" or 
+       if cmd.eql? "create" or cmd.eql? "remove" or 
                cmd.eql? "start" or cmd.eql? "upgrade" or
                cmd.eql? "stop" or 
                cmd.eql? "add-svr" or cmd.eql? "remove-svr" or
@@ -324,25 +324,25 @@ def option_parse
                cmd.eql? "add-dist" or cmd.eql? "remove-dist" or 
                cmd.eql? "add-sync" or cmd.eql? "remove-sync" or 
                cmd.eql? "add-prj" or cmd.eql? "remove-prj" or 
-               cmd.eql? "fullbuild" or cmd.eql? "register" or 
-               cmd.eql? "query" or
+               cmd.eql? "fullbuild" or cmd.eql? "register" or 
+               cmd.eql? "query" or
                cmd.eql? "set-attr" or cmd.eql? "get-attr" or 
-        cmd =~ /(-v)|(--version)/ or        
-        cmd =~ /(help)|(-h)|(--help)/ then
+               cmd =~ /(-v)|(--version)/ or        
+               cmd =~ /(help)|(-h)|(--help)/ then
 
-        if cmd.eql? "help" then 
+               if cmd.eql? "help" then 
                        ARGV[0] = "-h" 
                end
 
-        options[:cmd] = ARGV[0]
-    else
-        raise ArgumentError, "Usage: build-svr <SUBCOMMAND> [OPTS] or build-svr -h" 
-    end
+               options[:cmd] = ARGV[0]
+       else
+               raise ArgumentError, "Usage: build-svr <SUBCOMMAND> [OPTS] or build-svr -h" 
+       end
+
+       optparse.parse!
 
-    optparse.parse!
+       option_error_check options
 
-    option_error_check options
-   
-    return options
+       return options
 end 
 
index 038a238193e20ebf937a4bce3a5c74e92423e2ea..70cac51d1deae0f2935d1d8231e273ff538200e0 100644 (file)
@@ -98,7 +98,7 @@ class CommonJob
                @log =  logger
        end
 
-       
+
        # execute
        public
        def execute(sync=false)
@@ -110,16 +110,16 @@ class CommonJob
 
                                # parent job will call sub job's terminate method
                                if not is_sub_job? then terminate() end
-                       rescue => e
-                               @log.error e.message
-                               @log.error e.backtrace.inspect
-                       end
+               rescue => e
+                       @log.error e.message
+                       @log.error e.backtrace.inspect
+               end
                }
 
                if sync then
                        @thread.join
                end
-               
+
                return true      
        end
 
@@ -172,7 +172,7 @@ class CommonJob
                # do nothing
        end
 
-       
+
        protected
        def kill_sub_process()
                if @sub_pid != 0 then
@@ -180,6 +180,6 @@ class CommonJob
                                @log.info("Killing sub process! id = #{@sub_pid}")
                        end
                        Utils.kill_process(@sub_pid)
-        end
-    end
+               end
+       end
 end
index 11745e9f8a0f6586c961b1d1e218ab5e46d28083..3c2e144f3371265ac3c6ee629c540de3aa16fcb6 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  CommonProject.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -51,7 +51,7 @@ class CommonProject
                read_ext_info
        end
 
-       
+
        def init()
                # create project directory if not exist
                if not File.exist? @path then FileUtils.mkdir_p @path end
index b365a8a5df638fe0289af0fb9e1d782111f3241b..54ab618035e2471b4e754a118e02a8a2092756a7 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  DistributionManager.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -43,7 +43,7 @@ class PackageDistribution
                @name = name
                @pkgsvr_url = pkgsvr_url
                @pkgsvr_ip = pkgsvr_ip
-        @pkgsvr_port = pkgsvr_port
+               @pkgsvr_port = pkgsvr_port
        end
 end
 
@@ -63,11 +63,11 @@ class DistributionManager
                if @distributions.count > 0 then
                        return @distributions[0].name
                end
-       
+
                return nil
        end
 
-       
+
        def get_default_pkgsvr_url()
                if @distributions.count > 0 then
                        return @distributions[0].pkgsvr_url
@@ -84,7 +84,7 @@ class DistributionManager
                                return d
                        end
                }
-       
+
                return nil
        end
 
@@ -139,60 +139,60 @@ class DistributionManager
                                dist_addr = dist.pkgsvr_ip + ":" + dist.pkgsvr_port.to_s
                                db.do "INSERT INTO distributions VALUES('#{dist.name}','#{dist.pkgsvr_url}','#{dist_addr}')"
                        }
-               rescue DBI::DatabaseError => e
-                       puts "DB update failed!"
-                       puts e.errstr
-                       result = false
-               ensure
-                       db.disconnect if db
-               end
-               return result
-       end
-
+                               rescue DBI::DatabaseError => e
+                                       puts "DB update failed!"
+                                       puts e.errstr
+                                       result = false
+                               ensure
+                                       db.disconnect if db
+                               end
+                               return result
+                       end
 
-       # load
-       def load_db()
-               result = true
-               @distributions = []
 
-               sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@server.id}/server.db"
-               begin
-                       # open DB
-                       db = DBI.connect(sqlite_db_file)
+                       # load
+                       def load_db()
+                               result = true
+                               @distributions = []
+
+                               sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@server.id}/server.db"
+                               begin
+                                       # open DB
+                                       db = DBI.connect(sqlite_db_file)
+
+                                       # distributions
+                                       rs = db.execute "SELECT * FROM distributions"
+                                       rs.fetch_hash { |row|
+                                               pkgsvr_ip = row['pkgsvr_addr'].split(":")[0]
+                                               pkgsvr_port = row['pkgsvr_addr'].split(":")[1].to_i
+                                               add_distribution_internal(row['name'], row['pkgsvr_url'], pkgsvr_ip, pkgsvr_port)
+                                       }
+                                       rs.finish
+                               rescue DBI::DatabaseError => e
+                                       puts "DB loading failed!"
+                                       puts e.errstr
+                                       result = false
+                               ensure
+                                       rs.finish if not rs.finished?
+                                       db.disconnect if db
+                               end
+                               return result
+                       end
 
-                       # distributions
-                       rs = db.execute "SELECT * FROM distributions"
-                       rs.fetch_hash { |row|
-                               pkgsvr_ip = row['pkgsvr_addr'].split(":")[0]
-                               pkgsvr_port = row['pkgsvr_addr'].split(":")[1].to_i
-                               add_distribution_internal(row['name'], row['pkgsvr_url'], pkgsvr_ip, pkgsvr_port)
-                       }
-                       rs.finish
-               rescue DBI::DatabaseError => e
-                       puts "DB loading failed!"
-                       puts e.errstr
-                       result = false
-               ensure
-                       rs.finish if not rs.finished?
-                       db.disconnect if db
-               end
-               return result
-       end
 
+                       def add_distribution_internal(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port)
+                               @distributions.push PackageDistribution.new(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, @server)
+                       end
 
-       def add_distribution_internal(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port)
-               @distributions.push PackageDistribution.new(name, pkgsvr_url, pkgsvr_ip, pkgsvr_port, @server)
-       end
 
+                       def remove_distribution_internal(name)
+                               @distributions.delete get_distribution(name)
+                       end
 
-       def remove_distribution_internal(name)
-               @distributions.delete get_distribution(name)
-       end
 
-       
-       def get_all_distributions()
-               return @distributions
-       end
+                       def get_all_distributions()
+                               return @distributions
+                       end
 
-       #END
-end
+                       #END
+               end
index abbb10b347c6c09647a5834b13f899ff34af999d..2d744fadd797961c6a5fa1cbce9629d272a371a7 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  GitBuildJob.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -63,7 +63,7 @@ class GitBuildJob < BuildJob
                        @log.info( "Updating the source info for project \"#{@project.name}\"" , Log::LV_USER)
                        @project.add_source_info( @pkginfo.get_version(), @git_commit)
                        @project.copy_package_info( @pkginfo.get_version(), 
-                               "#{@source_path}/package/pkginfo.manifest")
+                                                                          "#{@source_path}/package/pkginfo.manifest")
                        @project.set_log_cnt( @log.cnt )
                        @project.write_ext_info
 
@@ -150,7 +150,7 @@ class GitBuildJob < BuildJob
 
                # set up pkg info
                begin
-               @pkginfo = PackageManifest.new("#{@source_path}/package/pkginfo.manifest")
+                       @pkginfo = PackageManifest.new("#{@source_path}/package/pkginfo.manifest")
                rescue => e
                        @log.error( e.message, Log::LV_USER)
                        return false
@@ -159,7 +159,7 @@ class GitBuildJob < BuildJob
                #set up change log
                change_log = {}
                begin
-               change_log = Parser.read_changelog "#{@source_path}/package/changelog" if File.exist? "#{@source_path}/package/changelog"
+                       change_log = Parser.read_changelog "#{@source_path}/package/changelog" if File.exist? "#{@source_path}/package/changelog"
                rescue => e
                        @log.error( e.message, Log::LV_USER)
                        return false
@@ -218,7 +218,7 @@ class GitBuildJob < BuildJob
                if not File.exist? cache_path then
                        FileUtils.mkdir_p cache_path
                end
-       
+
                # check branch name
                if File.exist? git_path then
                        current_branch =  git_cmd_return( "branch",  git_path).select{|x| x.start_with?("*")}[0].split(" ")[1].strip
@@ -277,8 +277,8 @@ class GitBuildJob < BuildJob
 
 
        protected
-    def git_cmd(cmd, working_dir, log)
-        build_command = "cd \"#{working_dir}\";#{@server.git_bin_path} #{cmd}"
+       def git_cmd(cmd, working_dir, log)
+               build_command = "cd \"#{working_dir}\";#{@server.git_bin_path} #{cmd}"
 
                pid, status = execute_command( build_command )
                if not status.nil? and status.exitstatus != 0 then 
@@ -290,10 +290,10 @@ class GitBuildJob < BuildJob
 
 
        protected
-    def git_cmd_return(cmd, working_dir)
-        build_command = "cd \"#{working_dir}\";#{@server.git_bin_path} #{cmd}"
+       def git_cmd_return(cmd, working_dir)
+               build_command = "cd \"#{working_dir}\";#{@server.git_bin_path} #{cmd}"
                ret = Utils.execute_shell_return(build_command)
-               
+
                return ret
        end
 end
index 670e86764892c73d20a7b4a968216c98ad295a3c..86ee54805ea3d72a80cdabf03315f22336b5826c 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  GitProject.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -80,7 +80,7 @@ class GitBuildProject < CommonProject
                if not commit.nil? then
                        new_job.git_commit = commit
                end
-               
+
                return new_job
        end
 
@@ -125,7 +125,7 @@ class GitBuildProject < CommonProject
        # add package info
        def add_package_info( version, path )
                begin
-               pkginfo =PackageManifest.new(path)
+                       pkginfo =PackageManifest.new(path)
                rescue => e
                        puts e.message
                        return
@@ -173,7 +173,7 @@ class GitBuildProject < CommonProject
                pkg_list.each do |pkg|
                        if pkg.package_name.eql? name  then return true end
                end
-               
+
                return false
        end
 
@@ -187,7 +187,7 @@ class GitBuildProject < CommonProject
                return true
        end
 
-       
+
        def load_db()
                # git
                config_file = "#{@path}/build"
@@ -222,13 +222,13 @@ class GitBuildProject < CommonProject
                                end
                        end             
                end
-       
+
                # read pkginfo
                pkginfo_dir = "#{@path}/pkginfos"
                if not File.exist? pkginfo_dir then FileUtils.mkdir_p pkginfo_dir end
                Dir.new(pkginfo_dir).entries.each do |file|
                        if file.eql? "." or file.eql? ".." then next end
-               
+
                        vlen = file.length - ".manifest".length 
                        version = file[0,vlen]
                        add_package_info( version, "#{pkginfo_dir}/#{file}" )
index 64265d7140341672338f0a7859a3593f31fcb536..509ca9a52705961c06805de31bf6d32ddf66f2ed 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  JobClean.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -37,7 +37,7 @@ require "ScheduledActionHandler.rb"
 $access_listfile = Mutex.new
 
 class JobCleanAction < Action
-       
+
        def initialize( time, job_path, list_file, server )
                super(time,0)
 
@@ -139,7 +139,7 @@ class JobCleaner
                                        hour = l.split(",")[4]  
                                        min = l.split(",")[5]   
                                        sec = l.split(",")[6]
-                       
+
                                        # create job and register       
                                        job_path = "#{jobs_path}/#{id}" 
                                        time = Time.mktime(year.to_i, month.to_i, day.to_i, hour.to_i, min.to_i, sec.to_i)      
@@ -170,7 +170,7 @@ class JobCleaner
                @handler.start 
        end
 
-       
+
        # clean after some time
        def clean_afterwards(job_id)
                time = Time.now + @server.keep_time
index e005207273b1f06456286e4baabdad1dbb93a7f8..11bcd66547341da0b2fab19d8aab325a0fb7a4b9 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  JobLog.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
index cd5ee6a9fd84255638062d784eaab8dbfc974851..e7d1ec6bd047a82005969fb4ac2c1efbc07e44ad 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  JobManager.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -90,7 +90,7 @@ class JobManager
                return new_idx
        end
 
-       
+
        def create_new_register_job( file_path, dist_name )
                return RegisterPackageJob.new( file_path, nil, @parent, nil, dist_name )
        end
@@ -141,10 +141,10 @@ class JobManager
                                        job.status = "WAITING"
                                end
                                @parent.log.info "Checking the job \"#{job.id}\" was finished!"
-                       rescue => e
-                               @parent.log.error e.message
-                               @parent.log.error e.backtrace.inspect
-                       end
+               rescue => e
+                       @parent.log.error e.message
+                       @parent.log.error e.backtrace.inspect
+               end
                }
                @parent.log.info "Job \"#{job.id}\" entered INITIALIZING status" 
        end
@@ -193,10 +193,10 @@ class JobManager
 
                                # call terminate process for job
                                job.terminate
-                       rescue => e
-                               @parent.log.error e.message
-                               @parent.log.error e.backtrace.inspect
-                       end
+               rescue => e
+                       @parent.log.error e.message
+                       @parent.log.error e.backtrace.inspect
+               end
                }
        end
 
@@ -273,7 +273,7 @@ class JobManager
                        if ( job.status == "WAITING" or job.status == "REMOTE_WORKING" or job.status == "PENDING") and 
                                not job.is_asynchronous_job? and 
                                not job.is_connected? then
-                       
+
                                job.status = "ERROR"
                                @jobs.delete( job )
                                @parent.log.info "Job \"#{job.id}\" is disconnected by user. Removed!"
@@ -349,7 +349,7 @@ class JobManager
                end
 
                parent_list.uniq!
-               
+
                return @max_working_jobs - working_cnt + parent_list.count
        end
 
@@ -447,7 +447,7 @@ class JobManager
                jobs.each do |job|
                        if job.cancel_state != "NONE" then next end
                        if job.status != "WAITING" then next end
-                       
+
                        # check build dependency against working job
                        pre_jobs = []
                        check_dep_jobs.each do |cjob|
@@ -456,13 +456,13 @@ class JobManager
                                if (cjob.status == "WORKING" or cjob.status == "REMOTE_WORKING" ) and
                                        (job.has_build_dependency?( cjob ) or job.is_compatible_with?( cjob)) then
                                        pre_jobs.push cjob
-                               # In case that "PENDING" job is depends on me (not depended )
+                                       # In case that "PENDING" job is depends on me (not depended )
                                elsif cjob.status == "PENDING"  and (not job.does_depend_on? cjob) and
                                        (job.has_build_dependency?( cjob ) or job.is_compatible_with?( cjob)) then
                                        pre_jobs.push cjob
                                elsif check_dep_wait and cjob.status == "WAITING" and 
                                        (job.does_depend_on? cjob or
-                                         (job.id > cjob.id and job.is_compatible_with? cjob) ) then
+                                        (job.id > cjob.id and job.is_compatible_with? cjob) ) then
                                        pre_jobs.push cjob
                                end
                        end
index 8b4daec832f11bd7eb5cc935cc6f8747db086697..011dc8b3fc715fe0cc37bd619f3bd99c893cd322 100644 (file)
@@ -138,34 +138,34 @@ class MultiBuildJob < CommonJob
                @pkgsvr_ip = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_ip
                @pkgsvr_port = @server.distmgr.get_distribution(first_project.dist_name).pkgsvr_port
                @pkgsvr_client =  Client.new(@pkgsvr_url, @job_working_dir, @log)
-       
+
                return true
        end
 
 
        #terminate
        def terminate()
+
                # report error
                if @status == "ERROR" then
                        # register delayed clean action for sub jobs
                        @sub_jobs.each do |job|
-               @server.cleaner.clean_afterwards(job.id)
+                               @server.cleaner.clean_afterwards(job.id)
                        end
 
                        # register delayed clean action for me
                        @log.error( "Job is stopped by ERROR" , Log::LV_USER)
                        @server.cleaner.clean_afterwards(@id)
 
-        elsif @status == "CANCELED" then
+               elsif @status == "CANCELED" then
                        # register delayed clean action for sub jobs
                        @sub_jobs.each do |job|
-               @server.cleaner.clean_afterwards(job.id)
+                               @server.cleaner.clean_afterwards(job.id)
                        end
 
                        # register delayed clean action for me
-            @log.error( "Job is stopped by CANCEL" , Log::LV_USER)
-            @server.cleaner.clean_afterwards(@id)
+                       @log.error( "Job is stopped by CANCEL" , Log::LV_USER)
+                       @server.cleaner.clean_afterwards(@id)
 
                else
                        # terminate all sub jobs
@@ -228,8 +228,8 @@ class MultiBuildJob < CommonJob
        def has_build_dependency?(other_job)
 
                if has_same_packages?(other_job) or
-                         does_depend_on?(other_job) or
-                         does_depended_by?(other_job) then
+                       does_depend_on?(other_job) or
+                       does_depended_by?(other_job) then
 
                        return true
                else
@@ -268,7 +268,7 @@ class MultiBuildJob < CommonJob
                if get_distribution_name() != wjob.get_distribution_name() then
                        return false
                end
+
                # compare build dependency
                get_build_dependencies(@os).each do |dep|
                        wjob.get_packages().each do |wpkg|
@@ -281,7 +281,7 @@ class MultiBuildJob < CommonJob
                                end
                        end
                end
-               
+
                return false
        end
 
@@ -338,30 +338,30 @@ class MultiBuildJob < CommonJob
                @log.info( "Invoking a thread for MULTI-BUILD Job #{@id}", Log::LV_USER)
                if @status == "ERROR" then return end
                @log.info( "New Job #{@id} is started", Log::LV_USER)
-       
+
                # initialize status map
                job_status_map = {}
                @sub_jobs.each do |job|
                        job_status_map[job.id] = job.status
                end
-                       
+
                # add to internal job
                @server.jobmgr.internal_job_schedule.synchronize {
                        @sub_jobs.each do |job|
                                # init finished, add internal_jobs
                                @server.jobmgr.add_internal_job(job)
                                @log.info( "Added new job \"#{job.get_project().name}\" for #{job.os}! (#{job.id})",
-                                       Log::LV_USER)
-                               if not @server.job_log_url.empty? then
-                                       @log.info( " * Log URL : #{@server.job_log_url}/#{job.id}/log", Log::LV_USER)
-                               end
+                                                 Log::LV_USER)
+                                                 if not @server.job_log_url.empty? then
+                                                         @log.info( " * Log URL : #{@server.job_log_url}/#{job.id}/log", Log::LV_USER)
+                                                 end
                        end
                }
 
                # show job status changes
                all_jobs_finished = false
                stop_status = "FINISHED"
-        while not all_jobs_finished
+               while not all_jobs_finished
                        all_jobs_finished = true
                        @sub_jobs.each do |job|
                                # check status chanaged, if then print
@@ -379,11 +379,11 @@ class MultiBuildJob < CommonJob
                                        # write url 
                                        write_log_url(job)
                                        # cancel all other un-finished jobs
-                       @sub_jobs.each do |sub|
-                               if sub.status != "ERROR" and sub.status != "FINISHED" and 
-                               sub.status != "CANCELED" and sub.cancel_state == "NONE" then
+                                       @sub_jobs.each do |sub|
+                                               if sub.status != "ERROR" and sub.status != "FINISHED" and 
+                                                       sub.status != "CANCELED" and sub.cancel_state == "NONE" then
                                                        @log.info(" * Sub-Job \"#{sub.get_project().name}(#{sub.os})\" has entered \"CANCELING\" state. (#{sub.id})", Log::LV_USER)
-                                       sub.cancel_state = "INIT"
+                                                       sub.cancel_state = "INIT"
                                                end
                                        end
 
@@ -416,7 +416,7 @@ class MultiBuildJob < CommonJob
        private 
        def upload()
                @log.info( "Uploading ...", Log::LV_USER)
-       
+
                # get package path list
                binpkg_path_list = Dir.glob("#{@source_path}/*_*_*.zip")
 
@@ -429,12 +429,12 @@ class MultiBuildJob < CommonJob
 
                        return false
                end
-       
+
                # update local
                @log.info( "Upload succeeded. Sync local pkg-server again...", Log::LV_USER)
                @pkgsvr_client.update
                @log.info("Snapshot: #{snapshot}", Log::LV_USER)
-       
+
                return true
        end
 
index c3bd3fdd8788cf34d6ea9c1774d3819f9725c54e..4f8f1d6423a201c0a9db3b5da3c6f28ecaec541e 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  PackageSync.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -37,7 +37,7 @@ require "ScheduledActionHandler.rb"
 
 class PackageSyncAction < Action
        @@new_id = 0
-       
+
        def initialize( time, url, dist_name, server )
                super(time, server.pkg_sync_period)
                my_id = @@new_id
@@ -73,7 +73,7 @@ class PackageSyncAction < Action
 
        def execute
                @server.log.info "Executing package-sync action for server \"#{@pkgsvr_url}\""
-               
+
                begin
                        execute_internal()
                rescue => e
@@ -113,7 +113,7 @@ class PackageSyncAction < Action
 
                # wait for finish all jobs
                all_jobs_finished = false
-        while not all_jobs_finished
+               while not all_jobs_finished
                        unfinished_jobs = registered_jobs.select { |j| 
                                (j.status != "ERROR" and j.status != "FINISHED" and j.status != "CANCELED")
                        }
@@ -123,7 +123,7 @@ class PackageSyncAction < Action
                                sleep 10
                        end
                end
-       
+
                # remove files  
                downloaded_files.each { |file_path|
                        @server.log.info "Removed downloaded file: \"#{file_path}\""
@@ -150,7 +150,7 @@ class PackageSyncAction < Action
                                if main_ver.nil? then next end
                                remote_ver = @pkgsvr_client.get_attr_from_pkg(pkg_name, os, "version")
                                if remote_ver.nil? then next end
-       
+
                                if Version.new(main_ver) < Version.new(remote_ver) then
                                        pkgs.push [pkg_name, os]
                                end
index 2fb36a3005794427b2f5ce47c2db914219b79dda..1908d567644d60caf82737ecc2cd7525336cdbfc 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  ProjectManager.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -63,7 +63,7 @@ class ProjectManager
                @projects.each do |prj|
                        if prj.name == name and prj.dist_name == dist_name then return prj end
                end
-       
+
                return nil
        end
 
@@ -73,7 +73,7 @@ class ProjectManager
 
                prj = get_project(name, dist_name)
                if not prj.nil? then return false end
-               
+
                new_prj = GitBuildProject.new(name, @server, os_list, dist_name, repos, branch)
                if not passwd.nil? and not passwd.empty? then
                        new_prj.passwd = passwd
@@ -98,7 +98,7 @@ class ProjectManager
 
                prj = get_project(name, dist_name)
                if not prj.nil? then return false end
-               
+
                new_prj = BinaryUploadProject.new(name, @server, os_list, dist_name, pkg_name)
                if not passwd.nil? and not passwd.empty? then
                        new_prj.passwd = passwd
@@ -166,17 +166,17 @@ class ProjectManager
                @projects.each do |prj|
                        if prj.type != "GIT" then next end      
                        if prj.dist_name != dist_name then next end
-       
+
                        prj.os_list.each do |os|
                                if not @server.supported_os_list.include? os then next end
-                               
+
                                new_job = create_new_job( prj.name, os, dist_name )
                                if new_job.nil? then next end
 
                                # This make project to build 
                                # even though there is a package of same version on pkg-server
                                new_job.set_force_rebuild(true)
-       
+
                                # add to multi job
                                result.add_sub_job( new_job )   
                        end     
@@ -231,7 +231,7 @@ class ProjectManager
                                return prj 
                        end
                }
-       
+
                return nil
        end
 
@@ -273,96 +273,96 @@ class ProjectManager
 
                                if not prj.save_db() then raise RuntimeError ,"Save project DB is failed!" end
                        }
-               rescue DBI::DatabaseError => e
-                       puts "DB update failed!"
-                       puts e.errstr
-                       result = false
-               ensure
-                       db.disconnect if db
-               end
-               return result
-       end
-
-
-       # load
-       def load_db()
-               result = true
-               @projects = []
-
-               sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@server.id}/server.db"
-               begin
-                       # open DB
-                       db = DBI.connect(sqlite_db_file)
-
-                       # distributions
-                       rs = db.execute "SELECT * FROM projects"
-                       rs.fetch_hash { |row|
-                               prj_id = row['id']
-                               prj_name = row['name']
-                               prj_type = row['type']
-                               prj_passwd = row['password']
-                               prj_dist = row['dist_name']
-
-                               @server.log.info "Loading project : #{prj_name}"
-                               # os
-                               prj_os_list = []
-                               rs2 = db.execute "SELECT os_name FROM project_os WHERE prj_id = #{prj_id}"
-                               rs2.fetch { |row2|
-                                       prj_os_list.push row2[0]
-                               }
-                               rs2.finish
-                               if prj_type == "GIT" then
-                                       new_project = GitBuildProject.new(prj_name, @server, prj_os_list, prj_dist)
-                               else
-                                       new_project = BinaryUploadProject.new(prj_name, @server, prj_os_list, prj_dist)
+                                       rescue DBI::DatabaseError => e
+                                               puts "DB update failed!"
+                                               puts e.errstr
+                                               result = false
+                                       ensure
+                                               db.disconnect if db
+                                       end
+                                       return result
                                end
 
-                               if not prj_passwd.empty? then
-                                       new_project.passwd = prj_passwd
+
+                               # load
+                               def load_db()
+                                       result = true
+                                       @projects = []
+
+                                       sqlite_db_file = "DBI:SQLite3:#{BuildServer::CONFIG_ROOT}/#{@server.id}/server.db"
+                                       begin
+                                               # open DB
+                                               db = DBI.connect(sqlite_db_file)
+
+                                               # distributions
+                                               rs = db.execute "SELECT * FROM projects"
+                                               rs.fetch_hash { |row|
+                                                       prj_id = row['id']
+                                                       prj_name = row['name']
+                                                       prj_type = row['type']
+                                                       prj_passwd = row['password']
+                                                       prj_dist = row['dist_name']
+
+                                                       @server.log.info "Loading project : #{prj_name}"
+                                                       # os
+                                                       prj_os_list = []
+                                                       rs2 = db.execute "SELECT os_name FROM project_os WHERE prj_id = #{prj_id}"
+                                                       rs2.fetch { |row2|
+                                                               prj_os_list.push row2[0]
+                                                       }
+                                                       rs2.finish
+                                                       if prj_type == "GIT" then
+                                                               new_project = GitBuildProject.new(prj_name, @server, prj_os_list, prj_dist)
+                                                       else
+                                                               new_project = BinaryUploadProject.new(prj_name, @server, prj_os_list, prj_dist)
+                                                       end
+
+                                                       if not prj_passwd.empty? then
+                                                               new_project.passwd = prj_passwd
+                                                       end
+
+                                                       if not new_project.load_db() then raise RuntimeError, "Project DB load failed!" end
+                                                       @projects.push new_project
+                                               }
+                                               rs.finish
+                                       rescue DBI::DatabaseError => e
+                                               puts "DB loading failed!"
+                                               puts e.errstr
+                                               result = false
+                                       ensure
+                                               rs.finish if not rs.finished?
+                                               db.disconnect if db
+                                       end
+                                       return result
                                end
 
-                               if not new_project.load_db() then raise RuntimeError, "Project DB load failed!" end
-                               @projects.push new_project
-                       }
-                       rs.finish
-               rescue DBI::DatabaseError => e
-                       puts "DB loading failed!"
-                       puts e.errstr
-                       result = false
-               ensure
-                       rs.finish if not rs.finished?
-                       db.disconnect if db
-               end
-               return result
-       end
 
+                               # write configuration
+                               def write_configuration(name, repos, branch, passwd, os_list  )
+                                       config_file = "#{@project_root}/#{name}/build"
+                                       File.open( config_file, "w" ) do |f|
+                                               f.puts "TYPE=GIT"
+                                               if not passwd.nil? and not passwd.empty? then
+                                                       f.puts "PASSWD=#{passwd}"
+                                               end
+                                               f.puts "GIT_REPOSITORY=#{repos}"
+                                               f.puts "GIT_BRANCH=#{branch}"
+                                               f.puts "OS_LIST=#{os_list.join(",")}"
+                                       end
+                               end
 
-       # write configuration
-       def write_configuration(name, repos, branch, passwd, os_list  )
-               config_file = "#{@project_root}/#{name}/build"
-               File.open( config_file, "w" ) do |f|
-                       f.puts "TYPE=GIT"
-                       if not passwd.nil? and not passwd.empty? then
-                               f.puts "PASSWD=#{passwd}"
-                       end
-                       f.puts "GIT_REPOSITORY=#{repos}"
-                       f.puts "GIT_BRANCH=#{branch}"
-                       f.puts "OS_LIST=#{os_list.join(",")}"
-               end
-       end
 
+                               # write configuration
+                               def write_configuration_for_binary_project(name, pkg_name, passwd, os_list  )
+                                       config_file = "#{@project_root}/#{name}/build"
+                                       File.open( config_file, "w" ) do |f|
+                                               f.puts "TYPE=BINARY"
+                                               if not passwd.nil? and not passwd.empty? then
+                                                       f.puts "PASSWD=#{passwd}"
+                                               end
+                                               f.puts "PACKAGE_NAME=#{pkg_name}"
+                                               f.puts "OS_LIST=#{os_list.join(",")}"
+                                       end
+                               end
 
-       # write configuration
-       def write_configuration_for_binary_project(name, pkg_name, passwd, os_list  )
-               config_file = "#{@project_root}/#{name}/build"
-               File.open( config_file, "w" ) do |f|
-                       f.puts "TYPE=BINARY"
-                       if not passwd.nil? and not passwd.empty? then
-                               f.puts "PASSWD=#{passwd}"
                        end
-                       f.puts "PACKAGE_NAME=#{pkg_name}"
-                       f.puts "OS_LIST=#{os_list.join(",")}"
-               end
-       end
-
-end
index f141982d2ef0fb2271228935493e105fe117cf8b..76c6108d39789a0e71042cf4039021df311cf64c 100644 (file)
@@ -47,7 +47,7 @@ class RegisterPackageJob < CommonJob
        attr_accessor :source_path
        attr_accessor :pkgsvr_client, :thread, :pkg_type
        attr_accessor :pkg_name, :pkginfo, :cancel_state
-       
+
 
        # initialize
        def initialize( local_path, project, server, ftpurl=nil, dist_name=nil )
@@ -75,7 +75,7 @@ class RegisterPackageJob < CommonJob
                @local_path=local_path
                @file_path = nil
                @filename = File.basename(local_path)
-               if @filename =~ /.*_.*_.*\.zip/ then
+               if @filename =~ /.*_.*_.*\.zip/ then
                        @pkg_type = "BINARY"
                        new_name = @filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
                        @pkg_name = new_name.split(",")[0]
@@ -265,7 +265,7 @@ class RegisterPackageJob < CommonJob
 
        def has_build_dependency?(other_job)
                if has_same_packages?(other_job) or
-                         does_depended_by?(other_job) then
+                       does_depended_by?(other_job) then
 
                        return true
                else
@@ -385,7 +385,7 @@ class RegisterPackageJob < CommonJob
                # if this package has compatible OS, check 
                if @pkg_type == "BINARY" and 
                        @pkginfo.packages[0].os_list.count > 1 then
-               
+
                        pkg = @pkginfo.packages[0]      
                        pkg.os_list.each do |os|
                                if @os == os then next end
@@ -436,7 +436,7 @@ class RegisterPackageJob < CommonJob
                else
                        rev_pkgs += @pkgsvr_client.get_reverse_source_dependent_packages(@pkg_name)
                end
-                       
+
                rev_projects = @server.prjmgr.get_projects_from_pkgs(rev_pkgs)
 
                # create reverse build job
@@ -488,7 +488,7 @@ class RegisterPackageJob < CommonJob
 
        def upload()
                @log.info( "Uploading ...", Log::LV_USER)
-       
+
                # get package path list
                if @pkg_type == "ARCHIVE" then
                        binpkg_path_list = Dir.glob("#{@source_path}/#{@pkg_name}")
@@ -505,12 +505,12 @@ class RegisterPackageJob < CommonJob
 
                        return false
                end
-       
+
                # update local
                @log.info( "Upload succeeded. Sync local pkg-server again...", Log::LV_USER)
                @pkgsvr_client.update
                @log.info("Snapshot: #{snapshot}", Log::LV_USER)
-       
+
                return true
        end
 
@@ -525,7 +525,7 @@ class RegisterPackageJob < CommonJob
                @pkginfo.packages.each do |pkg|
                        ver_local = pkg.version
                        #ver_svr = @pkgsvr_client.get_package_version( pkg.package_name, @os )
-            ver_svr = @pkgsvr_client.get_attr_from_pkg( pkg.package_name, @os, "version")
+                       ver_svr = @pkgsvr_client.get_attr_from_pkg( pkg.package_name, @os, "version")
                        if not ver_svr.nil? and Version.new(ver_local) <= Version.new(ver_svr) then
                                @log.error( "Version must be increased : #{ver_local} <= #{ver_svr}", Log::LV_USER)
                                return false
index 7e538ce46daf17b4e692965e2c1cafa1c5c7b8c3..f2679c780b8c47f837191a5dd3c51271816bb980 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  RemoteBuildServer.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -94,7 +94,7 @@ class RemoteBuildServer
                if client.send("QUERY|JOB") then
                        result = client.read_lines do |l|
                                tok = l.split(",").map { |x| x.strip }
-                               
+
                                job_status = tok[0]
                                job_id = tok[1]
                                new_job = RemoteBuildJob.new(job_id,self)
index 02e04c2406be7d888e1d5112930214c92e09ef90..557b4eef131f1b83c86caa60df292c8de65f4734 100644 (file)
@@ -62,8 +62,8 @@ class RemoteBuilder
 
                # build
                ret = build(@job.get_project().repository, @job.source_path, @job.os, 
-                       @job.is_rev_build_check_job(), @job.git_commit, @job.no_reverse,
-                       local_pkgs, @job.get_project().dist_name )
+                                       @job.is_rev_build_check_job(), @job.git_commit, @job.no_reverse,
+                                       local_pkgs, @job.get_project().dist_name )
 
                # reset job
                @job = nil
@@ -73,7 +73,7 @@ class RemoteBuilder
                return ret
        end
 
-       
+
        # build
        def build( git_repos, source_path, os, is_rev_build, srcinfo, no_reverse, local_pkgs, dist_name )
                @log.info( "Start to build on remote server...", Log::LV_USER )
@@ -85,10 +85,10 @@ class RemoteBuilder
                begin
                        @server.add_file_transfer()
                        local_pkgs.each do |pkg_path|
-                       @log.info( "Sending file... : #{pkg_path}", Log::LV_USER )
+                               @log.info( "Sending file... : #{pkg_path}", Log::LV_USER )
                                result = send_file_to_remote( pkg_path, dock )
                                if not result then
-                       @log.error( "File transfering failed!", Log::LV_USER )
+                                       @log.error( "File transfering failed!", Log::LV_USER )
                                        @server.remove_file_transfer()
                                        return false
                                end
@@ -100,24 +100,24 @@ class RemoteBuilder
                # send build request
                @log.info( "Sending build request to remote server...", Log::LV_USER )
                result, result_files = send_build_request(git_repos, os,
-                       is_rev_build, srcinfo, no_reverse, local_pkgs, dock, dist_name)
+                                                                                                 is_rev_build, srcinfo, no_reverse, local_pkgs, dock, dist_name)
 
-        @log.info( "Receiving log file from remote server...", Log::LV_USER )
+               @log.info( "Receiving log file from remote server...", Log::LV_USER )
                if not receive_file_from_remote( "#{source_path}/../remote_log", dock ) then
-               @log.warn( "File transfering failed! : remote_log", Log::LV_USER )
+                       @log.warn( "File transfering failed! : remote_log", Log::LV_USER )
                end
 
                if not result then
-               @log.error( "Building job on remote server failed!", Log::LV_USER )
+                       @log.error( "Building job on remote server failed!", Log::LV_USER )
                        return false
                end     
 
                # receive binary package
                result_files.each do |file_name|
-               @log.info( "Receiving file from remote server : #{file_name}", Log::LV_USER )
+                       @log.info( "Receiving file from remote server : #{file_name}", Log::LV_USER )
                        result = receive_file_from_remote( "#{source_path}/#{file_name}", dock )
                        if not result then
-               @log.error( "File transfering failed! : #{file_name}", Log::LV_USER )
+                               @log.error( "File transfering failed! : #{file_name}", Log::LV_USER )
                                return false
                        end
                end     
@@ -131,11 +131,11 @@ class RemoteBuilder
        protected
        def send_file_to_remote(file_path, dock = "0")
                # create client
-        client = BuildCommClient.create( @addr, @port, @log ) 
-        if client.nil? then
+               client = BuildCommClient.create( @addr, @port, @log ) 
+               if client.nil? then
                        @log.error( "Creating communication client failed!", Log::LV_USER)
-            return false 
-        end
+                       return false 
+               end
 
                # upload file
                result = true
@@ -156,7 +156,7 @@ class RemoteBuilder
 
                #close connections
                client.terminate
-               
+
                return result
        end
 
@@ -166,16 +166,16 @@ class RemoteBuilder
        def send_build_request(git_repos, os, is_rev_build, commit, no_reverse, local_pkgs, dock = "0", dist_name="BASE")
                result_files = []
 
-        client = BuildCommClient.create( @addr, @port, @log ) 
-        if client.nil? then
+               client = BuildCommClient.create( @addr, @port, @log ) 
+               if client.nil? then
                        @log.error( "Creating communication client failed!", Log::LV_USER)
-            return false, result_files 
-        end                                                                                            
-      
+                       return false, result_files 
+               end                                                                                            
+
                # get local package names
                local_pkg_names = local_pkgs.map { |path| File.basename(path) }
 
-        # send
+               # send
                # format: BUILD|GIT|repository|passwd|os|async|no_reverse|internal|rev-build|commit|pkgs|dock_num|dist_name
                # value : BUILD|GIT|repository|      |os|NO   |no_reverse|YES     |rev-build|commit|pkgs|dock_num|dist_name
                result = true
@@ -184,22 +184,22 @@ class RemoteBuilder
                rev = is_rev_build ? "YES":"NO"
                msg = "BUILD|GIT|#{git_repos}||#{os}|NO|#{no_reverse}|YES|#{rev}|#{commit}|#{pkg_list}|#{dock}|#{dist_name}"
                r_job_number = Regexp.new('Added new job "([^"]*)"')
-        if client.send( msg ) then 
-            result = client.read_lines do |l|
-                # write log first
-                @log.output( l.strip, Log::LV_USER)
+               if client.send( msg ) then 
+                       result = client.read_lines do |l|
+                               # write log first
+                               @log.output( l.strip, Log::LV_USER)
 
                                # set remote job id
                                if @remote_id.nil? and l =~ r_job_number then
                                        @remote_id = $1
                                end
+
                                # check build result
-                if l.include? "Job is stopped by ERROR" or
+                               if l.include? "Job is stopped by ERROR" or
                                        l.include? "Error:" then                                           
-                    result = false
+                                       result = false
                                        break
-                end
+                               end
 
                                # gather result files if not reverse build
                                if not is_rev_build and l =~ /Creating package file \.\.\. (.*)/ then
@@ -207,12 +207,12 @@ class RemoteBuilder
                                        result_files.push file_name
                                end
 
-            end
-        end                                                                                            
-        
-        # close socket
-        client.terminate
-               
+                       end
+               end                                                                                            
+
+               # close socket
+               client.terminate
+
                return result, result_files
        end
 
@@ -221,31 +221,31 @@ class RemoteBuilder
        protected
        def receive_file_from_remote(file_path, dock = "0")
                # create client
-        client = BuildCommClient.create( @addr, @port, @log ) 
-        if client.nil? then
+               client = BuildCommClient.create( @addr, @port, @log ) 
+               if client.nil? then
                        @log.error( "Creating communication client failed!", Log::LV_USER)
-            return false 
-        end
+                       return false 
+               end
 
                # download file
                result = true
                file_name = file_path.split("/")[-1]
                msg = "DOWNLOAD|#{dock}|#{file_name}"
-               if client.send( msg ) then
-                       if not @ftp_addr.nil? then
-                               transporter=FileTransferFTP.new(@log, @ftp_addr, @ftp_port, @ftp_username, @ftp_passwd)
-                       else
-                               transporter=FileTransferDirect.new(@log)
-                       end
-                       result=client.receive_file(file_path, transporter)
-                       if not result then
-                               @log.error( "File downloading failed...#{file_name}", Log::LV_USER)
-                       end
+                       if client.send( msg ) then
+                               if not @ftp_addr.nil? then
+                                       transporter=FileTransferFTP.new(@log, @ftp_addr, @ftp_port, @ftp_username, @ftp_passwd)
+                               else
+                                       transporter=FileTransferDirect.new(@log)
+                               end
+                               result=client.receive_file(file_path, transporter)
+                               if not result then
+                                       @log.error( "File downloading failed...#{file_name}", Log::LV_USER)
+                               end
                end
 
                #close connections
                client.terminate
-               
+
                return result
        end
 end
index ed3e476d8453b940ea7a281e31ee9d1dc7d1907d..b42ffd21167214480402b61fa87d2b49962edd30 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  ReverseBuildChecker.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -92,7 +92,7 @@ class ReverseBuildChecker
                                job.pending_ancestor.rev_fail_projects.each { |fp|
                                        f_prj = fp[0]
                                        f_os =  fp[1]
+
                                        if rev_prj == f_prj and rev_os == f_os then     
                                                found = true
                                                break
@@ -132,7 +132,7 @@ class ReverseBuildChecker
                        # add to job manager    
                        job.server.jobmgr.add_reverse_build_job(rev_job)
                        log.info( " * Added new job for reverse-build ... \
-                               #{rev_job.get_project().name}(#{rev_job.os}) (#{rev_job.id})", Log::LV_USER)
+                                        #{rev_job.get_project().name}(#{rev_job.os}) (#{rev_job.id})", Log::LV_USER)
                end
 
                # wait for job finish
index db3546dfeed76f9addb2b8596d31922797058810..6cf2a428725c9420bd81955ff3eab2b4ed499253 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  SocketJobRequestListener.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -53,7 +53,7 @@ class SocketJobRequestListener
                                        @log.error e.message
                                        @log.error e.backtrace.inspect
                                end
-                       end
+               end
                }
        end
 
@@ -63,7 +63,7 @@ class SocketJobRequestListener
        def stop_listening()
                @finish_loop = true
        end
-       
+
        private
 
        # thread main  
@@ -72,7 +72,7 @@ class SocketJobRequestListener
                begin
                        if not @parent_server.ftp_addr.nil? then
                                ftp_url = Utils.generate_ftp_url(@parent_server.ftp_addr, @parent_server.ftp_port,
-                                       @parent_server.ftp_username, @parent_server.ftp_passwd)
+                                                                                                @parent_server.ftp_username, @parent_server.ftp_passwd)
                        else
                                ftp_url = nil
                        end
@@ -89,7 +89,7 @@ class SocketJobRequestListener
                @log.info "Entering Control Listening Loop ... "        
                @finish_loop = false
                @comm_server.wait_for_connection(@finish_loop) do |req|
-                               handle_job_request( req )
+                       handle_job_request( req )
                end     
 
                # quit
@@ -101,7 +101,7 @@ class SocketJobRequestListener
        def wait_for_job_requests
                req_list = []
                req_list.push @tcp_server.accept                
-               
+
                return req_list
        end
 
@@ -118,7 +118,7 @@ class SocketJobRequestListener
                if req_line.split("|").count > 0 then
                        cmd = req_line.split("|")[0].strip 
                end
-               
+
                case  cmd
                when "BUILD"
                        @log.info "Received REQ: #{req_line}"
@@ -145,25 +145,25 @@ class SocketJobRequestListener
                        handle_cmd_register( req_line, req )
                        @log.info "Handled REQ: #{req_line}"
                when "DOWNLOAD"
-            Thread.new {
+                       Thread.new {
                                begin
-                               handle_cmd_download( req_line, req )
-                               rescue => e
-                                       @log.error "Transfering file failed!"
-                                       @log.error e.message
-                                       @log.error e.backtrace.inspect
-                               end
-            }             
+                                       handle_cmd_download( req_line, req )
+                       rescue => e
+                               @log.error "Transfering file failed!"
+                               @log.error e.message
+                               @log.error e.backtrace.inspect
+                       end
+                       }             
                when "UPLOAD"
-            Thread.new {
+                       Thread.new {
                                begin
-                               handle_cmd_upload( req_line, req )
-                               rescue => e
-                                       @log.error "Transfering file failed!"
-                                       @log.error e.message
-                                       @log.error e.backtrace.inspect
-                               end
-            }                
+                                       handle_cmd_upload( req_line, req )
+                       rescue => e
+                               @log.error "Transfering file failed!"
+                               @log.error e.message
+                               @log.error e.backtrace.inspect
+                       end
+                       }                
                else
                        @log.info "Received Unknown REQ: #{req_line}" 
                        raise "Unknown request: #{req_line}"
@@ -245,7 +245,7 @@ class SocketJobRequestListener
                                raise "Multi-Build Job creation failed!"
                        end
 
-               # transfered job
+                       # transfered job
                elsif is_internal then
                        git_repos = project_name_list[0]
                        os = os_list[0]
@@ -253,7 +253,7 @@ class SocketJobRequestListener
                        new_job = create_new_internal_job(git_repos, os, git_commit, pkg_files, dock_num, dist_name )
                        if rev_job then new_job.set_rev_build_check_job(nil) end
 
-               # single job
+                       # single job
                elsif project_name_list.count == 1 and os_list.count == 1 then
                        pname = project_name_list[0]
                        os = os_list[0]
@@ -273,7 +273,7 @@ class SocketJobRequestListener
                logger = JobLog.new( new_job, req )
                if not async then new_job.set_logger(logger) end
                logger.init
-       
+
                # notify that job has been received
                logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
                if not @parent_server.job_log_url.empty? then
@@ -307,13 +307,13 @@ class SocketJobRequestListener
                        raise "Project's password is not matched!!"
                end
 
-        # check project type
-        if prj.type == "BINARY" then
-            BuildCommServer.send_begin(req)
-            req.puts "Can't build about Binary type package."
-            BuildCommServer.send_end(req)
-            raise "Can't build about Binary type package."
-        end
+               # check project type
+               if prj.type == "BINARY" then
+                       BuildCommServer.send_begin(req)
+                       req.puts "Can't build about Binary type package."
+                       BuildCommServer.send_end(req)
+                       raise "Can't build about Binary type package."
+               end
        end
 
 
@@ -326,7 +326,7 @@ class SocketJobRequestListener
                end
 
                case tok[1]
-               # RESOLVE|GIT|repos|commit|os|async
+                       # RESOLVE|GIT|repos|commit|os|async
                when "GIT"
                        # parse
                        project_name=tok[2]
@@ -343,7 +343,7 @@ class SocketJobRequestListener
                        if prj.nil? then
                                raise "Requested project does not exist!"
                        end
-       
+
                        # check passwd
                        if not check_project_password(prj, passwd, req) then
                                raise "Project's password is not matched!!"
@@ -355,7 +355,7 @@ class SocketJobRequestListener
                                raise "Unsupported OS name is used!"
                        end
                        os = os_list[0]
-                       
+
                        # create new job
                        new_job = create_new_job( project_name, os, dist_name )
                        if new_job.nil? then
@@ -370,7 +370,7 @@ class SocketJobRequestListener
                        logger = JobLog.new( new_job, req )
                        if not async then new_job.set_logger(logger) end
                        logger.init
-               
+
                        # notify that job has been received
                        logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
                        if not @parent_server.job_log_url.empty? then
@@ -398,10 +398,10 @@ class SocketJobRequestListener
                        @log.info "Received Wrong REQ: #{line}" 
                        raise "Invalid request format is used: #{line}"
                end
-       
+
                case tok[1]
 
-               # QUERY, FTP
+                       # QUERY, FTP
                when "FTP"
                        BuildCommServer.send_begin(req)
                        if not @parent_server.ftp_addr.nil? then
@@ -412,7 +412,7 @@ class SocketJobRequestListener
                        BuildCommServer.send_end(req)
                        BuildCommServer.disconnect(req)
 
-               # QUERY,JOB
+                       # QUERY,JOB
                when "JOB"
                        #puts "Received QUERY JOB"
 
@@ -452,7 +452,7 @@ class SocketJobRequestListener
                        BuildCommServer.send_end(req)
                        BuildCommServer.disconnect(req)
 
-               # QUERY,SYSTEM
+                       # QUERY,SYSTEM
                when "SYSTEM"
                        #puts "Received QUERY SYSTEM" 
 
@@ -529,26 +529,26 @@ class SocketJobRequestListener
                        raise "There is no job \"#{tok[1]}\""
                else
                        if cancel_job.cancel_state == "NONE" then
-                       # check passwd
-                       if cancel_job.type == "MULTIBUILD" then
-                               cancel_job.get_sub_jobs().select{|x| x.cancel_state == "NONE" }.each do |sub|
-                                       if not check_project_password( sub.get_project, tok[2], req) then
-                                               BuildCommServer.send(req, "Project's password is not matched!!")
-                                               raise "Project's password is not matched!!"
+                               # check passwd
+                               if cancel_job.type == "MULTIBUILD" then
+                                       cancel_job.get_sub_jobs().select{|x| x.cancel_state == "NONE" }.each do |sub|
+                                               if not check_project_password( sub.get_project, tok[2], req) then
+                                                       BuildCommServer.send(req, "Project's password is not matched!!")
+                                                       raise "Project's password is not matched!!"
+                                               end
                                        end
-                               end
 
-                               BuildCommServer.send(req, "\"#{cancel_job.id}, #{cancel_job.get_sub_jobs().map{|x| x.id}.join(", ")}\" will be canceled")
-                               cancel_job.cancel_state = "INIT"
-                       else
-                               if not check_project_password( cancel_job.get_project, tok[2], req) then
-                                       BuildCommServer.send(req, "Project's password is not matched!!")
-                                       raise "Project's password is not matched!!"
-                               else
-                                       BuildCommServer.send(req, "\"#{cancel_job.id}\" will be canceled")
+                                       BuildCommServer.send(req, "\"#{cancel_job.id}, #{cancel_job.get_sub_jobs().map{|x| x.id}.join(", ")}\" will be canceled")
                                        cancel_job.cancel_state = "INIT"
+                               else
+                                       if not check_project_password( cancel_job.get_project, tok[2], req) then
+                                               BuildCommServer.send(req, "Project's password is not matched!!")
+                                               raise "Project's password is not matched!!"
+                                       else
+                                               BuildCommServer.send(req, "\"#{cancel_job.id}\" will be canceled")
+                                               cancel_job.cancel_state = "INIT"
+                                       end
                                end
-                       end
                        else
                                BuildCommServer.send(req, "\"#{cancel_job.id}\" is already canceled")
                        end
@@ -565,7 +565,7 @@ class SocketJobRequestListener
                        @log.info "Received Wrong REQ: #{line}" 
                        raise "Invalid request format is used: #{line}"
                end
-       
+
                BuildCommServer.send_begin(req)
                if tok[1] != @parent_server.password then
                        BuildCommServer.send(req,"Password mismatched!")
@@ -587,7 +587,7 @@ class SocketJobRequestListener
                        @log.info "Received Wrong REQ: #{line}" 
                        raise "Invalid request format is used: #{line}"
                end
-       
+
                BuildCommServer.send_begin(req)
                if tok[1] != @parent_server.password then
                        BuildCommServer.send(req,"Password mismatched!")
@@ -610,7 +610,7 @@ class SocketJobRequestListener
                        @log.info "Received Wrong REQ: #{line}" 
                        raise "Invalid request format is used: #{line}"
                end
-               
+
                server_passwd = tok[1]          
                dist_name = tok[2]              
                if (dist_name.nil? or dist_name.empty?) then
@@ -656,8 +656,8 @@ class SocketJobRequestListener
                type = tok[1]
 
                case type
-               # REGISTER|BINARY-LOCAL|local_path|passwd|dist_name
-               # REGISTER|SOURCE-LOCAL|local_path|passwd|dist_name
+                       # REGISTER|BINARY-LOCAL|local_path|passwd|dist_name
+                       # REGISTER|SOURCE-LOCAL|local_path|passwd|dist_name
                when "BINARY-LOCAL", "SOURCE-LOCAL"
                        file_path = tok[2]
                        dist_name = tok[4]
@@ -672,13 +672,13 @@ class SocketJobRequestListener
                        # add
                        @parent_server.jobmgr.add_job( new_job )
 
-               # REGISTER|BINARY|filename|passwd|dock|dist_name
+                       # REGISTER|BINARY|filename|passwd|dock|dist_name
                when "BINARY"
                        # parse
                        filename = tok[2]
                        passwd = tok[3]
                        dock = (tok[4].nil? or tok[4].empty?) ? "0" : tok[4].strip
-                       dist_name = tok[5]
+                       dist_name = tok[5]
                        if (dist_name.nil? or dist_name.empty?) then
                                dist_name = @parent_server.distmgr.get_default_distribution_name()
                        end
@@ -688,12 +688,12 @@ class SocketJobRequestListener
                        if prj.nil? then
                                raise "No project is defined for this binary : #{filename}!"
                        end
-       
+
                        # check passwd
                        if not check_project_password(prj, passwd, req) then
                                raise "Project's password is not matched!!"
                        end
-                       
+
                        # create new job
                        @log.info "Received a request for uploading binaries : #{filename}"
                        new_job = create_new_upload_job( prj.name, filename, dock, dist_name, req )
@@ -705,7 +705,7 @@ class SocketJobRequestListener
                        logger = JobLog.new( new_job, req )
                        new_job.set_logger(logger)
                        logger.init
-               
+
                        # notify that job has been received
                        logger.info( "Added new job \"#{new_job.id}\" for #{new_job.os}!", Log::LV_USER)
                        if not @parent_server.job_log_url.empty? then
@@ -718,7 +718,7 @@ class SocketJobRequestListener
                        @log.info "Received Wrong REQ: #{line}"
                        raise "Invalid request format is used: #{line}"
                end
-       
+
        end
 
 
@@ -754,7 +754,7 @@ class SocketJobRequestListener
 
                dock_num = tok[1].strip
                file_name = tok[2]
-       
+
                @log.info "Received a request for download file : #{file_name}"
                outgoing_dir = "#{@parent_server.transport_path}/#{dock_num}"
                BuildCommServer.send_begin(req)
@@ -791,8 +791,8 @@ class SocketJobRequestListener
        private
        def check_project_for_package_file_name(filename, dist_name, req)
                # get package name
-        new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
-        pkg_name = new_name.split(",")[0]
+               new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
+               pkg_name = new_name.split(",")[0]
 
                prj = @parent_server.prjmgr.get_project_from_package_name(pkg_name, dist_name)
                if prj.nil? then
index e85415f88b2de492950b711058477fe3f9043d71..71e4ff9bd324043d8612e0aa462461c9aac9704d 100644 (file)
@@ -56,7 +56,7 @@ class Builder
                end
        end
 
-       
+
        # create
        def self.create (id, pkgserver_url, log_path, buildroot_dir, cache_dir)
 
@@ -188,7 +188,7 @@ class Builder
                if not pkginfo.package_exist?(os, build_host_os )  then
                        if is_local_build and File.exist? "#{src_path}/package/pkginfo.manifest.local" then
                                begin
-                               pkginfo = PackageManifest.new("#{src_path}/package/pkginfo.manifest.local")
+                                       pkginfo = PackageManifest.new("#{src_path}/package/pkginfo.manifest.local")
                                rescue => e
                                        @log.error( e.message, Log::LV_USER)
                                        return false
@@ -251,13 +251,13 @@ class Builder
                        end
                        @log.info( " * #{dep.package_name}", Log::LV_USER)
 
-            # get local dependent package 
-            pkgexp = Regexp.new("\/#{dep.package_name}_.*_#{dep_target_os}\.zip$")
-            local_dep_pkgs = local_pkgs.select{|l| l =~ pkgexp}
+                       # get local dependent package 
+                       pkgexp = Regexp.new("\/#{dep.package_name}_.*_#{dep_target_os}\.zip$")
+                       local_dep_pkgs = local_pkgs.select{|l| l =~ pkgexp}
 
                        # install package from remote package server
                        if local_dep_pkgs.empty? then
-               if not cl.install(dep.package_name, dep_target_os, true, false)  then
+                               if not cl.install(dep.package_name, dep_target_os, true, false)  then
                                        @log.error( "Installing \"#{dep.package_name}\" failed!", Log::LV_USER)
                                        return false
                                end
@@ -267,23 +267,23 @@ class Builder
                                        if not File.exist? l then
                                                @log.error( "File not found!: #{l}", Log::LV_USER )
                                        end
-                       cl.install_local_pkg(l,true,false, repos_paths)
+                                       cl.install_local_pkg(l,true,false, repos_paths)
                                end
                        end
                end
 
                @log.info( "Downloading dependent source packages...", Log::LV_USER)
                src_archive_list = []
-        pkginfo.get_source_dependencies(os,build_host_os).each do |dep|
+               pkginfo.get_source_dependencies(os,build_host_os).each do |dep|
                        src_archive_list.push dep.package_name
-        end
+               end
                src_archive_list.uniq!
                src_archive_list.each do |archive_name|
-            @log.info( " * #{archive_name}", Log::LV_USER)
-            if cl.download_dep_source(archive_name).nil? then
-                @log.error( "Downloading \"#{archive_name}\" failed!", Log::LV_USER)
-                return false
-            end
+                       @log.info( " * #{archive_name}", Log::LV_USER)
+                       if cl.download_dep_source(archive_name).nil? then
+                               @log.error( "Downloading \"#{archive_name}\" failed!", Log::LV_USER)
+                               return false
+                       end
                end
 
                # make clean
@@ -357,27 +357,27 @@ class Builder
 
                # read configuration
                builder_dir = "#{CONFIG_ROOT}/#{id}"
-        log_path = nil
+               log_path = nil
                cache_dir = "#{CONFIG_ROOT}/#{id}/build_cache" 
                buildroot_dir = "#{CONFIG_ROOT}/#{id}/buildroot" 
                File.open( "#{builder_dir}/builder.cfg", "r" ) do |f|
                        f.each_line do |l|
                                if l.start_with?("PSERVER_URL=")
-                    pkgserver_url = l.split("=")[1].strip
-                elsif l.start_with?("LOG-PATH=")
-                    log_path = l.split("=")[1].strip 
-                    log_path = nil if log_path == "STDOUT" 
-                elsif l.start_with?("CACHE-DIR=")
-                    cache_dir = l.split("=")[1].strip 
-                elsif l.start_with?("BUILDROOT-DIR=")
-                    buildroot_dir = l.split("=")[1].strip 
+                                       pkgserver_url = l.split("=")[1].strip
+                               elsif l.start_with?("LOG-PATH=")
+                                       log_path = l.split("=")[1].strip 
+                                       log_path = nil if log_path == "STDOUT" 
+                               elsif l.start_with?("CACHE-DIR=")
+                                       cache_dir = l.split("=")[1].strip 
+                               elsif l.start_with?("BUILDROOT-DIR=")
+                                       buildroot_dir = l.split("=")[1].strip 
                                else
                                        next    
                                end 
                        end
                end
 
-        if log_path.empty? then log_path = nil end
+               if log_path.empty? then log_path = nil end
 
                # create object & return it
                return new( id, pkgserver_url, log_path, buildroot_dir, cache_dir )
@@ -464,7 +464,7 @@ VERSION=\"#{version}\" "
                        f.puts "echo \"success\""
                end
                Utils.execute_shell( "chmod +x #{src_path}/.build.sh" )
-        build_command = "cd \"#{src_path}\";" + env_def + "./.build.sh"
+               build_command = "cd \"#{src_path}\";" + env_def + "./.build.sh"
 
                # execute script
                status = nil
@@ -653,14 +653,14 @@ VERSION=\"#{version}\" "
                        install_dir = "#{src_path}/package/#{pkg.package_name}.package.#{os}"
                        if not File.exist? install_dir then
                                install_dir = "#{src_path}/package/#{pkg.package_name}.package.#{os_category}"
-                       
+
                                if not File.exist? install_dir then
                                        @log.error( "Following directory must be created before writing pkginfo.manifest", Log::LV_USER)
                                        @log.error( " * package/#{pkg.package_name}.package.#{os}", Log::LV_USER)
                                        return false
                                end
                        end
-                       
+
                        # zip   
                        @log.info( "Creating package file ... #{pkg.package_name}_#{pkg.version}_#{os}.zip", Log::LV_USER)
                        cmd = "cd \"#{install_dir}\"; zip -r -y #{src_path}/#{pkg.package_name}_#{pkg.version}_#{os}.zip *"
@@ -694,7 +694,7 @@ VERSION=\"#{version}\" "
 
                # create pkginfo
                begin
-               pkginfo = PackageManifest.new("#{src_path}/package/pkginfo.manifest")
+                       pkginfo = PackageManifest.new("#{src_path}/package/pkginfo.manifest")
                rescue => e
                        @log.error( e.message, Log::LV_USER)
                        return false
@@ -716,7 +716,7 @@ VERSION=\"#{version}\" "
                # clean local-only package's directory
                if File.exist? "#{src_path}/package/pkginfo.manifest.local" then
                        begin
-                       pkginfo = PackageManifest.new("#{src_path}/package/pkginfo.manifest.local")
+                               pkginfo = PackageManifest.new("#{src_path}/package/pkginfo.manifest.local")
                        rescue => e
                                @log.error( e.message, Log::LV_USER)
                                return false
index b2f5ad85f6b39d09d9bdfda5ab1896c2e246b803..5380aa760c350c248e43d4000600e7d4586f93b7 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  CleanOptionParser.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -33,25 +33,25 @@ require "utils"
 
 def parse()
 
-    #option parsing 
-    option = {}
-    optparse = OptionParser.new(nil, 32, ' '*8) do |opts|
-        opts.banner = "Clean the package service command-line tool." + "\n" \
-               + "\n" + "Usage: pkg-clean [-h] [-v]" + "\n" \
-               + "\n" + "Options:" + "\n"
-
-        opts.on('-h','--help', 'display help') do
-            puts opts
-            exit
-        end 
-
-        opts.on('-v','--version', 'display version') do 
-            puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
-            exit
-        end 
-    end 
-
-    optparse.parse!
-   return option
+       #option parsing 
+       option = {}
+       optparse = OptionParser.new(nil, 32, ' '*8) do |opts|
+               opts.banner = "Clean the package service command-line tool." + "\n" \
+                       + "\n" + "Usage: pkg-clean [-h] [-v]" + "\n" \
+                       + "\n" + "Options:" + "\n"
+
+               opts.on('-h','--help', 'display help') do
+                       puts opts
+                       exit
+               end 
+
+               opts.on('-v','--version', 'display version') do 
+                       puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
+                       exit
+               end 
+       end 
+
+       optparse.parse!
+
+       return option
 end 
index 3f23fc328139cd9d23f9b8c77fd11ca674da34fd..46be506bc6e34cbd426b5c8b850a92d5b1e92074 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  optionparser.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -33,48 +33,48 @@ require "utils"
 
 def parse()
 
-    #option parsing 
-    option = {}
-    optparse = OptionParser.new do |opts|
-        opts.banner = "Build and packaging service command-line tool." + "\n" \
-               + "\n" + "Usage: pkg-build -u <package server url> [-o <os>] [-c] [-h] [-v]" + "\n" \
-               + "\n" + "Options:" + "\n"
-
-        opts.on('-u','--url <package server url>', 'remote package server url: http://127.0.0.1/dibs/unstable') do |url|
-            option[:url] = url
-        end 
-
-        option[:os] = nil
-        opts.on('-o','--os <os>', 'operating system ') do |os|
-            option[:os] = os
-        end
-
-        option[:clean] = false
-        opts.on('-c','--clean', 'clean build') do 
-            option[:clean] = true
-        end
-
-        option[:rev] = false
-        #opts.on('-r','--rev', 'reverse build dependency check') do 
-        #    option[:rev] = true
-        #end 
-
-        opts.on('-h','--help', 'display help') do
-            puts opts
-            exit
-        end
-
-        opts.on('-v','--version', 'display version') do 
-            puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
-            exit
-        end 
-    end
-
-    optparse.parse!
-
-    if option[:url].nil? or option[:url].empty? then
-        raise ArgumentError, "Usage: pkg-build -u <package server url> [-o <os>] [-c] [-h]"
-    end
-    return option
+       #option parsing 
+       option = {}
+       optparse = OptionParser.new do |opts|
+               opts.banner = "Build and packaging service command-line tool." + "\n" \
+                       + "\n" + "Usage: pkg-build -u <package server url> [-o <os>] [-c] [-h] [-v]" + "\n" \
+                       + "\n" + "Options:" + "\n"
+
+               opts.on('-u','--url <package server url>', 'remote package server url: http://127.0.0.1/dibs/unstable') do |url|
+                       option[:url] = url
+               end 
+
+               option[:os] = nil
+               opts.on('-o','--os <os>', 'operating system ') do |os|
+                       option[:os] = os
+               end
+
+               option[:clean] = false
+               opts.on('-c','--clean', 'clean build') do 
+                       option[:clean] = true
+               end
+
+               option[:rev] = false
+               #opts.on('-r','--rev', 'reverse build dependency check') do 
+               #    option[:rev] = true
+               #end 
+
+               opts.on('-h','--help', 'display help') do
+                       puts opts
+                       exit
+               end
+
+               opts.on('-v','--version', 'display version') do 
+                       puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
+                       exit
+               end 
+       end
+
+       optparse.parse!
+
+       if option[:url].nil? or option[:url].empty? then
+               raise ArgumentError, "Usage: pkg-build -u <package server url> [-o <os>] [-c] [-h]"
+       end
+
+       return option
 end 
index 7b6455988efc6b76cb7b71c1d539d5f5a4da8a4c..0cbcace36c93d74c850820b0db1e02d1f12c8c0d 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  Action.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
index 9f9c0e3c26879b1f1af7f8d73b869bfc47e60685..004c90e9a770d37e432534a90cbbbb2a79a0ab28 100644 (file)
@@ -52,7 +52,7 @@ class BuildCommServer
                @download_cache_mutex = Mutex.new
        end
 
-    def self.create(port, log, ftp_url=nil, cache_dir=nil)
+       def self.create(port, log, ftp_url=nil, cache_dir=nil)
                # checking port is  available
                if port_open? port then
                        raise "Port \"#{@port}\" is already in use."
@@ -67,15 +67,15 @@ class BuildCommServer
                        FileUtils.mkdir_p cache_dir 
                end
 
-        return new(port, log, ftp_url, cache_dir)
-    end
+               return new(port, log, ftp_url, cache_dir)
+       end
 
 
        # wait for connection and handle request
        def wait_for_connection(quit_loop)
                while( not quit_loop )
                        req = @tcp_server.accept                
-       
+
                        begin
                                yield req if block_given?
                        rescue
@@ -92,7 +92,7 @@ class BuildCommServer
                @tcp_server.close()
        end
 
-       
+
        # send_begin
        def self.send_begin( req )
                send( req, "=BEGIN,#{VERSION}")
@@ -121,14 +121,14 @@ class BuildCommServer
 
 
        def send_file(req, src_file)
-        begin
-            if not File.exist? src_file then
-                @log.error "\"#{src_file}\" file does not exist"
-                req.puts "ERROR"
-                return false
-            end
-
-            req.puts "READY"
+               begin
+                       if not File.exist? src_file then
+                               @log.error "\"#{src_file}\" file does not exist"
+                               req.puts "ERROR"
+                               return false
+                       end
+
+                       req.puts "READY"
                        @log.info "Ready to send file"
 
                        while line = req.gets()
@@ -142,11 +142,11 @@ class BuildCommServer
                                                transporter = FileTransferDirect.new(@log)
                                        when "FTP"
                                                if not @ftp_url.nil? then
-                                       url_contents = Utils.parse_ftpserver_url(@ftp_url)
+                                                       url_contents = Utils.parse_ftpserver_url(@ftp_url)
                                                        ip = url_contents[0]
                                                        port = url_contents[1]
-                                       username = url_contents[2]
-                                       passwd = url_contents[3]
+                                                       username = url_contents[2]
+                                                       passwd = url_contents[3]
                                                        transporter = FileTransferFTP.new(@log, ip, port, username, passwd)
                                                else
                                                        transporter = FileTransferFTP.new(@log)
@@ -170,21 +170,21 @@ class BuildCommServer
                                end
                        end
 
-        rescue => e
-            puts "[BuildCommServer] Exception"
+               rescue => e
+                       puts "[BuildCommServer] Exception"
                        @log.error e.message
                        @log.error e.backtrace.inspect
                        return false                    
                end
 
-        return true
+               return true
        end
 
 
        # NOTE. dst_file can be directory
        def receive_file(req, dst_file)
                begin
-            req.puts "READY"
+                       req.puts "READY"
                        @log.info "Ready to receive file"
 
                        while line = req.gets()
@@ -195,11 +195,11 @@ class BuildCommServer
                                        file_name = tok[1]
                                        file_size = tok[2].to_i
                                        checksum = tok[3]
-       
+
                                        # check download cache                          
-                               if File.exist? dst_file and File.directory? dst_file then 
+                                       if File.exist? dst_file and File.directory? dst_file then 
                                                target_file = File.join(dst_file,file_name)
-                               else 
+                                       else 
                                                target_file = dst_file 
                                        end
                                        if not @cache_dir.nil? and 
@@ -219,11 +219,11 @@ class BuildCommServer
                                                transporter = FileTransferDirect.new(@log)
                                        when "FTP"
                                                if not @ftp_url.nil? then
-                                       url_contents = Utils.parse_ftpserver_url(@ftp_url)
+                                                       url_contents = Utils.parse_ftpserver_url(@ftp_url)
                                                        ip = url_contents[0]
                                                        port = url_contents[1]
-                                       username = url_contents[2]
-                                       passwd = url_contents[3]
+                                                       username = url_contents[2]
+                                                       passwd = url_contents[3]
                                                        transporter = FileTransferFTP.new(@log, ip, port, username, passwd)
                                                else
                                                        transporter = FileTransferFTP.new(@log)
@@ -244,20 +244,20 @@ class BuildCommServer
                                        if not @cache_dir.nil? then
                                                add_download_cache(target_file)
                                        end
-                    break
+                                       break
 
                                else
                                        @log.warn "Unhandled message: #{line}"
                                end
                        end                             
                rescue => e
-            puts "[BuildCommServer] Exception" 
+                       puts "[BuildCommServer] Exception" 
                        @log.error e.message
                        @log.error e.backtrace.inspect
                        return false                    
                end
 
-        return true
+               return true
        end
 
 
@@ -335,7 +335,7 @@ class BuildCommClient
        private_class_method :new
 
        def initialize(socket, log)
-        @log = log
+               @log = log
                @socket = socket
        end
 
@@ -393,7 +393,7 @@ class BuildCommClient
                                return false
                        end
 
-               
+
                        # get contents
                        while line = @socket.gets()
                                if line.strip == "=END" then break end
@@ -438,10 +438,10 @@ class BuildCommClient
                                yield line.strip if block_given?
                        end
                rescue Timeout::Error
-            puts "WARN: Connection timed out"
+                       puts "WARN: Connection timed out"
                        return false
                rescue => e
-            puts e.message
+                       puts e.message
                        return false
                end
 
@@ -467,7 +467,7 @@ class BuildCommClient
                                return nil
                        end
 
-               
+
                        # get contents
                        while line = @socket.gets()
                                if line.strip == "=END" then break end
@@ -486,60 +486,60 @@ class BuildCommClient
 
        def send_file(src_file, transporter )
                result = true
-        begin
-            l = @socket.gets()
-            if l.nil? then 
-                @log.error "[BuildCommClient] Connection refused"
+               begin
+                       l = @socket.gets()
+                       if l.nil? then 
+                               @log.error "[BuildCommClient] Connection refused"
                                return false 
                        end
 
                        # check protocol
                        if not protocol_matched? l.strip then
-                @log.error "[BuildCommClient] Comm. Protocol version is mismatched! #{VERSION}"
+                               @log.error "[BuildCommClient] Comm. Protocol version is mismatched! #{VERSION}"
                                return false
                        end
 
-            while line = @socket.gets()
-                cmd = line.split(",")[0].strip
+                       while line = @socket.gets()
+                               cmd = line.split(",")[0].strip
                                case cmd
-                when "READY"
-                       @log.info "Server is ready!"
+                               when "READY"
+                                       @log.info "Server is ready!"
                                        file_name = File.basename(src_file)
                                        file_size = File.size(src_file)
                                        checksum = Utils.checksum(src_file)
-                    send "CHECK_CACHE,#{file_name},#{file_size},#{checksum}"
+                                       send "CHECK_CACHE,#{file_name},#{file_size},#{checksum}"
 
-                when "CACHED"
-                    @log.info "Server already has cached file"
+                               when "CACHED"
+                                       @log.info "Server already has cached file"
                                        break
 
-                when "NOT_CACHED"
-                       @log.info "Server does not have cached file"
+                               when "NOT_CACHED"
+                                       @log.info "Server does not have cached file"
                                        send "CHECK_TRANSPORTER,#{transporter.type}"
 
                                when "TRANSPORTER_OK"                           
                                        if not transporter.send_file( src_file, @socket, true ) then
                                                result = false
                                        else
-                               @log.info "Sending file succeeded!"
+                                               @log.info "Sending file succeeded!"
                                        end
 
                                when "TRANSPORTER_FAIL"                         
                                        @log.warn "Server does not support transporter type: #{transporter.type}"
                                        result = false
 
-                when "ERROR"
+                               when "ERROR"
                                        result = false
 
-                when "=END"
+                               when "=END"
                                        break
-                               
+
                                else
                                        @log.warn "Unhandled message: #{line}"
-                end
-            end
-        rescue => e
-            puts "[BuildCommClient] Exception" 
+                               end
+                       end
+               rescue => e
+                       puts "[BuildCommClient] Exception" 
                        @log.error e.message
                        @log.error e.backtrace.inspect
                        return false                    
@@ -567,32 +567,32 @@ class BuildCommClient
                                return false
                        end
 
-            while line = @socket.gets()
-                cmd = line.split(",")[0].strip
+                       while line = @socket.gets()
+                               cmd = line.split(",")[0].strip
                                case cmd
-                when "READY"
-                       @log.info "Server is ready!"
+                               when "READY"
+                                       @log.info "Server is ready!"
                                        send "CHECK_TRANSPORTER,#{transporter.type}"
 
                                when "TRANSPORTER_OK"                           
                                        if not transporter.receive_file( dst_file, @socket, true ) then
                                                result = false
                                        else
-                               @log.info "Receiving file succeeded!"
+                                               @log.info "Receiving file succeeded!"
                                        end
 
-                when "ERROR"
+                               when "ERROR"
                                        result = false
 
-                when "=END"
+                               when "=END"
                                        break
 
                                else
                                        @log.warn "Unhandled message: #{line}"
-                end
-            end
+                               end
+                       end
                rescue => e
-            puts "[BuildCommServer] Exception" 
+                       puts "[BuildCommServer] Exception" 
                        @log.error e.message
                        @log.error e.backtrace.inspect
                        return false                    
@@ -606,7 +606,7 @@ class BuildCommClient
                @socket.close
        end
 
-       
+
        private
 
 
index 55072b39dfa6503f3b3d0af0cdf0a0253d24e3c1..dc7f30ecee2447780c1b7325ed23c7b3fee2194e 100644 (file)
@@ -18,7 +18,7 @@ class FileTransferDirect
 
        def send_file( src_file, conn, is_client=true )
 
-        filename = File.basename(src_file)
+               filename = File.basename(src_file)
                size = File.size( src_file )
                checksum = Utils.checksum( src_file )
 
@@ -31,7 +31,7 @@ class FileTransferDirect
                        cmd = tok[0].strip
                        case cmd
                        when "SEND_REQ"
-                       conn.puts "FILE_INFO,#{filename},#{size},#{checksum}"
+                               conn.puts "FILE_INFO,#{filename},#{size},#{checksum}"
                                # read file contents
                                # send via tcp/ip
                                File.open(src_file, "rb") {|io|
@@ -43,13 +43,13 @@ class FileTransferDirect
                                }
 
                                @log.info "Upload is succeeded!" 
-                       conn.puts "SEND_OK"
+                               conn.puts "SEND_OK"
 
-                       # wait for download result
+                               # wait for download result
                        when "RECEIVE_OK"
                                @log.info "Received download success message from remote site"
                                return true     
-                                       
+
                        when "RECEIVE_FAIL"
                                @log.info "Received download fail message from remote site"
                                return false
@@ -65,7 +65,7 @@ class FileTransferDirect
        def receive_file( dst_file, conn, is_client=false )
 
                if is_client then
-               conn.puts "SEND_REQ"
+                       conn.puts "SEND_REQ"
                end
 
                while line = conn.gets()
@@ -73,7 +73,7 @@ class FileTransferDirect
                        cmd = tok[0].strip
                        case cmd
                        when "RECEIVE_REQ"
-                       conn.puts "SEND_REQ"
+                               conn.puts "SEND_REQ"
                        when "FILE_INFO"
                                @log.info "Received file info from remote site"
                                filename = tok[1].strip
@@ -85,11 +85,11 @@ class FileTransferDirect
                                end
 
                                File.open( dst_file, "wb" ) { |io|
-                               while size > 0
-                                       buf = conn.read(size > 1024*1024 ? 1024*1024 : size)
-                                       io.write( buf )
-                                       size -= buf.length
-                               end
+                                       while size > 0
+                                               buf = conn.read(size > 1024*1024 ? 1024*1024 : size)
+                                               io.write( buf )
+                                               size -= buf.length
+                                       end
                                }
 
                                conn.puts "RECEIVE_OK"
@@ -98,7 +98,7 @@ class FileTransferDirect
                                @log.info "Received success message from remote site"
                                return true
 
-            else
+                       else
                                @log.error "Unhandled message: #{line}"
                                return false
                        end
index 9f0ce06145bf3cce4280b2221d02d6333e0c826e..029761b1cd88345dca3436f86ae3589dfc038071 100644 (file)
@@ -43,13 +43,13 @@ class FileTransferFTP
                                        port = tok[2].strip
                                        username = tok[3].strip
                                        passwd = tok[4].strip
-                    @log.info "Using FTP information from remote... [#{ip}, #{port}]"
+                                       @log.info "Using FTP information from remote... [#{ip}, #{port}]"
                                end
 
                                # upload to ftp
                                ftp_filepath = nil
                                for attempt in ATTEMPTS
-                               ftp_filepath = putfile( src_file, ip, port, username, passwd )
+                                       ftp_filepath = putfile( src_file, ip, port, username, passwd )
                                        if !ftp_filepath.nil? then 
                                                break
                                        else 
@@ -62,17 +62,17 @@ class FileTransferFTP
                                        return false 
                                else 
                                        @log.info "Upload is succeeded at #{attempt}" 
-                               conn.puts "UPLOAD_OK,#{ftp_filepath}"
+                                       conn.puts "UPLOAD_OK,#{ftp_filepath}"
                                end
 
-                       # wait for download result
+                               # wait for download result
                        when "DOWNLOAD_OK"
                                @log.info "Received download success message from remote site"
                                # clean
                                cleandir( ftp_filepath, ip, port, username, passwd) 
-                       @log.info "Cleaned temporary dir on FTP server: #{ftp_filepath}"
+                               @log.info "Cleaned temporary dir on FTP server: #{ftp_filepath}"
                                return true     
-                                       
+
                        when "DOWNLOAD_FAIL"
                                @log.info "Received download fail message from remote site"
                                return false
@@ -94,7 +94,7 @@ class FileTransferFTP
                                conn.puts "DOWNLOAD_FAIL"                                                       
                                return false 
                        end
-               conn.puts "UPLOAD_REQ,#{@ip},#{@port},#{@username},#{@passwd}"
+                       conn.puts "UPLOAD_REQ,#{@ip},#{@port},#{@username},#{@passwd}"
                end
 
                ip = @ip; port = @port; username = @username; passwd = @passwd
@@ -108,10 +108,10 @@ class FileTransferFTP
                                        port = tok[2].strip
                                        username = tok[3].strip
                                        passwd = tok[4].strip
-                    @log.info "Using FTP information from remote... [#{ip}, #{port}]"
+                                       @log.info "Using FTP information from remote... [#{ip}, #{port}]"
                                end
 
-                       conn.puts "UPLOAD_REQ,#{ip},#{port},#{username},#{passwd}"
+                               conn.puts "UPLOAD_REQ,#{ip},#{port},#{username},#{passwd}"
                        when "UPLOAD_OK"
                                @log.info "Received upload success message from remote site"
                                filepath = tok[1].strip
@@ -138,7 +138,7 @@ class FileTransferFTP
                                @log.info "Received upload fail message from remote site"
                                return false
 
-            else
+                       else
                                @log.error "Unhandled message: #{line}"
                                return false
                        end
@@ -146,25 +146,25 @@ class FileTransferFTP
        end
 
 
-    def putfile( bpath, ip, port, username, passwd )
-        filename = File.basename(bpath)
-        uniqdir = Utils.create_uniq_name
-        ftp_filepath = File.join(uniqdir, filename)
+       def putfile( bpath, ip, port, username, passwd )
+               filename = File.basename(bpath)
+               uniqdir = Utils.create_uniq_name
+               ftp_filepath = File.join(uniqdir, filename)
 
-        begin
-            ftp = Net::FTP.new
-            if port.nil? or port == "" then
-                ftp.connect(ip)
-            else
-                ftp.connect(ip, port)                                 
-            end
+               begin
+                       ftp = Net::FTP.new
+                       if port.nil? or port == "" then
+                               ftp.connect(ip)
+                       else
+                               ftp.connect(ip, port)                                 
+                       end
                        @log.info "[FTP log] Connected FTP server (#{ip}:#{port})"
-            ftp.login(username, passwd)
-            ftp.binary = true
+                       ftp.login(username, passwd)
+                       ftp.binary = true
                        ftp.passive = true                      
-            ftp.mkdir(uniqdir)
-            ftp.chdir(uniqdir)
-            ftp.put(bpath)
+                       ftp.mkdir(uniqdir)
+                       ftp.chdir(uniqdir)
+                       ftp.put(bpath)
                        @log.info "[FTP log] Put a file"
                        @log.info "[FTP log]   from \"#{bpath}\" to \"#{ftp_filepath}\""                        
                        files = ftp.list(filename)
@@ -172,46 +172,46 @@ class FileTransferFTP
                                @log.error "[FTP log] Failed to upload file (#{filename} does not exist)"
                                return nil      
                        end
-            ftp.quit
+                       ftp.quit
                        @log.info "[FTP log] Disconnected FTP server"
-        rescue => e
+               rescue => e
                        @log.error "[FTP log] Exception"
                        @log.error e.message
                        @log.error e.backtrace.inspect
                        return nil                      
-        end
+               end
                return ftp_filepath
-    end
+       end
 
-    def getfile( bpath, target, ip, port, username, passwd )
-        dirname = File.dirname(bpath)
-        filename = File.basename(bpath)
+       def getfile( bpath, target, ip, port, username, passwd )
+               dirname = File.dirname(bpath)
+               filename = File.basename(bpath)
 
-        # target can be directory or file
-        if File.directory? target then
-            dst_file = File.join(target,filename)
-        else
-            dst_file = target
-        end
+               # target can be directory or file
+               if File.directory? target then
+                       dst_file = File.join(target,filename)
+               else
+                       dst_file = target
+               end
 
-        begin
-            ftp = Net::FTP.new
-            if port.nil? or port == "" then
-                ftp.connect(ip)
-            else                
-                ftp.connect(ip, port)
-            end                
+               begin
+                       ftp = Net::FTP.new
+                       if port.nil? or port == "" then
+                               ftp.connect(ip)
+                       else                
+                               ftp.connect(ip, port)
+                       end                
                        @log.info "[FTP log] Connected FTP server (#{ip}:#{port})"
-            ftp.login(username, passwd)
-            ftp.binary = true
+                       ftp.login(username, passwd)
+                       ftp.binary = true
                        ftp.passive = true
-            ftp.chdir(dirname)
-            ftp.get(filename, dst_file)
+                       ftp.chdir(dirname)
+                       ftp.get(filename, dst_file)
                        @log.info "[FTP log] Get a file"
                        @log.info "[FTP log]   from \"#{bpath}\" to \"#{dst_file}\""
-            ftp.quit
+                       ftp.quit
                        @log.info "[FTP log] Disconnected FTP server"
-        rescue => e
+               rescue => e
                        @log.error "[FTP log] Exception"
                        @log.error e.message
                        @log.error e.backtrace.inspect
@@ -221,41 +221,41 @@ class FileTransferFTP
                        @log.error "[FTP log] Failed to download file (#{dst_file} does not exist)"
                        return nil
                end                             
-        return bpath
-    end
+               return bpath
+       end
 
-    def cleandir(path, ip, port, username, passwd)
-        dirname = File.dirname(path)
+       def cleandir(path, ip, port, username, passwd)
+               dirname = File.dirname(path)
 
-        begin
-            ftp = Net::FTP.new
-            if port.nil? or port == "" then
-                ftp.connect(ip)
-            else
-                ftp.connect(ip, port)                    
-            end                    
+               begin
+                       ftp = Net::FTP.new
+                       if port.nil? or port == "" then
+                               ftp.connect(ip)
+                       else
+                               ftp.connect(ip, port)                    
+                       end                    
                        @log.info "[FTP log] Connected FTP server (#{ip}:#{port})"
-            ftp.login(username, passwd)
-            old_dir = ftp.pwd
-            ftp.chdir(dirname)
-            list = ftp.ls
-            # TODO: if list is directory?
-            list.each do |l|
-                file = l.split(" ")[-1].strip
-                ftp.delete(file)
-            end
-            ftp.chdir(old_dir)
-            ftp.rmdir(dirname)
+                       ftp.login(username, passwd)
+                       old_dir = ftp.pwd
+                       ftp.chdir(dirname)
+                       list = ftp.ls
+                       # TODO: if list is directory?
+                       list.each do |l|
+                               file = l.split(" ")[-1].strip
+                               ftp.delete(file)
+                       end
+                       ftp.chdir(old_dir)
+                       ftp.rmdir(dirname)
                        @log.info "[FTP log] Clean dir (#{dirname})"                    
-            ftp.quit
+                       ftp.quit
                        @log.info "[FTP log] Disconnected FTP server"
-        rescue => e
+               rescue => e
                        @log.error "[FTP log] Exception"
                        @log.error e.message
                        @log.error e.backtrace.inspect
                        return nil                      
-        end
+               end
 
-        return true
+               return true
        end
 end
index 044b7b6b5a62955bc9086a6db1dd5bfb4b60fd5a..3c46f382de9b25468a9a99c0aa58efac1a1f1618 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  PackageManifest.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -53,11 +53,11 @@ class PackageManifest
                        end
                end
                list.uniq!
-               
+
                return list
        end     
 
-       
+
        # scan all source dependencies
        def get_source_dependencies( target_os, host_os )
                # for all
@@ -75,9 +75,9 @@ class PackageManifest
 
                        # package that has the target os
                        pkg.source_dep_list.each do |dep|
-                       #       if dep.target_os_list.include? target_os
-                                       list.push dep
-                       #       end
+                               #       if dep.target_os_list.include? target_os
+                               list.push dep
+                               #       end
                        end
                end
                list.uniq!
@@ -146,7 +146,7 @@ class PackageManifest
 
                        return true
                end
-       
+
                return false
        end
 end
index a62c5f0364f5ea88b80c7e5c7e095d2e79b610a5..f7ff28030983a49cabb360cb2e7fbd1149788167 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  ScheduledActionHandler.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -53,7 +53,7 @@ class ScheduledActionHandler
                @thread = Thread.new {
                        # main
                        thread_main()
-                       
+
                        # close 
                        terminate()
                } 
index 633d3784b1967b8183d7961164c5d5b16a800b47..9a8f61443153a51faf7c4e2d3c43bbc8d3bb448e 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  Version.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -28,8 +28,8 @@ Contributors:
 
 
 class Version < Array
-       def initialize s
-       super(s.split('.').map { |e| e.to_i })   
+       def initialize s
+               super(s.split('.').map { |e| e.to_i })   
        end   
        def < x     
                (self <=> x) < 0   
index a6e9499f13fa9e969ee66432a059de688f77382f..39e53b91a4123c470ec01e374b2e11242c43b05c 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
   dependency.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -30,25 +30,25 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
 require "Version" 
 
 class Dependency
-    attr_accessor :package_name, :comp, :base_version, :target_os_list
-    def initialize (package_name, comp, base_version, target_os_list)
-        @package_name = package_name
-        @comp = comp
-        @base_version = base_version
-        @target_os_list = target_os_list
-    end 
+       attr_accessor :package_name, :comp, :base_version, :target_os_list
+       def initialize (package_name, comp, base_version, target_os_list)
+               @package_name = package_name
+               @comp = comp
+               @base_version = base_version
+               @target_os_list = target_os_list
+       end 
+
+       def to_s
+               string = @package_name 
+               if not @comp.nil? and not @base_version.nil? then 
+                       string = string + " ( #{@comp} #{@base_version} )" 
+               end
 
-    def to_s
-        string = @package_name 
-        if not @comp.nil? and not @base_version.nil? then 
-            string = string + " ( #{@comp} #{@base_version} )" 
-        end
-        if not @target_os_list.empty? then 
-            string = string + " [ #{@target_os_list.join("|")} ]"
-        end 
-        return string
-    end 
+               if not @target_os_list.empty? then 
+                       string = string + " [ #{@target_os_list.join("|")} ]"
+               end 
+               return string
+       end 
 
        def match? ver
                if @base_version.nil? 
index e82676ddc2383a9117100efe9e436b81c3141116..040de045467de5b03d89d7ec619fe8cb69c2ffab 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/ruby
 =begin
+
  execute_with_log.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -48,8 +48,8 @@ cmd = Utils.generate_shell_command(cmd, nil)
 # execute and write log
 IO.popen("#{cmd} 2>&1") { |io|
        io.each { |line|
-               log.info line
-       }
+               log.info line
+       }
 }
 
 # return exit code
index 4a5ccb49b6694045caa3f6709f329c41ad0babe8..17ce07d2f30d13b08a4c086b2034c1f3dc8601cf 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  log.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -40,7 +40,7 @@ class Log
        # init
        def initialize(path, lv=LV_USER)
                @cnt = 0
-        @path = path
+               @path = path
                if @path.nil? then
                        @logger = Logger.new(STDOUT)
                else
@@ -59,8 +59,8 @@ class Log
 
 
        def info(msg, lv=LV_NORMAL)
-        if @path.nil? and not @second_out.nil? then puts "Info: #{msg}"
-        else @logger.info msg end
+               if @path.nil? and not @second_out.nil? then puts "Info: #{msg}"
+               else @logger.info msg end
                if not @second_out.nil? and lv >= @second_out_level then
                        output_extra "Info: " + msg
                end
@@ -68,7 +68,7 @@ class Log
        end
 
        def warn(msg, lv=LV_NORMAL)
-        if @path.nil? and not @second_out.nil? then puts "Warn: #{msg}"
+               if @path.nil? and not @second_out.nil? then puts "Warn: #{msg}"
                else @logger.warn msg end
                if not @second_out.nil? and lv >= @second_out_level then
                        output_extra "Warn: " + msg
@@ -78,7 +78,7 @@ class Log
 
 
        def error(msg, lv=LV_NORMAL)
-        if @path.nil? and not @second_out.nil? then puts "Error: #{msg}"
+               if @path.nil? and not @second_out.nil? then puts "Error: #{msg}"
                else @logger.error msg end
                if not @second_out.nil? and lv >= @second_out_level then
                        output_extra "Error: " + msg
@@ -88,7 +88,7 @@ class Log
 
 
        def output(msg, lv=LV_NORMAL)
-        if @path.nil? and not @second_out.nil? then puts msg
+               if @path.nil? and not @second_out.nil? then puts msg
                else @logger.info msg end
                if not @second_out.nil? and lv >= @second_out_level then
                        output_extra msg
index 5005b708f5b32852d9286f1ad0bd4c54093fcfd2..89fa15ac24cbb9d7b5ab97f9ac0375d0ff4a9f7d 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  mail.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -35,8 +35,8 @@ class Mail
        def Mail.send_mail( mail_to, subject, contents ) 
 
                if mail_to.nil? or mail_to.empty? \
-                               or subject.nil? or subject.empty? \
-                               or contents.nil? or contents.empty? then 
+                       or subject.nil? or subject.empty? \
+                       or contents.nil? or contents.empty? then 
                        return false
                end 
 
@@ -48,8 +48,8 @@ Subject: #{subject}
 #{contents}
 
 MESSAGE_END
-               
-               Mail.send_mail2( mail_to, message )
+
+Mail.send_mail2( mail_to, message )
        end
 
        def Mail.send_mail2( mail_to_list, message )
@@ -57,8 +57,8 @@ MESSAGE_END
                        puts "There is no maintainer email address "
                else
                        begin 
-                       Net::SMTP.start('localhost') do |smtp|
-                       smtp.send_message( message, SENDER, mail_to_list) 
+                               Net::SMTP.start('localhost') do |smtp|
+                                       smtp.send_message( message, SENDER, mail_to_list) 
                                end 
                        rescue => e 
                                puts "Can't send result email"
@@ -71,14 +71,14 @@ MESSAGE_END
                mail_list = []
                low_email_list.split(",").each do | low_email |  
                        ms = low_email.index('<')
-                       me = low_email.index('>')
-                       if ms.nil? or me.nil? then  
-                               next 
-                       else 
-                               mail = low_email[(ms+1)..(me-1)] 
-                       end
-                       
-                       if mail.include?("@") then mail_list.push mail end
+               me = low_email.index('>')
+               if ms.nil? or me.nil? then  
+                       next 
+               else 
+                       mail = low_email[(ms+1)..(me-1)] 
+               end
+
+               if mail.include?("@") then mail_list.push mail end
                end 
 
                return mail_list 
index d5119d7978807cd162e147fd32060c227d5d6e52..5be697cd2e21edec6e55577956b24523b5f0a3fc 100644 (file)
@@ -27,69 +27,69 @@ Contributors:
 =end
 
 class Package
-    attr_accessor :package_name, :label, :version, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :description, :os_list, :custom, :change_log
-    def initialize (package_name)
-        @package_name = package_name
-        @label = ""
-        @version = ""
-        @os = ""
-        @os_list = []
-        @build_host_os = []
-        @maintainer = ""
-        @attribute = []
-        @install_dep_list = []
-        @build_dep_list = []
-        @source_dep_list = []
-        @conflicts = []
-        @source = ""
-        @src_path = ""
-        @path = ""
-        @origin = ""
-        @checksum = ""
-        @size = ""
-        @description = ""
+       attr_accessor :package_name, :label, :version, :os, :build_host_os, :maintainer, :attribute, :install_dep_list, :build_dep_list, :source_dep_list, :conflicts, :source, :src_path, :path, :origin, :checksum, :size, :description, :os_list, :custom, :change_log
+       def initialize (package_name)
+               @package_name = package_name
+               @label = ""
+               @version = ""
+               @os = ""
+               @os_list = []
+               @build_host_os = []
+               @maintainer = ""
+               @attribute = []
+               @install_dep_list = []
+               @build_dep_list = []
+               @source_dep_list = []
+               @conflicts = []
+               @source = ""
+               @src_path = ""
+               @path = ""
+               @origin = ""
+               @checksum = ""
+               @size = ""
+               @description = ""
                @custom = ""
                @change_log = {}
-    end
+       end
 
-    def print
-        puts self.to_s
-    end
+       def print
+               puts self.to_s
+       end
 
-    def to_s
-        string =  "Package : " + @package_name
-        if not @label.empty? then string = string + "\n" +  "Label : " + @label end
-        if not @version.empty? then string = string + "\n" +  "Version : " + @version end
-        if not @os_list.empty? then string = string + "\n" + "OS : " + @os_list.join(", ") end
-        if not @build_host_os.empty? then string = string + "\n" + "Build-host-os : " + @build_host_os.join(", ") end
-        if not @maintainer.empty? then string = string + "\n" + "Maintainer : " + @maintainer end
-        if not @attribute.empty? then string = string + "\n" + "Attribute : " + @attribute.join("|") end
-        if not @install_dep_list.empty? then
-            string = string + "\n" + "Install-dependency : " + @install_dep_list.map {|x| x.to_s}.join(", ")
-        end
-        if not @build_dep_list.empty? then
-            string = string + "\n" + "Build-dependency : " + @build_dep_list.map {|x| x.to_s}.join(", ")
-        end
-        if not @source_dep_list.empty? then
-            string = string + "\n" + "Source-dependency : " + @source_dep_list.map {|x| x.to_s}.join(", ")
-        end
-        if not @conflicts.empty? then
-            string = string + "\n" + "Conflicts : " + @conflicts.map {|x| x.to_s}.join(", ")
-        end
-        if not @source.empty? then string = string + "\n" + "Source : " + @source end
-        if not @src_path.empty? then string = string + "\n" + "Src-path : " + @src_path end
-        if not @path.empty? then string = string + "\n" + "Path : " + @path end
-        if not @origin.empty? then string = string + "\n" + "Origin : " + @origin end
-        if not @checksum.empty? then string = string + "\n" + "SHA256 : " + @checksum end
-        if not @size.empty? then string = string + "\n" + "Size : " + @size end
-        if not @custom.empty? then string = string + "\n" + @custom end
-        if not @description.empty? then string = string + "\n" + "Description : " + @description end
-        return string
-    end
+       def to_s
+               string =  "Package : " + @package_name
+               if not @label.empty? then string = string + "\n" +  "Label : " + @label end
+               if not @version.empty? then string = string + "\n" +  "Version : " + @version end
+               if not @os_list.empty? then string = string + "\n" + "OS : " + @os_list.join(", ") end
+               if not @build_host_os.empty? then string = string + "\n" + "Build-host-os : " + @build_host_os.join(", ") end
+               if not @maintainer.empty? then string = string + "\n" + "Maintainer : " + @maintainer end
+               if not @attribute.empty? then string = string + "\n" + "Attribute : " + @attribute.join("|") end
+               if not @install_dep_list.empty? then
+                       string = string + "\n" + "Install-dependency : " + @install_dep_list.map {|x| x.to_s}.join(", ")
+               end
+               if not @build_dep_list.empty? then
+                       string = string + "\n" + "Build-dependency : " + @build_dep_list.map {|x| x.to_s}.join(", ")
+               end
+               if not @source_dep_list.empty? then
+                       string = string + "\n" + "Source-dependency : " + @source_dep_list.map {|x| x.to_s}.join(", ")
+               end
+               if not @conflicts.empty? then
+                       string = string + "\n" + "Conflicts : " + @conflicts.map {|x| x.to_s}.join(", ")
+               end
+               if not @source.empty? then string = string + "\n" + "Source : " + @source end
+               if not @src_path.empty? then string = string + "\n" + "Src-path : " + @src_path end
+               if not @path.empty? then string = string + "\n" + "Path : " + @path end
+               if not @origin.empty? then string = string + "\n" + "Origin : " + @origin end
+               if not @checksum.empty? then string = string + "\n" + "SHA256 : " + @checksum end
+               if not @size.empty? then string = string + "\n" + "Size : " + @size end
+               if not @custom.empty? then string = string + "\n" + @custom end
+               if not @description.empty? then string = string + "\n" + "Description : " + @description end
+               return string
+       end
 
-    def print_to_file(file)
-        file.puts self.to_s
-    end
+       def print_to_file(file)
+               file.puts self.to_s
+       end
 
        def change_log_string
                if @change_log.empty? then return "" end
index b57b82dfc37f5012023056582479c67d4694f13c..130c6c9f57620a221bdeb1f1fe7dad087f9992c3 100644 (file)
@@ -31,8 +31,8 @@ require "package"
 require "dependency"
 
 class Parser
-    def Parser.read_multy_pkginfo_from (file, only_common = false)
-        pkglist = []
+       def Parser.read_multy_pkginfo_from (file, only_common = false)
+               pkglist = []
                package = nil
                common_source = ""
                common_version = ""
@@ -44,10 +44,10 @@ class Parser
 
                #file check
 
-        File.open file,"r" do |f|
-            #variable initialize
+               File.open file,"r" do |f|
+                       #variable initialize
                        state = "INIT"
-            f.each_line do |l|
+                       f.each_line do |l|
                                # commant
                                if l.strip.start_with? "#" then next end
 
@@ -261,15 +261,15 @@ class Parser
                return read_multy_pkginfo_from(file,true)[3]
        end
 
-    def Parser.read_single_pkginfo_from (file)
-        return read_multy_pkginfo_from(file)[0]
-    end
+       def Parser.read_single_pkginfo_from (file)
+               return read_multy_pkginfo_from(file)[0]
+       end
 
-    def Parser.read_repo_pkg_list_from (file)
-        result = {}
-        read_multy_pkginfo_from(file).each { |x| result[x.package_name]=x }
-        return result
-    end
+       def Parser.read_repo_pkg_list_from (file)
+               result = {}
+               read_multy_pkginfo_from(file).each { |x| result[x.package_name]=x }
+               return result
+       end
 
        #for test
        def Parser.print (array)
@@ -279,42 +279,42 @@ class Parser
                end
        end
 
-    private
-    def Parser.dep_parser (string_list)
-        dependency_list = []
-        string_list.each do |dep|
-            #variable initialize
-            package_name = ""
-            comp = nil
-            base_version = nil
-            target_os_list = []
-            #string trim
-            dependency = dep.tr " \t\r\n", ""
-            #version extract
-            vs = dependency.index('(') 
-            ve = dependency.index(')') 
-            if not vs.nil? and not ve.nil? then 
-                comp = dependency[(vs+1)..(vs+2)]
-                base_version = dependency[(vs+3)..(ve-1)]
-            end 
-            #os list extract
-            os = dependency.index('[') 
-            oe = dependency.index(']') 
-            if not os.nil? and not oe.nil? then 
-                target_os_list = dependency[(os+1)..(oe-1)].split("|")
-            end 
-            # package_name extract
-            pe = dependency.index(/[\]\[\)\(]/)
-            if pe.nil?
-                package_name = dependency
-            else
-                package_name = dependency[0..pe-1]
-            end
-            #package_name check
-            if not package_name.empty? then 
-                dependency_list.push Dependency.new(package_name,comp,base_version,target_os_list)
-            end 
-        end 
-        return dependency_list
-    end 
+       private
+       def Parser.dep_parser (string_list)
+               dependency_list = []
+               string_list.each do |dep|
+                       #variable initialize
+                       package_name = ""
+                       comp = nil
+                       base_version = nil
+                       target_os_list = []
+                       #string trim
+                       dependency = dep.tr " \t\r\n", ""
+                       #version extract
+                       vs = dependency.index('(') 
+                       ve = dependency.index(')') 
+                       if not vs.nil? and not ve.nil? then 
+                               comp = dependency[(vs+1)..(vs+2)]
+                               base_version = dependency[(vs+3)..(ve-1)]
+                       end 
+                       #os list extract
+                       os = dependency.index('[') 
+                       oe = dependency.index(']') 
+                       if not os.nil? and not oe.nil? then 
+                               target_os_list = dependency[(os+1)..(oe-1)].split("|")
+                       end 
+                       # package_name extract
+                       pe = dependency.index(/[\]\[\)\(]/)
+                       if pe.nil?
+                               package_name = dependency
+                       else
+                               package_name = dependency[0..pe-1]
+                       end
+                       #package_name check
+                       if not package_name.empty? then 
+                               dependency_list.push Dependency.new(package_name,comp,base_version,target_os_list)
+                       end 
+               end 
+               return dependency_list
+       end 
 end 
index 4cad345b454334bc6ecf3a02337be73bfd4630d9..e2707f19bcd33da014a06aaecee9f79a6c5edb39 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  utils.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -36,28 +36,28 @@ class Utils
                os = "UnsupportedOS"
 
                case `uname -s`.strip
-                       when "Linux"
-                               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"
-                               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"
-                               end
-                       when "MINGW32_NT-5.1"
-                       progfile_path = Utils.execute_shell_return("echo $PROGRAMFILES","windows")[0].strip
-                               if progfile_path.include?("(x86)") then arch = "64" else arch = "32" end
-                               os = "windows-#{arch}"
-                       when "MINGW32_NT-6.1"
-                       progfile_path = Utils.execute_shell_return("echo $PROGRAMFILES","windows")[0].strip
-                               if progfile_path.include?("(x86)") then arch = "64" else arch = "32" end
-                               os = "windows-#{arch}"
-                       when "Darwin"
-                           os = "macos-64"
+               when "Linux"
+                       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"
+                       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"
+                       end
+               when "MINGW32_NT-5.1"
+                       progfile_path = Utils.execute_shell_return("echo $PROGRAMFILES","windows")[0].strip
+                       if progfile_path.include?("(x86)") then arch = "64" else arch = "32" end
+                       os = "windows-#{arch}"
+               when "MINGW32_NT-6.1"
+                       progfile_path = Utils.execute_shell_return("echo $PROGRAMFILES","windows")[0].strip
+                       if progfile_path.include?("(x86)") then arch = "64" else arch = "32" end
+                       os = "windows-#{arch}"
+               when "Darwin"
+                       os = "macos-64"
                end 
 
                return os 
@@ -78,95 +78,95 @@ class Utils
        end
 
 
-    def Utils.create_uniq_name      
-        time = Time.new     
+       def Utils.create_uniq_name      
+               time = Time.new     
 
-        # uniq snapshot_name name is year_month_day_hour_min_sec_microsec       
+               # uniq snapshot_name name is year_month_day_hour_min_sec_microsec       
                return time.strftime("%m%d%H%M%S") + time.usec.to_s.rjust(6, '0')
-    end
-
-    def Utils.is_url_remote(url)
-        if url.nil? then
-            return false
-        end
-
-        protocol = url.split(':')[0]
-
-        case protocol
-        when "http" then
-            return true
-        else 
-            return false
-        end
-    end
-
-    # if source_ver > target_ver, return -1
-    # if source_ver < target_ver, return 1
-    # if source_ver == target_ver, return 0
-    def Utils.compare_version(source_ver, target_ver)
-        sver = source_ver.split('-')[0]
-        tver = target_ver.split('-')[0]
-
-        arr_sver = sver.split('.')
-        arr_tver = tver.split('.')
-
-        slen = arr_sver.length
-        tlen = arr_tver.length
-        len = tlen 
-
-        if slen > tlen then
-            gap = slen - tlen
-            gap.times do
-                arr_tver.push("0")
-            end
-            len = slen
-        elsif tlen > slen then
-            gap = tlen - slen
-            gap.times do
-                arr_sver.push("0")
-            end
-            len = tlen
-        end 
-
-        len.times do |i|
-            if arr_sver[i].to_i < arr_tver[i].to_i then
-                return 1
-            elsif arr_sver[i].to_i > arr_tver[i].to_i then
-                return -1
-            end
-        end
-
-        return 0
-       end
-
-
-    def Utils.generate_shell_command(cmd, os_category = nil)
+       end
+
+       def Utils.is_url_remote(url)
+               if url.nil? then
+                       return false
+               end
+
+               protocol = url.split(':')[0]
+
+               case protocol
+               when "http" then
+                       return true
+               else 
+                       return false
+               end
+       end
+
+       # if source_ver > target_ver, return -1
+       # if source_ver < target_ver, return 1
+       # if source_ver == target_ver, return 0
+       def Utils.compare_version(source_ver, target_ver)
+               sver = source_ver.split('-')[0]
+               tver = target_ver.split('-')[0]
+
+               arr_sver = sver.split('.')
+               arr_tver = tver.split('.')
+
+               slen = arr_sver.length
+               tlen = arr_tver.length
+               len = tlen 
+
+               if slen > tlen then
+                       gap = slen - tlen
+                       gap.times do
+                               arr_tver.push("0")
+                       end
+                       len = slen
+               elsif tlen > slen then
+                       gap = tlen - slen
+                       gap.times do
+                               arr_sver.push("0")
+                       end
+                       len = tlen
+               end 
+
+               len.times do |i|
+                       if arr_sver[i].to_i < arr_tver[i].to_i then
+                               return 1
+                       elsif arr_sver[i].to_i > arr_tver[i].to_i then
+                               return -1
+                       end
+               end
+
+               return 0
+       end
+
+
+       def Utils.generate_shell_command(cmd, os_category = nil)
                if os_category.nil? then os_category = get_os_category( HOST_OS ) end
 
                if os_category == "windows" then
                        mingw_path = "sh.exe -c "
                        cmd = cmd.gsub("\"", "\\\"")
-            cmd = mingw_path + "\"#{cmd}\""
+                       cmd = mingw_path + "\"#{cmd}\""
                end
 
                return cmd
        end
 
 
-    def Utils.execute_shell(cmd, os_category = nil)
-        ret = false
-               
+       def Utils.execute_shell(cmd, os_category = nil)
+               ret = false
+
                # generate command
                cmd = generate_shell_command(cmd, os_category)
 
                `#{cmd}`
-        if $?.to_i == 0 then ret = true else ret = false end 
-               
+               if $?.to_i == 0 then ret = true else ret = false end 
+
                return ret
        end
 
 
-    def Utils.execute_shell_return(cmd, os_category = nil)
+       def Utils.execute_shell_return(cmd, os_category = nil)
                result_lines = []
 
                # generate command
@@ -178,21 +178,21 @@ class Utils
                                result_lines.push line
                        end
                }
-               
-        if $?.to_i == 0 then 
+
+               if $?.to_i == 0 then 
                        return result_lines
                else 
                        return nil
                end 
        end
 
-    def Utils.execute_shell_return_ret(cmd, os_category = nil)
+       def Utils.execute_shell_return_ret(cmd, os_category = nil)
 
                # generate command
                cmd = generate_shell_command(cmd, os_category)
 
-        return `#{cmd}`
-    end
+               return `#{cmd}`
+       end
 
 
        # create process and log its all output(stderr, stdout)
@@ -204,8 +204,8 @@ class Utils
                end
 
                ruby_path=File.join(Config::CONFIG["bindir"],
-                                  Config::CONFIG["RUBY_INSTALL_NAME"] +
-                                  Config::CONFIG["EXEEXT"])
+                                                       Config::CONFIG["RUBY_INSTALL_NAME"] +
+                                                       Config::CONFIG["EXEEXT"])
 
                # call execute
                os_category = get_os_category( HOST_OS )
@@ -228,7 +228,7 @@ class Utils
        def Utils.execute_shell_with_stdout(cmd, os_category = nil)
 
                logger = Logger.new(STDOUT)
-               
+
                # generate command
                cmd = generate_shell_command(cmd, os_category)
 
@@ -243,8 +243,8 @@ class Utils
        end
 
 
-    def Utils.spawn(cmd, os_category = nil)
-               
+       def Utils.spawn(cmd, os_category = nil)
+
                if os_category.nil? then os_category = get_os_category( HOST_OS ) end
 
                if os_category == "windows" then
@@ -282,7 +282,7 @@ class Utils
                        'L', # IN LPCSTR lpCurrentDirectory
                        'P', # IN LPSTARTUPINFOA lpStartupInfo
                        'P'  # OUT LPPROCESS_INFORMATION lpProcessInformation
-                       ]
+               ]
                returnValue = 'I' # BOOL
 
                startupInfo = [STARTUP_INFO_SIZE].pack('I') + ([0].pack('I') * (STARTUP_INFO_SIZE - 4))
@@ -353,96 +353,96 @@ class Utils
 
                return lock_file
        end
-       
+
        def Utils.file_unlock(lock_file)
                lock_file.close
        end
 
-    def Utils.parse_server_addr(saddr)
-        addr = saddr.split(":")
-        return nil unless addr.length == 2
-        return addr
-    end
-
-    def Utils.parse_ftpserver_url(surl)
-        return nil unless surl.start_with? "ftp://"
-
-        surl = surl[6..-1]
-        parse1 = surl.split("@")
-        return nil unless parse1.length == 2
-        
-        idpw = parse1[0]
-        url = parse1[1]
-        parse1 = idpw.split(":")
-        return nil unless parse1.length == 2
-
-        id = parse1[0]
-        passwd = parse1[1]
-        if url.end_with? "/" then url = url.chop end
-
-        parse1 = url.split(":")
-        if parse1.length == 2 then
-            ip = parse1[0]
-            port = parse1[1]
-        elsif parse1.length == 1 then
-            ip = parse1[0]
-            port = 21
-        else
-            return nil                
-        end                
-
-        return [ip, port, id, passwd]
-    end
-
-
-    def Utils.generate_ftp_url(addr, port, username, passwd)
+       def Utils.parse_server_addr(saddr)
+               addr = saddr.split(":")
+               return nil unless addr.length == 2
+               return addr
+       end
+
+       def Utils.parse_ftpserver_url(surl)
+               return nil unless surl.start_with? "ftp://"
+
+               surl = surl[6..-1]
+               parse1 = surl.split("@")
+               return nil unless parse1.length == 2
+
+               idpw = parse1[0]
+               url = parse1[1]
+               parse1 = idpw.split(":")
+               return nil unless parse1.length == 2
+
+               id = parse1[0]
+               passwd = parse1[1]
+               if url.end_with? "/" then url = url.chop end
+
+               parse1 = url.split(":")
+               if parse1.length == 2 then
+                       ip = parse1[0]
+                       port = parse1[1]
+               elsif parse1.length == 1 then
+                       ip = parse1[0]
+                       port = 21
+               else
+                       return nil                
+               end                
+
+               return [ip, port, id, passwd]
+       end
+
+
+       def Utils.generate_ftp_url(addr, port, username, passwd)
                return "ftp://#{username}:#{passwd}@#{addr}:#{port}"
-    end
-
-
-    def Utils.extract_a_file(file_path, target_file, path)
-        dirname = File.dirname(file_path)
-        filename = File.basename(file_path)
-        ext = File.extname(filename)
-        
-        # path should be unix path if it is used in tar command 
-        _package_file_path = Utils.get_unix_path(file_path)
-        _path = Utils.get_unix_path(path)
-
-        case ext
-        when ".zip" then
-            if not path.nil? then
-                extract_file_command = "unzip -xo #{_package_file_path} #{target_file} -d #{_path}"
-            else
-                extract_file_command = "unzip -xo #{_package_file_path} #{target_file}"
-            end
-        when ".tar" then
-            if not path.nil? then
-                extract_file_command = "tar xf #{_package_file_path} -C #{_path} #{target_file}"
-            else
-                extract_file_command = "tar xf #{_package_file_path} #{target_file}"
-            end
-        end
+       end
+
+
+       def Utils.extract_a_file(file_path, target_file, path)
+               dirname = File.dirname(file_path)
+               filename = File.basename(file_path)
+               ext = File.extname(filename)
+
+               # path should be unix path if it is used in tar command 
+               _package_file_path = Utils.get_unix_path(file_path)
+               _path = Utils.get_unix_path(path)
+
+               case ext
+               when ".zip" then
+                       if not path.nil? then
+                               extract_file_command = "unzip -xo #{_package_file_path} #{target_file} -d #{_path}"
+                       else
+                               extract_file_command = "unzip -xo #{_package_file_path} #{target_file}"
+                       end
+               when ".tar" then
+                       if not path.nil? then
+                               extract_file_command = "tar xf #{_package_file_path} -C #{_path} #{target_file}"
+                       else
+                               extract_file_command = "tar xf #{_package_file_path} #{target_file}"
+                       end
+               end
 
                # check exit code
-        ret = execute_shell "#{extract_file_command}"
+               ret = execute_shell "#{extract_file_command}"
                if not ret then return false end        
 
                # check result file 
-        if not path.nil? then
-            target_file_path = File.join(path, target_file)
-        else
-            target_file_path = target_file
-        end
+               if not path.nil? then
+                       target_file_path = File.join(path, target_file)
+               else
+                       target_file_path = target_file
+               end
 
-        if not File.exist? target_file_path then
+               if not File.exist? target_file_path then
                        return false
                else
                        return true
                end
-    end
+       end
+
 
-       
        # check if the os is windows-like
        def Utils.is_windows_like_os(os_name)
                if os_name.start_with? "windows-" then
@@ -468,7 +468,7 @@ 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? "opensuse-" then
                        return true
                else
                        return false
@@ -485,7 +485,7 @@ class Utils
                end
        end
 
-       
+
        def Utils.get_os_category(os_name)
                if os_name.start_with? "ubuntu-" or os_name.start_with? "opensuse-" then
                        return "linux"
@@ -501,7 +501,7 @@ class Utils
 
        def Utils.get_package_name_from_package_file( local_path )
                filename = File.basename(local_path)
-               if filename =~ /.*_.*_.*\.zip/ then
+               if filename =~ /.*_.*_.*\.zip/ then
                        new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
                        return new_name.split(",")[0]
                end
@@ -511,7 +511,7 @@ class Utils
 
        def Utils.get_version_from_package_file( local_path )
                filename = File.basename(local_path)
-               if filename =~ /.*_.*_.*\.zip/ then
+               if filename =~ /.*_.*_.*\.zip/ then
                        new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
                        return new_name.split(",")[1]
                end
@@ -521,7 +521,7 @@ class Utils
 
        def Utils.get_os_from_package_file( local_path )
                filename = File.basename(local_path)
-               if filename =~ /.*_.*_.*\.zip/ then
+               if filename =~ /.*_.*_.*\.zip/ then
                        new_name = filename.sub(/(.*)_(.*)_(.*)\.zip/,'\1,\2,\3')
                        return new_name.split(",")[2]
                end
@@ -584,17 +584,17 @@ class Utils
        end
 
 
-    def Utils.get_sub_processes(base=Process.pid)
-        descendants = Hash.new{|ht,k| ht[k]=[k]}
+       def Utils.get_sub_processes(base=Process.pid)
+               descendants = Hash.new{|ht,k| ht[k]=[k]}
 
                # generate pid => ppid hash
                # NOTE. MinGW does not support "-o" option and has different output format
                os_category = get_os_category(HOST_OS)
                if os_category != "windows" then        
-               Hash[*`ps -eo pid,ppid`.scan(/\d+/).map{|x| x.to_i}].each{|pid,ppid|
-                descendants[ppid] << descendants[pid]
-               }       
-               return descendants[base].flatten - [base]
+                       Hash[*`ps -eo pid,ppid`.scan(/\d+/).map{|x| x.to_i}].each{|pid,ppid|
+                               descendants[ppid] << descendants[pid]
+                       }       
+                       return descendants[base].flatten - [base]
                else
                        result = []
 
@@ -602,16 +602,16 @@ class Utils
                        require 'rubygems'
                        require 'sys/proctable'
                        win_pids = [base]
-                       Sys::ProcTable.ps { |proc|
-                       win_pids << proc.pid if win_pids.include?(proc.ppid)
-                       }
+                       Sys::ProcTable.ps { |proc|
+                               win_pids << proc.pid if win_pids.include?(proc.ppid)
+                       }
                        result += win_pids
 
                        # gather MinGW/MSYS process id 
                        Hash[*`ps -e`.scan(/^[\t\s]*(\d+)[\t\s]+(\d+)/).flatten.map{|x| x.to_i}].each {|pid,ppid|
-                descendants[ppid] << descendants[pid]
-               }
-                       
+                               descendants[ppid] << descendants[pid]
+                       }
+
                        # get sub processes of windows pids
                        win_pids.each { |pid|
                                if not descendants[pid].nil? then
@@ -623,7 +623,7 @@ class Utils
 
                        return result
                end
-    end 
+       end 
 
 
 
index 5fb6df9ec1bb8008d506a32a05a176e000497d12..a896d3174bb24a224188ba89969b9176c2766185 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  DistSync.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -35,7 +35,7 @@ require "Action.rb"
 require "ScheduledActionHandler.rb"
 
 class DistSyncAction < Action
-       
+
        def initialize(time, pkgserver, dist_name )
                super(time, pkgserver.sync_interval)
 
index 6ed2882a1166fd4cb0aa7f99567b593950853922..738ec6c751fae46a4ceb0a9dd385e17530b28312 100644 (file)
@@ -1,3 +1,31 @@
+=begin
+
+ SocketRegisterListener.rb
+
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+Contact:
+Taejun Ha <taejun.ha@samsung.com>
+Jiil Hyoun <jiil.hyoun@samsung.com>
+Donghyuk Yang <donghyuk.yang@samsung.com>
+DongHee Yang <donghee.yang@samsung.com>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Contributors:
+- S-Core Co., Ltd
+=end
+
 require 'socket'
 require 'thread'
 $LOAD_PATH.unshift File.dirname(__FILE__) 
@@ -32,7 +60,7 @@ class SocketRegisterListener
        def stop_listening()
                @finish_loop = true
        end
-       
+
        private
 
        # thread main  
@@ -69,7 +97,7 @@ class SocketRegisterListener
        def wait_for_job_requests
                req_list = []
                req_list.push @tcp_server.accept                
-               
+
                return req_list
        end
 
@@ -85,16 +113,16 @@ class SocketRegisterListener
                if req_line.split("|").count > 0 then
                        cmd = req_line.split("|")[0].strip 
                end
-               
+
                case cmd
                when "UPLOAD"
-            Thread.new {        
-                       handle_cmd_upload( req_line, req )
-            }             
+                       Thread.new {        
+                               handle_cmd_upload( req_line, req )
+                       }             
                when "REGISTER"
-            Thread.new {        
+                       Thread.new {        
                                handle_cmd_register( req_line, req )
-            }             
+                       }             
                when "STOP"
                        handle_cmd_stop( req_line, req )
                else
@@ -117,16 +145,16 @@ class SocketRegisterListener
                else
                        incoming_dir = "#{@parent_server.incoming_path}"
                end 
-               
+
                file_path_list = []
-        begin
-            @comm_server.receive_file(req, incoming_dir)
-        rescue => e
-            @log.error "Failed to transfer file"
-            @log.error e.message
-            @log.error e.backtrace.inspect
-        end
-        BuildCommServer.send_end(req)
+               begin
+                       @comm_server.receive_file(req, incoming_dir)
+               rescue => e
+                       @log.error "Failed to transfer file"
+                       @log.error e.message
+                       @log.error e.backtrace.inspect
+               end
+               BuildCommServer.send_end(req)
        end
 
        # "Register"    
@@ -141,7 +169,7 @@ class SocketRegisterListener
                        return
                end
                dist_name = tok[1].strip 
-               
+
                if tok[2].start_with? "DOCK" then
                        dock_name = tok[3]
                        idx = 4
@@ -166,27 +194,27 @@ class SocketRegisterListener
                                @parent_server.reload_dist_package()
                                snapshot_name = @parent_server.register( file_path_list, dist_name, true, false, true) 
                                BuildCommServer.send(req,"SUCC|#{snapshot_name}") 
-                       rescue => e
-                               @log.error "register failed"
-                               @log.error e.message
-                               @log.error e.backtrace.inspect
-                               BuildCommServer.send(req, "ERROR|#{e.message}")
-                               @parent_server.release_lock_file
-                               return
-                       end
+               rescue => e
+                       @log.error "register failed"
+                       @log.error e.message
+                       @log.error e.backtrace.inspect
+                       BuildCommServer.send(req, "ERROR|#{e.message}")
+                       @parent_server.release_lock_file
+                       return
+               end
                }
-                               
+
                if not dock_name.empty? then
                        FileUtils.rm_rf "#{@parent_server.incoming_path}/#{dock_name}"
                end
 
                BuildCommServer.send_end(req)
        end
-       
+
        # "STOP"
        def handle_cmd_stop( line, req )
                @log.info "Received STOP REQ"
-               
+
                BuildCommServer.send_begin(req)
 
                tok = line.split("|").map { |x| x.strip }
@@ -196,7 +224,7 @@ class SocketRegisterListener
                        return
                end
                passwd = tok[1].strip 
-               
+
                if @parent_server.passwd.eql? passwd then 
                        @parent_server.finish = true
                        @log.info "Package server stop flag set"
index 0e2702c8a7e5afe598946dcde8a5477b6515af3f..a603d8863b7fec55b3e4145bf40ad2f2e70c4553 100644 (file)
@@ -50,33 +50,33 @@ $get_snapshot_mutex = Mutex.new
 $filemove_mutex = Mutex.new
 class Client
 
-    # constant
-    PKG_LIST_FILE_PREFIX = "pkg_list_"
-    INSTALLED_PKG_LIST_FILE = "installedpackage.list"
-    CONFIG_PATH = "#{PackageServerConfig::CONFIG_ROOT}/client"
-    PACKAGE_INFO_DIR = ".info"
-    DEFAULT_INSTALL_DIR = "#{Utils::HOME}/build_root"
-    DEFAULT_SERVER_ADDR = "http://172.21.17.55/dibs/unstable"
+       # constant
+       PKG_LIST_FILE_PREFIX = "pkg_list_"
+       INSTALLED_PKG_LIST_FILE = "installedpackage.list"
+       CONFIG_PATH = "#{PackageServerConfig::CONFIG_ROOT}/client"
+       PACKAGE_INFO_DIR = ".info"
+       DEFAULT_INSTALL_DIR = "#{Utils::HOME}/build_root"
+       DEFAULT_SERVER_ADDR = "http://172.21.17.55/dibs/unstable"
        OS_INFO_FILE = "os_info"
        ARCHIVE_PKG_LIST_FILE = "archive_pkg_list"      
-    
-    attr_accessor :server_addr, :location, :pkg_hash_os, :is_server_remote, :installed_pkg_hash_loc, :archive_pkg_list, :all_dep_list, :log, :support_os_list, :config_dist_path, :download_path, :tmp_path, :snapshot_path, :snapshots_path, :snapshot_url
 
-    public
-    # initialize
-    # create "remote package hash" and "installed package hash"
-    # @server_addr = server address (can be included distribution, snapshot)
-    # @location = client location (download and install file to this location)
-    def initialize(server_addr, location, logger)
+       attr_accessor :server_addr, :location, :pkg_hash_os, :is_server_remote, :installed_pkg_hash_loc, :archive_pkg_list, :all_dep_list, :log, :support_os_list, :config_dist_path, :download_path, :tmp_path, :snapshot_path, :snapshots_path, :snapshot_url
 
-        # create directory
+       public
+       # initialize
+       # create "remote package hash" and "installed package hash"
+       # @server_addr = server address (can be included distribution, snapshot)
+       # @location = client location (download and install file to this location)
+       def initialize(server_addr, location, logger)
+
+               # create directory
                if not File.exist? CONFIG_PATH then FileUtils.mkdir_p "#{CONFIG_PATH}" end
 
-        # set default server address, location
-        if server_addr.nil? then server_addr = get_default_server_addr() end
+               # set default server address, location
+               if server_addr.nil? then server_addr = get_default_server_addr() end
                if location.nil? then location = get_default_inst_dir() end
 
-        # chop server address, if end with "/"        
+               # chop server address, if end with "/"        
                if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
 
                @snapshot_path = nil
@@ -86,35 +86,35 @@ class Client
                        @snapshot_url = true                            
                        @server_addr, @snapshot_path = split_addr_and_snapshot(server_addr) 
                else                    
-               @server_addr = server_addr
+                       @server_addr = server_addr
                end                             
 
-        @location = location
-        @pkg_hash_os = {}
-        @installed_pkg_hash_loc = {}
-        @archive_pkg_list = []
-        @all_dep_list = []
-        @is_server_remote = Utils.is_url_remote(server_addr)
+               @location = location
+               @pkg_hash_os = {}
+               @installed_pkg_hash_loc = {}
+               @archive_pkg_list = []
+               @all_dep_list = []
+               @is_server_remote = Utils.is_url_remote(server_addr)
                @support_os_list = []
                @config_dist_path = CONFIG_PATH + "/" + get_flat_serveraddr
                @download_path = @config_dist_path + "/downloads"
                @tmp_path = @config_dist_path + "/tmp"
                @snapshots_path = @config_dist_path + "/snapshots"
 
-        # create directory
+               # create directory
                if not File.exist? @config_dist_path then FileUtils.mkdir_p "#{@config_dist_path}" end
                if not File.exist? @download_path then FileUtils.mkdir_p "#{@download_path}" end
                if not File.exist? @snapshots_path then FileUtils.mkdir_p "#{@snapshots_path}" end
                if not File.exist? @tmp_path then FileUtils.mkdir_p "#{@tmp_path}" end
 
-        # set log
-        if logger.nil? or logger.class.to_s.eql? "String" then
-           @log = Log.new(logger)
-        else
-           @log = logger
+               # set log
+               if logger.nil? or logger.class.to_s.eql? "String" then
+                       @log = Log.new(logger)
+               else
+                       @log = logger
                end
 
-        # read installed pkg list, and create hash
+               # read installed pkg list, and create hash
                if not File.exist? @location then FileUtils.mkdir_p "#{@location}" end
                @log.info "Update local package list.. [#{@location}]"          
                read_installed_pkg_list()
@@ -125,9 +125,9 @@ class Client
                @log.info "Initialize - #{server_addr}, #{location}"
        end
 
-    public
-    # update package list from server
-    def update()
+       public
+       # update package list from server
+       def update()
                if not @snapshot_url then               
                        $get_snapshot_mutex.synchronize {
                                @snapshot_path = get_lastest_snapshot(@is_server_remote)
@@ -146,7 +146,7 @@ class Client
                else                    
                        @log.info "Snapshot information is not cached"                          
                end
-               
+
                list_path = get_pkglist_path()
                if list_path.nil? then 
                        @log.error "Failed to get package list path"                            
@@ -189,11 +189,11 @@ class Client
                end             
 
                $update_mutex.synchronize {
-               create_default_config(@server_addr)
-               @log.info "Update package list from \"#{@server_addr}\".. OK"
+                       create_default_config(@server_addr)
+                       @log.info "Update package list from \"#{@server_addr}\".. OK"
                }
 
-        return true
+               return true
        end
 
        private
@@ -204,52 +204,52 @@ class Client
                @log.info "Cleard package list, supported os list.. OK"
        end                     
 
-    public
-    # download package
-    def download(pkg_name, os, trace, loc = nil)
+       public
+       # download package
+       def download(pkg_name, os, trace, loc = nil)
 
                if loc.nil? then loc = @location end
 
-        dependent_pkg_list = []
+               dependent_pkg_list = []
 
-        # get dependent list
-        if trace then
-            dependent_pkg_list = get_install_dependent_packages(pkg_name, os, true, true)
-            if dependent_pkg_list.nil? then
-                @log.error "Failed to get dependency for \"#{pkg_name}\" package"
-                return nil
-            end
-        else dependent_pkg_list = [pkg_name] end
+               # get dependent list
+               if trace then
+                       dependent_pkg_list = get_install_dependent_packages(pkg_name, os, true, true)
+                       if dependent_pkg_list.nil? then
+                               @log.error "Failed to get dependency for \"#{pkg_name}\" package"
+                               return nil
+                       end
+               else dependent_pkg_list = [pkg_name] end
 
                surl = @server_addr
-        # download files
-        file_local_path = []
-        dependent_pkg_list.each do |p|
+               # download files
+               file_local_path = []
+               dependent_pkg_list.each do |p|
                        pkg_name = get_attr_from_pkg(p, os, "name")                             
-            pkg_path = get_attr_from_pkg(p, os, "path")
-            pkg_ver = get_attr_from_pkg(p, os, "version")
+                       pkg_path = get_attr_from_pkg(p, os, "path")
+                       pkg_ver = get_attr_from_pkg(p, os, "version")
                        pkg_checksum = get_attr_from_pkg(p, os, "checksum")
                        pkg_size = get_attr_from_pkg(p, os, "size")
-            if pkg_path.nil? or pkg_ver.nil? then
-                @log.error "\"#{p}\" package does not exist in package server. If it exist in package server, then try \"pkg-cli update\""
-                return nil
-            end
-            url = surl + pkg_path
-            filename = pkg_path.split('/')[-1]
-                       
-            if not FileDownLoader.download(url, loc, @log) then
-            end
-
-               file_path = File.join(loc, filename)
-            file_local_path.push(file_path)
-        end
-
-        if trace then
-            @log.info "Downloaded \"#{pkg_name}\" package with all dependent packages.. OK"
-        end
-        @log.info "  [path: #{file_local_path.join(", ")}]"
-
-        return file_local_path
+                       if pkg_path.nil? or pkg_ver.nil? then
+                               @log.error "\"#{p}\" package does not exist in package server. If it exist in package server, then try \"pkg-cli update\""
+                               return nil
+                       end
+                       url = surl + pkg_path
+                       filename = pkg_path.split('/')[-1]
+
+                       if not FileDownLoader.download(url, loc, @log) then
+                       end
+
+                       file_path = File.join(loc, filename)
+                       file_local_path.push(file_path)
+               end
+
+               if trace then
+                       @log.info "Downloaded \"#{pkg_name}\" package with all dependent packages.. OK"
+               end
+               @log.info "  [path: #{file_local_path.join(", ")}]"
+
+               return file_local_path
        end
 
        private
@@ -275,10 +275,10 @@ class Client
                $filemove_mutex.synchronize {
                        if not File.exist? distfile then
                                Utils.execute_shell("mv #{filepath} #{distfile}")
-                       else 
-                               Utils.execute_shell("rm -f #{filepath}")                                
-                               return distfile 
-                       end
+               else 
+                       Utils.execute_shell("rm -f #{filepath}")                                
+                       return distfile 
+               end
                }
 
                if File.exist? distfile then return distfile
@@ -315,342 +315,342 @@ class Client
                return nil
        end                                     
 
-    public
-    # download dependent source
-    def download_dep_source(file_name)
-
-        file_url = @server_addr + "/source/#{file_name}"
-        if not FileDownLoader.download(file_url, @location, @log) then
-            @log.error "Failed download #{file_name}"
-            return nil
-        end
-        file_local_path = File.join(@location, file_name)
-        @log.info "Downloaded \"#{file_name}\" source file.. OK"
-        @log.info "  [path: #{file_local_path}]"
-
-        return file_local_path
-    end
-
-    public
-    # upload package
-    def upload(ip, port, binary_path_list, ftp_addr=nil, ftp_port=nil, ftp_username=nil, ftp_passwd=nil)
-
-           # check ip and port
-           if ip.nil? or port.nil? then
-               @log.error "Ip and port should be set."
-               return nil
-           end
-
-        # check binary path list
-        if binary_path_list.nil? or binary_path_list.empty? then
-            @log.error "Binary package path should be set."
-            return nil
-        end
+       public
+       # download dependent source
+       def download_dep_source(file_name)
+
+               file_url = @server_addr + "/source/#{file_name}"
+               if not FileDownLoader.download(file_url, @location, @log) then
+                       @log.error "Failed download #{file_name}"
+                       return nil
+               end
+               file_local_path = File.join(@location, file_name)
+               @log.info "Downloaded \"#{file_name}\" source file.. OK"
+               @log.info "  [path: #{file_local_path}]"
+
+               return file_local_path
+       end
+
+       public
+       # upload package
+       def upload(ip, port, binary_path_list, ftp_addr=nil, ftp_port=nil, ftp_username=nil, ftp_passwd=nil)
+
+               # check ip and port
+               if ip.nil? or port.nil? then
+                       @log.error "Ip and port should be set."
+                       return nil
+               end
+
+               # check binary path list
+               if binary_path_list.nil? or binary_path_list.empty? then
+                       @log.error "Binary package path should be set."
+                       return nil
+               end
 
                # create unique dock number
                dock = Utils.create_uniq_name()
 
-        # upload file
-        binary_list = []
-           binary_path_list.each do |bpath|
-            filename = File.basename(bpath)
-               client = BuildCommClient.create(ip, port, @log)
-
-               if client.nil? then
-                @log.error "Failed to create BuildCommClient instance.."
-                   return nil
-               end
-            
-               @log.info "Send ready REQ..  [UPLOAD]"
-            result = client.send("UPLOAD|#{dock}")
-            if not result then
-                @log.error "Failed to send ready REQ.."
-                return nil
-            end
-
-            begin
+               # upload file
+               binary_list = []
+               binary_path_list.each do |bpath|
+                       filename = File.basename(bpath)
+                       client = BuildCommClient.create(ip, port, @log)
+
+                       if client.nil? then
+                               @log.error "Failed to create BuildCommClient instance.."
+                               return nil
+                       end
+
+                       @log.info "Send ready REQ..  [UPLOAD]"
+                       result = client.send("UPLOAD|#{dock}")
+                       if not result then
+                               @log.error "Failed to send ready REQ.."
+                               return nil
+                       end
+
+                       begin
                                if not ftp_addr.nil? then
                                        transporter=FileTransferFTP.new(@log, ftp_addr, ftp_port, ftp_username, ftp_passwd)
                                else
                                        transporter=FileTransferDirect.new(@log)
                                end
 
-                result = client.send_file(bpath, transporter)
-            rescue => e
-                @log.error "FTP failed to put file (exception)"
-                @log.error "#{e.message}"
-                @log.error e.backtrace.inspect
-                return nil
-            end
+                               result = client.send_file(bpath, transporter)
+                       rescue => e
+                               @log.error "FTP failed to put file (exception)"
+                               @log.error "#{e.message}"
+                               @log.error e.backtrace.inspect
+                               return nil
+                       end
 
-            if not result then
+                       if not result then
                                @log.error "FTP failed to put file (result is false)"
-                return nil
-            end
+                               return nil
+                       end
 
                        client.terminate
-            binary_list.push(filename)
-           end
+                       binary_list.push(filename)
+               end
 
-        # register file
+               # register file
                if not binary_list.empty? then 
-                   client = BuildCommClient.create(ip, port, @log)
-            dist = get_distribution
-            if dist.empty? then
-                @log.error "Distribution is empty.."
-                return nil
-            end
-              @log.info "Send register message..  [REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}]"
-            snapshot = nil
-              if client.send "REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}" then
-                output = client.read_lines do |l|
-                    line = l.split("|")
-                    if line[0].strip == "ERROR" then
-                        @log.error l.strip
-                        return nil
-                    elsif line[0].strip == "SUCC" then
-                        snapshot = line[1].strip
-                    end
-                end
-                if not output then
-                    @log.error "Failed to register"
-                    return nil
-                end
-            end    
-
-                   client.terminate
-            snapshot = @server_addr + "/snapshots/" + snapshot
-            @log.info "Registered successfully!  [#{binary_path_list.join("|")}]"
-            if snapshot.empty? then
-                @log.error "Failed to generate snapshot"
-            end
-               end
-
-        return snapshot
-    end
-
-    private
-    # verify package before uploading
-    def verify_upload(pkg_name, pkg_path)
-
-        manifest_file = "pkginfo.manifest"
-        uniq_name = Utils.create_uniq_name
-        path = Utils::HOME + "/tmp/#{uniq_name}"
-        if not File.exist? path then FileUtils.mkdir_p "#{path}" end
-        begin
-            if not FileInstaller.extract_a_file(pkg_path, manifest_file, path, @log) then
-                @log.error "The \"pkginfo.manifest\" file does not exist in \"#{pkg_path}\""
-                return false
-            end
-            manifest_path = File.join(path, manifest_file)
-            pkg = Parser.read_single_pkginfo_from manifest_path
+                       client = BuildCommClient.create(ip, port, @log)
+                       dist = get_distribution
+                       if dist.empty? then
+                               @log.error "Distribution is empty.."
+                               return nil
+                       end
+
+                       @log.info "Send register message..  [REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}]"
+                               snapshot = nil
+                       if client.send "REGISTER|#{dist}|DOCK|#{dock}|#{binary_list.join("|")}" then
+                               output = client.read_lines do |l|
+                               line = l.split("|")
+                               if line[0].strip == "ERROR" then
+                                       @log.error l.strip
+                                       return nil
+                               elsif line[0].strip == "SUCC" then
+                                       snapshot = line[1].strip
+                               end
+                       end
+                       if not output then
+                               @log.error "Failed to register"
+                               return nil
+                       end
+                       end    
+
+                       client.terminate
+                       snapshot = @server_addr + "/snapshots/" + snapshot
+                       @log.info "Registered successfully!  [#{binary_path_list.join("|")}]"
+                       if snapshot.empty? then
+                               @log.error "Failed to generate snapshot"
+                       end
+               end
+
+               return snapshot
+       end
+
+       private
+       # verify package before uploading
+       def verify_upload(pkg_name, pkg_path)
+
+               manifest_file = "pkginfo.manifest"
+               uniq_name = Utils.create_uniq_name
+               path = Utils::HOME + "/tmp/#{uniq_name}"
+               if not File.exist? path then FileUtils.mkdir_p "#{path}" end
+               begin
+                       if not FileInstaller.extract_a_file(pkg_path, manifest_file, path, @log) then
+                               @log.error "The \"pkginfo.manifest\" file does not exist in \"#{pkg_path}\""
+                               return false
+                       end
+                       manifest_path = File.join(path, manifest_file)
+                       pkg = Parser.read_single_pkginfo_from manifest_path
                        if File.exists? manifest_path then FileUtils.rm_f(manifest_path) end
-            FileUtils.remove_dir(path, true)
-        rescue Interrupt
-            @log.error "Client: Interrupted.."
-            FileUtils.remove_dir(path, true)
-            @log.info "Removed #{path}"
-            raise Interrupt
+                       FileUtils.remove_dir(path, true)
+               rescue Interrupt
+                       @log.error "Client: Interrupted.."
+                       FileUtils.remove_dir(path, true)
+                       @log.info "Removed #{path}"
+                       raise Interrupt
                rescue RuntimeError => e
                        @log.error( e.message, Log::LV_USER)
-            FileUtils.remove_dir(path, true)
-            @log.info "Removed #{path}"
+                       FileUtils.remove_dir(path, true)
+                       @log.info "Removed #{path}"
                        return false
-        end
-        new_pkg_ver = pkg.version
-        new_pkg_install_dep_list = pkg.install_dep_list
-        os = pkg.os
-
-        list = get_all_reverse_install_dependent_packages_remote(pkg_name, os, true)
-
-        if not list.nil? then 
-            list.each do |p|
-                ilist = get_attr_from_pkg(p, os, "install_dep_list")
-                if ilist.nil? then next end
-                ilist.each do |l|
-                    if l.package_name.eql? pkg_name then
-                        if not l.match? new_pkg_ver then
-                            @log.error "\"#{p}\" package has following install dependency : #{l.package_name} (#{l.comp} #{l.base_version})"
-                            return false
-                        end
-                    end
-                end
-            end
-        end
-
-        if not new_pkg_install_dep_list.nil? then
-            new_pkg_install_dep_list.each do |l|
-                if not check_remote_pkg(l.package_name, os) then
-                    @log.error "\"#{pkg_name}\" package has following install dependency : #{l.package_name} (#{l.comp} #{l.base_version}), but \"#{l.package_name}\" is not exist on server"
-                    return false
-                end
-                rver = get_attr_from_pkg(l.package_name, os, "version")
-                if not l.match? rver then
-                    @log.error "\"#{pkg_name}\" package has following install dependency : #{l.package_name} (#{l.comp} #{l.base_version})"
-                    return false
-                end
-            end
-        end
-
-        @log.info "Passed to verify packages for uploading.. OK"
-        return true
-    end
-
-    private    
-    # get distribution
-    def get_distribution()
-        server = @server_addr
-        if server.nil? or server.empty? then
-            @log.error "Server addr is nil"
-            return nil
-        end
-
-        dist = ""
+               end
+               new_pkg_ver = pkg.version
+               new_pkg_install_dep_list = pkg.install_dep_list
+               os = pkg.os
+
+               list = get_all_reverse_install_dependent_packages_remote(pkg_name, os, true)
+
+               if not list.nil? then 
+                       list.each do |p|
+                               ilist = get_attr_from_pkg(p, os, "install_dep_list")
+                               if ilist.nil? then next end
+                               ilist.each do |l|
+                                       if l.package_name.eql? pkg_name then
+                                               if not l.match? new_pkg_ver then
+                                                       @log.error "\"#{p}\" package has following install dependency : #{l.package_name} (#{l.comp} #{l.base_version})"
+                                                       return false
+                                               end
+                                       end
+                               end
+                       end
+               end
+
+               if not new_pkg_install_dep_list.nil? then
+                       new_pkg_install_dep_list.each do |l|
+                               if not check_remote_pkg(l.package_name, os) then
+                                       @log.error "\"#{pkg_name}\" package has following install dependency : #{l.package_name} (#{l.comp} #{l.base_version}), but \"#{l.package_name}\" is not exist on server"
+                                       return false
+                               end
+                               rver = get_attr_from_pkg(l.package_name, os, "version")
+                               if not l.match? rver then
+                                       @log.error "\"#{pkg_name}\" package has following install dependency : #{l.package_name} (#{l.comp} #{l.base_version})"
+                                       return false
+                               end
+                       end
+               end
+
+               @log.info "Passed to verify packages for uploading.. OK"
+               return true
+       end
+
+       private    
+       # get distribution
+       def get_distribution()
+               server = @server_addr
+               if server.nil? or server.empty? then
+                       @log.error "Server addr is nil"
+                       return nil
+               end
+
+               dist = ""
                dist = File.basename(server)
 
-        return dist
+               return dist
        end
 
        private
        def get_flat_serveraddr()
-        server = @server_addr
-        if server.nil? or server.empty? then
-            @log.error "Server addr is nil"
-            return nil
+               server = @server_addr
+               if server.nil? or server.empty? then
+                       @log.error "Server addr is nil"
+                       return nil
                end
-               
+
                server = server.delete ".:/@"
                return server
        end                                     
 
-    public
+       public
        # install package
-    # install all install dependency packages
-    def install(pkg_name, os, trace, force)
+       # install all install dependency packages
+       def install(pkg_name, os, trace, force)
 
                ret = install_internal( pkg_name, os, trace, force )
                return ret      
        end
 
 
-    private
-    def install_internal(pkg_name, os, trace, force)
-
-        if trace.nil? then trace = true end
-        if force.nil? then force = false end
-
-        # check meta package
-        is_meta_pkg = check_meta_pkg(pkg_name, os)
-        if is_meta_pkg then trace = true end
-
-        # compare package version with installed package's
-        pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
-        if pkg_ver.nil? or pkg_ver.empty? then
-            @log.error "#{pkg_name} package does not exist in remote package list"
-            return false
-        end
-               
-
-        compare_result = compare_version_with_installed_pkg(pkg_name, pkg_ver)
-        if not force then
-               case compare_result
-               when -1 then
-                       @log.warn "Checked \"#{pkg_name}\" package version : it is bigger then remote package version"
-                       return true
-               when 0 then
-                       @log.warn "Checked \"#{pkg_name}\" package version : it is same with remote package version"
-                       return true
-               when 1, 2 then
-               end
-        end
-
-               # if enable trace, create all dependent package list
-               if trace then
-               dependent_pkg_list = get_install_dependent_packages(pkg_name, os, true, force)
-               if dependent_pkg_list.nil? then
-                       @log.error "Failed to get dependency for \"#{pkg_name}\" package"
-                       return false
-               end
-               else
-               dependent_pkg_list = [pkg_name]
-               end
-
-               # TODO: need to compare dependent package version
-               # install packages including dependent packages
-               dependent_pkg_list.each do |pkg|
-               if not install_pkg(pkg, os, force) then 
-                       @log.error "#{pkg} does not exist"
-                       return false
-               end
-               add_pkg_info(pkg, os)
-               end
-
-               # write installed package information to file
-               write_pkg_hash_to_file(nil)
-
-        if trace then
-            @log.info "Installed \"#{pkg_name} [#{pkg_ver}]\" package with all dependent packages.. OK"
-            @log.info "  [#{dependent_pkg_list.join(" -> ")}]"
-        else
-            @log.info "Install only \"#{pkg_name} [#{pkg_ver}]\" package.. OK"
-        end
-
-        return true
+       private
+       def install_internal(pkg_name, os, trace, force)
+
+               if trace.nil? then trace = true end
+               if force.nil? then force = false end
+
+               # check meta package
+               is_meta_pkg = check_meta_pkg(pkg_name, os)
+               if is_meta_pkg then trace = true end
+
+               # compare package version with installed package's
+               pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
+               if pkg_ver.nil? or pkg_ver.empty? then
+                       @log.error "#{pkg_name} package does not exist in remote package list"
+                       return false
+               end
+
+
+               compare_result = compare_version_with_installed_pkg(pkg_name, pkg_ver)
+               if not force then
+                       case compare_result
+                       when -1 then
+                               @log.warn "Checked \"#{pkg_name}\" package version : it is bigger then remote package version"
+                               return true
+                       when 0 then
+                               @log.warn "Checked \"#{pkg_name}\" package version : it is same with remote package version"
+                               return true
+                       when 1, 2 then
+                       end
+               end
+
+               # if enable trace, create all dependent package list
+               if trace then
+                       dependent_pkg_list = get_install_dependent_packages(pkg_name, os, true, force)
+                       if dependent_pkg_list.nil? then
+                               @log.error "Failed to get dependency for \"#{pkg_name}\" package"
+                               return false
+                       end
+               else
+                       dependent_pkg_list = [pkg_name]
+               end
+
+               # TODO: need to compare dependent package version
+               # install packages including dependent packages
+               dependent_pkg_list.each do |pkg|
+                       if not install_pkg(pkg, os, force) then 
+                               @log.error "#{pkg} does not exist"
+                               return false
+                       end
+                       add_pkg_info(pkg, os)
+               end
+
+               # write installed package information to file
+               write_pkg_hash_to_file(nil)
+
+               if trace then
+                       @log.info "Installed \"#{pkg_name} [#{pkg_ver}]\" package with all dependent packages.. OK"
+                       @log.info "  [#{dependent_pkg_list.join(" -> ")}]"
+               else
+                       @log.info "Install only \"#{pkg_name} [#{pkg_ver}]\" package.. OK"
+               end
+
+               return true
        end
 
 
-    public
-    # install local package (ignore dependent packages)
-    def install_local_pkg(pkg_path, trace, force, repos_paths = nil)
+       public
+       # install local package (ignore dependent packages)
+       def install_local_pkg(pkg_path, trace, force, repos_paths = nil)
 
                ret = install_local_pkg_internal(pkg_path, trace, force, repos_paths)
                return ret
        end
 
 
-    private
-    def install_local_pkg_internal(pkg_path, trace, force, repos_paths)
+       private
+       def install_local_pkg_internal(pkg_path, trace, force, repos_paths)
 
-        file_name = File.basename(pkg_path)
-        pkg_name = file_name.split('_')[0]
+               file_name = File.basename(pkg_path)
+               pkg_name = file_name.split('_')[0]
 
-        if not File.exist? pkg_path then
-            @log.error "\"#{pkg_path}\" file does not exist"
-            return false
-        end
-        filename = File.basename(pkg_path)
-        ext = File.extname(filename)
-        if not ext.eql? ".zip" then
-            @log.error "\"#{file_name}\" is not zip file. binary package file should have .zip ext"
-            return false
-        end
-        pkg_name = filename.split("_")[0]
-        manifest_file = "pkginfo.manifest"
+               if not File.exist? pkg_path then
+                       @log.error "\"#{pkg_path}\" file does not exist"
+                       return false
+               end
+               filename = File.basename(pkg_path)
+               ext = File.extname(filename)
+               if not ext.eql? ".zip" then
+                       @log.error "\"#{file_name}\" is not zip file. binary package file should have .zip ext"
+                       return false
+               end
+               pkg_name = filename.split("_")[0]
+               manifest_file = "pkginfo.manifest"
 
-        uniq_name = Utils.create_uniq_name
-        path = Utils::HOME + "/tmp/#{uniq_name}"
+               uniq_name = Utils.create_uniq_name
+               path = Utils::HOME + "/tmp/#{uniq_name}"
                if not File.exist? path then FileUtils.mkdir_p "#{path}" end
-        begin
-            if not FileInstaller.extract_a_file(pkg_path, manifest_file, path, @log) then
-                @log.error "pkginfo.manifest file does not exist in #{pkg_path}"
-                return false
-            end
-            manifest_path = File.join(path, manifest_file)
-            pkg = Parser.read_single_pkginfo_from manifest_path
-            new_pkg_ver = pkg.version
-            FileUtils.remove_dir(path, true)
-        rescue Interrupt
-            @log.error "Client: Interrupted.."
-            FileUtils.remove_dir(path, true)
-            @log.info "Removed #{path}"
-            raise Interrupt
+               begin
+                       if not FileInstaller.extract_a_file(pkg_path, manifest_file, path, @log) then
+                               @log.error "pkginfo.manifest file does not exist in #{pkg_path}"
+                               return false
+                       end
+                       manifest_path = File.join(path, manifest_file)
+                       pkg = Parser.read_single_pkginfo_from manifest_path
+                       new_pkg_ver = pkg.version
+                       FileUtils.remove_dir(path, true)
+               rescue Interrupt
+                       @log.error "Client: Interrupted.."
+                       FileUtils.remove_dir(path, true)
+                       @log.info "Removed #{path}"
+                       raise Interrupt
                rescue RuntimeError => e
                        @log.error( e.message, Log::LV_USER)
                        FileUtils.remove_dir(path, true)
-            @log.info "Removed #{path}"
+                       @log.info "Removed #{path}"
                        return false
-        end
+               end
 
                compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
                if not force then
@@ -665,8 +665,8 @@ class Client
                        end
                end
 
-               if check_installed_pkg(pkg_name) then
-               uninstall(pkg_name, false)
+               if check_installed_pkg(pkg_name) then
+                       uninstall(pkg_name, false)
                end
 
                if trace then
@@ -708,689 +708,689 @@ class Client
                add_local_pkg_info(pkg_name)
                write_pkg_hash_to_file(nil)
 
-        @log.info "Installed \"#{pkg_path} [#{new_pkg_ver}]\" file.. OK"
-        return true
-    end
-
-
-    public
-    # upgrade package
-    def upgrade(os, trace)
-
-        if trace.nil? then trace = true end
-        list = check_upgrade(os)
-
-        if list.empty? or list.nil? then
-            @log.info "There is no packages for upgrading.."
-            return false
-        end
-
-        list.each do |p|
-            if check_installed_pkg(p) then
-                if not uninstall(p, trace) then
-                    @log.error "Failed to uninstall \"#{p}\" package.."
-                    return false
-                end
-            end
-
-            if not install_internal(p, os, trace, false) then
-                @log.error "Failed to install \"#{p}\" package.."
-                return false
-            end
-        end
-
-        @log.info "Upgraded packages from #{@server_addr}.. OK"
-        return true
-    end
-
-    public
-    # check package which will be upgraded
-    def check_upgrade(os)
-
-        update_pkgs = []
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        installed_pkg_hash = installed_pkg_hash_loc[installed_pkg_hash_key]
-        remote_pkg_hash = pkg_hash_os[os]
-        
-        if remote_pkg_hash.nil? then
-            @log.error "There is no remote package list for #{os}. please pkg-cli update"
-            return nil
-        end
-
-        if installed_pkg_hash.nil? then
-            @log.warn "There is no any installed package in \"#{@location}\""
-            return remote_pkg_hash.keys
-        end
-
-        arr_keys = installed_pkg_hash.keys
-        arr_keys.each do |k|
-            installed_ver = get_attr_from_installed_pkg(k, "version")
-            if not check_remote_pkg(k, os) then next end
-            remote_ver = get_attr_from_pkg(k, os, "version")
-            compare_result = compare_version_with_installed_pkg(k, remote_ver)
-            case compare_result
-            when -1 then next
-            when 0 then next
-            when 1 then 
-                @log.output "\"#{k}\" package : #{installed_ver} -> #{remote_ver}"
-                update_pkgs.push(k) 
-            end
-        end
-
-        @log.info "Checked packages for upgrading.. OK"
-        return update_pkgs    
-    end
-
-    public
-    def get_default_server_addr()
-        filepath = "#{CONFIG_PATH}/config"
-        server_addr = nil
-
-        if not File.exist? filepath then create_default_config(nil) end
-        if not File.exist? filepath then
-            @log.error "There is no default server address in #{filepath}"
-            return nil
-        end
-
-        File.open filepath, "r" do |f|
-            f.each_line do |l|
-                if l.strip.start_with? "DEFAULT_SERVER_ADDR :" then
-                    server_addr = l.split("DEFAULT_SERVER_ADDR :")[1].strip
-                break
-                else next end
-            end
-        end
-
-        if server_addr.nil? then create_default_config(DEFAULT_SERVER_ADDR) end
-        return server_addr
-    end
-
-    public
-    # get default path for installing
-    def get_default_inst_dir()
-        return Dir.pwd 
-    end
-
-    private
-    # create default config file (Utils::HOME/.build_tools/client/config)
-    def create_default_config(server_addr)
-        filepath = "#{CONFIG_PATH}/config"
-        if server_addr.nil? then server_addr = DEFAULT_SERVER_ADDR end
-
-        if File.exist? filepath then
-            FileUtils.rm_f(filepath)
-        end
-
-        if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
-        
-        File.open(filepath, "a+") do |file|
-            file.puts "DEFAULT_SERVER_ADDR : #{server_addr}"
-        end
-    end
-
-    public
-    # uninstall package
-    # trace : if true, uninstall all dependent packages
-    def uninstall(pkg_name, trace)
-
-        type = "binary"
-        pkg_list = []
-        pkg_hash = nil
-
-        if not check_installed_pkg(pkg_name) then
-            @log.error "\"#{pkg_name}\" package is not installed."
-            return false 
-        end
-
-        pkg_ver = get_attr_from_installed_pkg(pkg_name, "version")
-
-        if trace then
-            pkg_list = get_all_reverse_install_dependent_packages(pkg_name, true)
-            if pkg_list.nil? then
-                @log.error "Failed to get \"#{pkg_name}\" package dependency information."
-                return false
-            end
-        else
-            pkg_list.push(pkg_name)
-        end
-
-        pkg_list.each do |p|
-            if not check_installed_pkg(p) then next end
-            if not FileInstaller.uninstall(p, type, @location, @log) then
-                @log.error "Failed uninstall \"#{pkg_name}\" package"
-                return false
-            end
-            pkg_hash = remove_pkg_info(p)
-        end
-
-        if trace then
-            @log.info "Uninstalled \"#{pkg_name} [#{pkg_ver}]\" package with all dependent packages.. OK"
-            @log.info "  [#{pkg_list.join(" -> ")}]"
-        else
-            @log.info "Uninstalled only \"#{pkg_name} [#{pkg_ver}]\" package.. OK"
-        end
-
-        write_pkg_hash_to_file(nil)
-        return true
-    end
-
-    public 
-    # clean
-    def clean(force)
-        if not force then
-            puts "Do you really want to remove \"#{@location}\" path? [yes]"
-            input = $stdin.gets.strip
-            if input.upcase.eql? "YES" then
-                @log.info "Removed \"#{@location}\""
-            else
-                @log.info "Canceled"
-                return
-            end
-        end
+               @log.info "Installed \"#{pkg_path} [#{new_pkg_ver}]\" file.. OK"
+               return true
+       end
+
+
+       public
+       # upgrade package
+       def upgrade(os, trace)
+
+               if trace.nil? then trace = true end
+               list = check_upgrade(os)
+
+               if list.empty? or list.nil? then
+                       @log.info "There is no packages for upgrading.."
+                       return false
+               end
+
+               list.each do |p|
+                       if check_installed_pkg(p) then
+                               if not uninstall(p, trace) then
+                                       @log.error "Failed to uninstall \"#{p}\" package.."
+                                       return false
+                               end
+                       end
+
+                       if not install_internal(p, os, trace, false) then
+                               @log.error "Failed to install \"#{p}\" package.."
+                               return false
+                       end
+               end
+
+               @log.info "Upgraded packages from #{@server_addr}.. OK"
+               return true
+       end
+
+       public
+       # check package which will be upgraded
+       def check_upgrade(os)
+
+               update_pkgs = []
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               installed_pkg_hash = installed_pkg_hash_loc[installed_pkg_hash_key]
+               remote_pkg_hash = pkg_hash_os[os]
+
+               if remote_pkg_hash.nil? then
+                       @log.error "There is no remote package list for #{os}. please pkg-cli update"
+                       return nil
+               end
+
+               if installed_pkg_hash.nil? then
+                       @log.warn "There is no any installed package in \"#{@location}\""
+                       return remote_pkg_hash.keys
+               end
+
+               arr_keys = installed_pkg_hash.keys
+               arr_keys.each do |k|
+                       installed_ver = get_attr_from_installed_pkg(k, "version")
+                       if not check_remote_pkg(k, os) then next end
+                       remote_ver = get_attr_from_pkg(k, os, "version")
+                       compare_result = compare_version_with_installed_pkg(k, remote_ver)
+                       case compare_result
+                       when -1 then next
+                       when 0 then next
+                       when 1 then 
+                               @log.output "\"#{k}\" package : #{installed_ver} -> #{remote_ver}"
+                               update_pkgs.push(k) 
+                       end
+               end
+
+               @log.info "Checked packages for upgrading.. OK"
+               return update_pkgs    
+       end
+
+       public
+       def get_default_server_addr()
+               filepath = "#{CONFIG_PATH}/config"
+               server_addr = nil
+
+               if not File.exist? filepath then create_default_config(nil) end
+               if not File.exist? filepath then
+                       @log.error "There is no default server address in #{filepath}"
+                       return nil
+               end
+
+               File.open filepath, "r" do |f|
+                       f.each_line do |l|
+                               if l.strip.start_with? "DEFAULT_SERVER_ADDR :" then
+                                       server_addr = l.split("DEFAULT_SERVER_ADDR :")[1].strip
+                                       break
+                               else next end
+                       end
+               end
+
+               if server_addr.nil? then create_default_config(DEFAULT_SERVER_ADDR) end
+               return server_addr
+       end
+
+       public
+       # get default path for installing
+       def get_default_inst_dir()
+               return Dir.pwd 
+       end
+
+       private
+       # create default config file (Utils::HOME/.build_tools/client/config)
+       def create_default_config(server_addr)
+               filepath = "#{CONFIG_PATH}/config"
+               if server_addr.nil? then server_addr = DEFAULT_SERVER_ADDR end
+
+               if File.exist? filepath then
+                       FileUtils.rm_f(filepath)
+               end
+
+               if server_addr.strip.end_with? "/" then server_addr = server_addr.chop end
+
+               File.open(filepath, "a+") do |file|
+                       file.puts "DEFAULT_SERVER_ADDR : #{server_addr}"
+               end
+       end
+
+       public
+       # uninstall package
+       # trace : if true, uninstall all dependent packages
+       def uninstall(pkg_name, trace)
+
+               type = "binary"
+               pkg_list = []
+               pkg_hash = nil
+
+               if not check_installed_pkg(pkg_name) then
+                       @log.error "\"#{pkg_name}\" package is not installed."
+                       return false 
+               end
+
+               pkg_ver = get_attr_from_installed_pkg(pkg_name, "version")
+
+               if trace then
+                       pkg_list = get_all_reverse_install_dependent_packages(pkg_name, true)
+                       if pkg_list.nil? then
+                               @log.error "Failed to get \"#{pkg_name}\" package dependency information."
+                               return false
+                       end
+               else
+                       pkg_list.push(pkg_name)
+               end
+
+               pkg_list.each do |p|
+                       if not check_installed_pkg(p) then next end
+                       if not FileInstaller.uninstall(p, type, @location, @log) then
+                               @log.error "Failed uninstall \"#{pkg_name}\" package"
+                               return false
+                       end
+                       pkg_hash = remove_pkg_info(p)
+               end
+
+               if trace then
+                       @log.info "Uninstalled \"#{pkg_name} [#{pkg_ver}]\" package with all dependent packages.. OK"
+                       @log.info "  [#{pkg_list.join(" -> ")}]"
+               else
+                       @log.info "Uninstalled only \"#{pkg_name} [#{pkg_ver}]\" package.. OK"
+               end
+
+               write_pkg_hash_to_file(nil)
+               return true
+       end
+
+       public 
+       # clean
+       def clean(force)
+               if not force then
+                       puts "Do you really want to remove \"#{@location}\" path? [yes]"
+                       input = $stdin.gets.strip
+                       if input.upcase.eql? "YES" then
+                               @log.info "Removed \"#{@location}\""
+                       else
+                               @log.info "Canceled"
+                               return
+                       end
+               end
                if File.exist? @location then FileUtils.rm_rf(@location) end
-        FileUtils.mkdir_p(@location)
-        #@pkg_hash_os.clear
-        @installed_pkg_hash_loc.clear
-        #@archive_pkg_list.clear
-        @log.info "Cleaned \"#{@location}\" path.. OK"
-    end
-
-    public
+               FileUtils.mkdir_p(@location)
+               #@pkg_hash_os.clear
+               @installed_pkg_hash_loc.clear
+               #@archive_pkg_list.clear
+               @log.info "Cleaned \"#{@location}\" path.. OK"
+       end
+
+       public
        # get reverse build dependent packages (just 1 depth)
-    def get_reverse_build_dependent_packages(pkg_name, os)
+       def get_reverse_build_dependent_packages(pkg_name, os)
 
-        result = []
-        pkg_hash = @pkg_hash_os[os]
+               result = []
+               pkg_hash = @pkg_hash_os[os]
                if pkg_hash.nil? then return [] end
-        pkg_list = pkg_hash.values
-        pkg_list.each do |pkg|
-            pkg.build_dep_list.each do |dep|
-                if dep.package_name.eql? pkg_name and
+               pkg_list = pkg_hash.values
+               pkg_list.each do |pkg|
+                       pkg.build_dep_list.each do |dep|
+                               if dep.package_name.eql? pkg_name and
                                        not dep.target_os_list.nil? and 
                                        dep.target_os_list.include? os then
-                    result.push(pkg)
-                end
-            end
-        end
+                                       result.push(pkg)
+                               end
+                       end
+               end
 
-        return result
-    end
+               return result
+       end
 
-    public
+       public
        # get reverse source dependent packages (just 1 depth)
-    def get_reverse_source_dependent_packages(pkg_name)
+       def get_reverse_source_dependent_packages(pkg_name)
 
-        result = []
-        @support_os_list.each do |os|
-               pkg_hash = @pkg_hash_os[os]
-               pkg_list = pkg_hash.values
-               pkg_list.each do |pkg|
-               pkg.source_dep_list.each do |p|
-                       if p.package_name.eql? pkg_name then
-                       result.push(pkg)
-                       end
-               end
-               end
+               result = []
+               @support_os_list.each do |os|
+                       pkg_hash = @pkg_hash_os[os]
+                       pkg_list = pkg_hash.values
+                       pkg_list.each do |pkg|
+                               pkg.source_dep_list.each do |p|
+                                       if p.package_name.eql? pkg_name then
+                                               result.push(pkg)
+                                       end
+                               end
+                       end
                end
 
-        return result
-    end
+               return result
+       end
 
-    public
+       public
        # get reverse install dependent packages (jush 1 depth)
-    def get_reverse_install_dependent_packages(pkg_name, os)
-
-        result = []
-        pkg_hash = @pkg_hash_os[os]
-        pkg_list = pkg_hash.values
-        pkg_list.each do |pkg|
-            pkg.install_dep_list.each do |p|
-                if p.package_name.eql? pkg_name then
-                    result.push(pkg.package_name)
-                end
-            end
-        end
-
-        return result
-    end
-
-    public
+       def get_reverse_install_dependent_packages(pkg_name, os)
+
+               result = []
+               pkg_hash = @pkg_hash_os[os]
+               pkg_list = pkg_hash.values
+               pkg_list.each do |pkg|
+                       pkg.install_dep_list.each do |p|
+                               if p.package_name.eql? pkg_name then
+                                       result.push(pkg.package_name)
+                               end
+                       end
+               end
+
+               return result
+       end
+
+       public
        # get all build dependent packages (considered build priority, and reverse)
-    def get_build_dependent_packages(pkg_name, os, reverse)
-
-        if not check_remote_pkg(pkg_name, os) then return nil end
-        if reverse.nil? then reverse = true end
-
-        @all_dep_list.clear
-        begin            
-            get_build_dependency_arr(pkg_name, os, 0)
-        # in case of cross build dependency
-        rescue SystemStackError
-            @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
-            return nil
-        end
-
-        max = 0
-        @all_dep_list.each do |p|
-            if p[0].to_i > max then
-                max = p[0].to_i
-            else next end
-        end
-
-        result = []
-        i = 0
-        while i <= max
-            @all_dep_list.each do |p|
-                if p[0].to_i.eql? i then
-                    d = p[1]
-                    remote_os = get_attr_from_pkg(d.package_name, os, "os")
-                    remote_ver = get_attr_from_pkg(d.package_name, os, "version") 
-                    if not d.target_os_list.include? remote_os then
-                        @log.error "\"#{pkg_name}\" package needs \"#{d.package_name}\" #{d.target_os_list.to_s}, but \"#{d.package_name}\" (#{remote_os}) package is in server"
-                        return nil
-                    end
-                    if not d.match? remote_ver then
-                        @log.error "\"#{pkg_name}\" package needs \"#{d.package_name}\" #{d.comp} #{d.base_version}, but \"#{d.package_name}\" (#{remote_ver}) package is in server"
-                        return nil
-                    else result.push(d.package_name) end
-                end
-            end
-            i = i + 1
-        end
-
-        @log.info "Get build dependent packages for #{pkg_name} package.. OK"
-        if reverse then return result.reverse.uniq.push(pkg_name)
-        else return result.uniq.insert(0, pkg_name) end
-    end
-
-    public
+       def get_build_dependent_packages(pkg_name, os, reverse)
+
+               if not check_remote_pkg(pkg_name, os) then return nil end
+               if reverse.nil? then reverse = true end
+
+               @all_dep_list.clear
+               begin            
+                       get_build_dependency_arr(pkg_name, os, 0)
+                       # in case of cross build dependency
+               rescue SystemStackError
+                       @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
+                       return nil
+               end
+
+               max = 0
+               @all_dep_list.each do |p|
+                       if p[0].to_i > max then
+                               max = p[0].to_i
+                       else next end
+               end
+
+               result = []
+               i = 0
+               while i <= max
+                       @all_dep_list.each do |p|
+                               if p[0].to_i.eql? i then
+                                       d = p[1]
+                                       remote_os = get_attr_from_pkg(d.package_name, os, "os")
+                                       remote_ver = get_attr_from_pkg(d.package_name, os, "version") 
+                                       if not d.target_os_list.include? remote_os then
+                                               @log.error "\"#{pkg_name}\" package needs \"#{d.package_name}\" #{d.target_os_list.to_s}, but \"#{d.package_name}\" (#{remote_os}) package is in server"
+                                               return nil
+                                       end
+                                       if not d.match? remote_ver then
+                                               @log.error "\"#{pkg_name}\" package needs \"#{d.package_name}\" #{d.comp} #{d.base_version}, but \"#{d.package_name}\" (#{remote_ver}) package is in server"
+                                               return nil
+                                       else result.push(d.package_name) end
+                               end
+                       end
+                       i = i + 1
+               end
+
+               @log.info "Get build dependent packages for #{pkg_name} package.. OK"
+               if reverse then return result.reverse.uniq.push(pkg_name)
+               else return result.uniq.insert(0, pkg_name) end
+       end
+
+       public
        # get all install dependent packages (considered install priority, reverse, and force)
-    # reverse : return reverse result
-    # force : install package force
-    def get_install_dependent_packages(pkg_name, os, reverse, force)
-
-        if not check_remote_pkg(pkg_name, os) then return nil end
-        if reverse.nil? then reverse = true end
-
-        @all_dep_list.clear
-        begin            
-            get_install_dependency_arr(pkg_name, os, force, 0)
-        # in case of cross build dependency
-        rescue SystemStackError
-            @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
-            return nil
-        end
-
-        max = 0
-        @all_dep_list.each do |p|
-            if p[0].to_i > max then
-                max = p[0].to_i
-            else next end
-        end
-
-        result = []
-        i = 0
-        while i <= max
-            @all_dep_list.each do |p|
-                if p[0].to_i.eql? i then
-                    d = p[1]
-                    remote_ver = get_attr_from_pkg(d.package_name, os, "version") 
-                    if not d.match? remote_ver then
-                        @log.error "\"#{pkg_name}\" package needs \"#{d.package_name}\" #{d.comp} #{d.base_version}, but \"#{d.package_name}\" (#{remote_ver}) package is in server"
-                        return nil
-                    else result.push(d.package_name) end
-                end
-            end
-            i = i + 1
-        end
-        
-        @log.info "Get install dependent packages for \"#{pkg_name}\" package.. OK"
-        if reverse then return result.reverse.uniq.push(pkg_name)
-        else return result.uniq.insert(0, pkg_name) end
-    end
-
-    public
-    # get all reverse install dependent packages (considered reverse install priority for tracing uninstall)
-    def get_all_reverse_install_dependent_packages(pkg_name, reverse)
-
-        if not check_installed_pkg(pkg_name) then return nil end
-        if reverse.nil? then reverse = true end
-
-        begin
-            res = get_all_reverse_install_dependency_arr(pkg_name, 0)
-        rescue SystemStackError
-            @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
-            return nil
-        end
-        res2 = res.split("::")
-        result = []
-        res2.each do |r|
-            result.push(r.split(':')[1])
-        end
-
-        @log.info "Get all reverse install dependent packages for #{pkg_name} package.. OK"
-        if reverse then return result.reverse.uniq
-        else return result end
-    end
-
-    public
-    # get all reverse remote dependent packages (considered reverse install priority for tracing uninstall)
-    def get_all_reverse_install_dependent_packages_remote(pkg_name, os, reverse)
-        #if not check_remote_pkg(pkg_name, os) then return nil end
-        if reverse.nil? then reverse = true end
-
-        begin
-            res = get_all_reverse_install_dependency_arr_remote(pkg_name, os, 0)
-        rescue SystemStackError
-            @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
-            return nil
-        end
-        res2 = res.split("::")
-        result = []
-        res2.each do |r|
-            result.push(r.split(':')[1])
-        end
-
-        @log.info "Get all reverse install dependent packages for #{pkg_name} package.. OK"
-        if reverse then return result.reverse
-        else return result end
-    end
-
-    public
-    # check package whether to exist in remote server
-    def check_remote_pkg(pkg_name, os)
-
-        pkg_hash = @pkg_hash_os[os]
-        if pkg_hash.nil? then return false end
-        pkg = pkg_hash[pkg_name]
-        if pkg.nil? then
-            #@log.warn "There is no \"#{pkg_name}\" remote package information in list"
-            return false
-        end
-
-        return true
-    end
-
-    public
-    # check package whether to exist in installed packages
-    def check_installed_pkg(pkg_name)
-
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]
-        if pkg_hash.nil? then return false end
-        pkg = pkg_hash[pkg_name]
-
-        if pkg.nil? then return false end
-        return true
-    end
-
-    public
-    # get attribute from installed package
-    def get_attr_from_installed_pkg(pkg_name, attr)
-
-        if not check_installed_pkg(pkg_name) then return nil end
-        pkg = get_installed_pkg_from_list(pkg_name)
-
-        if pkg.nil? then return nil end
-
-        case attr
-        when "version" then return pkg.version
-        when "source" then return pkg.source
-        when "src_path" then return pkg.src_path
-        when "os" then return pkg.os
-        when "build_dep_list" then return pkg.build_dep_list
-        when "install_dep_list" then return pkg.install_dep_list
-        when "attribute" then return pkg.attribute
-        end
-    end
-
-    public
-    # get attribute from remote package
-    def get_attr_from_pkg(pkg_name, os, attr)
-
-        if not check_remote_pkg(pkg_name, os) then return nil end
-        pkg = get_pkg_from_list(pkg_name, os)
-
-        if pkg.nil? then return nil end
-
-        case attr
-        when "name" then return pkg.package_name
-        when "path" then return pkg.path
-        when "source" then return pkg.source
-        when "version" then return pkg.version
-        when "src_path" then return pkg.src_path
-        when "os" then return pkg.os
-        when "build_dep_list" then return pkg.build_dep_list
-        when "install_dep_list" then return pkg.install_dep_list
-        when "attribute" then return pkg.attribute
+       # reverse : return reverse result
+       # force : install package force
+       def get_install_dependent_packages(pkg_name, os, reverse, force)
+
+               if not check_remote_pkg(pkg_name, os) then return nil end
+               if reverse.nil? then reverse = true end
+
+               @all_dep_list.clear
+               begin            
+                       get_install_dependency_arr(pkg_name, os, force, 0)
+                       # in case of cross build dependency
+               rescue SystemStackError
+                       @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
+                       return nil
+               end
+
+               max = 0
+               @all_dep_list.each do |p|
+                       if p[0].to_i > max then
+                               max = p[0].to_i
+                       else next end
+               end
+
+               result = []
+               i = 0
+               while i <= max
+                       @all_dep_list.each do |p|
+                               if p[0].to_i.eql? i then
+                                       d = p[1]
+                                       remote_ver = get_attr_from_pkg(d.package_name, os, "version") 
+                                       if not d.match? remote_ver then
+                                               @log.error "\"#{pkg_name}\" package needs \"#{d.package_name}\" #{d.comp} #{d.base_version}, but \"#{d.package_name}\" (#{remote_ver}) package is in server"
+                                               return nil
+                                       else result.push(d.package_name) end
+                               end
+                       end
+                       i = i + 1
+               end
+
+               @log.info "Get install dependent packages for \"#{pkg_name}\" package.. OK"
+               if reverse then return result.reverse.uniq.push(pkg_name)
+               else return result.uniq.insert(0, pkg_name) end
+       end
+
+       public
+       # get all reverse install dependent packages (considered reverse install priority for tracing uninstall)
+       def get_all_reverse_install_dependent_packages(pkg_name, reverse)
+
+               if not check_installed_pkg(pkg_name) then return nil end
+               if reverse.nil? then reverse = true end
+
+               begin
+                       res = get_all_reverse_install_dependency_arr(pkg_name, 0)
+               rescue SystemStackError
+                       @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
+                       return nil
+               end
+               res2 = res.split("::")
+               result = []
+               res2.each do |r|
+                       result.push(r.split(':')[1])
+               end
+
+               @log.info "Get all reverse install dependent packages for #{pkg_name} package.. OK"
+               if reverse then return result.reverse.uniq
+               else return result end
+       end
+
+       public
+       # get all reverse remote dependent packages (considered reverse install priority for tracing uninstall)
+       def get_all_reverse_install_dependent_packages_remote(pkg_name, os, reverse)
+               #if not check_remote_pkg(pkg_name, os) then return nil end
+               if reverse.nil? then reverse = true end
+
+               begin
+                       res = get_all_reverse_install_dependency_arr_remote(pkg_name, os, 0)
+               rescue SystemStackError
+                       @log.error "Failed to get dependency relation because #{pkg_name} package has cross install dependency."
+                       return nil
+               end
+               res2 = res.split("::")
+               result = []
+               res2.each do |r|
+                       result.push(r.split(':')[1])
+               end
+
+               @log.info "Get all reverse install dependent packages for #{pkg_name} package.. OK"
+               if reverse then return result.reverse
+               else return result end
+       end
+
+       public
+       # check package whether to exist in remote server
+       def check_remote_pkg(pkg_name, os)
+
+               pkg_hash = @pkg_hash_os[os]
+               if pkg_hash.nil? then return false end
+               pkg = pkg_hash[pkg_name]
+               if pkg.nil? then
+                       #@log.warn "There is no \"#{pkg_name}\" remote package information in list"
+                       return false
+               end
+
+               return true
+       end
+
+       public
+       # check package whether to exist in installed packages
+       def check_installed_pkg(pkg_name)
+
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]
+               if pkg_hash.nil? then return false end
+               pkg = pkg_hash[pkg_name]
+
+               if pkg.nil? then return false end
+               return true
+       end
+
+       public
+       # get attribute from installed package
+       def get_attr_from_installed_pkg(pkg_name, attr)
+
+               if not check_installed_pkg(pkg_name) then return nil end
+               pkg = get_installed_pkg_from_list(pkg_name)
+
+               if pkg.nil? then return nil end
+
+               case attr
+               when "version" then return pkg.version
+               when "source" then return pkg.source
+               when "src_path" then return pkg.src_path
+               when "os" then return pkg.os
+               when "build_dep_list" then return pkg.build_dep_list
+               when "install_dep_list" then return pkg.install_dep_list
+               when "attribute" then return pkg.attribute
+               end
+       end
+
+       public
+       # get attribute from remote package
+       def get_attr_from_pkg(pkg_name, os, attr)
+
+               if not check_remote_pkg(pkg_name, os) then return nil end
+               pkg = get_pkg_from_list(pkg_name, os)
+
+               if pkg.nil? then return nil end
+
+               case attr
+               when "name" then return pkg.package_name
+               when "path" then return pkg.path
+               when "source" then return pkg.source
+               when "version" then return pkg.version
+               when "src_path" then return pkg.src_path
+               when "os" then return pkg.os
+               when "build_dep_list" then return pkg.build_dep_list
+               when "install_dep_list" then return pkg.install_dep_list
+               when "attribute" then return pkg.attribute
                when "checksum" then return pkg.checksum
                when "size" then return pkg.size
 
-        end
-    end
-
-    public
-    # show a package information
-    def show_pkg_info(pkg_name, os)
-        if not check_remote_pkg(pkg_name, os) then
-            @log.error "\"#{pkg_name}\" package does not exist"
-            return ""
-        end
-
-        pkg = get_pkg_from_list(pkg_name, os)
-        return pkg.to_s
-    end
-
-    public
-    # show all packages information 
-    def show_pkg_list(os)
-        pkg_hash = @pkg_hash_os[os]
-        if pkg_hash.nil? then
-            @log.error "\"#{os}\" package list does not exist"
-            return ""
-        end
-
-        pkg_all_list = []
-        pkg_list = pkg_hash.values
-        pkg_list.each do |p|
-            pkg_all_list.push([p.package_name, p.version, p.description])
-        end
-        return pkg_all_list.sort
-    end
-
-    public
-    # show installed package information
-    def show_installed_pkg_info(pkg_name)
-
-        if not check_installed_pkg(pkg_name) then
-            @log.error "\"#{pkg_name}\" package does not exist"
-            return ""
-        end
-
-        pkg = get_installed_pkg_from_list(pkg_name)
-        return pkg.to_s
-    end
-
-    public
-    # show all installed packages information 
-    def show_installed_pkg_list()
-
-        file_path = get_installed_pkg_list_file_path()
-        pkg_hash = @installed_pkg_hash_loc[file_path]
-        if pkg_hash.nil? then
-            @log.error "Installed package list does not exist"
-            return nil
-        end
-        pkg_all_list = [] 
-        pkg_list = pkg_hash.values
-        pkg_list.each do |p|
-            pkg_all_list.push([p.package_name, p.version, p.description])
-        end
-        return pkg_all_list.sort
-    end
-    
-    private
-    def get_build_dependency_arr(pkg_name, os, n)
-        pkg_hash = @pkg_hash_os[os]
-        pkg = pkg_hash[pkg_name]
-
-        if pkg.nil? then
-            @log.error "\"#{pkg_name}\" package does not exist in server. please check it"
-            return
-        end
-
-        # if package is already installed, skip tracing dependency
-        if check_installed_pkg(pkg_name) then
-            # compare version with installed package version
-            new_pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
-            compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
-            if compare_result == -1 or compare_result == 0 then return end
-        end
-
-        pkg.build_dep_list.each do |l|
-            @all_dep_list.push([n, l])
-            get_build_dependency_arr(l.package_name, os, n+1)
-        end
-    
-        return
-    end
-
-    private
-    def get_install_dependency_arr(pkg_name, os, force, n)
-
-        pkg_hash = @pkg_hash_os[os]
-        pkg = pkg_hash[pkg_name]
-
-        if pkg.nil? then
-            @log.error "\"#{pkg_name}\" package does not exist in server. please check it"
-            return
-        end
-    
-        # if package is already installed, skip tracing dependency
-        if check_installed_pkg(pkg_name) then
-            # compare version with installed package version
-            new_pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
-            compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
-            if not force then
-                if compare_result == -1 or compare_result == 0 then return end
-            end
-        end
-
-        pkg.install_dep_list.each do |l|
-            @all_dep_list.push([n, l])
-            get_install_dependency_arr(l.package_name, os, force, n+1)
-        end
-    
-        return 
-    end
-    
-    private
-    def get_all_reverse_install_dependency_arr(pkg_name, n)
-
-        s = "#{n}:#{pkg_name}"
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]                 
-        pkg_list = pkg_hash.values
-        pkg_list.each do |pkg|
-            pkg.install_dep_list.each do |l|
-                if l.package_name.eql? pkg_name then
-                    s = s + "::" + get_all_reverse_install_dependency_arr(pkg.package_name, n+1)
-                end
-            end
-        end
-
-        return s
-    end
-
-    private
-    def get_all_reverse_install_dependency_arr_remote(pkg_name, os, n)
-
-        s = "#{n}:#{pkg_name}"
-        pkg_hash = @pkg_hash_os[os]                 
-        pkg_list = pkg_hash.values
-        pkg_list.each do |pkg|
-            pkg.install_dep_list.each do |l|
-                if l.package_name.eql? pkg_name then
-                    s = s + "::" + get_all_reverse_install_dependency_arr_remote(pkg.package_name, os, n+1)
-                end
-            end
-        end
-
-        return s
-    end
-
-    public
-    def get_pkg_from_list(pkg_name, os)
-
-        pkg_hash = @pkg_hash_os[os]
-        if pkg_hash.nil? then return nil end
-
-        pkg = pkg_hash[pkg_name]
-        
-        return pkg
-    end
-
-    private
-    def get_installed_pkg_from_list(pkg_name)
-
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]
-        pkg = pkg_hash[pkg_name]
-        if pkg.nil? then return nil end
-
-        return pkg
-    end
-    
-    private
-    # install a package to @location after uninstalling and downloading
-    def install_pkg(pkg_name, os, force)
-
-        new_pkg_ver = ""
-        
-        # install remote server package file
-        if not check_remote_pkg(pkg_name, os) then
-            @log.error "\"#{pkg_name}\" package does not exist in remote server"
-            return false
-        end
-        path = get_attr_from_pkg(pkg_name, os, "path")
-        # type should be binary. type = "binary"
-        # below code should be changed
-        type = path.split('/')[-2]
-        new_pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
+               end
+       end
+
+       public
+       # show a package information
+       def show_pkg_info(pkg_name, os)
+               if not check_remote_pkg(pkg_name, os) then
+                       @log.error "\"#{pkg_name}\" package does not exist"
+                       return ""
+               end
+
+               pkg = get_pkg_from_list(pkg_name, os)
+               return pkg.to_s
+       end
+
+       public
+       # show all packages information 
+       def show_pkg_list(os)
+               pkg_hash = @pkg_hash_os[os]
+               if pkg_hash.nil? then
+                       @log.error "\"#{os}\" package list does not exist"
+                       return ""
+               end
+
+               pkg_all_list = []
+               pkg_list = pkg_hash.values
+               pkg_list.each do |p|
+                       pkg_all_list.push([p.package_name, p.version, p.description])
+               end
+               return pkg_all_list.sort
+       end
+
+       public
+       # show installed package information
+       def show_installed_pkg_info(pkg_name)
+
+               if not check_installed_pkg(pkg_name) then
+                       @log.error "\"#{pkg_name}\" package does not exist"
+                       return ""
+               end
+
+               pkg = get_installed_pkg_from_list(pkg_name)
+               return pkg.to_s
+       end
+
+       public
+       # show all installed packages information 
+       def show_installed_pkg_list()
+
+               file_path = get_installed_pkg_list_file_path()
+               pkg_hash = @installed_pkg_hash_loc[file_path]
+               if pkg_hash.nil? then
+                       @log.error "Installed package list does not exist"
+                       return nil
+               end
+               pkg_all_list = [] 
+               pkg_list = pkg_hash.values
+               pkg_list.each do |p|
+                       pkg_all_list.push([p.package_name, p.version, p.description])
+               end
+               return pkg_all_list.sort
+       end
+
+       private
+       def get_build_dependency_arr(pkg_name, os, n)
+               pkg_hash = @pkg_hash_os[os]
+               pkg = pkg_hash[pkg_name]
+
+               if pkg.nil? then
+                       @log.error "\"#{pkg_name}\" package does not exist in server. please check it"
+                       return
+               end
+
+               # if package is already installed, skip tracing dependency
+               if check_installed_pkg(pkg_name) then
+                       # compare version with installed package version
+                       new_pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
+                       compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
+                       if compare_result == -1 or compare_result == 0 then return end
+               end
+
+               pkg.build_dep_list.each do |l|
+                       @all_dep_list.push([n, l])
+                       get_build_dependency_arr(l.package_name, os, n+1)
+               end
+
+               return
+       end
+
+       private
+       def get_install_dependency_arr(pkg_name, os, force, n)
+
+               pkg_hash = @pkg_hash_os[os]
+               pkg = pkg_hash[pkg_name]
+
+               if pkg.nil? then
+                       @log.error "\"#{pkg_name}\" package does not exist in server. please check it"
+                       return
+               end
+
+               # if package is already installed, skip tracing dependency
+               if check_installed_pkg(pkg_name) then
+                       # compare version with installed package version
+                       new_pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
+                       compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
+                       if not force then
+                               if compare_result == -1 or compare_result == 0 then return end
+                       end
+               end
+
+               pkg.install_dep_list.each do |l|
+                       @all_dep_list.push([n, l])
+                       get_install_dependency_arr(l.package_name, os, force, n+1)
+               end
+
+               return 
+       end
+
+       private
+       def get_all_reverse_install_dependency_arr(pkg_name, n)
+
+               s = "#{n}:#{pkg_name}"
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]                 
+               pkg_list = pkg_hash.values
+               pkg_list.each do |pkg|
+                       pkg.install_dep_list.each do |l|
+                               if l.package_name.eql? pkg_name then
+                                       s = s + "::" + get_all_reverse_install_dependency_arr(pkg.package_name, n+1)
+                               end
+                       end
+               end
+
+               return s
+       end
+
+       private
+       def get_all_reverse_install_dependency_arr_remote(pkg_name, os, n)
+
+               s = "#{n}:#{pkg_name}"
+               pkg_hash = @pkg_hash_os[os]                 
+               pkg_list = pkg_hash.values
+               pkg_list.each do |pkg|
+                       pkg.install_dep_list.each do |l|
+                               if l.package_name.eql? pkg_name then
+                                       s = s + "::" + get_all_reverse_install_dependency_arr_remote(pkg.package_name, os, n+1)
+                               end
+                       end
+               end
+
+               return s
+       end
+
+       public
+       def get_pkg_from_list(pkg_name, os)
+
+               pkg_hash = @pkg_hash_os[os]
+               if pkg_hash.nil? then return nil end
+
+               pkg = pkg_hash[pkg_name]
+
+               return pkg
+       end
+
+       private
+       def get_installed_pkg_from_list(pkg_name)
+
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]
+               pkg = pkg_hash[pkg_name]
+               if pkg.nil? then return nil end
+
+               return pkg
+       end
+
+       private
+       # install a package to @location after uninstalling and downloading
+       def install_pkg(pkg_name, os, force)
+
+               new_pkg_ver = ""
+
+               # install remote server package file
+               if not check_remote_pkg(pkg_name, os) then
+                       @log.error "\"#{pkg_name}\" package does not exist in remote server"
+                       return false
+               end
+               path = get_attr_from_pkg(pkg_name, os, "path")
+               # type should be binary. type = "binary"
+               # below code should be changed
+               type = path.split('/')[-2]
+               new_pkg_ver = get_attr_from_pkg(pkg_name, os, "version")
                pkg_checksum = get_attr_from_pkg(pkg_name, os, "checksum")
                pkg_size = get_attr_from_pkg(pkg_name, os, "size")
                pkg_path = get_attr_from_pkg(pkg_name, os, "path")
                filename = pkg_path.split('/')[-1]
-            
-        # compare version with installed package versiona
-        compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
-        if not force then
-            case compare_result
-            when -1 then
-               @log.warn "Checked \"#{pkg_name}\" package version : it is bigger then remote package version"
-               return true
-            when 0 then
-               @log.warn "Checked \"#{pkg_name}\" package version : it is same with remote package version"
-               return true
-            end
-        end
-        
-        # if package is already installed, then uninstall it
-        if check_installed_pkg(pkg_name) then
-            if not uninstall(pkg_name, false) then
-                @log.error "Failed to uninstall \"#{pkg_name}\""
-                return false
-            end
-        end 
-
-        # install package
+
+               # compare version with installed package versiona
+               compare_result = compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
+               if not force then
+                       case compare_result
+                       when -1 then
+                               @log.warn "Checked \"#{pkg_name}\" package version : it is bigger then remote package version"
+                               return true
+                       when 0 then
+                               @log.warn "Checked \"#{pkg_name}\" package version : it is same with remote package version"
+                               return true
+                       end
+               end
+
+               # if package is already installed, then uninstall it
+               if check_installed_pkg(pkg_name) then
+                       if not uninstall(pkg_name, false) then
+                               @log.error "Failed to uninstall \"#{pkg_name}\""
+                               return false
+                       end
+               end 
+
+               # install package
                cached_filepath = nil
                if Utils.is_linux_like_os( Utils::HOST_OS ) then
                        cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
                end                     
                if not cached_filepath.nil? then
                        @log.info "Cached #{pkg_name} package file.. OK"                                
-            ret = FileInstaller.install(pkg_name, cached_filepath, type, @location, @log)
+                       ret = FileInstaller.install(pkg_name, cached_filepath, type, @location, @log)
                else
                        filepath = download(pkg_name, os, false, @tmp_path)
                        if filepath.nil? then
@@ -1400,88 +1400,88 @@ class Client
                        if filepath.nil? then
                                return false                            
                        end     
-            ret = FileInstaller.install(pkg_name, filepath, type, @location, @log)
+                       ret = FileInstaller.install(pkg_name, filepath, type, @location, @log)
                        remove_downloaded_pkgs(pkg_name, os)                            
                end                     
-        return ret
+               return ret
        end
 
-    private
+       private
        def compare_version_with_installed_pkg(pkg_name, new_pkg_ver)
 
-        if check_installed_pkg_list_file() then
-            read_installed_pkg_list()
-            if check_installed_pkg(pkg_name) then
-                installed_pkg_ver = get_attr_from_installed_pkg(pkg_name, "version")
-                compare_result = Utils.compare_version(installed_pkg_ver, new_pkg_ver)
-                return compare_result
-            end
-        end
-
-        return 2
-    end
-
-    private
-    def remove_pkg_info(pkg_name)
-
-        pkg_hash = {}
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then
-            pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]
-            if pkg_hash.include? pkg_name then
-                pkg_hash.delete(pkg_name)
-            end
-            @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
-        else return nil end
-        
-        @log.info "Removed information for \"#{pkg_name}\" package.. OK"
-        return pkg_hash
-    end
-
-    private
-    def add_pkg_info(pkg_name, os)
-
-        pkg_hash = {}
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then
-            pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]                
-            pkg_hash[pkg_name] = get_pkg_from_list(pkg_name, os)
-        else pkg_hash[pkg_name] = get_pkg_from_list(pkg_name, os) end
-        @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
-
-        #@log.info "Added information for \"#{pkg_name}\" package.. OK"
-        return pkg_hash
-    end
-
-    private
-    # add package manifest info
-    def add_local_pkg_info(pkg_name)
-
-        config_path = File.join(@location, PACKAGE_INFO_DIR, "#{pkg_name}")
-        pkg = read_pkginfo_file(pkg_name, config_path)
-
-        if pkg.nil? then
-            @log.error "Failed to read pkginfo.manifest file"
-            return nil
-        end
-
-        pkg_hash = {} 
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then
-            pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]                
-            pkg_hash[pkg_name] = pkg
-        else pkg_hash[pkg_name] = pkg end
-        @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
-
-        #@log.info "Added information for \"#{pkg_name}\" package.. OK"
-        return pkg_hash
-    end
-
-    private
-    # read package manifet info
-    def read_pkginfo_file(pkg_name, path)
-
-        file_path = File.join(path, "pkginfo.manifest")
+               if check_installed_pkg_list_file() then
+                       read_installed_pkg_list()
+                       if check_installed_pkg(pkg_name) then
+                               installed_pkg_ver = get_attr_from_installed_pkg(pkg_name, "version")
+                               compare_result = Utils.compare_version(installed_pkg_ver, new_pkg_ver)
+                               return compare_result
+                       end
+               end
+
+               return 2
+       end
+
+       private
+       def remove_pkg_info(pkg_name)
+
+               pkg_hash = {}
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then
+                       pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]
+                       if pkg_hash.include? pkg_name then
+                               pkg_hash.delete(pkg_name)
+                       end
+                       @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
+               else return nil end
+
+               @log.info "Removed information for \"#{pkg_name}\" package.. OK"
+               return pkg_hash
+       end
+
+       private
+       def add_pkg_info(pkg_name, os)
+
+               pkg_hash = {}
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then
+                       pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]                
+                       pkg_hash[pkg_name] = get_pkg_from_list(pkg_name, os)
+               else pkg_hash[pkg_name] = get_pkg_from_list(pkg_name, os) end
+               @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
+
+               #@log.info "Added information for \"#{pkg_name}\" package.. OK"
+               return pkg_hash
+       end
+
+       private
+       # add package manifest info
+       def add_local_pkg_info(pkg_name)
+
+               config_path = File.join(@location, PACKAGE_INFO_DIR, "#{pkg_name}")
+               pkg = read_pkginfo_file(pkg_name, config_path)
+
+               if pkg.nil? then
+                       @log.error "Failed to read pkginfo.manifest file"
+                       return nil
+               end
+
+               pkg_hash = {} 
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then
+                       pkg_hash = @installed_pkg_hash_loc[installed_pkg_hash_key]                
+                       pkg_hash[pkg_name] = pkg
+               else pkg_hash[pkg_name] = pkg end
+               @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
+
+               #@log.info "Added information for \"#{pkg_name}\" package.. OK"
+               return pkg_hash
+       end
+
+       private
+       # read package manifet info
+       def read_pkginfo_file(pkg_name, path)
+
+               file_path = File.join(path, "pkginfo.manifest")
                begin
                        pkg = Parser.read_single_pkginfo_from file_path
                rescue => e
@@ -1489,29 +1489,29 @@ class Client
                        return nil
                end
 
-        if pkg.nil? then
-            @log.error "Failed to read manifest file : #{file_path}"
-            return nil
-        end
+               if pkg.nil? then
+                       @log.error "Failed to read manifest file : #{file_path}"
+                       return nil
+               end
 
-        @log.info "Read information for \"#{pkg_name}\" package.. OK"
-        return pkg
-    end
+               @log.info "Read information for \"#{pkg_name}\" package.. OK"
+               return pkg
+       end
 
-    # get the lastest snapshot 
-    # from_server : if true, update from server
+       # get the lastest snapshot 
+       # from_server : if true, update from server
        def get_lastest_snapshot(from_server)
                ssinfo_file = "snapshot.info"
                file_url = File.join(@server_addr, ssinfo_file)
                if from_server then
                        if not FileDownLoader.download(file_url, @config_dist_path, @log) then
-                @log.warn "Server does not have \"#{ssinfo_file}\" file. This error can be ignored."
+                               @log.warn "Server does not have \"#{ssinfo_file}\" file. This error can be ignored."
                        end
                else
                        if File.exist? file_url then FileUtils.cp(file_url, @config_dist_path) 
                        else @log.warn "Server does not have \"#{ssinfo_file}\" file. This error can be ignored." end
                end
-               
+
                file_path = File.join(@config_dist_path, ssinfo_file)
                if not File.exist? file_path then return nil end
 
@@ -1536,22 +1536,22 @@ class Client
        # if url includes snapshot infomation, retuen true
        def is_snapshot_url(addr = nil)
                if addr.nil? then addr = @server_addr end                       
-        addr_arr = addr.split('/')
-        if addr_arr[-2].eql? "snapshots" then
+               addr_arr = addr.split('/')
+               if addr_arr[-2].eql? "snapshots" then
                        return true                             
-        else 
+               else 
                        return false                    
-        end
+               end
        end             
 
        def split_addr_and_snapshot(addr = nil)
                if addr.nil? then addr = @server_addr end                       
-        addr_arr = addr.split('/')
-        if addr_arr[-2].eql? "snapshots" then                                                  
+               addr_arr = addr.split('/')
+               if addr_arr[-2].eql? "snapshots" then                                                   
                        return addr_arr[0..-3].join("/"), addr_arr[-2..-1].join("/")
-        else 
+               else 
                        return nil              
-        end
+               end
        end                     
 
        def is_snapshot_exist(ss_path = nil)
@@ -1564,10 +1564,10 @@ class Client
        end
 
        def read_remote_pkg_list(list_path)
-        @support_os_list.each do |os|
+               @support_os_list.each do |os|
                        filename = PKG_LIST_FILE_PREFIX + os
                        local_file_path = File.join(list_path, filename)
-            if File.exist? local_file_path then
+                       if File.exist? local_file_path then
                                begin
                                        pkg_hash = Parser.read_repo_pkg_list_from local_file_path
                                        @pkg_hash_os[os] = pkg_hash 
@@ -1586,23 +1586,23 @@ class Client
        def read_supported_os_list(list_path)
                local_file_path = File.join(list_path, OS_INFO_FILE)
                if File.exist? local_file_path then
-            File.open(local_file_path, "r") do |f|
-                f.each_line do |l|
+                       File.open(local_file_path, "r") do |f|
+                               f.each_line do |l|
                                        os = l.strip
                                        if @support_os_list.index(os).nil? then @support_os_list.push(os) end
-                end
+                               end
                        end
                        @log.info "Get supported os infomation.. OK"
                else                    
                        @log.warn "Failed to get supported os infomation"
-        end
+               end
        end
 
        def download_os_list(from_server, dist = nil)
                if dist.nil? then dist = get_pkglist_path end                   
-        file_url = File.join(@server_addr, OS_INFO_FILE)
-        if from_server then
-            if not FileDownLoader.download(file_url, dist, @log) then return false end
+               file_url = File.join(@server_addr, OS_INFO_FILE)
+               if from_server then
+                       if not FileDownLoader.download(file_url, dist, @log) then return false end
                else
                        if File.exist? file_url then FileUtils.cp(file_url, dist) 
                        else return false end
@@ -1612,24 +1612,24 @@ class Client
        end             
 
        def read_archive_pkg_list(list_path)
-        local_file_path = File.join(list_path, ARCHIVE_PKG_LIST_FILE)
-        if File.exist? local_file_path then
-            File.open(local_file_path, "r") do |f|
-                f.each_line do |l|
+               local_file_path = File.join(list_path, ARCHIVE_PKG_LIST_FILE)
+               if File.exist? local_file_path then
+                       File.open(local_file_path, "r") do |f|
+                               f.each_line do |l|
                                        pkg = l.strip                                           
                                        if @archive_pkg_list.index(pkg).nil? then @archive_pkg_list.push(pkg) end
-                end
+                               end
                        end
                        @log.info "Get archive package infomation.. OK"
                else                    
                        @log.warn "Failed to get archive package infomation"
-        end
+               end
        end
 
        def download_archive_pkg_list(from_server, dist = nil)
                if dist.nil? then dist = get_pkglist_path end                   
-        file_url = File.join(@server_addr, @snapshot_path, ARCHIVE_PKG_LIST_FILE)
-        if from_server then
+               file_url = File.join(@server_addr, @snapshot_path, ARCHIVE_PKG_LIST_FILE)
+               if from_server then
                        if not FileDownLoader.download(file_url, dist, @log) then return false end
                else
                        if File.exist? file_url then FileUtils.cp(file_url, dist) 
@@ -1659,17 +1659,17 @@ class Client
        # create installed package hash
        def read_installed_pkg_list()
 
-        config_path = File.join(@location, PACKAGE_INFO_DIR)
-        if not File.directory? config_path then return end
-
-        installed_pkg_hash_key = get_installed_pkg_list_file_path()
-        if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then return
-        else
-            file_path = installed_pkg_hash_key
-            if not File.exist? file_path then
-                #raise RuntimeError, "#{file_path} file does not exist"
-                return
-            end
+               config_path = File.join(@location, PACKAGE_INFO_DIR)
+               if not File.directory? config_path then return end
+
+               installed_pkg_hash_key = get_installed_pkg_list_file_path()
+               if @installed_pkg_hash_loc.has_key? installed_pkg_hash_key then return
+               else
+                       file_path = installed_pkg_hash_key
+                       if not File.exist? file_path then
+                               #raise RuntimeError, "#{file_path} file does not exist"
+                               return
+                       end
                        begin
                                pkg_hash = Parser.read_repo_pkg_list_from file_path
                        rescue => e
@@ -1680,54 +1680,54 @@ class Client
                end
        end
 
-    private
-    # check to exist installed package list file
-    def check_installed_pkg_list_file()
-
-        if @location.nil? then raise RuntimeError, "#{@location} path does not exist" end
-        file_path = get_installed_pkg_list_file_path()
-        if File.exist? file_path then return true
-        else return false end
-    end
-
-    private
-    # get installed package list file path
-    def get_installed_pkg_list_file_path()
-
-        file_full_path = File.join(@location, PACKAGE_INFO_DIR, INSTALLED_PKG_LIST_FILE)        
-        return file_full_path
-    end
-
-    private
-    # write package hash to file
-    def write_pkg_hash_to_file(pkg_hash)
-
-        file_path = get_installed_pkg_list_file_path()
-        if pkg_hash.nil? then
-            pkg_hash = @installed_pkg_hash_loc[file_path]
-        end
-        if not pkg_hash.nil? then
-            config_path = File.join(@location, PACKAGE_INFO_DIR)
-            if not File.exist? config_path then FileUtils.mkdir_p "#{config_path}" end
-            if File.exist? file_path then File.delete(file_path) end
-            File.open(file_path, "a+") do |file|
-                pkg_list = pkg_hash.values
-                pkg_list.each do |pkg|
-                    pkg.print_to_file(file)
-                    file.puts "\n"
-                end
-            end
-        end
-        @log.info "Write package informations to \"#{file_path}\".. OK"
-    end
-
-    private
-    def check_meta_pkg(pkg_name, os)
-        if not check_remote_pkg(pkg_name, os) then return false end
-
-        attr = get_attr_from_pkg(pkg_name, os, "attribute")
-        if attr.nil? or attr.empty? then return false end
-        if attr[0].strip.upcase.eql? "META" then return true
-        else return false end
-    end
+       private
+       # check to exist installed package list file
+       def check_installed_pkg_list_file()
+
+               if @location.nil? then raise RuntimeError, "#{@location} path does not exist" end
+               file_path = get_installed_pkg_list_file_path()
+               if File.exist? file_path then return true
+               else return false end
+       end
+
+       private
+       # get installed package list file path
+       def get_installed_pkg_list_file_path()
+
+               file_full_path = File.join(@location, PACKAGE_INFO_DIR, INSTALLED_PKG_LIST_FILE)        
+               return file_full_path
+       end
+
+       private
+       # write package hash to file
+       def write_pkg_hash_to_file(pkg_hash)
+
+               file_path = get_installed_pkg_list_file_path()
+               if pkg_hash.nil? then
+                       pkg_hash = @installed_pkg_hash_loc[file_path]
+               end
+               if not pkg_hash.nil? then
+                       config_path = File.join(@location, PACKAGE_INFO_DIR)
+                       if not File.exist? config_path then FileUtils.mkdir_p "#{config_path}" end
+                       if File.exist? file_path then File.delete(file_path) end
+                       File.open(file_path, "a+") do |file|
+                               pkg_list = pkg_hash.values
+                               pkg_list.each do |pkg|
+                                       pkg.print_to_file(file)
+                                       file.puts "\n"
+                               end
+                       end
+               end
+               @log.info "Write package informations to \"#{file_path}\".. OK"
+       end
+
+       private
+       def check_meta_pkg(pkg_name, os)
+               if not check_remote_pkg(pkg_name, os) then return false end
+
+               attr = get_attr_from_pkg(pkg_name, os, "attribute")
+               if attr.nil? or attr.empty? then return false end
+               if attr[0].strip.upcase.eql? "META" then return true
+               else return false end
+       end
 end
index 695bd43b609952e5ff0165747896d6c593a8ee08..13e2127d22f57b96c4b1cb8891c86644a2f33c74 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  clientOptParser.rb
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -40,57 +40,57 @@ def option_error_check( options )
 
        case options[:cmd]
 
-    when "update" then
+       when "update" then
 
-    when "clean" then
+       when "clean" then
 
-    when "upgrade" then
+       when "upgrade" then
 
-    when "check-upgrade" then
+       when "check-upgrade" then
 
-    when "download" then
-        if options[:pkg].nil? or options[:pkg].empty? then 
-                   raise ArgumentError, "Usage: pkg-cli download -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace]"
-        end
+       when "download" then
+               if options[:pkg].nil? or options[:pkg].empty? then 
+                       raise ArgumentError, "Usage: pkg-cli download -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace]"
+               end
 
-    when "install" then
-        if options[:pkg].nil? or options[:pkg].empty? then 
-                   raise ArgumentError, "Usage: pkg-cli install -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace] [--force]"
-        end
+       when "install" then
+               if options[:pkg].nil? or options[:pkg].empty? then 
+                       raise ArgumentError, "Usage: pkg-cli install -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace] [--force]"
+               end
 
-    when "install-file" then
-        if options[:pkg].nil? or options[:pkg].empty? then 
-                   raise ArgumentError, "Usage: pkg-cli install-lpkg -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]"
-        end
+       when "install-file" then
+               if options[:pkg].nil? or options[:pkg].empty? then 
+                       raise ArgumentError, "Usage: pkg-cli install-lpkg -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]"
+               end
 
-    when "uninstall" then
-        if options[:pkg].nil? or options[:pkg].empty? then 
-                   raise ArgumentError, "Usage: pkg-cli uninstall -P <package name> [-l <location>] [--trace]"
-        end
+       when "uninstall" then
+               if options[:pkg].nil? or options[:pkg].empty? then 
+                       raise ArgumentError, "Usage: pkg-cli uninstall -P <package name> [-l <location>] [--trace]"
+               end
 
-    when "show-rpkg" then
-        if options[:pkg].nil? or options[:pkg].empty? then
-                   raise ArgumentError, "Usage: pkg-cli show-rpkg -P <package name> [-o <os>] [-u <package server url>]"
-        end
+       when "show-rpkg" then
+               if options[:pkg].nil? or options[:pkg].empty? then
+                       raise ArgumentError, "Usage: pkg-cli show-rpkg -P <package name> [-o <os>] [-u <package server url>]"
+               end
 
-    when "list-rpkg" then
+       when "list-rpkg" then
 
-    when "show-lpkg" then
-        if options[:pkg].nil? or options[:pkg].empty? then
-                   raise ArgumentError, "Usage: pkg-cli show-lpkg -P <package name> [-l <location>]"
-        end
+       when "show-lpkg" then
+               if options[:pkg].nil? or options[:pkg].empty? then
+                       raise ArgumentError, "Usage: pkg-cli show-lpkg -P <package name> [-l <location>]"
+               end
 
-    when "list-lpkg" then
+       when "list-lpkg" then
 
-    when "build-dep" then
-        if options[:pkg].nil? or options[:pkg].empty? then
-                   raise ArgumentError, "Usage: pkg-cli build-dep -P <package name> [-o <os>]"
-        end
+       when "build-dep" then
+               if options[:pkg].nil? or options[:pkg].empty? then
+                       raise ArgumentError, "Usage: pkg-cli build-dep -P <package name> [-o <os>]"
+               end
 
-    when "install-dep" then
-        if options[:pkg].nil? or options[:pkg].empty? then
-                   raise ArgumentError, "Usage: pkg-cli install-dep -P <package name> [-o <os>]"
-        end
+       when "install-dep" then
+               if options[:pkg].nil? or options[:pkg].empty? then
+                       raise ArgumentError, "Usage: pkg-cli install-dep -P <package name> [-o <os>]"
+               end
 
        else
                raise ArgumentError, "Input is incorrect : #{options[:cmd]}"
@@ -98,109 +98,109 @@ def option_error_check( options )
 end
 
 def option_parse 
-    options = {}
-    banner = "Requiest service to package-server and control packages service command-line tool." + "\n" \
-        + "\n" + "Usage: pkg-cli <SUBCOMMAND> [OPTS] or pkg-cli (-h|-v)" + "\n" \
-        + "\n" + "Subcommands:" + "\n" \
-        + "\t" + "update        Update to the latest package in your SDK environment." + "\n" \
-        + "\t" + "clean         Delete the package in your SDK environment." + "\n" \
-        + "\t" + "download      Download the package in your SDK environment." + "\n" \
-        + "\t" + "install       Download the package from package-server and install the package in your SDK environment." + "\n" \
-        + "\t" + "install-file  Install the package in your SDK environment." + "\n" \
-        + "\t" + "uninstall     Uninstall the package in your SDK environment." + "\n" \
-        + "\t" + "upgrade       Upgrade your SDK environment." + "\n" \
-        + "\t" + "check-upgrade Check packages to upgrade." + "\n" \
-        + "\t" + "show-rpkg     Show the package in the package-server." + "\n" \
-        + "\t" + "list-rpkg     Show the all packages in the package-server." + "\n" \
-        + "\t" + "show-lpkg     Show the package in your SDK environment." + "\n" \
-        + "\t" + "list-lpkg     Show the all packages in your SDK environment." + "\n" \
-        + "\t" + "build-dep    Show build-dependency packages" + "\n" \
-        + "\t" + "install-dep  Show install-dependency packages" + "\n" \
-       + "\n" + "Subcommand usage:" + "\n" \
-        + "\t" + "pkg-cli update [-u <remote server url>]" + "\n" \
-        + "\t" + "pkg-cli clean [-l <location>] [--force]" + "\n" \
-        + "\t" + "pkg-cli download -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace]" + "\n" \
-        + "\t" + "pkg-cli install -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
-        + "\t" + "pkg-cli install-file -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
-        + "\t" + "pkg-cli uninstall -P <package name> [-l <location>] [--trace]" + "\n" \
-        + "\t" + "pkg-cli upgrade [-l <location>] [-o <os>] [-u <package server url>] [--trace]" + "\n" \
-        + "\t" + "pkg-cli check-upgrade [-l <location>] [-o <os>] [-u <package server url>]" + "\n" \
-        + "\t" + "pkg-cli show-rpkg -P <package name> [-o <os>] [-u <package server url>]" + "\n"  \
-        + "\t" + "pkg-cli list-rpkg [-o <os>] [-u <package server url>]" + "\n" \
-        + "\t" + "pkg-cli show-lpkg -P <package name> [-l <location>]" + "\n"  \
-        + "\t" + "pkg-cli list-lpkg [-l <location>]" + "\n" \
-        + "\t" + "pkg-cli build-dep -P <package name> [-o <os>]" + "\n" \
-        + "\t" + "pkg-cli install-dep -P <package name> [-o <os>]" + "\n" \
-       + "\n" + "Options:" + "\n"
-
-    optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
-        # Set a banner, displayed at the top
-        # of the help screen.
-
-        opts.banner = banner
-
-        opts.on( '-P', '--pkg <package name/file>', 'package name or package file name' ) do |name|
-            options[:pkg] = name 
-        end
-        
-           opts.on( '-o', '--os <operating system>', 'target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64' ) do |os|
-            options[:os] = os
-        end
-               
-           opts.on( '-u', '--url <server url>', 'package server url: http://127.0.0.1/dibs/unstable' ) do |url|
-            options[:url] = url 
-        end
-
-       opts.on( '-l', '--loc <location>', 'install/download location' ) do |loc|
-            options[:loc] = loc            
-        end
-
-           opts.on( '--trace', 'enable trace dependent packages' ) do
-            options[:t] = true
-        end
-
-           opts.on( '--force', 'enable force' ) do
-            options[:f] = true
-        end
-               
-           opts.on( '-h', '--help', 'display help' ) do
-            puts opts
-               exit
-        end
+       options = {}
+       banner = "Requiest service to package-server and control packages service command-line tool." + "\n" \
+               + "\n" + "Usage: pkg-cli <SUBCOMMAND> [OPTS] or pkg-cli (-h|-v)" + "\n" \
+               + "\n" + "Subcommands:" + "\n" \
+               + "\t" + "update        Update to the latest package in your SDK environment." + "\n" \
+               + "\t" + "clean         Delete the package in your SDK environment." + "\n" \
+               + "\t" + "download      Download the package in your SDK environment." + "\n" \
+               + "\t" + "install       Download the package from package-server and install the package in your SDK environment." + "\n" \
+               + "\t" + "install-file  Install the package in your SDK environment." + "\n" \
+               + "\t" + "uninstall     Uninstall the package in your SDK environment." + "\n" \
+               + "\t" + "upgrade       Upgrade your SDK environment." + "\n" \
+               + "\t" + "check-upgrade Check packages to upgrade." + "\n" \
+               + "\t" + "show-rpkg     Show the package in the package-server." + "\n" \
+               + "\t" + "list-rpkg     Show the all packages in the package-server." + "\n" \
+               + "\t" + "show-lpkg     Show the package in your SDK environment." + "\n" \
+               + "\t" + "list-lpkg     Show the all packages in your SDK environment." + "\n" \
+               + "\t" + "build-dep     Show build-dependency packages" + "\n" \
+               + "\t" + "install-dep   Show install-dependency packages" + "\n" \
+               + "\n" + "Subcommand usage:" + "\n" \
+               + "\t" + "pkg-cli update [-u <remote server url>]" + "\n" \
+               + "\t" + "pkg-cli clean [-l <location>] [--force]" + "\n" \
+               + "\t" + "pkg-cli download -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace]" + "\n" \
+               + "\t" + "pkg-cli install -P <package name> [-o <os>] [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
+               + "\t" + "pkg-cli install-file -P <package file> [-l <location>] [-u <package server url>] [--trace] [--force]" + "\n" \
+               + "\t" + "pkg-cli uninstall -P <package name> [-l <location>] [--trace]" + "\n" \
+               + "\t" + "pkg-cli upgrade [-l <location>] [-o <os>] [-u <package server url>] [--trace]" + "\n" \
+               + "\t" + "pkg-cli check-upgrade [-l <location>] [-o <os>] [-u <package server url>]" + "\n" \
+               + "\t" + "pkg-cli show-rpkg -P <package name> [-o <os>] [-u <package server url>]" + "\n"  \
+               + "\t" + "pkg-cli list-rpkg [-o <os>] [-u <package server url>]" + "\n" \
+               + "\t" + "pkg-cli show-lpkg -P <package name> [-l <location>]" + "\n"  \
+               + "\t" + "pkg-cli list-lpkg [-l <location>]" + "\n" \
+               + "\t" + "pkg-cli build-dep -P <package name> [-o <os>]" + "\n" \
+               + "\t" + "pkg-cli install-dep -P <package name> [-o <os>]" + "\n" \
+               + "\n" + "Options:" + "\n"
+
+       optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
+               # Set a banner, displayed at the top
+               # of the help screen.
+
+               opts.banner = banner
+
+               opts.on( '-P', '--pkg <package name/file>', 'package name or package file name' ) do |name|
+                       options[:pkg] = name 
+               end
+
+               opts.on( '-o', '--os <operating system>', 'target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64' ) do |os|
+                       options[:os] = os
+               end
+
+               opts.on( '-u', '--url <server url>', 'package server url: http://127.0.0.1/dibs/unstable' ) do |url|
+                       options[:url] = url 
+               end
+
+               opts.on( '-l', '--loc <location>', 'install/download location' ) do |loc|
+                       options[:loc] = loc         
+               end
+
+               opts.on( '--trace', 'enable trace dependent packages' ) do
+                       options[:t] = true
+               end
+
+               opts.on( '--force', 'enable force' ) do
+                       options[:f] = true
+               end
+
+               opts.on( '-h', '--help', 'display help' ) do
+                       puts opts
+                       exit
+               end
 
                opts.on( '-v', '--version', 'display version' ) do
-            puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
+                       puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
                        exit
-        end
-    end
-
-    cmd = ARGV[0] 
-    if cmd.eql? "update" or cmd.eql? "download" or
-            cmd.eql? "install" or cmd.eql? "show-rpkg" or
-            cmd.eql? "list-rpkg" or
-            cmd.eql? "uninstall" or cmd.eql? "show-lpkg" or
-            cmd.eql? "list-lpkg" or
-            cmd.eql? "install-file" or cmd.eql? "clean" or
-            cmd.eql? "upgrade" or cmd.eql? "check-upgrade" or
-            cmd.eql? "build-dep" or cmd.eql? "install-dep" or
-            cmd =~ /(-v)|(--version)/  or
-            cmd =~ /(help)|(-h)|(--help)/  then
-
-        if cmd.eql? "help" then 
-            V[0] = "-h" 
-        end
-        options[:cmd] = ARGV[0]
-    else
-        raise ArgumentError, "Usage: pkg-cli <SUBCOMMAND> [OPTS] or pkg-cli -h"
-    end
-
-    optparse.parse!
+               end
+       end
+
+       cmd = ARGV[0] 
+       if cmd.eql? "update" or cmd.eql? "download" or
+               cmd.eql? "install" or cmd.eql? "show-rpkg" or
+               cmd.eql? "list-rpkg" or
+               cmd.eql? "uninstall" or cmd.eql? "show-lpkg" or
+               cmd.eql? "list-lpkg" or
+               cmd.eql? "install-file" or cmd.eql? "clean" or
+               cmd.eql? "upgrade" or cmd.eql? "check-upgrade" or
+               cmd.eql? "build-dep" or cmd.eql? "install-dep" or
+               cmd =~ /(-v)|(--version)/  or
+               cmd =~ /(help)|(-h)|(--help)/  then
+
+               if cmd.eql? "help" then 
+                       V[0] = "-h" 
+               end
+               options[:cmd] = ARGV[0]
+       else
+               raise ArgumentError, "Usage: pkg-cli <SUBCOMMAND> [OPTS] or pkg-cli -h"
+       end
+
+       optparse.parse!
 
        set_default options
 
        # option error check 
        option_error_check options
 
-    return options
+       return options
 end 
 
index 4226a32725e85c3f55b1297b6702894033e83b38..e5d4b30d904d6f95c3a01416ed37825ae2bf72a0 100644 (file)
@@ -34,8 +34,8 @@ require "installer"
 class Distribution 
        attr_accessor :name, :location, :server_url, :lock_file_path, :last_sync_changes
 
-    # constant
-    PKG_LIST_FILE_PREFIX = "pkg_list_"
+       # constant
+       PKG_LIST_FILE_PREFIX = "pkg_list_"
        ARCHIVE_PKG_FILE = "archive_pkg_list"
        OS_INFO_FILE = "os_info"
        SNAPSHOT_INFO_FILE = "snapshot.info"
@@ -70,7 +70,7 @@ class Distribution
                end
 
                exist_pkg = @pkg_hash_os[pkg.os][pkg.package_name]
-          
+
                # version check and if existing version is higher then upload version?
                if (not exist_pkg.nil?) and (not internal_flag) then
                        if not ( Utils.compare_version( exist_pkg.version, pkg.version ) == 1 ) then
@@ -80,7 +80,7 @@ class Distribution
 
                # modified pkg class
                pkg.origin = "local" 
-        pkg.source = ""
+               pkg.source = ""
                pkg.path = "/binary/" + File.basename( file_path )
                if pkg.checksum.empty? then
                        # TODO: windows and mac : sha256sum
@@ -94,7 +94,7 @@ class Distribution
                end
 
                @pkg_hash_os[pkg.os][pkg.package_name] = pkg 
-               
+
                return pkg
        end
 
@@ -105,7 +105,7 @@ class Distribution
 
                # modified pkg class
                pkg.origin = "local" 
-        pkg.source = ""
+               pkg.source = ""
                pkg.path = "/temp/" + File.basename( file_path )
                # TODO: windows and mac : sha256sum
                if Utils.is_unix_like_os( Utils::HOST_OS ) then
@@ -147,46 +147,46 @@ class Distribution
                end
 
                # copy package list
-        @support_os_list.each do |os|
+               @support_os_list.each do |os|
                        FileUtils.copy_file( "#{snapshot_path}/#{PKG_LIST_FILE_PREFIX}#{os}",  
-                               "#{@location}/snapshots/#{name}/#{PKG_LIST_FILE_PREFIX}#{os}" )
+                                                               "#{@location}/snapshots/#{name}/#{PKG_LIST_FILE_PREFIX}#{os}" )
                end 
-               
+
                # copy archive package list
                FileUtils.copy_file( "#{snapshot_path}/#{ARCHIVE_PKG_FILE}", 
-                               "#{@location}/snapshots/#{name}/#{ARCHIVE_PKG_FILE}" )
-               
-               # copy os info file 
-               FileUtils.copy_file( "#{snapshot_path}/#{OS_INFO_FILE}", 
-                               "#{@location}/snapshots/#{name}/#{OS_INFO_FILE}" )
-
-               # generate temp file
-               tmp_file_name = ""
-               while ( tmp_file_name.empty? )
-                       tmp_file_name = @location + "/temp/." + Utils.create_uniq_name
-
-                       if File.exist? tmp_file_name then 
-                               tmp_file_name = ""
-                       end 
-               end
-
-               FileUtils.copy_file( "#{@location}/#{SNAPSHOT_INFO_FILE}", tmp_file_name )
-               File.open( tmp_file_name, "a" ) do |f|
-                       f.puts "name : #{name}"
-                       f.puts "time : #{Time.now.strftime("%Y%m%d%H%M%S")}"
-                       if from_cmd then 
-                               f.puts "type : manual"
-                       else
-                               f.puts "type : auto"
-                       end
-                       f.puts "path : /snapshots/#{name}"
-                       f.puts
-               end
-               FileUtils.mv( tmp_file_name, "#{@location}/#{SNAPSHOT_INFO_FILE}", :force => true )
-               
-               # snapshot is generated
-               @log.output( "snapshot is generated : #{@location}/snapshots/#{name}", Log::LV_USER)
-               return name
+                                                       "#{@location}/snapshots/#{name}/#{ARCHIVE_PKG_FILE}" )
+
+                                                       # copy os info file 
+                                                       FileUtils.copy_file( "#{snapshot_path}/#{OS_INFO_FILE}", 
+                                                                                               "#{@location}/snapshots/#{name}/#{OS_INFO_FILE}" )
+
+                                                                                               # generate temp file
+                                                                                               tmp_file_name = ""
+                                                                                               while ( tmp_file_name.empty? )
+                                                                                                       tmp_file_name = @location + "/temp/." + Utils.create_uniq_name
+
+                                                                                                       if File.exist? tmp_file_name then 
+                                                                                                               tmp_file_name = ""
+                                                                                                       end 
+                                                                                               end
+
+                                                                                               FileUtils.copy_file( "#{@location}/#{SNAPSHOT_INFO_FILE}", tmp_file_name )
+                                                                                               File.open( tmp_file_name, "a" ) do |f|
+                                                                                                       f.puts "name : #{name}"
+                                                                                                       f.puts "time : #{Time.now.strftime("%Y%m%d%H%M%S")}"
+                                                                                                       if from_cmd then 
+                                                                                                               f.puts "type : manual"
+                                                                                                       else
+                                                                                                               f.puts "type : auto"
+                                                                                                       end
+                                                                                                       f.puts "path : /snapshots/#{name}"
+                                                                                                       f.puts
+                                                                                               end
+                                                                                               FileUtils.mv( tmp_file_name, "#{@location}/#{SNAPSHOT_INFO_FILE}", :force => true )
+
+                                                                                               # snapshot is generated
+                                                                                               @log.output( "snapshot is generated : #{@location}/snapshots/#{name}", Log::LV_USER)
+                                                                                               return name
        end  
 
        def sync(force, snapshot = "") 
@@ -250,7 +250,7 @@ class Distribution
                                end
                        end
                end
-               
+
                # sync archive package
                update_archive_list = sync_archive_pkg()
 
@@ -356,7 +356,7 @@ class Distribution
                used_archive_list = []
 
                # collect remaining file's name from current package server version
-        @support_os_list.each do |os|
+               @support_os_list.each do |os|
                        @pkg_hash_os[os].each_value{ |pkg|
                                file_list.push(pkg.path.sub("/binary/",""))
 
@@ -385,7 +385,7 @@ class Distribution
                                                os_list.push l.strip
                                        end
                                end
-                       # if snapshot does not have os_info file then using package server os_info list
+                               # if snapshot does not have os_info file then using package server os_info list
                        else
                                os_list = @support_os_list
                        end
@@ -399,7 +399,7 @@ class Distribution
                                        end
 
                                        pkg_list = Parser.read_repo_pkg_list_from(info_file) 
-                    
+
                                        pkg_list.each_value{ |pkg|
                                                file_list.push(pkg.path.sub("/binary/",""))
                                        }
@@ -431,7 +431,7 @@ class Distribution
                                FileUtils.rm "#{@location}/source/#{file}"
                        end
                end 
-               
+
                # remove unused snapshot 
                Dir.new( @location + "/snapshots" ).each do |snapshot|
                        if snapshot.start_with? "." then next end
@@ -517,7 +517,7 @@ class Distribution
                pkg_name_list.each do |package_name|
                        removed_flag = false 
 
-               os_list.each do |os|
+                       os_list.each do |os|
                                if not @support_os_list.include? os then
                                        @log.error( "package server does not support input os : #{os}")
                                        next
@@ -538,7 +538,7 @@ class Distribution
                                end
                        end
                end 
-               
+
                # check install dependency integrity
                if @integrity.eql? "YES" then
                        @log.info "integrity check"
@@ -579,7 +579,7 @@ class Distribution
                if not removed_snapshot.empty? then 
                        @log.output( "snapshot removed: #{removed_snapshot.join(",")}", Log::LV_USER )
                end
-               
+
                update_snapshot_info_file(remain_snapshot)
        end
 
@@ -603,7 +603,7 @@ class Distribution
                        else 
                                raise RuntimeError,(error_msg + dep.to_s) 
                        end
-               
+
                        # check package's version 
                        if not dep.match? target_pkg.version then 
                                raise RuntimeError,(error_msg + dep.to_s)
@@ -624,13 +624,13 @@ class Distribution
                        else 
                                raise RuntimeError,(error_msg + dep.to_s) 
                        end
-                       
+
                        # check package's version 
                        if not dep.match? target_pkg.version then 
                                raise RuntimeError,(error_msg + dep.to_s)
                        end 
                end 
-               
+
                error_msg = "[[#{pkg.package_name}] in #{pkg.os}]'s source dependency not matched in "  
                pkg.source_dep_list.each do |dep|
                        if not @archive_pkg_list.include? dep.package_name then
@@ -639,32 +639,32 @@ class Distribution
                end 
        end
 
-    def read_archive_pkg_list( snapshot_name )
-        pkg_list = []
+       def read_archive_pkg_list( snapshot_name )
+               pkg_list = []
 
-        if snapshot_name.empty?
-            file_name = @location + "/" + ARCHIVE_PKG_FILE
-        else
-            file_name = @location + "/snapshots/" + snapshot_name + "/" + ARCHIVE_PKG_FILE
-        end 
+               if snapshot_name.empty?
+                       file_name = @location + "/" + ARCHIVE_PKG_FILE
+               else
+                       file_name = @location + "/snapshots/" + snapshot_name + "/" + ARCHIVE_PKG_FILE
+               end 
 
-        if File.exist? file_name 
-            File.open(file_name, "r") do |f| 
-                f.each_line do |l| 
-                    pkg_list.push(l.strip)
-                end 
-            end 
-        end 
+               if File.exist? file_name 
+                       File.open(file_name, "r") do |f| 
+                               f.each_line do |l| 
+                                       pkg_list.push(l.strip)
+                               end 
+                       end 
+               end 
 
-        return pkg_list
-    end 
+               return pkg_list
+       end 
 
        def write_archive_pkg_list()
-        File.open( "#{@location}/#{ARCHIVE_PKG_FILE}", "w" ) do |f|
-            @archive_pkg_list.each do |pkg| 
-                               f.puts(pkg) 
-                       end
-        end
+               File.open( "#{@location}/#{ARCHIVE_PKG_FILE}", "w" ) do |f|
+                       @archive_pkg_list.each do |pkg| 
+                       f.puts(pkg) 
+               end
+               end
        end
 
        def initialize_pkg_list
@@ -676,12 +676,12 @@ class Distribution
                @support_os_list = []
                File.open( "#{@location}/#{OS_INFO_FILE}", "r" ) do |f|
                        f.each_line do |l|
-                               @support_os_list.push l.strip
-                       end
+                       @support_os_list.push l.strip
+               end
                end
 
                # read package_list file
-        @support_os_list.each do |os|
+               @support_os_list.each do |os|
                        @pkg_hash_os[os] = {}
                        pkg_list_file = "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}" 
 
@@ -705,7 +705,7 @@ class Distribution
                        if pkg_os.eql? os then next end 
                        # skip in unsupported os 
                        if not @support_os_list.include? os then next end 
-                       
+
                        exist_pkg = @pkg_hash_os[os][pkg.package_name] 
                        if exist_pkg.nil? then next end
 
@@ -743,20 +743,20 @@ class Distribution
                                # local_pkg is generated from local and not force mode then skip update
                                return nil
                        end 
-                               
+
                        pkg = sync_package2( server_pkg, client, os )
                        return ["ADD", os, pkg]
-               # if package exist only server
+                       # if package exist only server
                elsif ( not server_pkg.nil? ) then
                        pkg = sync_package2( server_pkg, client, os )
                        return ["ADD", os, pkg]
-               # if package exist only local
+                       # if package exist only local
                elsif ( not local_pkg.nil? ) then  
                        # if local pkg is generated from local then skip
                        if local_pkg.origin.eql? "local" and (not force) then  
                                return nil
                        end
-                       
+
                        # package remove
                        return ["REMOVE", os, local_pkg]
                else
@@ -771,7 +771,7 @@ class Distribution
 
                # package update
                file_path_list = client.download( pkg_name, os, false )
-               
+
                # file download error check 
                if file_path_list.nil? or file_path_list.empty? then   
                        @log.error("Can't download package file [#{pkg_name}]", Log::LV_USER)
@@ -779,7 +779,7 @@ class Distribution
                else
                        file_path = file_path_list[0]
                end 
-                               
+
                # update pkg class  
                pkg.path = "/binary/#{File.basename(file_path)}"
                pkg.origin = client.server_addr
@@ -829,10 +829,10 @@ class Distribution
        def get_all_reverse_depends_pkgs(pkg, checked_list)
                depends_list = []
 
-        @support_os_list.each do |os|
+               @support_os_list.each do |os|
                        @pkg_hash_os[os].each_value{ |dpkg|
                                if dpkg.install_dep_list.include? pkg or \
-                                               dpkg.build_dep_list.include? pkg then
+                                       dpkg.build_dep_list.include? pkg then
                                        depends_list.push opkg  
                                end
 
@@ -856,12 +856,12 @@ class Distribution
                @support_os_list = []
                File.open( "#{@location}/#{OS_INFO_FILE}", "r" ) do |f|
                        f.each_line do |l|
-                               @support_os_list.push l.strip
-                       end
+                       @support_os_list.push l.strip
+               end
                end
 
                # read binary package_list file
-        @support_os_list.each do |os|
+               @support_os_list.each do |os|
                        @pkg_hash_os[os] = {}
                        pkg_list_file = "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}" 
 
@@ -913,26 +913,26 @@ class Distribution
                File.delete( "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}" ) 
        end
 
-    def sync_archive_pkg
-        client = Client.new( @server_url, "#{@location}/source", @log )
+       def sync_archive_pkg
+               client = Client.new( @server_url, "#{@location}/source", @log )
 
-        download_list = client.archive_pkg_list - @archive_pkg_list
+               download_list = client.archive_pkg_list - @archive_pkg_list
 
                updated_file_list = []
 
                # if update list is empty then return empty array
                if download_list.empty? then return updated_file_list end 
 
-        download_list.each do |pkg|
+               download_list.each do |pkg|
                        file = client.download_dep_source(pkg)
-               if file.nil?
-                       @log.error("Can't download archive package [#{pkg}]", Log::LV_USER)
+                       if file.nil?
+                               @log.error("Can't download archive package [#{pkg}]", Log::LV_USER)
                        else
                                updated_file_list.push pkg
-               end
-        end
+                       end
+               end
 
                return updated_file_list
-    end
+       end
 
 end
index 2d104a7c6e599521242bf0fd117b2ecc52b31029..1443e83969a490830eb416a046bb3c7338d6f8e6 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  downloader.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -31,40 +31,40 @@ require "utils"
 
 class FileDownLoader
 
-    def FileDownLoader.download(url, path, logger)
-        ret = false
+       def FileDownLoader.download(url, path, logger)
+               ret = false
 
-        if not File.directory? path then
-            logger.error "\"#{path}\" does not exist"
-            return ret
+               if not File.directory? path then
+                       logger.error "\"#{path}\" does not exist"
+                       return ret
                end
 
-        is_remote = Utils.is_url_remote(url)
-        filename = url.split('/')[-1]
-        fullpath = File.join(path, filename)
+               is_remote = Utils.is_url_remote(url)
+               filename = url.split('/')[-1]
+               fullpath = File.join(path, filename)
 
                logger.info "Downloading #{url}"
-        if is_remote then
-            pid,status = Utils.execute_shell_with_log( "wget #{url} -O #{fullpath} -nv --tries=3", logger.path )
+               if is_remote then
+                       pid,status = Utils.execute_shell_with_log( "wget #{url} -O #{fullpath} -nv --tries=3", logger.path )
                        ret = (not status.nil? and status.exitstatus) != 0 ? false : true
-            #ret = Utils.execute_shell( "wget #{url} -O #{fullpath} -q")
-        else
-            if not File.exist? url then
-                logger.error "\"#{url}\" file does not exist"
-                return false
-            else
-                ret = system "cp #{url} #{fullpath}"
-            end
-        end
+                       #ret = Utils.execute_shell( "wget #{url} -O #{fullpath} -q")
+               else
+                       if not File.exist? url then
+                               logger.error "\"#{url}\" file does not exist"
+                               return false
+                       else
+                               ret = system "cp #{url} #{fullpath}"
+                       end
+               end
 
-        # need verify
+               # need verify
                if ret then
                        logger.info "Downloaded #{filename}.. OK"
                else 
                        logger.info "Failed to download #{filename}"                    
                        logger.info "  [dist: #{path}]"
                end                             
-        return ret
-    end
+               return ret
+       end
 end
 
index 5a46b8389964b44f596eba66272ebf8a93601666..faf04a7ade2262897e26a250328bd135ad600b83 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  installer.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -32,34 +32,34 @@ require "packageServerConfig"
 require "log"
 require "utils"
 if Utils.is_windows_like_os( Utils::HOST_OS ) then
-    require "rubygems"
-    require "zip/zip"
+       require "rubygems"
+       require "zip/zip"
 end
 
 class FileInstaller
 
-    CONFIG_PATH = "#{PackageServerConfig::CONFIG_ROOT}/client"
-    PACKAGE_INFO_DIR = ".info"
+       CONFIG_PATH = "#{PackageServerConfig::CONFIG_ROOT}/client"
+       PACKAGE_INFO_DIR = ".info"
        PACKAGE_MANIFEST = "pkginfo.manifest"
 
-    def FileInstaller.install(package_name, package_file_path, type, target_path, logger)
-
-        if not File.exist? package_file_path then
-            logger.error "\"#{package_file_path}\" file does not exist."
-            return false
-        end
-
-        case type
-        # install script when binary package
-        when "binary" then
-            uniq_name = Utils.create_uniq_name
-            path = Utils::HOME + "/tmp/#{uniq_name}"
-            # windows has limitation for file path length
-            if Utils.is_windows_like_os( Utils::HOST_OS ) then
-                drive = Utils::HOME.split("/")[0]
-                path = "#{drive}/#{uniq_name}"
-            end
-            if not File.exist? path then FileUtils.mkdir_p "#{path}" end
+       def FileInstaller.install(package_name, package_file_path, type, target_path, logger)
+
+               if not File.exist? package_file_path then
+                       logger.error "\"#{package_file_path}\" file does not exist."
+                       return false
+               end
+
+               case type
+                       # install script when binary package
+               when "binary" then
+                       uniq_name = Utils.create_uniq_name
+                       path = Utils::HOME + "/tmp/#{uniq_name}"
+                       # windows has limitation for file path length
+                       if Utils.is_windows_like_os( Utils::HOST_OS ) then
+                               drive = Utils::HOME.split("/")[0]
+                               path = "#{drive}/#{uniq_name}"
+                       end
+                       if not File.exist? path then FileUtils.mkdir_p "#{path}" end
 
                        if File.directory? path then
                                log = "## create temporary dir : #{path}\n"
@@ -69,68 +69,68 @@ class FileInstaller
                                return false 
                        end
 
-            begin
+                       begin
                                logger.info "Installing \"#{package_name}\" package.."
                                logger.info "  [file: #{package_file_path}]"                            
 
-                log = log + "## Extract file : #{package_file_path}\n"
+                               log = log + "## Extract file : #{package_file_path}\n"
                                result = extract_file(package_name, package_file_path, path, target_path, logger)
                                if result == "" or result.nil? then     
                                        write_log(target_path, package_name, log)
                                        return false 
                                else log = log + result end
 
-                log = log + "## Move files : \"#{path}\" to \"#{target_path}\"\n"
+                               log = log + "## Move files : \"#{path}\" to \"#{target_path}\"\n"
                                result = move_dir(package_name, path, target_path, logger)
                                if result.nil? then 
                                        write_log(target_path, package_name, log)
                                        return false
                                else log = log + result end                                             
 
-                log = log + "## Execute install script\n"
-                result = execute_install_script(package_name, path, target_path, logger)
+                               log = log + "## Execute install script\n"
+                               result = execute_install_script(package_name, path, target_path, logger)
                                if result.nil? then
                                        write_log(target_path, package_name, log)
                                        return false
                                else log = log + result end                                             
-                                                                               
-                log = log + "## Move remove script\n"
-                result = move_remove_script(package_name, path, target_path, logger)
+
+                               log = log + "## Move remove script\n"
+                               result = move_remove_script(package_name, path, target_path, logger)
                                if result.nil? then
                                        write_log(target_path, package_name, log)
                                        return false
                                else log = log + result end                                             
 
-                log = log + "## Remove temporary dir : #{path} #####\n"
-                result = Utils.execute_shell_return("rm -rf #{path}")
+                               log = log + "## Remove temporary dir : #{path} #####\n"
+                               result = Utils.execute_shell_return("rm -rf #{path}")
                                if result.nil? then
                                        logger.warn "Failed to remove temporary path"
                                        logger.info "  [path: #{path}]"
                                end                                     
-            rescue Interrupt
-                logger.error "FileInstaller: Interrupted.."
-                Utils.execute_shell("rm -rf #{path}")
-                logger.info "Removed #{path}"
-                raise Interrupt
-            end
+                       rescue Interrupt
+                               logger.error "FileInstaller: Interrupted.."
+                               Utils.execute_shell("rm -rf #{path}")
+                               logger.info "Removed #{path}"
+                               raise Interrupt
+                       end
                        write_log(target_path, package_name, log)
 =begin
-            target_config_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
-            if not File.exist? target_config_path then FileUtils.mkdir_p(target_config_path) end
-            pkg_inst_log = "#{package_name}_inst.log"
-            pkg_inst_log_path = File.join(target_config_path, pkg_inst_log)
-
-            File.open(pkg_inst_log_path, "a+") do |f|
-                f.puts log
-            end
+                       target_config_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
+                       if not File.exist? target_config_path then FileUtils.mkdir_p(target_config_path) end
+                       pkg_inst_log = "#{package_name}_inst.log"
+                       pkg_inst_log_path = File.join(target_config_path, pkg_inst_log)
+
+                       File.open(pkg_inst_log_path, "a+") do |f|
+                               f.puts log
+                       end
 =end
-        when "source" then
-        end
+               when "source" then
+               end
 
-        # need verify
+               # need verify
                logger.info "Installed \"#{package_name}\" package.. OK"
                logger.info "  [path: #{target_path}]"
-        return true;
+               return true;
        end
 
        def FileInstaller.write_log(target_path, package_name, log)
@@ -144,14 +144,14 @@ class FileInstaller
                end
        end                     
 
-    def FileInstaller.move_remove_script(package_name, path, target_path, logger)
-        target_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
-        if not File.exist? target_path then FileUtils.mkdir_p(target_path) end
-        script_file_prefix = "#{path}/remove.*"
-        script_file = Dir.glob(script_file_prefix)[0]
+       def FileInstaller.move_remove_script(package_name, path, target_path, logger)
+               target_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
+               if not File.exist? target_path then FileUtils.mkdir_p(target_path) end
+               script_file_prefix = "#{path}/remove.*"
+               script_file = Dir.glob(script_file_prefix)[0]
                log = ""
 
-        if not script_file.nil? then
+               if not script_file.nil? then
                        result = Utils.execute_shell_return("mv #{script_file} #{target_path}")
                        if result.nil? then
                                logger.error "Failed to move a remove script"
@@ -167,136 +167,136 @@ class FileInstaller
                end
 
                return log
-    end 
+       end 
 
 
        # Does not verify that the script execution is successful.
        # Register shortcut should be failed.
-    def FileInstaller.execute_install_script(package_name, path, target_path, logger)
-        script_file_prefix = "#{path}/install.*"
-        script_file = Dir.glob(script_file_prefix)[0]
-        log = ""
-        
-        if not script_file.nil? then
-            logger.info "Execute \"#{script_file}\" file"
-            if Utils.is_windows_like_os( Utils::HOST_OS ) then
+       def FileInstaller.execute_install_script(package_name, path, target_path, logger)
+               script_file_prefix = "#{path}/install.*"
+               script_file = Dir.glob(script_file_prefix)[0]
+               log = ""
+
+               if not script_file.nil? then
+                       logger.info "Execute \"#{script_file}\" file"
+                       if Utils.is_windows_like_os( Utils::HOST_OS ) then
                                target_path = target_path.gsub("/","\\")
-                cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"        
-            else
-                cmd = "INSTALLED_PATH=\"#{target_path}\" #{script_file}"
+                               cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"        
+                       else
+                               cmd = "INSTALLED_PATH=\"#{target_path}\" #{script_file}"
                        end
                        logger.info "  [cmd: #{cmd}]"
-            log = `#{cmd}`
+                       log = `#{cmd}`
                        logger.info "Executed install script file.. OK"
                        log = log + "[file: #{script_file}]\n"
                        log = log + "[cmd: #{cmd}]\n"
                end
 
-        return log
-    end
+               return log
+       end
 
        # Does not verify that the script execution is successful.
        # Removing shortcut should be failed.
-    def FileInstaller.execute_remove_script(package_name, target_path, logger)
-        info_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
-        if not File.directory? info_path then
+       def FileInstaller.execute_remove_script(package_name, target_path, logger)
+               info_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
+               if not File.directory? info_path then
                        logger.error "\"#{info_path}\" does not exist."                 
-            return nil 
-        end
-
-        script_file_prefix = "#{info_path}/remove.*"
-        script_file = Dir.glob(script_file_prefix)[0]
-        log = ""
-
-        if not script_file.nil? then
-            logger.info "Execute \"#{script_file}\" file"
-            if Utils.is_windows_like_os( Utils::HOST_OS ) then
-                cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"
-            else
-                cmd = "INSTALLED_PATH=\"#{target_path}\" #{script_file}"
-            end
+                       return nil 
+               end
+
+               script_file_prefix = "#{info_path}/remove.*"
+               script_file = Dir.glob(script_file_prefix)[0]
+               log = ""
+
+               if not script_file.nil? then
+                       logger.info "Execute \"#{script_file}\" file"
+                       if Utils.is_windows_like_os( Utils::HOST_OS ) then
+                               cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"
+                       else
+                               cmd = "INSTALLED_PATH=\"#{target_path}\" #{script_file}"
+                       end
                        logger.info "  [cmd: #{cmd}]"
-            log = `#{cmd}`
+                       log = `#{cmd}`
                        logger.info "Executed remote script file.. OK"
                        log = log + "[file: #{script_file}]\n"
                        log = log + "[cmd: #{cmd}]\n"
                end
 
                return log
-    end
+       end
 
-    def FileInstaller.remove_pkg_files(package_name, target_path, logger)
-        list_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
+       def FileInstaller.remove_pkg_files(package_name, target_path, logger)
+               list_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
 
-        if not File.directory? list_path then
+               if not File.directory? list_path then
                        logger.error "\"#{list_path}\" does not exist."                         
-            return false 
-        end
-
-        list_file_name = "#{list_path}/#{package_name}.list"
-        list_file = Dir.glob(list_file_name)[0]
-        directories = []
-
-        if not list_file.nil? then
-            File.open(list_file, "r") do |file|
-                file.each_line do |f|
-                    f = f.strip
-                    if f.nil? or f.empty? then next end
-                    file_path = File.join(target_path, f)
-                    if File.directory? file_path then
-                        if File.symlink? file_path then 
-                            File.unlink file_path
-                            next
-                        end
-                        entries = Dir.entries(file_path)
-                        if entries.include? "." then entries.delete(".") end
-                        if entries.include? ".." then entries.delete("..") end
-                        if entries.empty? or entries.nil? then
-                            begin
-                                Dir.rmdir(file_path)
-                            rescue SystemCallError
-                                logger.warn "\"#{file_path}\" directory is not empty"
-                            end 
-                        else directories.push(file_path) end
-                    elsif File.file? file_path then FileUtils.rm_f(file_path)
-                    elsif File.symlink? file_path then File.unlink file_path 
-                    # if files are already removed by remove script,
-                    else logger.warn "\"#{file_path}\" does not exist" end
-                end
-            end
-
-            directories.reverse.each do |path|
+                       return false 
+               end
+
+               list_file_name = "#{list_path}/#{package_name}.list"
+               list_file = Dir.glob(list_file_name)[0]
+               directories = []
+
+               if not list_file.nil? then
+                       File.open(list_file, "r") do |file|
+                               file.each_line do |f|
+                                       f = f.strip
+                                       if f.nil? or f.empty? then next end
+                                       file_path = File.join(target_path, f)
+                                       if File.directory? file_path then
+                                               if File.symlink? file_path then 
+                                                       File.unlink file_path
+                                                       next
+                                               end
+                                               entries = Dir.entries(file_path)
+                                               if entries.include? "." then entries.delete(".") end
+                                               if entries.include? ".." then entries.delete("..") end
+                                               if entries.empty? or entries.nil? then
+                                                       begin
+                                                               Dir.rmdir(file_path)
+                                                       rescue SystemCallError
+                                                               logger.warn "\"#{file_path}\" directory is not empty"
+                                                       end 
+                                               else directories.push(file_path) end
+                                       elsif File.file? file_path then FileUtils.rm_f(file_path)
+                                       elsif File.symlink? file_path then File.unlink file_path 
+                                               # if files are already removed by remove script,
+                                       else logger.warn "\"#{file_path}\" does not exist" end
+                               end
+                       end
+
+                       directories.reverse.each do |path|
                                if not File.directory? path     then next end
-                entries = Dir.entries(path)
-                if entries.include? "." then entries.delete(".") end
-                if entries.include? ".." then entries.delete("..") end
-                if entries.empty? or entries.nil? then
-                begin
-                    Dir.rmdir(path)
-                rescue SystemCallError
-                    logger.warn "\"#{file_path}\" directory is not empty"
-                end 
-                else next end
-           end
-        end
-        Utils.execute_shell("rm -rf #{list_path}")
-        return true
-    end
-
-    def FileInstaller.uninstall(package_name, type, target_path, logger)
-        case type
-        when "binary" then
-            result = execute_remove_script(package_name, target_path, logger)
+                               entries = Dir.entries(path)
+                               if entries.include? "." then entries.delete(".") end
+                               if entries.include? ".." then entries.delete("..") end
+                               if entries.empty? or entries.nil? then
+                                       begin
+                                               Dir.rmdir(path)
+                                       rescue SystemCallError
+                                               logger.warn "\"#{file_path}\" directory is not empty"
+                                       end 
+                               else next end
+                       end
+               end
+               Utils.execute_shell("rm -rf #{list_path}")
+               return true
+       end
+
+       def FileInstaller.uninstall(package_name, type, target_path, logger)
+               case type
+               when "binary" then
+                       result = execute_remove_script(package_name, target_path, logger)
                        if result.nil? then return false end                                    
                        if not remove_pkg_files(package_name, target_path, logger) then return false end
-        when "source" then
-        end
+               when "source" then
+               end
 
-        return true
-    end
+               return true
+       end
 
-    def FileInstaller.move_dir(package_name, source_path, target_path, logger)
-        config_path = File.join(target_path, PACKAGE_INFO_DIR, package_name)
+       def FileInstaller.move_dir(package_name, source_path, target_path, logger)
+               config_path = File.join(target_path, PACKAGE_INFO_DIR, package_name)
                pkginfo_path = File.join(source_path, PACKAGE_MANIFEST)
                data_path = File.join(source_path, "data")
                log = ""
@@ -308,11 +308,11 @@ class FileInstaller
 
                if File.exist? data_path then
                        # if os is linux, use cpio. it is faster than cp                
-               if Utils.is_linux_like_os( Utils::HOST_OS ) then
+                       if Utils.is_linux_like_os( Utils::HOST_OS ) then
                                absolute_path = `readlink -f #{target_path}`
-                       result = Utils.execute_shell_return("cd #{data_path}; find . -depth | cpio -pldm #{absolute_path}")
+                               result = Utils.execute_shell_return("cd #{data_path}; find . -depth | cpio -pldm #{absolute_path}")
                        else                    
-                       result = Utils.execute_shell_return("cp -r #{data_path}/* #{target_path}")
+                               result = Utils.execute_shell_return("cp -r #{data_path}/* #{target_path}")
                        end
                        if result.nil? then
                                logger.error "Failed to move files"
@@ -326,64 +326,64 @@ class FileInstaller
                else logger.warn "\"data\" directory does not exist." end
 
                return log
-    end
-
-    def FileInstaller.extract_file(package_name, package_file_path, path, target_path, logger)
-        dirname = File.dirname(package_file_path)
-        filename = File.basename(package_file_path)
-        ext = File.extname(filename)
-
-        target_config_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
-        if not File.exist? target_config_path then FileUtils.mkdir_p(target_config_path) end
-        pkg_file_list = "#{package_name}.list"
-        pkg_file_list_path = File.join(target_config_path, pkg_file_list)
-        temp_pkg_file_list = "temp_file_list"
-        temp_pkg_file_list_path = File.join(target_config_path, "temp_file_list")
-
-        show_file_list_command = nil
-        extrach_file_list_command = nil
+       end
+
+       def FileInstaller.extract_file(package_name, package_file_path, path, target_path, logger)
+               dirname = File.dirname(package_file_path)
+               filename = File.basename(package_file_path)
+               ext = File.extname(filename)
+
+               target_config_path = target_path + "/#{PACKAGE_INFO_DIR}/#{package_name}"
+               if not File.exist? target_config_path then FileUtils.mkdir_p(target_config_path) end
+               pkg_file_list = "#{package_name}.list"
+               pkg_file_list_path = File.join(target_config_path, pkg_file_list)
+               temp_pkg_file_list = "temp_file_list"
+               temp_pkg_file_list_path = File.join(target_config_path, "temp_file_list")
+
+               show_file_list_command = nil
+               extrach_file_list_command = nil
                log = ""
 
-        case ext
-        when ".zip" then
-            show_file_list_command = "zip -sf #{package_file_path}"
-            extract_file_list_command = "unzip -o \"#{package_file_path}\" -d \"#{path}\""
-        when ".tar" then
-            # path should be unix path if it is used in tar command 
-            _package_file_path = Utils.get_unix_path(package_file_path)
-            _path = Utils.get_unix_path(path)
-            show_file_list_command = "tar -tf #{_package_file_path}"
-            extract_file_list_command = "tar xf \"#{_package_file_path}\" -C \"#{_path}\""
-        else
-            logger.error "\"#{filename}\" is not supported."
-            return nil 
-        end
-
-        system "#{show_file_list_command} > #{temp_pkg_file_list_path}"
-        File.open(pkg_file_list_path, "a+") do |targetfile|
-            File.open(temp_pkg_file_list_path, "r") do |sourcefile|
-                sourcefile.each_line do |l|
-                    if l.strip.start_with? "data/" then
-                        ml = l.strip[5..-1]
-                        targetfile.puts ml
-                    else next end
-                end
-            end
-        end
-        File.delete(temp_pkg_file_list_path)
-
-        case ext
-        when ".zip" then
-            if Utils.is_windows_like_os( Utils::HOST_OS ) then
-                log = unzip_file(package_file_path, path)
-            else
+               case ext
+               when ".zip" then
+                       show_file_list_command = "zip -sf #{package_file_path}"
+                       extract_file_list_command = "unzip -o \"#{package_file_path}\" -d \"#{path}\""
+               when ".tar" then
+                       # path should be unix path if it is used in tar command 
+                       _package_file_path = Utils.get_unix_path(package_file_path)
+                       _path = Utils.get_unix_path(path)
+                       show_file_list_command = "tar -tf #{_package_file_path}"
+                       extract_file_list_command = "tar xf \"#{_package_file_path}\" -C \"#{_path}\""
+               else
+                       logger.error "\"#{filename}\" is not supported."
+                       return nil 
+               end
+
+               system "#{show_file_list_command} > #{temp_pkg_file_list_path}"
+               File.open(pkg_file_list_path, "a+") do |targetfile|
+                       File.open(temp_pkg_file_list_path, "r") do |sourcefile|
+                               sourcefile.each_line do |l|
+                                       if l.strip.start_with? "data/" then
+                                               ml = l.strip[5..-1]
+                                               targetfile.puts ml
+                                       else next end
+                               end
+                       end
+               end
+               File.delete(temp_pkg_file_list_path)
+
+               case ext
+               when ".zip" then
+                       if Utils.is_windows_like_os( Utils::HOST_OS ) then
+                               log = unzip_file(package_file_path, path)
+                       else
                                #result = Utils.execute_shell_return(extract_file_list_command)
                                #if result.nil? then log = nil 
                                #else log = result.join("") end 
                                log = `#{extract_file_list_command}`
-            end
-        when ".tar" then
-            #result = Utils.execute_shell_return(extract_file_list_command)
+                       end
+               when ".tar" then
+                       #result = Utils.execute_shell_return(extract_file_list_command)
                        #if result.nil? then log = nil
                        #else log = result.join("") end                                                 
                        log = `#{extract_file_list_command}`
@@ -399,86 +399,86 @@ class FileInstaller
                        return nil
                end                     
 
-        logger.info "Extracted \"#{filename}\" file.. OK"
+               logger.info "Extracted \"#{filename}\" file.. OK"
                log = log + "[file: #{package_file_path}]\n"
                log = log + "[from: #{path}]\n"
                log = log + "[to: #{target_path}]\n"
                log = log + "[cmd: #{extract_file_list_command}]\n"
-        return log
-    end
-
-    def FileInstaller.extract_a_file(package_file_path, target_file, path, logger)
-        dirname = File.dirname(package_file_path)
-        filename = File.basename(package_file_path)
-        ext = File.extname(filename)
-        
-        case ext
-        when ".zip" then
-            if not path.nil? then
-                extract_file_command = "unzip -x #{package_file_path} #{target_file} -d #{path}"
-            else
-                extract_file_command = "unzip -x #{package_file_path} #{target_file}"
-            end
-        when ".tar" then
-            # path should be unix path if it is used in tar command 
-            _package_file_path = Utils.get_unix_path(package_file_path)
-            _path = Utils.get_unix_path(path)
-            if not path.nil? then
-                extract_file_command = "tar xf #{_package_file_path} -C #{_path} #{target_file}"
-            else
-                extract_file_command = "tar xf #{_package_file_path} #{target_file}"
-            end
-        end
-
-        system "#{extract_file_command}"
-        
-        if not path.nil? then
-            target_file_path = File.join(path, target_file)
-        else
-            target_file_path = target_file
-        end
-
-        if File.exist? target_file_path then
-            logger.info "Extracted \"#{target_file}\" file.."
-            return true
-        else
-            logger.warn "Failed to extracted \"#{target_file}\" file.."
+               return log
+       end
+
+       def FileInstaller.extract_a_file(package_file_path, target_file, path, logger)
+               dirname = File.dirname(package_file_path)
+               filename = File.basename(package_file_path)
+               ext = File.extname(filename)
+
+               case ext
+               when ".zip" then
+                       if not path.nil? then
+                               extract_file_command = "unzip -x #{package_file_path} #{target_file} -d #{path}"
+                       else
+                               extract_file_command = "unzip -x #{package_file_path} #{target_file}"
+                       end
+               when ".tar" then
+                       # path should be unix path if it is used in tar command 
+                       _package_file_path = Utils.get_unix_path(package_file_path)
+                       _path = Utils.get_unix_path(path)
+                       if not path.nil? then
+                               extract_file_command = "tar xf #{_package_file_path} -C #{_path} #{target_file}"
+                       else
+                               extract_file_command = "tar xf #{_package_file_path} #{target_file}"
+                       end
+               end
+
+               system "#{extract_file_command}"
+
+               if not path.nil? then
+                       target_file_path = File.join(path, target_file)
+               else
+                       target_file_path = target_file
+               end
+
+               if File.exist? target_file_path then
+                       logger.info "Extracted \"#{target_file}\" file.."
+                       return true
+               else
+                       logger.warn "Failed to extracted \"#{target_file}\" file.."
                        logger.info "  [file: #{package_file_path}]"
                        logger.info "  [path: #{path}]"
                        logger.info "  [cmd: #{extract_file_command}]"
-            return false
-        end
-    end
-
-    def FileInstaller.unzip_file(zipfile, dest)
-        log = "" 
-        Zip::ZipFile.open(zipfile) do |zip_file|
-            zip_file.each do |f|
-                f_path = File.join(dest, f.name)
-                FileUtils.mkdir_p(File.dirname(f_path))
-                if File.exist?(f_path) then
-                    log = log + "[Warn] Exist file : #{f_path}\n" unless f_path.end_with? "/"
-                else
-                    zip_file.extract(f, f_path)
-                    if not f_path.end_with? "/" then
-                        log = log + "[info] Extracted file : #{f_path}\n"
-                    end
-                end
-            end
-        end
-        return log
-    end
-
-    def FileInstaller.unzip_a_file(zipfile, file, dest)
-        Zip::ZipFile.open(zipfile) do |zip_file|
-            zip_file.each do |f|
-                if f.name.strip == file then
-                    f_path = File.join(dest, f.name)
-                    FileUtils.mkdir_p(File.dirname(f_path))
-                    zip_file.extract(f, f_path) unless File.exist?(f_path)
-                    break
-                end
-            end
-        end
-    end
+                       return false
+               end
+       end
+
+       def FileInstaller.unzip_file(zipfile, dest)
+               log = "" 
+               Zip::ZipFile.open(zipfile) do |zip_file|
+                       zip_file.each do |f|
+                               f_path = File.join(dest, f.name)
+                               FileUtils.mkdir_p(File.dirname(f_path))
+                               if File.exist?(f_path) then
+                                       log = log + "[Warn] Exist file : #{f_path}\n" unless f_path.end_with? "/"
+                               else
+                                       zip_file.extract(f, f_path)
+                                       if not f_path.end_with? "/" then
+                                               log = log + "[info] Extracted file : #{f_path}\n"
+                                       end
+                               end
+                       end
+               end
+               return log
+       end
+
+       def FileInstaller.unzip_a_file(zipfile, file, dest)
+               Zip::ZipFile.open(zipfile) do |zip_file|
+                       zip_file.each do |f|
+                               if f.name.strip == file then
+                                       f_path = File.join(dest, f.name)
+                                       FileUtils.mkdir_p(File.dirname(f_path))
+                                       zip_file.extract(f, f_path) unless File.exist?(f_path)
+                                       break
+                               end
+                       end
+               end
+       end
 end
index f4433157d70e20461d3dda6470b0d9a9c621fd41..8c6e80d644c421dc97c4fa348c677bd641e83f1d 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  packageServer.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -46,8 +46,8 @@ class PackageServer
        attr_accessor :incoming_path
        attr_accessor :distribution_list
        attr_accessor :sync_interval, :passwd
-    
-    # constant
+
+       # constant
        SERVER_ROOT = "#{PackageServerConfig::CONFIG_ROOT}/pkg_server"
        DIBS_LOCK_FILE_PATH = "#{SERVER_ROOT}/.server_loc"
 
@@ -65,7 +65,7 @@ class PackageServer
                @lock_file= nil
                @sync_interval = 3600
                @passwd = ""
-               
+
                update_config_information(id)
 
                if not File.exist?( SERVER_ROOT )
@@ -94,7 +94,7 @@ class PackageServer
                if File.exist? @config_dir
                        raise RuntimeError, "Server create fail. server id [#{@id}] is already exist"
                end
-               
+
                # name check 
                if dist_name.strip.eql? "distribution.info" then 
                        raise RuntimeError, "id \"distribution.info\" is not available"
@@ -108,9 +108,9 @@ class PackageServer
                FileUtils.mkdir_p @incoming_path
 
                if (not server_url.empty?) and \
-                               (not Utils.is_url_remote(server_url)) and \
-                               (not Utils.is_absolute_path(server_url)) then
-                               # if server_url is local server address then generate absoulte path 
+                       (not Utils.is_url_remote(server_url)) and \
+                       (not Utils.is_absolute_path(server_url)) then
+                       # if server_url is local server address then generate absoulte path 
                        server_url = File.join(Utils::WORKING_DIR, server_url)
                end 
 
@@ -122,10 +122,10 @@ class PackageServer
                        f.puts "sync interval : #{@sync_interval}"
                        f.puts "server_url : #{dist_name} ->  #{server_url}"
                end
-               
+
                # create location's directory
                FileUtils.mkdir_p "#{@location}"
-               
+
                create_distribution_struct( dist_name, server_url )
                Utils.file_unlock(lock_file)
 
@@ -138,7 +138,7 @@ class PackageServer
 
                # distribution lock 
                @lock_file = Utils.file_lock(distribution.lock_file_path)
-               
+
                updated_os_list = []
                registed_package_list = []
                binary_pkg_file_path_list = []
@@ -148,7 +148,7 @@ class PackageServer
 
                file_path_list.each do |f|
                        # error check for file exist 
-            if not File.exist? f
+                       if not File.exist? f
                                raise RuntimeError, "package file does not exist [#{f}]"
                        end 
 
@@ -177,10 +177,10 @@ class PackageServer
                                end
 
                                updated_pkg = register_package(distribution, pkg, f, test_flag, internal_flag)
-                               
+
                                updated_os_list.push updated_pkg.os 
                                registed_package_list.push updated_pkg
-                       # archive package
+                               # archive package
                        else
                                if test_flag then 
                                        @log.error("archive package does not using test mode", Log::LV_USER)
@@ -201,13 +201,13 @@ class PackageServer
                end
 
                # move file to package server
-        binary_pkg_file_path_list.each do |l|
-            if test_flag then 
-                FileUtils.copy_file( l, "#{distribution.location}/temp/#{File.basename(l)}" )
-            else    
-                FileUtils.copy_file( l, "#{distribution.location}/binary/#{File.basename(l)}" )
-            end     
-        end  
+               binary_pkg_file_path_list.each do |l|
+                       if test_flag then 
+                               FileUtils.copy_file( l, "#{distribution.location}/temp/#{File.basename(l)}" )
+                       else    
+                               FileUtils.copy_file( l, "#{distribution.location}/binary/#{File.basename(l)}" )
+                       end     
+               end  
 
                # link to package server 
                link_pkg_file_path_list.each do |l|
@@ -222,14 +222,14 @@ class PackageServer
                        end
                end
 
-        archive_pkg_file_path_list.each do |l|
-            FileUtils.mv( l, "#{distribution.location}/source/" )
-        end  
+               archive_pkg_file_path_list.each do |l|
+                       FileUtils.mv( l, "#{distribution.location}/source/" )
+               end  
 
                # write package list for updated os
                updated_os_list.uniq!
                updated_os_list.each do |os|
-               distribution.write_pkg_list(os) 
+                       distribution.write_pkg_list(os) 
                end
 
                # register archive pakcage list. 
@@ -240,14 +240,14 @@ class PackageServer
                        msg_list = []
 
                        registed_package_list.each { |p| 
-                                       msg_list.push("%-30s: %08s" % [ p.package_name.strip, p.version.strip ] )
+                               msg_list.push("%-30s: %08s" % [ p.package_name.strip, p.version.strip ] )
                        } 
                        # email just remote package server
                        # Mail.send_package_registe_mail( msg_list, @id )  
                end
 
-        # if snapshot mode is true then generate snapshot
-        if snapshot or test_flag then
+               # if snapshot mode is true then generate snapshot
+               if snapshot or test_flag then
                        @log.info "generaging snapshot"
                        snapshot_name = distribution.generate_snapshot("", "", false, get_changelog_string(registed_package_list) )
                end
@@ -256,7 +256,7 @@ class PackageServer
                @log.output( "package registed successfully", Log::LV_USER)
 
                return snapshot_name
-    end
+       end
 
        def get_changelog_string( package_list )
                log_list = []
@@ -275,14 +275,14 @@ class PackageServer
                snapshot_name = distribution.generate_snapshot( snpashot_name, base_snapshot, true, "SYSTEM:")
 
                Utils.file_unlock(@lock_file)
-               
+
                return snapshot_name
        end
 
        def sync( dist_name, mode, snapshot = "" )
                @log.info "sync from server"
                distribution = get_distribution( dist_name ) 
-       
+
                if distribution.server_url.empty? then 
                        @log.error( "This distribution has not remote server", Log::LV_USER) 
                        return
@@ -298,19 +298,19 @@ class PackageServer
 
        def add_distribution( dist_name, server_url, clone )
                lock_file = Utils.file_lock(@server_lock_file_path)
-               
+
                # error check : check for already exist in server directory 
                if @dist_to_server_url.keys.include? dist_name.strip then
                        Utils.file_unlock(@lock_file)
                        raise RuntimeError, "distribution already exist : #{dist_name}"
                end
-               
+
                # name check 
                if dist_name.strip.eql? "distribution.info" then 
                        Utils.file_unlock(@lock_file)
                        raise RuntimeError, "id \"distribution.info\" is not available"
                end 
-        
+
                # modify server url
                if (not server_url.empty?) and (not Utils.is_url_remote(server_url))
                        # if server_url is local server address then generate absoulte path 
@@ -332,10 +332,10 @@ class PackageServer
 
        def add_os(dist_name, os)
                dist = get_distribution(dist_name)
-               
+
                # distribution lock 
                @lock_file = Utils.file_lock(dist.lock_file_path)
-               
+
                dist.add_os(os)
 
                @log.info "generaging snapshot"
@@ -347,7 +347,7 @@ class PackageServer
 
        def remove_server()
                @log.info( "Package server [#{@id}] will be removed and all server information delete", Log::LV_USER)
-               
+
                lock_file = Utils.file_lock(DIBS_LOCK_FILE_PATH)
                if File.exist? @config_file_path then
                        File.open @config_file_path do |f|
@@ -362,10 +362,10 @@ class PackageServer
                else
                        @log.error( "Can't find server information : #{@id}", Log::LV_USER)
                end 
-               
+
                FileUtils.rm_rf @config_dir
                FileUtils.rm_rf @log_file_path
-               
+
                Utils.file_unlock(lock_file)
                @log.output( "package server [#{@id}] removed successfully", Log::LV_USER )
        end
@@ -375,7 +375,7 @@ class PackageServer
                distribution = get_distribution( dist_name )
 
                lock_file = Utils.file_lock(@server_lock_file_path)
-               
+
                # modify config file 
                config_file = File.readlines(@config_file_path)
                File.open(@config_file_path, 'w') do |f|
@@ -407,7 +407,7 @@ class PackageServer
 
                # remove distribution directory 
                FileUtils.rm_rf distribution.location
-               
+
                # remove distribution struct
                @distribution_list.delete distribution 
 
@@ -419,9 +419,9 @@ class PackageServer
                distribution = get_distribution( dist_name )
 
                lock_file = Utils.file_lock(@server_lock_file_path)
-               
+
                distribution.remove_pkg(pkg_name_list, os)
-       
+
                # generate snapshot     
                @log.info "generaging snapshot"
                distribution.generate_snapshot("", "", false, "SYSTEM: Package \"#{pkg_name_list.join(", ")}\" is(are) removed in #{os} server")
@@ -429,15 +429,15 @@ class PackageServer
                Utils.file_unlock(lock_file)
                @log.output( "package removed successfully", Log::LV_USER )
        end
-       
+
        def remove_snapshot( dist_name, snapshot_list )
                @log.info "remove snapshot in server"
                distribution = get_distribution( dist_name )
 
                lock_file = Utils.file_lock(@server_lock_file_path)
-               
+
                distribution.remove_snapshot(snapshot_list)
-               
+
                Utils.file_unlock(lock_file)
        end
 
@@ -446,34 +446,34 @@ class PackageServer
                distribution = get_distribution( dist_name )
 
                lock_file = Utils.file_lock(@server_lock_file_path)
-               
+
                distribution.clean( snapshot_list ) 
 
                # remove incoming dir 
                FileUtils.rm_rf incoming_path
                FileUtils.mkdir incoming_path
-               
+
                Utils.file_unlock(lock_file)
        end
 
        # start server daemon
        def start( port, passwd ) 
-        @log.info "Package server Start..."
+               @log.info "Package server Start..."
                # set port number. default port is 3333
                @port = port 
 
                # set job request listener
-        @log.info "Setting listener..."
+               @log.info "Setting listener..."
                listener = SocketRegisterListener.new(self)
                listener.start
 
-        # set auto sync
+               # set auto sync
                if @auto_sync_flag.eql? "YES" then
-             @log.info "Setting auto sync..."
-             autosync = DistSync.new(self)
-             autosync.start
+                       @log.info "Setting auto sync..."
+                       autosync = DistSync.new(self)
+                       autosync.start
                end
-       
+
                # set password 
                @passwd = passwd
 
@@ -499,7 +499,7 @@ class PackageServer
                # set port number. default port is 3333
                @port = port 
                @finish = false
-               
+
                client = BuildCommClient.create("127.0.0.1", @port, @log)
                if client.nil? then 
                        raise RuntimeError, "Server does not listen in #{@port} port"
@@ -514,7 +514,7 @@ class PackageServer
                        @log.output( "Package server return error message : #{ret}", Log::LV_USER)
                end
                client.terminate
-       
+
        end 
 
        def self.list_id  
@@ -524,7 +524,7 @@ class PackageServer
                s = d.select {|f| not f.start_with?(".") }  
                s.sort!
                server_list = []
-       
+
                @@log.output( "=== server ID list ===", Log::LV_USER)
                s.each do |id|
                        if File.extname(id).eql?(".log") then next end
@@ -540,7 +540,7 @@ class PackageServer
 
        def self.list_dist( id )
                @@log = PackageServerLog.new( "#{SERVER_ROOT}/.log" ) 
-               
+
                @@log.output( "=== ID [#{id}]'s distribution list ===", Log::LV_USER)
 
                dist_list = []
@@ -550,7 +550,7 @@ class PackageServer
                if not File.exist? config_file_path
                        raise RuntimeError, "[#{id}] is not server ID"
                end 
-               
+
                File.open config_file_path do |f|
                        f.each_line do |l|
                                if l.start_with?( "server_url : ") and l.include?( "->" ) then
@@ -625,7 +625,7 @@ class PackageServer
                                        end
                                end
                        end
-               
+
                        @dist_to_server_url.each do |dist_name, server_url|
                                @distribution_list.push Distribution.new( dist_name, "#{@location}/#{dist_name}", server_url, self )
                        end
@@ -653,7 +653,7 @@ class PackageServer
                if File.exist? "#{@location}/#{dist_name}"
                        raise RuntimeError, "distribution directory already exist [#{@location}/#{dist_name}]" 
                end
-               
+
                FileUtils.mkdir "#{@location}/#{dist_name}"
                FileUtils.mkdir "#{@location}/#{dist_name}/binary"
                FileUtils.mkdir "#{@location}/#{dist_name}/source"
@@ -668,7 +668,7 @@ class PackageServer
 
                # add dist
                @distribution_list.push distribution
-       
+
                if not server_url.empty?  then
                        @log.info "generate package server using remote package server [#{server_url}]"
 
@@ -677,12 +677,12 @@ class PackageServer
                        else 
                                @log.info "[#{dist_name}] distribution creation. using local server [#{server_url}]"
                        end
-                       
+
                        distribution.sync(false)
                        distribution.generate_snapshot("", "", false, distribution.last_sync_changes)
                else
                        @log.info "generate package server do not using remote package server"
-       
+
                        # write_pkg_list for empty file
                        distribution.write_pkg_list(nil)
                        distribution.write_archive_pkg_list()
@@ -701,11 +701,11 @@ class PackageServer
                if pkg.nil? or pkg.package_name.empty? then
                        raise "[#{file_path}]'s pkginfo.manifest file is incomplete."
                end 
-               
+
                if not test_flag then 
                        # error check
                        if pkg.package_name.empty? or pkg.version.empty? \
-                                       or pkg.os.empty? or pkg.maintainer.empty? then
+                               or pkg.os.empty? or pkg.maintainer.empty? then
                                raise "[#{file_path}]'s pkginfo.manifest file is incomplete."
                        end 
 
index b2b447a92063696a1ce9dcc07277ee82d218bb55..9e13adb431d3748d418396acb56e0a4de6625fd9 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  serverConfig.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
index d9c46198ec79790b4d36e4f5ee5ab740c8787365..d633b120aa2d264ca601386a2711432c0e62d21e 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  packageServerLog.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
index 8c86fc34af58882344ec8a71ceaf49e7f288648c..3a36ae29071a0e6830710ae03fe91a299ad2ed16 100644 (file)
@@ -1,5 +1,5 @@
 =begin
+
  serverOptParser.rb 
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
@@ -49,38 +49,38 @@ def set_default( options )
 end
 
 def option_error_check( options )
-               
+
        case options[:cmd] 
        when "create" 
-           if  options[:id].empty? or options[:dist].empty? then
+               if      options[:id].empty? or options[:dist].empty? then
                        raise ArgumentError, "Usage: pkg-svr create -n <server name> -d <distribution> [-u <remote server url>] [-l <location>] "
                end
        when "remove"
                if      options[:id].empty? then
-               raise ArgumentError, "Usage: pkg-svr remove -n <server name> "
+                       raise ArgumentError, "Usage: pkg-svr remove -n <server name> "
                end
        when "remove-pkg"
                if      options[:pkgs].empty? then
-               raise ArgumentError, "Usage: pkg-svr remove-pkg -n <server name> -d <distribution> -P <package file list> [-o <os>]" + "\n" \
+                       raise ArgumentError, "Usage: pkg-svr remove-pkg -n <server name> -d <distribution> -P <package file list> [-o <os>]" + "\n" \
                end
        when "remove-snapshot"
                if      options[:snaps].empty? then
-               raise ArgumentError, "Usage: pkg-svr remove-snapshot -n <server name> -d <distribution> -s <snapshot list>"
+                       raise ArgumentError, "Usage: pkg-svr remove-snapshot -n <server name> -d <distribution> -s <snapshot list>"
                end
        when "add-dist"
-           if  options[:id].empty? or options[:dist].empty? then
+               if      options[:id].empty? or options[:dist].empty? then
                        raise ArgumentError, "Usage: pkg-svr add-dist -n <server name> -d <distribution> [-u <remote server url>] [--clone] "
                end
        when "add-os"
-           if options[:os].empty?  then
+               if options[:os].empty?  then
                        raise ArgumentError, "Usage: pkg-svr add-os -n <server name> -d <distribution> -o <os>] "
                end
        when "remove-dist"
-           if  options[:id].empty? or options[:dist].empty? then
+               if      options[:id].empty? or options[:dist].empty? then
                        raise ArgumentError, "Usage: pkg-svr remove-dist -n <server name> -d <distribution> "
                end
        when "register"
-           if  options[:pkgs].empty? then
+               if      options[:pkgs].empty? then
                        raise ArgumentError, "Usage: pkg-svr register -n <server name> -d <distribution> -P <package file list> [--gen] [--test] "
                end
        when "gen-snapshot"
@@ -104,150 +104,150 @@ def option_error_check( options )
 end
 
 def option_parse 
-    options = {}
-    banner = "Package-server administer service command-line tool." + "\n" \
-        + "\n" + "Usage: pkg-svr <SUBCOMMAND> [OPTS] or pkg-svr (-h|-v)" + "\n" \
-        + "\n" + "Subcommands:" + "\n" \
-        + "\t" + "create          Create a package-server." + "\n" \
-        + "\t" + "add-dist        Add a distribution to package-server." + "\n" \
-        + "\t" + "add-os          Add supported os." + "\n" \
-        + "\t" + "register        Register a package in package-server." + "\n" \
-        + "\t" + "remove          Remove a package-server." + "\n" \
-        + "\t" + "remove-dist     Remove a distribution to package-server." + "\n" \
-        + "\t" + "remove-pkg      Remove a package in package-server." + "\n" \
-        + "\t" + "remove-snapshot Remove a snapshot in package-server." + "\n" \
-        + "\t" + "gen-snapshot    Generate a snapshot in package-server." + "\n" \
-        + "\t" + "sync            Synchronize the package-server from parent package server." + "\n" \
-        + "\t" + "start           Start the package-server." + "\n" \
-        + "\t" + "stop            Stop the package-server." + "\n" \
-        + "\t" + "clean           Delete unneeded package files in package-server." + "\n" \
-        + "\t" + "list            Show all pack" + "\n" \
-        + "\n" + "Subcommand usage:" + "\n" \
-        + "\t" + "pkg-svr create -n <server name> -d <distribution> [-u <remote server url>] [-l <location>] " + "\n" \
-        + "\t" + "pkg-svr add-dist -n <server name> -d <distribution> [-u <remote server url>] [--clone] " + "\n" \
-        + "\t" + "pkg-svr add-os -n <server name> -d <distribution> -o <os> " + "\n" \
-        + "\t" + "pkg-svr register -n <server name> -d <distribution> -P <package file list> [--gen] [--test] " + "\n" \
-        + "\t" + "pkg-svr remove -n <server name> " + "\n" \
-        + "\t" + "pkg-svr remove-dist -n <server name> -d <distribution>"  + "\n" \
-        + "\t" + "pkg-svr remove-pkg -n <server name> -d <distribution> -P <package name list> [-o <os>] " + "\n" \
-        + "\t" + "pkg-svr remove-snapshot -n <server name> -d <distribution> -s <snapshot list>" + "\n" \
-        + "\t" + "pkg-svr gen-snapshot -n <server name> -d <distribution> -s <snapshot name> [-b <base snapshot name>] " + "\n"  \
-        + "\t" + "pkg-svr sync -n <server name> -d <distribution> -s <snapshot_name> [--force] " + "\n"  \
-        + "\t" + "pkg-svr clean -n <server name> -d <distribution> [-s <snapshot list>] " + "\n" \
-        + "\t" + "pkg-svr start -n <server name> -p <port> [-w <password>]" + "\n" \
-        + "\t" + "pkg-svr stop -n <server name> -p <port> [-w <password>]" + "\n" \
-        + "\t" + "pkg-svr list [-n <server name>] " + "\n" \
-        + "\n" + "Options:" + "\n"
-
-    optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
-        # Set a banner, displayed at the top
-        # of the help screen.
+       options = {}
+       banner = "Package-server administer service command-line tool." + "\n" \
+               + "\n" + "Usage: pkg-svr <SUBCOMMAND> [OPTS] or pkg-svr (-h|-v)" + "\n" \
+               + "\n" + "Subcommands:" + "\n" \
+               + "\t" + "create          Create a package-server." + "\n" \
+               + "\t" + "add-dist        Add a distribution to package-server." + "\n" \
+               + "\t" + "add-os          Add supported os." + "\n" \
+               + "\t" + "register        Register a package in package-server." + "\n" \
+               + "\t" + "remove          Remove a package-server." + "\n" \
+               + "\t" + "remove-dist     Remove a distribution to package-server." + "\n" \
+               + "\t" + "remove-pkg      Remove a package in package-server." + "\n" \
+               + "\t" + "remove-snapshot Remove a snapshot in package-server." + "\n" \
+               + "\t" + "gen-snapshot    Generate a snapshot in package-server." + "\n" \
+               + "\t" + "sync            Synchronize the package-server from parent package server." + "\n" \
+               + "\t" + "start           Start the package-server." + "\n" \
+               + "\t" + "stop            Stop the package-server." + "\n" \
+               + "\t" + "clean           Delete unneeded package files in package-server." + "\n" \
+               + "\t" + "list            Show all pack" + "\n" \
+               + "\n" + "Subcommand usage:" + "\n" \
+               + "\t" + "pkg-svr create -n <server name> -d <distribution> [-u <remote server url>] [-l <location>] " + "\n" \
+               + "\t" + "pkg-svr add-dist -n <server name> -d <distribution> [-u <remote server url>] [--clone] " + "\n" \
+               + "\t" + "pkg-svr add-os -n <server name> -d <distribution> -o <os> " + "\n" \
+               + "\t" + "pkg-svr register -n <server name> -d <distribution> -P <package file list> [--gen] [--test] " + "\n" \
+               + "\t" + "pkg-svr remove -n <server name> " + "\n" \
+               + "\t" + "pkg-svr remove-dist -n <server name> -d <distribution>"  + "\n" \
+               + "\t" + "pkg-svr remove-pkg -n <server name> -d <distribution> -P <package name list> [-o <os>] " + "\n" \
+               + "\t" + "pkg-svr remove-snapshot -n <server name> -d <distribution> -s <snapshot list>" + "\n" \
+               + "\t" + "pkg-svr gen-snapshot -n <server name> -d <distribution> -s <snapshot name> [-b <base snapshot name>] " + "\n"  \
+               + "\t" + "pkg-svr sync -n <server name> -d <distribution> -s <snapshot_name> [--force] " + "\n"  \
+               + "\t" + "pkg-svr clean -n <server name> -d <distribution> [-s <snapshot list>] " + "\n" \
+               + "\t" + "pkg-svr start -n <server name> -p <port> [-w <password>]" + "\n" \
+               + "\t" + "pkg-svr stop -n <server name> -p <port> [-w <password>]" + "\n" \
+               + "\t" + "pkg-svr list [-n <server name>] " + "\n" \
+               + "\n" + "Options:" + "\n"
+
+       optparse = OptionParser.new(nil, 32, ' '*8) do|opts|
+               # Set a banner, displayed at the top
+               # of the help screen.
 
                opts.banner = banner 
 
-        opts.on( '-n', '--name <server name>', 'package server name' ) do|name|
-            options[:id] = name 
-        end
-        
+               opts.on( '-n', '--name <server name>', 'package server name' ) do|name|
+                       options[:id] = name 
+               end
+
                opts.on( '-d', '--dist <distribution>', 'package server distribution' ) do|dist|
-            options[:dist] = dist 
-        end
-               
+                       options[:dist] = dist 
+               end
+
                opts.on( '-u', '--url <server url>', 'remote server url: http://127.0.0.1/dibs/unstable' ) do|url|
-            options[:url] = url 
-        end
-               
+                       options[:url] = url 
+               end
+
                opts.on( '-o', '--os <operating system>', 'target operating system' ) do|os|
-            options[:os] = os
-        end
-               
+                       options[:os] = os
+               end
+
                opts.on( '-P', '--pkgs <package file list>', 'package file path list' ) do|pkgs|
                        if not Utils.multi_argument_test( pkgs, "," ) then
                                raise ArgumentError, "Package variable parsing error : #{pkgs}"
                        end
-            list = pkgs.tr(" \t","").split(",")
-            list.each do |l|
+                       list = pkgs.tr(" \t","").split(",")
+                       list.each do |l|
                                if l.start_with? "~" then l = Utils::HOME + l.delete("~") end
                                options[:pkgs].push l 
-            end 
-        end
-               
+                       end 
+               end
+
                opts.on( '-s', '--snapshot <snapshot>', 'a snapshot name or snapshot list' ) do|snaplist|
                        if not Utils.multi_argument_test( snaplist, "," ) then
                                raise ArgumentError, "Snapshot variable parsing error : #{snaplist}"
                        end
-            options[:snaps] = snaplist.split(",")
-        end
+                       options[:snaps] = snaplist.split(",")
+               end
 
                opts.on( '-b', '--base <base snapshot>', 'base snapshot name' ) do|bsnap|
-            options[:bsnap] = bsnap 
-        end
-               
+                       options[:bsnap] = bsnap 
+               end
+
                opts.on( '-l', '--loc <location>', 'server location' ) do|loc|
-            options[:loc] = loc 
-        end
-               
+                       options[:loc] = loc 
+               end
+
                opts.on( '-p', '--port <port>', 'port number' ) do|port|
-            options[:port] = port
-        end
-               
+                       options[:port] = port
+               end
+
                opts.on( '-w', '--passwd <password>', 'password for package server' ) do|passwd|
-            options[:passwd] = passwd
-        end
+                       options[:passwd] = passwd
+               end
 
                opts.on( '--clone', 'clone mode' ) do
-            options[:clone] = true
-        end
+                       options[:clone] = true
+               end
 
                opts.on( '--force', 'force update pkg file' ) do
-            options[:force] = true
-        end
-               
+                       options[:force] = true
+               end
+
                opts.on( '--test', 'upload for test' ) do
-            options[:test] = true
-        end
+                       options[:test] = true
+               end
 
                opts.on( '--gen', 'generate snapshot' ) do
-            options[:gensnap] = true
+                       options[:gensnap] = true
                end
-               
+
                opts.on( '-h', '--help', 'display help' ) do
-            puts opts
+                       puts opts
                        exit
-        end
+               end
 
                opts.on( '-v', '--version', 'display version' ) do
-            puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
+                       puts "DIBS(Distributed Intelligent Build System) version " + Utils.get_version()
                        exit
-        end
-    end
-    
+               end
+       end
+
        cmd = ARGV[0] 
 
-    if cmd.eql? "create" or cmd.eql? "sync" \
-                       or cmd.eql? "register" \
-                       or cmd.eql? "gen-snapshot" \
-                       or cmd.eql? "add-dist" or cmd.eql? "add-os" \
-                       or cmd.eql? "remove" or cmd.eql? "remove-dist" \
-                       or cmd.eql? "remove-pkg" or cmd.eql? "remove-snapshot" \
-                       or cmd.eql? "start" or cmd.eql? "stop" or cmd.eql? "clean" \
-                       or cmd.eql? "list" \
-            or cmd =~ /(-v)|(--version)/ \
-            or cmd =~ /(help)|(-h)|(--help)/ then
-        if cmd.eql? "help" then ARGV[0] = "-h" end
-        options[:cmd] = ARGV[0]
-    else
-        raise ArgumentError, "Usage: pkg-svr <SUBCOMMAND> [OPTS] or pkg-svr -h"
-    end
+       if cmd.eql? "create" or cmd.eql? "sync" \
+               or cmd.eql? "register" \
+               or cmd.eql? "gen-snapshot" \
+               or cmd.eql? "add-dist" or cmd.eql? "add-os" \
+               or cmd.eql? "remove" or cmd.eql? "remove-dist" \
+               or cmd.eql? "remove-pkg" or cmd.eql? "remove-snapshot" \
+               or cmd.eql? "start" or cmd.eql? "stop" or cmd.eql? "clean" \
+               or cmd.eql? "list" \
+               or cmd =~ /(-v)|(--version)/ \
+               or cmd =~ /(help)|(-h)|(--help)/ then
+               if cmd.eql? "help" then ARGV[0] = "-h" end
+               options[:cmd] = ARGV[0]
+       else
+               raise ArgumentError, "Usage: pkg-svr <SUBCOMMAND> [OPTS] or pkg-svr -h"
+       end
 
        # default value setting 
        set_default options
-    
+
        optparse.parse!
 
        # option error check 
        option_error_check options
 
-    return options
+       return options
 end