upload tizen1.0 source 23/23/1 1.0_post
authorSungho Park <chywoo.park@samsung.com>
Mon, 30 Apr 2012 09:06:24 +0000 (18:06 +0900)
committerSungho Park <chywoo.park@samsung.com>
Mon, 30 Apr 2012 09:06:24 +0000 (18:06 +0900)
Change-Id: Idf28b98e2a198ba71a6ca50e76cf17eb0812d119

81 files changed:
build-cli
build-svr
package/pkginfo.manifest
pkg-cli
pkg-svr
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/GitBuildJob.rb
src/build_server/JobManager.rb [new file with mode: 0644]
src/build_server/LocalBuildJob.rb
src/build_server/RemoteBuildServer.rb [new file with mode: 0644]
src/build_server/SocketJobRequestListener.rb
src/common/mail.rb
src/pkg_server/client.rb
src/pkg_server/distribution.rb
src/pkg_server/installer.rb
src/pkg_server/packageServer.rb
src/pkg_server/packageServerConfig.rb [moved from src/pkg_server/serverConfig.rb with 81% similarity]
src/pkg_server/packageServerLog.rb
src/pkg_server/serverOptParser.rb
test/build-cli-01.testcase [new file with mode: 0644]
test/build-cli-02.testcase [new file with mode: 0644]
test/build-cli-03.testcase [new file with mode: 0644]
test/buildcli.testsuite [new file with mode: 0644]
test/buildserver.testsuite [new file with mode: 0644]
test/buildserver01.testcase [new file with mode: 0644]
test/buildserver02.testcase [new file with mode: 0644]
test/buildserver03.testcase [new file with mode: 0644]
test/buildserver04.testcase [new file with mode: 0644]
test/buildserver05.testcase [new file with mode: 0644]
test/buildserver06.testcase [new file with mode: 0644]
test/packageserver.testsuite [new file with mode: 0644]
test/packageserver01.testcase [new file with mode: 0644]
test/packageserver02.testcase [new file with mode: 0644]
test/packageserver03.testcase [new file with mode: 0644]
test/packageserver04.testcase [new file with mode: 0644]
test/packageserver05.testcase [new file with mode: 0644]
test/packageserver06.testcase [new file with mode: 0644]
test/packageserver07.testcase [new file with mode: 0644]
test/packageserver08.testcase [new file with mode: 0644]
test/packageserver09.testcase [new file with mode: 0644]
test/packageserver10.testcase [new file with mode: 0644]
test/packageserver11.testcase [new file with mode: 0644]
test/packageserver12.testcase [new file with mode: 0644]
test/packageserver13.testcase [new file with mode: 0644]
test/packageserver14.testcase [new file with mode: 0644]
test/packageserver15.testcase [new file with mode: 0644]
test/packageserver16.testcase [new file with mode: 0644]
test/packageserver17.testcase [new file with mode: 0644]
test/packageserver18.testcase [new file with mode: 0644]
test/packageserver19.testcase [new file with mode: 0644]
test/packageserver20.testcase [new file with mode: 0644]
test/packageserver21.testcase [new file with mode: 0644]
test/packageserver22.testcase [new file with mode: 0644]
test/packageserver23.testcase [new file with mode: 0644]
test/pkg-cli-checkupgrade.testcase [new file with mode: 0644]
test/pkg-cli-clean-f.testcase [new file with mode: 0644]
test/pkg-cli-download-t.testcase [new file with mode: 0644]
test/pkg-cli-download.testcase [new file with mode: 0644]
test/pkg-cli-install-f.testcase [new file with mode: 0644]
test/pkg-cli-install-t.testcase [new file with mode: 0644]
test/pkg-cli-install.testcase [new file with mode: 0644]
test/pkg-cli-installfile-f.testcase [new file with mode: 0644]
test/pkg-cli-installfile.testcase [new file with mode: 0644]
test/pkg-cli-listlpkg.testcase [new file with mode: 0644]
test/pkg-cli-listrpkg.testcase [new file with mode: 0644]
test/pkg-cli-showlpkg.testcase [new file with mode: 0644]
test/pkg-cli-showrpkg.testcase [new file with mode: 0644]
test/pkg-cli-source.testcase [new file with mode: 0644]
test/pkg-cli-uninstall-t.testcase [new file with mode: 0644]
test/pkg-cli-uninstall.testcase [new file with mode: 0644]
test/pkg-cli-update.testcase [new file with mode: 0644]
test/pkg-cli-upgrade.testcase [new file with mode: 0644]
test/pkg-cli.testsuite [new file with mode: 0644]
test/regression.rb [new file with mode: 0755]
test/test.sh [new file with mode: 0755]
test/test_server
tizen-ide/get_ide_sources.sh [new file with mode: 0644]

index 425c32a..4bec172 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -50,7 +50,7 @@ else
 end
 
 if option[:domain].nil? then
-       option[:domain] = "172.21.17.46"
+       option[:domain] = "127.0.0.1"
 end
 
 if option[:port].nil? then
index f1ddaf9..66aed20 100755 (executable)
--- a/build-svr
+++ b/build-svr
@@ -78,22 +78,8 @@ begin
                BuildServerController.remove_server( option[:name] ) 
        when "start"
                BuildServerController.start_server( option[:name], option[:port] ) 
-       when "build"
-               if not option[:git].nil? then
-                       if option[:resolve] then
-                               BuildServerController.resolve_git( option[:name], option[:git], option[:commit], option[:os], nil )
-                       else
-                               BuildServerController.build_git( option[:name], option[:git], option[:commit], option[:os], nil )
-                       end
-               elsif not option[:local].nil? then
-                       if option[:resolve] then
-                               BuildServerController.resolve_local( option[:name], option[:local], option[:os], nil )
-                       else
-                               BuildServerController.build_local( option[:name], option[:local], option[:os], nil )
-                       end
-               else
-                       RuntimeError "Wrong build options are specified!"
-               end
+       when "stop"
+               BuildServerController.stop_server( option[:name] ) 
        when "add"
                BuildServerController.add_friend_server( option[:name], option[:domain], option[:port] ) 
        else
index 3e172a3..8f8eda2 100644 (file)
@@ -1,5 +1,5 @@
 Package : dibs
-Version : 0.20.7
+Version : 0.20.9
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, <donghyouk.yang@samsung.com>, donghee yang< donghee.yang@samsung.com >
 Description : Distribute Inteligent Build System
 OS : linux
@@ -7,7 +7,7 @@ Build-host-os : linux
 Source : dibs
 
 Package : dibs
-Version : 0.20.7
+Version : 0.20.9
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, <donghyouk.yang@samsung.com>, donghee yang< donghee.yang@samsung.com >
 Description : Distribute Inteligent Build System
 OS : windows
diff --git a/pkg-cli b/pkg-cli
index 2e0f21e..3a04581 100755 (executable)
--- a/pkg-cli
+++ b/pkg-cli
@@ -151,6 +151,8 @@ when "list-lpkg" then
             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 )
diff --git a/pkg-svr b/pkg-svr
index 3cf4121..7a80d61 100755 (executable)
--- a/pkg-svr
+++ b/pkg-svr
@@ -76,18 +76,20 @@ begin
        when "spkg-path" 
                server.find_source_package_path( option[:dist], option[:spkgs] )
        when "remove"
-               puts  "Do you want to really? then input \"YES\""
-               input = $stdin.gets.strip
-               if input.eql? "YES" then   
-                       puts "Remove server!"
-               else
-                       puts "Remove is canceled by user input"
-                       exit(0)
+               if not option[:force] then
+                       puts  "Do you want to really? then input \"YES\""
+                       input = $stdin.gets.strip
+                       if input.eql? "YES" then   
+                               puts "Remove server!"
+                       else
+                               puts "Remove is canceled by user input"
+                               exit(0)
+                       end
                end
 
                server.remove_server( option[:id] )
        when "remove-pkg"
-               server.remove_pkg( option[:id], option[:dist], option[:bpkgs] )
+               server.remove_pkg( option[:id], option[:dist], option[:bpkgs], option[:os] )
        else
                raise RuntimeError, "input option incorrect : #{option[:cmd]}"
        end
index 79941ca..1adf0b0 100644 (file)
@@ -33,7 +33,7 @@ def option_parse
     banner = "Usage: build-cli {build|resolve|query} ..." + "\n" \
                + "\t" + "build-cli build -g <git-repository> -c <git-commit> [-d <svr domain>] [-p <svr-port>] [-o <os>] [-a <async>] " + "\n" \
                + "\t" + "build-cli resolve -g <git-repository> -c <git-commit> [-d <svr domain>] [-p <svr-port>] [-o <os>] [-a <async>] " + "\n" \
-               + "\t" + "build-cli query [-d <svr domain>] [-p <svr-port>] [-o <os>] " + "\n" 
+               + "\t" + "build-cli query [-d <svr domain>] [-p <svr-port>]" + "\n" 
 
     optparse = OptionParser.new do|opts|
         # Set a banner, displayed at the top
@@ -50,7 +50,7 @@ def option_parse
         end
 
         options[:domain] = nil
-               opts.on( '-d', '--domain <build-svr-domain>', 'remote build server ip address. default 172.21.111.177' ) do|domain|
+               opts.on( '-d', '--domain <build-svr-domain>', 'remote build server ip address. default 127.0.0.1' ) do|domain|
             options[:domain] = domain
         end
                
index 2a7f5c7..f29bdaf 100644 (file)
@@ -88,6 +88,19 @@ class BuildJob
        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
+
+                       return true
+               else
+                       return false
+               end
+       end
+
+
        def has_same_packages?( wjob )
                for pkg in @pkginfo.packages
                        for wpkg in wjob.pkginfo.packages
@@ -163,8 +176,6 @@ class BuildJob
        def thread_main
                @log.info( "New Job #{@id} is started", Log::LV_USER)
                
-               @status = "BUILDING"
-
                # update local package server
                @server.local_pkgsvr.sync( @server.local_pkgsvr.get_default_dist_name(), false )
 
@@ -272,7 +283,7 @@ class BuildJob
         pending_pkg_dir_list = []
         ignore_rev_dep_build_list = []
         @pkginfo.packages.each do |i|
-            @server.pending_jobs.each do |pj|
+            @server.jobmgr.get_pending_jobs.each do |pj|
                 if pj.rev_fail_list.include? i.package_name then 
                     pending_pkg_dir_list.push pj.source_path
                     pending_pkg_dir_list += pj.rev_success_list.map {|pjs| pjs.source_path}
@@ -305,6 +316,7 @@ class BuildJob
                 @status = ""
             end
 
+            @log.info "Enters the PENGING state ..."
             while @status == "PENDING" 
                 sleep 1
             end 
@@ -316,7 +328,7 @@ class BuildJob
             end
 
             if dependency_package_exist then 
-                @server.pending_jobs.each do |j| 
+                @server.jobmgr.get_pending_jobs.each do |j| 
                     if j.source_path == pending_pkg_dir_list[0] then 
                         j.rev_fail_list -= @pkginfo.packages.map{|p| p.package_name}
                         j.rev_success_list.push self
@@ -327,6 +339,7 @@ class BuildJob
                             j.status = ""
                         else
                             @status = "PENDING"
+                            @log.info "Enters the PENGING state ..."
                             while @status == "PENDING" 
                                 sleep 1
                             end 
@@ -377,10 +390,8 @@ class BuildJob
        def remote_thread_main(server)
                @log.info( "Job #{@id} is requested to be built on remote server ", Log::LV_USER)
                
-               @status = "REMOTE_BUILDING"
-
                # open
-               client = BuildCommClient.create( server.remote_ip, server.port )
+               client = BuildCommClient.create( server.ip, server.port )
                if client.nil? then
                        @status = "ERROR"
                        return
index 7862f98..d1d993d 100644 (file)
@@ -33,16 +33,20 @@ require "SocketJobRequestListener.rb"
 require "RemoteBuildJob.rb"
 require "LocalBuildJob.rb"
 require "packageServer.rb"
+require "JobManager.rb"
+require "RemoteBuildServer.rb"
 
 class BuildServer
-       attr_accessor :id, :path, :pkgserver_url, :pkgserver_addr, :pkgserver_id, :remote_ip, :port, :status, :friend_servers, :host_os, :log
-       attr_accessor :max_working_jobs, :working_jobs, :waiting_jobs, :remote_jobs, :pending_jobs
+       attr_accessor :id, :path, :pkgserver_url, :pkgserver_addr, :pkgserver_id, :port, :status, :friend_servers, :host_os, :log
        attr_accessor :git_server_url, :git_bin_path
        attr_accessor :job_log_url
-       attr_accessor :job_index
        attr_accessor :allowed_git_branch
        attr_accessor :pkgsvr_cache_path, :local_pkgsvr
-
+       attr_accessor :send_mail
+       attr_accessor :jobmgr
+       attr_accessor :test_time
+       attr_accessor :password
+       attr_accessor :finish
        CONFIG_ROOT = "#{Utils::HOME}/.build_tools/build_server"
        HOST_OS = Utils::HOST_OS
 
@@ -54,15 +58,8 @@ class BuildServer
                @pkgserver_addr = pkgserver_addr
                @pkgserver_id = pkgserver_id
                @friend_servers = []
-               @waiting_jobs = []
-               @working_jobs = []
-               @pending_jobs = []
-               @remote_jobs = []
-               @max_working_jobs=2
                @req_listener = []
                @finish = false
-               # for friend server
-               @remote_ip = nil
                # port number
                @port = 2222
                # status
@@ -70,21 +67,25 @@ class BuildServer
                # host_os
                @host_os = HOST_OS
                # log
-               @log = nil
+               @log =nil
                @git_server_url = "gerrithost"
                @git_bin_path = "/usr/bin/git"
-               @job_index = 0
                @job_log_url = ""
                @allowed_git_branch = ""
+               @send_mail = "NO"
                # local package server
                @pkgsvr_cache_path = nil
                @local_pkgsvr = nil
+               # Job Manager
+               @jobmgr = JobManager.new(self)
+               @test_time=0 #test time in mili-seconds
+               @password="0000"
        end
 
 
        # start server daemon
        def start
-               # start logger
+               # start
                @log = Log.new( "#{BuildServer::CONFIG_ROOT}/#{@id}/log" )
 
                # set local package server for cache
@@ -114,61 +115,38 @@ class BuildServer
        
                # main loop
                @log.info "Entering main loop..."
+               if @test_time > 0 then start_time = Time.now end
                while( not @finish )
-                       # handle jobs
-                       handle()
-                       sleep 1
-               end
-       end
 
-
-       # stop sever daemon
-       def stop
-               @finish = true
-       end
-
-
-       # add a normal job
-       def add_job ( new_job )
-               @log.info "Added new job \"#{new_job.id}\""
-
-               Thread.new {
-                       # pre-verifiy
-                       if not new_job.pre_verify or new_job.status == "ERROR" then
-                               new_job.status = "ERROR"
-                               @log.info "Adding the job \"#{new_job.id}\" is canceled"
-                               new_job.terminate()
-                               Thread.current.exit
+                       # update friend server status
+                       for server in @friend_servers
+                               # update state
+                               server.update_state
                        end
 
-                       # check availabiltiy
-                       if not check_job_availability( new_job ) then
-                               new_job.log.error( "No servers that are able to build your packages.", Log::LV_USER)
-                               new_job.status = "ERROR"
-                               @log.info "Adding the job \"#{new_job.id}\" is canceled"
-                               new_job.terminate()
-                               Thread.current.exit
+                       # handle jobs
+                       @jobmgr.handle()
+
+                       # sleep
+                       if @test_time > 0 then
+                               curr_time = Time.now
+                               if (curr_time - start_time).to_i > @test_time then
+                                       puts "Test time is elapsed!"
+                                       break 
+                               end
+                       else
+                               sleep 1
                        end
+               end
 
-                       @waiting_jobs.push( new_job )
-                       new_job.status = "WAITING"
-                       @log.info "Checking the job \"#{new_job.id}\" was finished!"
-               }
-       end
-
-
-       # get job list
-       def get_job_list()
-               list = []
-               list = list + @working_jobs + @remote_jobs + @waiting_jobs
+               # TODO: something should be done for server down
 
-               return list
        end
 
 
-       # query job status
-       def get_job_status( job )
-               return job.status
+       # stop sever daemon
+       def stop
+               @finish = true
        end
 
 
@@ -184,257 +162,30 @@ class BuildServer
        end
 
 
-       def get_new_job_id
-               # get new id
-               new_id = @job_index
-
-               # save it
-               server_dir = "#{BuildServer::CONFIG_ROOT}/#{@id}"
-               f = File.open( "#{server_dir}/latest_job", "w" )
-               f.puts "#{new_id}"
-               f.close
-
-               # increae job idex
-               @job_index = @job_index + 1
-
-               return new_id
-       end
-
-
        # add new remote friend server
-       def add_friend_server( ip, port )
+       def add_remote_server( ip, port )
        
                # if already exit, return false
                for svr in @friend_servers
-                       if svr.remote_ip.eql? ip and svr.port == port then
+                       if svr.ip.eql? ip and svr.port == port then
                                return false
                        end     
                end
 
                # create new one, and add it into list
-               new_server = BuildServer.new( "#{ip}_#{port}", nil, nil, nil, nil )
-               new_server.remote_ip = ip
-               new_server.port = port
-               new_server.status = "UNDEFINED"
+               new_server = RemoteBuildServer.new( ip, port )
                @friend_servers.push new_server
 
                return true
        end
 
 
-       # query remote server info & update server state
-       def update_state
-
-               # only friend server
-               if not @path.nil? then return end
-
-               # send 
-               @status = "DISCONNECTED"
-               client = BuildCommClient.create( @remote_ip, @port )
-               if client.nil? then return end
-               if client.send("QUERY,SYSTEM") then
-                       result = client.read_lines do |l|
-                               tok = l.split(",").map { |x| x.strip }
-                               @host_os = tok[0]
-                               @max_working_jobs = tok[1].to_i
-                               @status = "RUNNING"
-                       end
-                       if not result then @status = "DISCONNECTED" end
-               end
-               client.terminate
-               if @status == "DISCONNECTED" then return end
-
-               # send  
-               @working_jobs = []
-               @waiting_jobs = []
-               client = BuildCommClient.create( @remote_ip, @port )
-               if client.nil? then return end
-               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)
-                               case job_status
-                               when "WAITING" 
-                                       @waiting_jobs.push new_job
-                               when "WORKING" 
-                                       @working_jobs.push new_job
-                               else
-                                       #puts "Uncontrolled status"
-                               end     
-                       end
-                       if not result then @status = "DISCONNECTED" end
-               else
-                       @status = "DISCONNECTED"
-               end
-               client.terminate
-       end
-
-
-       private
-
-       def handle()
-               # update friend server status
-               for server in @friend_servers
-                       # update state
-                       server.update_state
-               end
-
-               # Move working -> finished
-               #) Move working -> pending
-               for job in @working_jobs
-                       if job.status == "ERROR"
-                               @log.info "Job \"#{job.id}\" is stopped by ERROR" 
-                               @working_jobs.delete job        
-                       elsif job.status == "FINISHED" 
-                               @working_jobs.delete job
-                       elsif job.status == "PENDING" 
-                               @working_jobs.delete job
-                               @pending_jobs.push job
-                       end
-               end
-
-               # Move pending -> finished 
-               for job in @pending_jobs
-                       if job.status == "ERROR"
-                               @log.info "Job \"#{job.id}\" is stopped by ERROR" 
-                               @pending_jobs.delete job        
-                       elsif job.status == "FINISHED" 
-                               @pending_jobs.delete job
-                       end
-               end
-
-               # Move remote -> finished 
-               for job in @remote_jobs
-                       if job.status == "ERROR"
-                               @log.info "Job \"#{job.id}\" is stopped by ERROR" 
-                               @remote_jobs.delete job 
-                       elsif job.status == "FINISHED" 
-                               @remote_jobs.delete job
-                       end
-               end
-
-               # MOVE waiting -> finished
-               for job in @waiting_jobs
-                       if job.status == "ERROR"  then
-                               @waiting_jobs.delete( job )
-                               @log.info "Job \"#{job.id}\" is removed by internal error"
-                       end
-               end
-
-               # MOVE waiting -> working
-               if @waiting_jobs.count > 0 then
-                       
-                       # get available job
-                       job = get_available_job
-
-                       # available job not exist?, continue
-                       if ( job.nil? ) then return end
-
-                       # oherwise, check remote server
-                       rserver = get_available_server( job )
-
-                       # request for build
-                       if rserver != nil and rserver == self then
-
-                               # change 
-                               @waiting_jobs.delete job
-                               @working_jobs.push job
-
-                               # start build
-                               job.execute
-                               @log.info "Moved the job \"#{job.id}\" to working job list" 
-
-                       elsif rserver != nil  then
-                               if job.execute_remote( rserver ) then
-
-                                       # status change & job control
-                                       job.status = "REMOTE_WAITING"
-                                       @waiting_jobs.delete( job )
-                                       @remote_jobs.push( job )
-                                       @log.info "Moved the job \"#{job.id}\" to remote job list" 
-                               else
-                                       @log.info "Moving the job \"#{job.id}\" to remote failed" 
-                               end
-                       else
-                               #puts "No available server"
-                       end
-               end
-
-               #check the connection if the waiting job is not asynchronous job
-               for job in @waiting_jobs
-                       if not job.is_asynchronous_job? and not job.is_connected? then
-                               @waiting_jobs.delete( job )
-                               @log.info "Job \"#{job.id}\" is disconneted by user. Removed!"
-                       end
-               end
-               for job in @remote_jobs
-                       if not job.is_asynchronous_job? and not job.is_connected? then
-                               @remote_jobs.delete( job )
-                               @log.info "Job \"#{job.id}\" is disconneted by user. Removed!"
-                       end
-               end
-               
-       end
-
-
-       # select the job whith no build-dependency problem 
-       def get_available_job
-       
-               # gather all working jobs
-               all_working_jobs = [] + @working_jobs
-               all_working_jobs = all_working_jobs + @remote_jobs
-       
-               # for waiting jobs      
-               for job in @waiting_jobs
-                       blocked_by = []
-                       is_changed = false
-               
-                       # should not have same packages with workings
-                       # should not depend on workings
-                       # should not be depended by workings
-                       for wjob in all_working_jobs
-                               if job.has_same_packages?( wjob ) or
-                                       job.does_depend_on?( wjob ) or
-                                       job.does_depended_by?( wjob ) then
-       
-                                       blocked_by.push wjob
-                                       # if there are some changes, check it
-                                       if not job.blocked_by.include? wjob then is_changed = true end
-                               end
-                       end
-                               
-                       # if available , then FIFO      
-                       if blocked_by.empty? then
-                               job.blocked_by = []
-                               return job
-                       else
-                               # check count
-                               if blocked_by.count != job.blocked_by.count then is_changed = true end
-
-                               # if somthing changed, print it and save it
-                               if is_changed then
-                                       job.log.info( "Waiting for finishing following jobs:", Log::LV_USER)
-                                       for bjob in blocked_by  
-                                               job.log.info( " * #{wjob.id} #{wjob.pkginfo.packages[0].source}", Log::LV_USER)
-                                       end
-                                       job.blocked_by = blocked_by
-                               end
-                       end
-               end
-               
-               return nil      
-       end
-
-
        # get remote server     
        def get_available_server ( job )
                candidates = []
                
                # check local
-               if @working_jobs.count < @max_working_jobs and can_build?(job) then
+               if @jobmgr.get_number_of_empty_room > 0 and can_build?(job) then
                        candidates.push self
                end
 
@@ -445,8 +196,8 @@ class BuildServer
                for server in @friend_servers
                        # select only "RUNNING" & possible one
                        if ( server.status == "RUNNING" and server.can_build?( job ) and
-                               server.waiting_jobs.count == 0 and 
-                               server.working_jobs.count < server.max_working_jobs )
+                               not server.has_waiting_jobs and 
+                               server.get_number_of_empty_room > 0 )
                                candidates.push server
                        end
                end
@@ -456,16 +207,16 @@ class BuildServer
 
                # get best 
                # it is better if working jobs count is less
-               max_empty_room = best_server.max_working_jobs - best_server.working_jobs.count
+               max_empty_room = best_server.get_number_of_empty_room
                for server in candidates
                        # check whether idle, use it 
-                       if server.working_jobs.count == 0 then return server end
+                       if not server.has_working_jobs then return server end
 
                        # skip
                        if server == best_server then next end
                
                        # compare remain rooms
-                       empty_room = server.max_working_jobs - server.working_jobs.count
+                       empty_room = server.get_number_of_empty_room
                        if empty_room > max_empty_room then
                                max_empty_room = empty_root
                                best_server = server
@@ -492,5 +243,23 @@ class BuildServer
 
                return false
        end
+
+       
+       # return available working slot
+       def get_number_of_empty_room
+               return @jobmgr.get_number_of_empty_room
+       end
+
+
+       # check there are working jobs
+       def has_working_jobs
+               return @jobmgr.has_working_jobs
+       end
+
+
+       # check there are waiting jobs
+       def has_waiting_jobs
+               return @jobmgr.has_waiting_jobs
+       end
 end
 
index b0b237b..a58734d 100644 (file)
@@ -55,8 +55,9 @@ class BuildServerController
                        @@instance_map[id].git_bin_path="/usr/bin/git"
                end
                @@instance_map[id].allowed_git_branch=nil
-               @@instance_map[id].max_working_jobs= 2
+               @@instance_map[id].jobmgr.max_working_jobs= 2
                @@instance_map[id].job_log_url=""
+               @@instance_map[id].send_mail="NO"
                @@instance_map[id].pkgsvr_cache_path="#{path}/pkgsvr_cache"
        
 
@@ -117,18 +118,6 @@ class BuildServerController
                f.puts port
                f.close 
 
-               # write run job 
-               if File.exist? "#{server_dir}/latest_job" then
-                       f = File.open( "#{server_dir}/latest_job", "r" )
-                       server.job_index = f.gets.strip.to_i + 1
-                       f.close 
-               else
-                       f = File.open( "#{server_dir}/latest_job", "w" )
-                       f.puts "0"
-                       server.job_index = 0
-                       f.close
-               end     
-
                # start
                server.port = port
                server.start
@@ -137,11 +126,39 @@ class BuildServerController
 
        # stop server
        def self.stop_server( id )
+
+               # server
                server = get_server(id)
+               client = BuildCommClient.create( "127.0.0.1", server.port )
+               if client.nil? then
+                       puts "Server is not running!"
+                       return false
+               end
+
+               # send request
+               stop_ok = false
+               if client.send "STOP,#{server.password}" then
+                       # recevie & print
+                       mismatched = false
+                       result = client.read_lines do |l|
+                               puts l
+                               if l.include? "Password mismatched!" then
+                                       mismatched = true
+                               end
+                       end
+                       if result and not mismatched then
+                               stop_ok = true
+                       end
+               end
 
-               # if the server is not running => error
+               # terminate     
+               client.terminate
+       
+               if not stop_ok then     
+                       puts "Server stop failed!"
+               end
 
-               # request stop
+               return true
        end
 
 
@@ -150,7 +167,7 @@ class BuildServerController
                server = get_server(id)
                
                # add
-               if server.add_friend_server( ip, port ) then
+               if server.add_remote_server( ip, port ) then
 
                        # write config  
                        server_dir = "#{BuildServer::CONFIG_ROOT}/#{server.id}"
@@ -277,8 +294,11 @@ class BuildServerController
                        f.puts "GIT_SERVER_URL=#{server.git_server_url}"
                        f.puts "GIT_BIN_PATH=#{server.git_bin_path}"
                        f.puts "ALLOWED_GIT_BRANCH=#{server.allowed_git_branch}"
-                       f.puts "MAX_WORKING_JOBS=#{server.max_working_jobs}"
+                       f.puts "MAX_WORKING_JOBS=#{server.jobmgr.max_working_jobs}"
                        f.puts "JOB_LOG_URL=#{server.job_log_url}"
+                       f.puts "SEND_MAIL=#{server.send_mail}"
+                       f.puts "TEST_TIME=#{server.test_time}" if server.test_time > 0
+                       f.puts "PASSWORD=#{server.test_time}" if server.password != "0000"
                end
        end
 
@@ -295,31 +315,43 @@ class BuildServerController
                allowed_git_branch=""
                max_working_jobs= 2
                job_log_url=""
+               send_mail="NO"
+               test_time=0
+               password="0000"
 
                # read configuration
                server_dir = "#{BuildServer::CONFIG_ROOT}/#{id}"
                File.open( "#{server_dir}/server.cfg", "r" ) do |f|
-                       f.each_line do |l|
+                       f.each_line do |l| 
+                               idx = l.index("=") + 1
+                               length = l.length - idx 
+
                                if l.start_with?("PATH=")
-                                       path = l.split("=")[1].strip
+                                       path = l[idx,length].strip
                                elsif l.start_with?("PSERVER_URL=")
-                                       pkgsvr_url = l.split("=")[1].strip
+                                       pkgsvr_url = l[idx,length].strip
                                elsif l.start_with?("PSERVER_ADDR=")
-                                       pkgsvr_addr = l.split("=")[1].strip
+                                       pkgsvr_addr = l[idx,length].strip
                                elsif l.start_with?("PSERVER_ID=")
-                                       pkgsvr_id = l.split("=")[1].strip
+                                       pkgsvr_id = l[idx,length].strip
                                elsif l.start_with?("PSERVER_CACHE_PATH=")
-                                       pkgsvr_cache_path = l.split("=")[1].strip
+                                       pkgsvr_cache_path = l[idx,length].strip
                                elsif l.start_with?("GIT_SERVER_URL=")
-                                       git_server_url = l.split("=")[1].strip
+                                       git_server_url = l[idx,length].strip
                                elsif l.start_with?("GIT_BIN_PATH=")
-                                       git_bin_path = l.split("=")[1].strip
+                                       git_bin_path = l[idx,length].strip
                                elsif l.start_with?("ALLOWED_GIT_BRANCH=")
-                                       allowed_git_branch = l.split("=")[1].strip
+                                       allowed_git_branch = l[idx,length].strip
                                elsif l.start_with?("MAX_WORKING_JOBS=")
-                                       max_working_jobs = l.split("=")[1].strip.to_i
+                                       max_working_jobs = l[idx,length].strip.to_i
                                elsif l.start_with?("JOB_LOG_URL=")
-                                       job_log_url = l.split("=")[1].strip
+                                       job_log_url = l[idx,length].strip
+                               elsif l.start_with?("SEND_MAIL=")
+                                       send_mail = l[idx,length].strip
+                               elsif l.start_with?("TEST_TIME=")
+                                       test_time = l[idx,length].strip.to_i
+                               elsif l.start_with?("PASSWORD=")
+                                       password = l[idx,length].strip.to_i
                                else
                                        next    
                                end 
@@ -344,7 +376,7 @@ class BuildServerController
                                        if l.split(",").count < 2 then next end
                                        ip = l.split(",")[0].strip
                                        port = l.split(",")[1].strip
-                                       obj.add_friend_server( ip, port.to_i )
+                                       obj.add_remote_server( ip, port.to_i )
                                end
                        end
                end             
@@ -356,11 +388,14 @@ class BuildServerController
                obj.git_bin_path = git_bin_path
        
                # set git binary path
-               obj.max_working_jobs = max_working_jobs
+               obj.jobmgr.max_working_jobs = max_working_jobs
 
                # set job log url
                obj.job_log_url = job_log_url
 
+               # set send mail
+               obj.send_mail = send_mail
+
                # set allowed git branch name
                obj.allowed_git_branch = allowed_git_branch
 
@@ -368,6 +403,12 @@ class BuildServerController
                pkgsvr_cache_path = (pkgsvr_cache_path.empty? ? "#{path}/pkgsvr_cache":pkgsvr_cache_path)
                obj.pkgsvr_cache_path= pkgsvr_cache_path
 
+               # set test time 
+               obj.test_time = test_time
+
+               # set password
+               obj.password = password
+
                # save config
                write_server_config( obj )
                
index 55fc370..f14f69c 100644 (file)
@@ -34,7 +34,7 @@ def option_parse
         + "\t" + "build-svr create -n <name> -u <pkg-server-url> -d <pkg-server-domain> -i <pkg-server-id>" + "\n" \
         + "\t" + "build-svr remove -n <name>" + "\n" \
         + "\t" + "build-svr start -n <name> [-p <port]" + "\n" \
-        + "\t" + "build-svr build -n <name> [-l <local-path>] [-g <git-repository> -c <git-commit>] [-o <os>] [-r]" + "\n"  \
+        + "\t" + "build-svr stop -n <name> " + "\n" \
         + "\t" + "build-svr add -n <name> [-d <frined-svr-domain> -p <friend-svr port>]" + "\n" 
 
     optparse = OptionParser.new do|opts|
@@ -64,30 +64,6 @@ def option_parse
             options[:port] = port.strip.to_i
         end
                
-               opts.on( '-l', '--local <local-path>', 'local source path' ) do|path|
-            options[:local] = path
-        end
-               
-               opts.on( '-g', '--git <git-repository>', 'git repository gerrithost:/xxx/yyy/zzz' ) do|git|
-            options[:git] = git
-        end
-
-               opts.on( '-c', '--commit <git-commit>', 'git commit id/tag' ) do|git|
-               if git.start_with? "/" then
-                       git = git[1..-1]
-               end
-            options[:commit] = git
-        end
-
-               opts.on( '-o', '--os <operating system>', 'target operating system linux/windows/darwin' ) do|os|
-            options[:os] = os
-        end
-               
-        options[:resolve] = false
-               opts.on( '-r', '--resolve', 'reverse build dependency fail resolve' ) do
-            options[:resolve] = true
-        end
-
                opts.on( '-h', '--help', 'display this information' ) do
             puts opts
                        exit
@@ -98,7 +74,7 @@ def option_parse
        cmd = ARGV[0] 
 
     if cmd.eql? "create" or cmd.eql? "remove" or cmd.eql? "start" or 
-               cmd.eql? "build" or cmd.eql? "add" or
+               cmd.eql? "stop" or cmd.eql? "add" or
                 cmd =~ /(help)|(-h)|(--help)/ then
 
         if cmd.eql? "help" then 
index d328925..75fc502 100644 (file)
@@ -40,7 +40,7 @@ class GitBuildJob < BuildJob
                super()
         @rev_fail_list = []
         @rev_success_list = []
-               @id = server.get_new_job_id()
+               @id = server.jobmgr.get_new_job_id()
                @server = server
                @parent = parent
                @git_repos = repos
@@ -87,7 +87,7 @@ class GitBuildJob < BuildJob
                end
 
                # send mail 
-               if ( not @pkginfo.nil? ) and not ( @pkginfo.packages.nil? ) then 
+               if ( @server.send_mail.eql? "YES" ) and ( not @pkginfo.nil? ) and ( not @pkginfo.packages.nil? ) then 
                        mail_list = []
                        contents = []
                        done_pkg_list = []
@@ -110,7 +110,7 @@ class GitBuildJob < BuildJob
                        else
                                subject = "[DIBS] Build success" 
                        end
-                       #Mail.send_mail(mail_list, subject, contents.join("\n"))
+                       Mail.send_mail(mail_list, subject, contents.join("\n"))
                end 
 
                # close logger
diff --git a/src/build_server/JobManager.rb b/src/build_server/JobManager.rb
new file mode 100644 (file)
index 0000000..853c74c
--- /dev/null
@@ -0,0 +1,314 @@
+=begin
+ JobManager.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 'fileutils'
+$LOAD_PATH.unshift File.dirname(__FILE__)
+$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/pkg_server"
+require "SocketJobRequestListener.rb"
+require "RemoteBuildJob.rb"
+require "LocalBuildJob.rb"
+require "packageServer.rb"
+
+class JobManager
+       attr_accessor :max_working_jobs, :jobs
+
+       # initialize
+       def initialize( parent )
+               @parent = parent
+               @jobs = []
+               @max_working_jobs=2
+               @new_job_index = 0
+       end
+
+
+       # get new id
+       def get_new_job_id
+               # check file
+               server_dir = "#{BuildServer::CONFIG_ROOT}/#{@parent.id}"
+               if File.exist? "#{server_dir}/latest_job" then
+                       f = File.open( "#{server_dir}/latest_job", "r" )
+                       @new_job_index = f.gets.strip.to_i + 1
+                       f.close 
+               end     
+
+               # get new id
+               new_id = @new_job_index
+
+               # save it
+               f = File.open( "#{server_dir}/latest_job", "w" )
+               f.puts "#{new_id}"
+               f.close
+
+               return new_id
+       end
+
+
+       # add a normal job
+       def add_job ( new_job )
+               @parent.log.info "Added new job \"#{new_job.id}\""
+               new_job.status = "JUST_CREATED"
+               @jobs.push( new_job )
+       end
+
+
+       # intialize normal job
+       def initialize_job ( job )
+               job.status = "INITIALIZING"
+               Thread.new {
+                       # pre-verifiy
+                       if not job.pre_verify or job.status == "ERROR" then
+                               job.status = "ERROR"
+                               @parent.log.info "Adding the job \"#{job.id}\" is canceled"
+                               job.terminate()
+                               Thread.current.exit
+                       end
+
+                       # check availabiltiy
+                       if not @parent.check_job_availability( job ) then
+                               job.log.error( "No servers that are able to build your packages.", Log::LV_USER)
+                               job.status = "ERROR"
+                               @parent.log.info "Adding the job \"#{job.id}\" is canceled"
+                               job.terminate()
+                               Thread.current.exit
+                       end
+
+                       job.status = "WAITING"
+                       @parent.log.info "Checking the job \"#{job.id}\" was finished!"
+               }
+       end
+
+
+       #execute
+       def execute(job)
+               job.status = "WORKING"
+
+               # start build
+               job.execute
+               @parent.log.info "Moved the job \"#{job.id}\" to working job list" 
+       end
+
+
+       # execute remote
+       def execute_remote(job, rserver)
+
+               # start build
+               if job.execute_remote( rserver) then
+                       # status change & job control
+                       job.status = "REMOTE_WORKING"
+                       @parent.log.info "Moved the job \"#{job.id}\" to remote job list" 
+               else
+                       @parent.log.info "Moving the job \"#{job.id}\" to remote failed" 
+               end
+       end
+
+
+       # handle
+       def handle()
+
+               # if "ERROR", "FINISHED", remove it from list
+               for job in @jobs
+                       if job.status == "ERROR"
+                               @parent.log.info "Job \"#{job.id}\" is stopped by ERROR" 
+                               @jobs.delete job        
+                       elsif job.status == "FINISHED" 
+                               @jobs.delete job
+                       end
+               end
+
+               # if "JUST_CREATED", initialize it
+               for job in @jobs
+                       if job.status != "JUST_CREATED" then next end
+                       initialize_job( job )
+               end
+
+               # get available job
+               job = get_available_job
+
+               # available job not exist?, continue
+               if not job.nil? then
+                       # oherwise, check remote server
+                       rserver = @parent.get_available_server( job )
+
+                       # request for build
+                       if rserver != nil and rserver == @parent then
+                               execute(job)    
+                       elsif rserver != nil  then
+                               execute_remote(job, rserver)
+                       else
+                               #puts "No available server"
+                       end
+               end
+
+               # check the connection if job is not asynchronous job
+               for job in @jobs
+                       if ( job.status == "WAITING" or job.status == "REMOTE_WORKING") and 
+                               not job.is_asynchronous_job? and 
+                               not job.is_connected? then
+
+                               @jobs.delete( job )
+                               @parent.log.info "Job \"#{job.id}\" is disconnected by user. Removed!"
+                       end
+               end
+       end
+
+
+       # select the job whith no build-dependency problem 
+       def get_available_job
+       
+               # gather all working jobs
+               all_working_jobs = []
+               for job in @jobs
+                       if job.status == "WORKING" or job.status == "REMOTE_WORKING" then
+                               all_working_jobs.push job
+                       end
+               end
+       
+               # for waiting jobs      
+               for job in @jobs
+                       if job.status != "WAITING" then next end
+
+                       blocked_by = []
+                       is_changed = false
+               
+                       # should not have same packages with workings
+                       # should not depend on workings
+                       # should not be depended by workings
+                       for wjob in all_working_jobs
+                               if job.has_build_dependency?( wjob ) then
+
+                                       # if there are some changes, check it
+                                       blocked_by.push wjob
+                                       if not job.blocked_by.include? wjob then is_changed = true end
+                               end
+                       end
+                               
+                       # if available , then FIFO      
+                       if blocked_by.empty? then
+                               job.blocked_by = []
+                               return job
+                       else
+                               # check count
+                               if blocked_by.count != job.blocked_by.count then is_changed = true end
+
+                               # if somthing changed, print it and save it
+                               if is_changed then
+                                       job.log.info( "Waiting for finishing following jobs:", Log::LV_USER)
+                                       for bjob in blocked_by  
+                                               job.log.info( " * #{bjob.id} #{bjob.pkginfo.packages[0].source}", Log::LV_USER)
+                                       end
+                                       job.blocked_by = blocked_by
+                               end
+                       end
+               end
+               
+               return nil      
+       end
+
+
+       # return "max_working_jobs_cnt - current_working_jobs_cnt"
+       def get_number_of_empty_room
+               working_cnt = 0
+               for job in @jobs
+                       if job.status == "WORKING" then
+                               working_cnt = working_cnt + 1
+                       end     
+               end
+
+               return @max_working_jobs - working_cnt
+       end
+
+
+       # check there are working jobs
+       def has_working_jobs
+               working_cnt = 0
+               for job in @jobs
+                       if job.status == "WORKING" then
+                               return true
+                       end     
+               end
+
+               return false
+       end
+
+
+       # check there are waiting jobs
+       def has_waiting_jobs
+               waiting_cnt = 0
+               for job in @jobs
+                       if job.status == "WAITING" then
+                               return true
+                       end     
+               end
+
+               return false
+       end
+
+
+       def get_working_jobs
+               result = []
+               for job in @jobs
+                       if job.status == "WORKING" then
+                               result.push job
+                       end     
+               end
+               return result   
+       end
+
+
+       def get_waiting_jobs
+               result = []
+               for job in @jobs
+                       if job.status == "WAITING" then
+                               result.push job
+                       end     
+               end
+               return result   
+       end
+
+
+       def get_remote_jobs
+               result = []
+               for job in @jobs
+                       if job.status == "REMOTE_WORKING" then
+                               result.push job
+                       end     
+               end
+               return result   
+       end
+
+
+       def get_pending_jobs
+               result = []
+               for job in @jobs
+                       if job.status == "PENDING" then
+                               result.push job
+                       end     
+               end
+               return result   
+       end
+end
index 008ece6..e178616 100644 (file)
@@ -39,7 +39,7 @@ class LocalBuildJob < BuildJob
                super()
         @rev_fail_list = []
         @rev_success_list = []
-               @id = server.get_new_job_id()
+               @id = server.jobmgr.get_new_job_id()
                @server = server
                @parent = parent
                @local_path = local_path
@@ -85,7 +85,7 @@ class LocalBuildJob < BuildJob
                end
 
                # send mail 
-               if ( not @pkginfo.nil? ) and not ( @pkginfo.packages.nil? ) then 
+               if ( @server.send_mail.eql? "YES" ) and ( not @pkginfo.nil? ) and ( not @pkginfo.packages.nil? ) then 
                        mail_list = []
                        contents = []
                        done_pkg_list = []
@@ -106,7 +106,7 @@ class LocalBuildJob < BuildJob
                        else
                                subject = "[DIBS] Build success" 
                        end
-                       #Mail.send_mail(mail_list, subject, contents.join("\n")) 
+                       Mail.send_mail(mail_list, subject, contents.join("\n")) 
                end
                        
                # close logger
diff --git a/src/build_server/RemoteBuildServer.rb b/src/build_server/RemoteBuildServer.rb
new file mode 100644 (file)
index 0000000..07f4fa5
--- /dev/null
@@ -0,0 +1,127 @@
+=begin
+ RemoteBuildServer.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 'fileutils'
+$LOAD_PATH.unshift File.dirname(__FILE__)
+require "RemoteBuildJob.rb"
+require "BuildComm.rb"
+
+class RemoteBuildServer
+       attr_accessor :ip, :port, :status, :host_os
+       attr_accessor :max_working_jobs, :working_jobs, :waiting_jobs
+
+       # initialize
+       def initialize(ip, port)
+               @ip = ip
+               @port = port
+               @status = "DISCONNECTED"
+               @host_os = Utils::HOST_OS
+               @max_working_jobs = 2
+               @working_jobs = []
+               @waiting_jobs = []
+       end
+
+
+       # check the job can be built on this server
+       def can_build?(job)
+
+               # check me
+               if job.can_be_built_on? @host_os then
+                       return true
+               end
+
+               return false
+       end
+
+
+       # query remote server info & update server state
+       def update_state
+
+               # send 
+               @status = "DISCONNECTED"
+               client = BuildCommClient.create( @ip, @port )
+               if client.nil? then return end
+               if client.send("QUERY,SYSTEM") then
+                       result = client.read_lines do |l|
+                               tok = l.split(",").map { |x| x.strip }
+                               @host_os = tok[0]
+                               @max_working_jobs = tok[1].to_i
+                               @status = "RUNNING"
+                       end
+                       if not result then @status = "DISCONNECTED" end
+               end
+               client.terminate
+               if @status == "DISCONNECTED" then return end
+
+               # send  
+               @working_jobs = []
+               @waiting_jobs = []
+               client = BuildCommClient.create( @ip, @port )
+               if client.nil? then return end
+               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)
+                               case job_status
+                               when "WAITING" 
+                                       @waiting_jobs.push new_job
+                               when "WORKING" 
+                                       @working_jobs.push new_job
+                               else
+                                       #puts "Uncontrolled status"
+                               end     
+                       end
+                       if not result then @status = "DISCONNECTED" end
+               else
+                       @status = "DISCONNECTED"
+               end
+               client.terminate
+       end
+
+
+       # return available working slot
+       def get_number_of_empty_room
+               return @max_working_jobs - @working_jobs.count
+       end
+
+
+       # check there are working jobs
+       def has_working_jobs
+               return (@working_jobs.count > 0)
+       end
+
+
+       # check there are waiting jobs
+       def has_waiting_jobs
+               return (@waiting_jobs.count > 0)
+       end
+end
+
index 4cfa794..f7656a5 100644 (file)
@@ -110,6 +110,8 @@ class SocketJobRequestListener
                        handle_cmd_resolve( req_line, req )
                when "QUERY"
                        handle_cmd_query( req_line, req )
+               when "STOP"
+                       handle_cmd_stop( req_line, req )
                else
                        @log.info "Received Unknown REQ: #{req_line}" 
                        raise "Unknown request: #{req_line}"
@@ -151,8 +153,8 @@ class SocketJobRequestListener
                        # if asynchronouse, quit connection
                        if async then
                                if not @parent_server.job_log_url.empty? then
-                                       req.puts ( "Info: Added new job \"#{new_job.id}\"! Check following URL")
-                                       req.puts ( "Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
+                                       req.puts( "Info: Added new job \"#{new_job.id}\"! Check following URL")
+                                       req.puts( "Info: * Log URL : #{@parent_server.job_log_url}/#{new_job.id}/log")
                                else
                                        req.puts( "Info: Added new job \"#{new_job.id}\"!")
                                end
@@ -162,14 +164,14 @@ class SocketJobRequestListener
                        end     
 
                        # add
-                       @parent_server.add_job( new_job )
+                       @parent_server.jobmgr.add_job( new_job )
 
                # BUILD,LOCAL,path,os,url
                when "LOCAL"
                        @log.info "Received BUILD LOCAL => #{tok[2]}" 
                        
                        BuildCommServer.send_begin(req)
-                       @parent_server.add_job( 
+                       @parent_server.jobmgr.add_job( 
                                LocalBuildJob.new( tok[2], tok[3], tok[4], [], @parent_server, nil, req, false))
                else
                        @log.info "Received Wrong REQ: #{line}"
@@ -192,14 +194,14 @@ class SocketJobRequestListener
                        @log.info "Received RESOLVE GIT => #{tok[2]}"
 
                        BuildCommServer.send_begin(req)
-                       @parent_server.add_job( 
+                       @parent_server.jobmgr.add_job( 
                                GitBuildJob.new( tok[2], tok[3], tok[4], tok[5], [], @parent_server, nil, req, true))
                # RESOLVE,LOCAL,path,os,url
                when "LOCAL"
                        @log.info "Received RESOLVE LOCAL => #{tok[2]}" 
 
                        BuildCommServer.send_begin(req)
-                       @parent_server.add_job( 
+                       @parent_server.jobmgr.add_job( 
                                LocalBuildJob.new( tok[2], tok[3], tok[4], [], @parent_server, nil, req, true))
                else
                        @log.info "Received Wrong REQ: #{line}" 
@@ -222,13 +224,13 @@ class SocketJobRequestListener
                        #puts "Received QUERY JOB"
 
                        BuildCommServer.send_begin(req)
-                       for job in @parent_server.working_jobs
+                       for job in @parent_server.jobmgr.get_working_jobs
                                BuildCommServer.send(req,"WORKING,#{job.id},#{job.pkginfo.packages[0].source}")
                        end
-                       for job in @parent_server.waiting_jobs
+                       for job in @parent_server.jobmgr.get_waiting_jobs
                                BuildCommServer.send(req,"WAITING,#{job.id},#{job.pkginfo.packages[0].source}")
                        end
-                       for job in @parent_server.remote_jobs
+                       for job in @parent_server.jobmgr.get_remote_jobs
                                BuildCommServer.send(req,"REMOTE ,#{job.id},#{job.pkginfo.packages[0].source}")
                        end
                        BuildCommServer.send_end(req)
@@ -239,7 +241,7 @@ class SocketJobRequestListener
                        #puts "Received QUERY SYSTEM" 
 
                        BuildCommServer.send_begin(req)
-                       BuildCommServer.send(req,"#{@parent_server.host_os},#{@parent_server.max_working_jobs}")
+                       BuildCommServer.send(req,"#{@parent_server.host_os},#{@parent_server.jobmgr.max_working_jobs}")
                        BuildCommServer.send_end(req)
                        BuildCommServer.disconnect(req)
                else
@@ -248,4 +250,25 @@ class SocketJobRequestListener
                end
        end
 
+
+       # "STOP"
+       def handle_cmd_stop( line, req )
+               tok = line.split(",").map { |x| x.strip }
+               if tok.count < 2 then 
+                       @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!")
+               else
+                       BuildCommServer.send(req,"Server will be down!")
+               end
+               BuildCommServer.send_end(req)
+               BuildCommServer.disconnect(req)
+               if tok[1] == @parent_server.password then
+                       @parent_server.finish = true
+               end
+       end
 end
index a49c1d2..5005b70 100644 (file)
@@ -69,7 +69,7 @@ MESSAGE_END
 
        def Mail.parse_email( low_email_list )
                mail_list = []
-               low_email_list.each do | low_email |  
+               low_email_list.split(",").each do | low_email |  
                        ms = low_email.index('<')
                        me = low_email.index('>')
                        if ms.nil? or me.nil? then  
index 8bffbd2..5cf8423 100644 (file)
@@ -32,7 +32,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
 $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
 require "downloader"
 require "installer"
-require "serverConfig"
+require "packageServerConfig"
 require "package"
 require "parser"
 require "utils"
@@ -45,7 +45,7 @@ class Client
     SUPPORTED_OS = ["linux", "windows", "darwin"]
     PKG_LIST_FILE_PREFIX = "pkg_list_"
     INSTALLED_PKG_LIST_FILE = "installedpackage.list"
-    CONFIG_PATH = "#{$build_tools}/client"
+    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"
@@ -119,7 +119,7 @@ class Client
             dependent_pkg_list = get_install_dependent_packages(pkg_name, os, true, false)
             if dependent_pkg_list.nil? then
                 @log.error "Failed to get dependency for \"#{pkg_name}\" package"
-                return false
+                return nil
             end
         else dependent_pkg_list = [pkg_name] end
 
@@ -136,6 +136,10 @@ class Client
         dependent_pkg_list.each do |p|
             pkg_path = get_attr_from_pkg(p, os, "path")
             pkg_ver = get_attr_from_pkg(p, os, "version")
+            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, @location) then
@@ -143,10 +147,18 @@ class Client
                 return nil
             end
 
-            file_local_path.push(File.join(@location, filename))
-            @log.info "Downloaded \"#{pkg_name} [#{pkg_ver}]\" package file.. OK"
-            @log.info "  [path : #{file_local_path.join(", ")}]"
+            file_path = File.join(@location, filename)
+            file_local_path.push(file_path)
+            @log.info "Downloaded \"#{p} [#{pkg_ver}]\" package file.. OK"
+            #@log.info "  [path : #{file_path}]"
+        end
+
+        if trace then
+            @log.info "Downloaded \"#{pkg_name}\" package with all dependent packages.. OK"
+        else
+            @log.info "Downloaded only \"#{pkg_name}\" package.. OK"
         end
+        @log.info "  [path : #{file_local_path.join(", ")}]"
 
         return file_local_path
     end
@@ -302,7 +314,7 @@ class Client
             server_src_pkg_list_command = server_src_pkg_list_command + server_src_pkg_path + ","
             # upload source package
             if File.exist? spath then
-                system "scp #{spath} #{ssh_alias}:#{server_src_pkg_path}"
+                               Utils.execute_shell("cd #{File.dirname(spath)};scp #{File.basename(spath)} #{ssh_alias}:#{server_src_pkg_path}")
             else
                 @log.error "#{spath} file does not exist"
                 return nil
@@ -482,7 +494,8 @@ class Client
         # 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"
@@ -502,7 +515,7 @@ class Client
             end
         end
 
-        # if enable trace, crate all dependent package list
+        # 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
@@ -513,11 +526,6 @@ class Client
             dependent_pkg_list = [pkg_name]
         end
 
-        # if meta package, dependent list does not need to include self name
-        #if is_meta_pkg then
-        #    dependent_pkg_list.delete(pkg_name.strip)
-        #end
-
         # TODO: need to compare dependent package version
         # install packages including dependent packages
         dependent_pkg_list.each do |pkg|
@@ -527,6 +535,8 @@ class Client
             end
             add_pkg_info(pkg, os)
         end
+
+        # write installed package information to file
         write_pkg_hash_to_file(nil)
 
         if trace then
@@ -1099,7 +1109,7 @@ class Client
         pkg_hash = @installed_pkg_hash_loc[file_path]
         if pkg_hash.nil? then
             @log.error "Installed package list does not exist"
-            return
+            return nil
         end
         pkg_all_list = [] 
         pkg_list = pkg_hash.values
@@ -1221,6 +1231,7 @@ class Client
     end
     
     private
+    # install a package to @location after uninstalling and downloading
     def install_pkg(pkg_name, os, force)
 
         new_pkg_ver = ""
@@ -1249,11 +1260,15 @@ class Client
             end
         end
         
+        # if package is already installed, then uninstall it
         if check_installed_pkg(pkg_name) then
-            uninstall(pkg_name, false)
+            if not uninstall(pkg_name, false) then
+                @log.error "Failed to uninstall \"#{pkg_name}\""
+                return false
+            end
         end 
 
-        # download file
+        # download package file
         # change download location temporary (back to the origin path after downloading)
         loc_back = @location
         uniq_name = Utils.create_uniq_name
@@ -1262,7 +1277,10 @@ class Client
         @location = tmppath
         file_local_path = download(pkg_name, os, false)[0]
         @location = loc_back        
-        if file_local_path.nil? then return false end
+        if file_local_path.nil? then 
+            FileUtils.remove_dir(tmppath, true)
+            return false 
+        end
     
         # install package
         ret = FileInstaller.install(pkg_name, file_local_path, type, @location)
index 09f8da1..535f99e 100644 (file)
@@ -38,15 +38,17 @@ class Distribution
     PKG_LIST_FILE_PREFIX = "pkg_list_" 
        ARCHIVE_PKG_LIST = "archive_pkg_list"
 
-       def initialize (name, location, server_url, log)
+       def initialize( name, location, server_url, pkg_server )
 
                @name = name
                @location = location
-               @pkg_hash_os = {}
-               @log = log
                @server_url = server_url
+               @log = pkg_server.log
+               @integrity = pkg_server.integrity 
+
                @log.info "Distribution class[#{name}] initialize "
 
+               @pkg_hash_os = {}  
         for os in SUPPORTED_OS 
                        if @location.empty? or ( not File.exist? "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}" ) then
                                @pkg_hash_os[os] = {}
@@ -232,15 +234,12 @@ class Distribution
                        # if server and local has package
                        if ( not server_pkg.nil? ) and ( not local_pkg.nil? ) then
                                # if server version is not updated then skip
-                               if not ( Utils.compare_version( local_pkg.version, server_pkg.version ).eql? 1 ) then 
-                                       @log.info "existing packages version equal or higher then server's version so package[#{pkg_name}] skip"
-                                       @log.info "server package version: [#{server_pkg.version}]"
-                                       @log.info "local package version: [#{local_pkg.version}]" 
+                               if ( Utils.compare_version( local_pkg.version, server_pkg.version ).eql? 0 ) then 
+                                       @log.info "existing packages version equal to server's version. so package[#{pkg_name}] skip"
                                        
                                        next
                                end 
 
-                               # if server version is not updated then skip
                                # if server's pakcage is local package and mode is not force then local package will be upaded 
                                if ( local_pkg.origin.eql? "local" ) and ( not force ) then
                                        @log.info "package [#{pkg_name}] is local package. so skip update"
@@ -399,11 +398,15 @@ class Distribution
                return pkg
        end 
 
-       def remove_pkg( pkg_name_list )  
+       def remove_pkg( pkg_name_list, os )  
                for package_name in pkg_name_list
                        removed_flag = false 
 
-               for os in SUPPORTED_OS 
+                       if os.eql? "all" then os_list = SUPPORTED_OS
+                       else os_list = [ os ]
+                       end
+
+               for os in os_list
                                if @pkg_hash_os[os].key?(package_name) then 
                                        @log.info( "remove package [#{package_name}] in #{os}", Log::LV_USER)
                                        @pkg_hash_os[os].delete(package_name)  
@@ -417,16 +420,21 @@ class Distribution
                end 
 
                # check install dependency integrity
-               check_instll_dependency_integrity 
+               check_integrity 
 
         for os in SUPPORTED_OS 
                        write_pkg_list(os) 
                end
        end 
 
-       def check_instll_dependency_integrity 
+       def check_integrity 
                @log.info "check server pkg's install dependency integrity" 
 
+               if not @integrity.eql? "YES" then
+                       @log.info "skip integrity check"
+                       return 
+               end 
+
                for os in SUPPORTED_OS 
                        for pkg in @pkg_hash_os[os].each_value 
                                error_msg = "[#{pkg.package_name}]'s install dependency not matched in "  
@@ -438,25 +446,13 @@ class Distribution
                                                raise RuntimeError,(error_msg + dep.to_s) 
                                        end
                                
-                                       # TODO: check just install dependency exist
-                                       next 
-                                       
                                        # check package's version 
                                        if not dep.match? target_pkg.version then 
                                                raise RuntimeError,(error_msg + dep.to_s)
                                        end 
 
-                                       # TODO: install dependency's os is always ture
-                                       #if not dep.target_os_list.length == 0 then 
-                                       #       if not dep.target_os_list.include? target_pkg.os then  
-                                       #               raise RuntimeError,(error_msg + dep.to_s)
-                                       #       end 
-                                       #end 
                                end 
 
-                               # TODO: check just install dependency 
-                               next 
-
                                error_msg = "[#{pkg.package_name}]'s build dependency not matched in "  
                                for dep in pkg.build_dep_list 
                                        if dep.target_os_list.length == 0 then
@@ -476,12 +472,6 @@ class Distribution
                                                raise RuntimeError,(error_msg + dep.to_s)
                                        end 
 
-                                       # TODO: check package's target_os   
-                                       #if not dep.target_os_list.length == 0 then 
-                                       #       if not dep.target_os_list.include? target_pkg.os then  
-                                       #               raise RuntimeError,(error_msg + dep.to_s)
-                                       #       end 
-                                       #end 
                                end 
 
                                error_msg = "[#{pkg.package_name}]'s source dependency not matched in "  
index 0006b8d..84ea930 100644 (file)
@@ -28,13 +28,13 @@ Contributors:
 
 $LOAD_PATH.unshift File.dirname(__FILE__)
 $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
-require "serverConfig"
+require "packageServerConfig"
 require "log"
 require "utils"
 
 class FileInstaller
 
-    CONFIG_PATH = "#{$build_tools}/client"
+    CONFIG_PATH = "#{PackageServerConfig::CONFIG_ROOT}/client"
     PACKAGE_INFO_DIR = ".info"
 
     @@log = nil
@@ -116,7 +116,11 @@ class FileInstaller
         
         if not script_file.nil? then
             @@log.info "Execute \"#{script_file}\" file"
-            cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"
+            if Utils::HOST_OS.eql? "windows" then
+                cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"
+            else
+                cmd = "INSTALLED_PATH=\"#{target_path}\" #{script_file}"
+            end
             log = `#{cmd}`
         end
         return log
@@ -134,7 +138,11 @@ class FileInstaller
 
         if not script_file.nil? then
             @@log.info "Execute \"#{script_file}\" file"
-            cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"
+            if Utils::HOST_OS.eql? "windows" then
+                cmd = "set INSTALLED_PATH=\"#{target_path}\"& #{script_file}"
+            else
+                cmd = "INSTALLED_PATH=\"#{target_path}\" #{script_file}"
+            end
             log = `#{cmd}`
         end
     end
@@ -254,7 +262,7 @@ class FileInstaller
 
         File.delete(temp_pkg_file_list_path)
         log = `#{extract_file_list_command}`
-        @@log.info "Extracted \"#{filename}\" file.."
+        @@log.info "Extracted \"#{filename}\" file.. OK"
         if log.nil? then log = "" end
         return log
     end
index dce1b6b..86abc39 100644 (file)
@@ -30,14 +30,14 @@ require 'fileutils'
 $LOAD_PATH.unshift File.dirname(__FILE__)
 $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
 require "packageServerLog"
-require "serverConfig"
+require "packageServerConfig"
 require "distribution"
 require "client"
 require "utils"
 require "mail"
 
 class PackageServer
-       attr_accessor :id, :location
+       attr_accessor :id, :location, :log, :integrity
     
        # constant
     SUPPORTED_OS = ["linux", "windows", "darwin"]
@@ -49,14 +49,14 @@ class PackageServer
                @distribution_list = []
                # distribution name -> server_url hash
                @dist_to_server_url = {}
+               @integrity = "NO"
 
-               if not File.exist? $server_root then
-                       FileUtils.mkdir_p( $server_root )
+               if not File.exist?( PackageServerConfig::SERVER_ROOT )
+                       FileUtils.mkdir_p( PackageServerConfig::SERVER_ROOT )
                end
-               @log = PackageServerLog.new( "#{$server_root}/.#{@id}.log", $stdout
+               @log = PackageServerLog.new( "#{PackageServerConfig::SERVER_ROOT}/.#{@id}.log" 
 
                server_information_initialize()
-               set_distribution_list()
        end
 
        # create
@@ -73,14 +73,14 @@ class PackageServer
                end
 
                # create locking file
-               File.open("#{$server_create_loc_file}", File::RDWR|File::CREAT, 0644) {|f|
+               File.open("#{PackageServerConfig::LOCK_FILE}", File::RDWR|File::CREAT, 0644) {|f|
                        f.flock(File::LOCK_EX)
                        f.rewind
                        f.flush
                        f.truncate(f.pos)
 
                        # error check : check for already exist in server id 
-                       if File.exist? "#{$server_root}/#{id}" 
+                       if File.exist? "#{PackageServerConfig::SERVER_ROOT}/#{id}" 
                                raise RuntimeError, "Server create fail. server id [#{id}] is already exist"
                        end
                        
@@ -90,8 +90,8 @@ class PackageServer
                        end
     
                        # create server config directory
-                       FileUtils.mkdir_p "#{$server_root}/#{id}"
-                       FileUtils.mkdir_p "#{$server_root}/#{id}/incoming"
+                       FileUtils.mkdir_p "#{PackageServerConfig::SERVER_ROOT}/#{id}"
+                       FileUtils.mkdir_p "#{PackageServerConfig::SERVER_ROOT}/#{id}/incoming"
 
                        if (not server_url.empty?) and (not Utils.is_url_remote(server_url))
                                # if server_url is local server address then generate absoulte path 
@@ -105,8 +105,9 @@ class PackageServer
                        end 
 
                        # create server configure file
-                       File.open( "#{$server_root}/#{id}/config", "w" ) do |f|
+                       File.open( "#{PackageServerConfig::SERVER_ROOT}/#{id}/config", "w" ) do |f|
                                f.puts "location : #{@location}"
+                               f.puts "integrity check : NO"
                                f.puts "server_url : #{dist_name} ->  #{server_url}"
                        end
                        
@@ -114,7 +115,9 @@ class PackageServer
                        FileUtils.mkdir_p "#{@location}"
                        
                        create_distribution_struct( dist_name, server_url )
-               }       
+               }
+
+               @log.output( "package server [#{@id}] created successfully", Log::LV_USER )
        end
 
        def register( source_pkg_file_path_list, binary_pkg_file_path_list, dist_name, snapshot, test )
@@ -199,7 +202,7 @@ class PackageServer
                        end 
 
                        # check install dependency integrity
-                       if not test then distribution.check_instll_dependency_integrity end
+                       if not test then distribution.check_integrity end
                
                        source_pkg_file_path_list.each do |source_path|
                                source_name = File.basename(source_path)
@@ -251,6 +254,7 @@ class PackageServer
                                # Mail.send_package_registe_mail( msg_list, @id )  
                        end
         }
+               @log.output( "package registed successfully", Log::LV_USER)
     end
 
        def generate_snapshot( snpashot_name, dist_name, base_snapshot, binary_pkg_file_path_list)
@@ -303,10 +307,12 @@ class PackageServer
                        distribution.sync( mode, "darwin" )
                        distribution.sync_archive_pkg
                }
+               
+               @log.output( "package server [#{@id}]'s distribution [#{dist_name}] has the synchronization.", Log::LV_USER )
        end
 
        def add_distribution( dist_name, server_url, clone )
-               File.open("#{$server_create_loc_file}", File::RDWR|File::CREAT, 0644) {|f|
+               File.open("#{PackageServerConfig::LOCK_FILE}", File::RDWR|File::CREAT, 0644) {|f|
                        f.flock(File::LOCK_EX)
                        f.rewind
                        f.flush
@@ -331,7 +337,7 @@ class PackageServer
                                end
                        end 
 
-                       File.open( "#{$server_root}/#{@id}/config", "a" ) do |f|
+                       File.open( "#{PackageServerConfig::SERVER_ROOT}/#{@id}/config", "a" ) do |f|
                                if clone then 
                                        @log.info "add distribution using [#{server_url}] in clone mode"
                                        f.puts "server_url : #{dist_name} ->  "
@@ -343,13 +349,14 @@ class PackageServer
                        
                        create_distribution_struct( dist_name, server_url )
                }
+               @log.output( "distribution [#{dist_name}] added successfully", Log::LV_USER )
        end
 
        def remove_server( id )
                @log.info( "Package server [#{id}] will be removed and all server information delete", Log::LV_USER)
 
-               if File.exist? "#{$server_root}/#{id}/config" then
-                       File.open "#{$server_root}/#{id}/config" do |f|
+               if File.exist? "#{PackageServerConfig::SERVER_ROOT}/#{id}/config" then
+                       File.open "#{PackageServerConfig::SERVER_ROOT}/#{id}/config" do |f|
                                f.each_line do |l|
                                        if l.start_with?( "location : ") then 
                                                location= l.split(" : ")[1]
@@ -362,11 +369,13 @@ class PackageServer
                        @log.error( "Can't find server information : #{id}", Log::LV_USER)
                end 
                
-               FileUtils.rm_rf "#{$server_root}/.#{id}.log"
-               FileUtils.rm_rf "#{$server_root}/#{id}"
+               FileUtils.rm_rf "#{PackageServerConfig::SERVER_ROOT}/.#{id}.log"
+               FileUtils.rm_rf "#{PackageServerConfig::SERVER_ROOT}/#{id}"
+               
+               @log.output( "package server [#{id}] removed successfully", Log::LV_USER )
        end
 
-       def remove_pkg( id, dist_name, pkg_name_list )
+       def remove_pkg( id, dist_name, pkg_name_list, os )
                @log.info "package remove in server"
                if dist_name.empty? then dist_name = get_default_dist_name() end
                if dist_name.empty? then raise RuntimeError,"Can't find distribution information" end
@@ -379,8 +388,9 @@ class PackageServer
                        f.flush
                        f.truncate(f.pos) 
 
-                       distribution.remove_pkg(pkg_name_list)
+                       distribution.remove_pkg(pkg_name_list, os)
                }
+               @log.output( "package removed successfully", Log::LV_USER )
        end
 
        def find_source_package_path( dist_name, pkg_file_name_list ) 
@@ -391,17 +401,17 @@ class PackageServer
                pkg_file_name_list.each do |pkg|
                        pkg_path = "#{@location}/#{dist_name}/source/#{pkg}"
                        if File.exist? pkg_path then
-                               @log.info( "#{pkg}", Log::LV_USER)
+                               @log.output( "#{pkg}", Log::LV_USER)
                        else
                                @log.error( "Can't find [#{pkg}] in source package", Log::LV_USER)
                        end
                end 
        end
 
-       def PackageServer.list_id  
-               @@log = PackageServerLog.new( "#{$server_root}/.log", $stdout
+       def self.list_id  
+               @@log = PackageServerLog.new( "#{PackageServerConfig::SERVER_ROOT}/.log" 
 
-               d = Dir.new( $server_root )
+               d = Dir.new( PackageServerConfig::SERVER_ROOT )
                s = d.select {|f| not f.start_with?(".") }  
                s.sort!
        
@@ -411,14 +421,14 @@ class PackageServer
                end 
        end
 
-       def PackageServer.list_dist( id )
-               @@log = PackageServerLog.new( "#{$server_root}/.log", $stdout
+       def self.list_dist( id )
+               @@log = PackageServerLog.new( "#{PackageServerConfig::SERVER_ROOT}/.log" 
                
                @@log.output( "=== ID [#{id}]'s distribution list ===", Log::LV_USER)
 
                # read package id information
-               if File.exist? "#{$server_root}/#{id}/config" then
-                       File.open "#{$server_root}/#{id}/config" do |f|
+               if File.exist? "#{PackageServerConfig::SERVER_ROOT}/#{id}/config" then
+                       File.open "#{PackageServerConfig::SERVER_ROOT}/#{id}/config" do |f|
                                f.each_line do |l|
                                        if l.start_with?( "server_url : ") and l.include?( "->" ) then
                                                @@log.output( l.split(" : ")[1].split("->")[0], Log::LV_USER)
@@ -443,7 +453,7 @@ class PackageServer
        def server_information_initialize 
                # if id is nil or empty then find default id
                if @id.nil? or @id.empty? 
-                       d = Dir.new( $server_root )
+                       d = Dir.new( PackageServerConfig::SERVER_ROOT )
                        s = d.select {|f| not f.start_with?(".") }
                        if s.length.eql? 1 then
                                @log.info "using default server ID [#{s[0]}]"
@@ -454,11 +464,13 @@ class PackageServer
                end
 
                # read package id information
-               if File.exist? $server_root and File.exist? "#{$server_root}/#{@id}/config" then
-                       File.open "#{$server_root}/#{@id}/config" do |f|
+               if File.exist? PackageServerConfig::SERVER_ROOT and File.exist? "#{PackageServerConfig::SERVER_ROOT}/#{@id}/config" then
+                       File.open "#{PackageServerConfig::SERVER_ROOT}/#{@id}/config" do |f|
                                f.each_line do |l|
                                        if l.start_with?( "location : ") then 
                                                @location = l.split(" : ")[1].strip
+                                       elsif l.start_with?( "integrity check : ") then 
+                                               @integrity = l.split(" : ")[1].strip
                                        elsif l.start_with?( "server_url : " ) then
                                                info = l.split(" : ")[1].split("->")
                                                @dist_to_server_url[info[0].strip] = info[1].strip 
@@ -468,11 +480,9 @@ class PackageServer
                                end
                        end
                end
-       end
-
-       def set_distribution_list
+               
                @dist_to_server_url.each do |dist_name, server_url|
-                       @distribution_list.push Distribution.new( dist_name, "#{@location}/#{dist_name}", server_url,  @log)
+                       @distribution_list.push Distribution.new( dist_name, "#{@location}/#{dist_name}", server_url, self )
                end
        end
 
@@ -494,7 +504,7 @@ class PackageServer
                FileUtils.mkdir "#{@location}/#{dist_name}/snapshots"
            
                # generate distribution
-               distribution = Distribution.new( dist_name, "#{@location}/#{dist_name}", server_url, @log )
+               distribution = Distribution.new( dist_name, "#{@location}/#{dist_name}", server_url, self )
 
                # add dist
                @distribution_list.push distribution
similarity index 81%
rename from src/pkg_server/serverConfig.rb
rename to src/pkg_server/packageServerConfig.rb
index 9841d2b..7e19000 100644 (file)
@@ -29,7 +29,8 @@ Contributors:
 $LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
 require "utils"
 
-$build_root = Utils::HOME + "/.build_root"
-$build_tools = Utils::HOME + "/.build_tools"
-$server_root = $build_tools + "/pkg_server"
-$server_create_loc_file = "#{$server_root}/.server_create_loc"
+class PackageServerConfig
+       CONFIG_ROOT = "#{Utils::HOME}/.build_tools"
+       SERVER_ROOT = "#{PackageServerConfig::CONFIG_ROOT}/pkg_server"
+       LOCK_FILE = "#{PackageServerConfig::SERVER_ROOT}/.server_loc"
+end
index b20c798..d9c4619 100644 (file)
@@ -32,14 +32,14 @@ require "logger"
 
 class PackageServerLog < Log
 
-       def initialize(path, stream_out)
+       def initialize(path)
                super(path)
-               @extra_out = stream_out
+               @second_out = $stdout
        end
 
        protected
        def output_extra(msg)
-               @extra_out.puts msg
+               @second_out.puts msg
        end     
 
 
index bdacd82..da06a21 100644 (file)
@@ -55,7 +55,7 @@ def option_error_check( options )
                end
        when "remove-pkg"
                if      options[:bpkgs].empty? then
-               raise ArgumentError, "pkg-svr remove-pkg -i <id> -d <distribution> -p <binary_package_name_list> " + "\n" \
+               raise ArgumentError, "pkg-svr remove-pkg -i <id> -d <distribution> -p <binary_package_name_list> [-o <os>]" + "\n" \
                end
        when "spkg-path"
                if      options[:spkgs].empty? then
@@ -89,7 +89,7 @@ def option_parse
         + "\t" + "pkg-svr add-dist -i<id> -d <distribution> [-u <remote_server_url>] [-c] " + "\n" \
         + "\t" + "pkg-svr remove -i <id> " + "\n" \
         + "\t" + "pkg-svr register -i <id> -d <distribution> -p <binary_package_file_path_list> -s <source_package_file_path_list> [-g] [-t] " + "\n" \
-        + "\t" + "pkg-svr remove-pkg -i <id> -d <distribution> -p <binary_package_name_list> " + "\n" \
+        + "\t" + "pkg-svr remove-pkg -i <id> -d <distribution> -p <binary_package_name_list> [-o <os>] " + "\n" \
         + "\t" + "pkg-svr gen-snapshot -i<id> -d <distribution> [-n <snapshot name>] [-b <base_snapshot_name>] [-p <binary_package_file_path_list>] " + "\n"  \
         + "\t" + "pkg-svr sync -i <id> -d <distribution> [-f] " + "\n"  \
         + "\t" + "pkg-svr spkg-path -i <id> -d <distribution> -s <source_package_name> " + "\n" \
diff --git a/test/build-cli-01.testcase b/test/build-cli-01.testcase
new file mode 100644 (file)
index 0000000..6e47b8c
--- /dev/null
@@ -0,0 +1,16 @@
+#PRE-EXEC
+#EXEC
+../build-cli -h
+#POST-EXEC
+#EXPECT
+Usage: build-cli {build|resolve|query} ...
+       build-cli build -g <git-repository> -c <git-commit> [-d <svr domain>] [-p <svr-port>] [-o <os>] [-a <async>] 
+       build-cli resolve -g <git-repository> -c <git-commit> [-d <svr domain>] [-p <svr-port>] [-o <os>] [-a <async>] 
+       build-cli query [-d <svr domain>] [-p <svr-port>] 
+    -g, --git <git-repository>       git repository
+    -c, --commit <git-commit>        git commit id/tag
+    -d, --domain <build-svr-domain>  remote build server ip address. default 127.0.0.1
+    -p, --port <build-svr-port>      remote build server port. default 2222
+    -o, --os <operating system>      target operating system linux/windows/darwin
+    -a, --async                      asynchronous job
+    -h, --help                       display this information
diff --git a/test/build-cli-02.testcase b/test/build-cli-02.testcase
new file mode 100644 (file)
index 0000000..c49e5d1
--- /dev/null
@@ -0,0 +1,16 @@
+#PRE-EXEC
+mkdir buildsvr01
+cd buildsvr01; ../../build-svr create -n testserver3 -u http://172.21.111.132/emptyserver/unstable -d pkgserver -i emptyserver
+../build-svr start -n testserver3 -p 2223 &
+sleep 1
+#EXEC
+../build-cli query -d 127.0.0.1 -p 2223
+#POST-EXEC
+../build-svr stop -n testserver3
+sleep 1
+../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+HOST-OS:
+MAX_WORKING_JOBS:
+* JOB *
diff --git a/test/build-cli-03.testcase b/test/build-cli-03.testcase
new file mode 100644 (file)
index 0000000..c49e5d1
--- /dev/null
@@ -0,0 +1,16 @@
+#PRE-EXEC
+mkdir buildsvr01
+cd buildsvr01; ../../build-svr create -n testserver3 -u http://172.21.111.132/emptyserver/unstable -d pkgserver -i emptyserver
+../build-svr start -n testserver3 -p 2223 &
+sleep 1
+#EXEC
+../build-cli query -d 127.0.0.1 -p 2223
+#POST-EXEC
+../build-svr stop -n testserver3
+sleep 1
+../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+HOST-OS:
+MAX_WORKING_JOBS:
+* JOB *
diff --git a/test/buildcli.testsuite b/test/buildcli.testsuite
new file mode 100644 (file)
index 0000000..06947c4
--- /dev/null
@@ -0,0 +1,2 @@
+build-cli-01.testcase
+build-cli-02.testcase
diff --git a/test/buildserver.testsuite b/test/buildserver.testsuite
new file mode 100644 (file)
index 0000000..f908bff
--- /dev/null
@@ -0,0 +1,6 @@
+buildserver01.testcase
+buildserver02.testcase
+buildserver03.testcase
+buildserver04.testcase
+buildserver05.testcase
+buildserver06.testcase
diff --git a/test/buildserver01.testcase b/test/buildserver01.testcase
new file mode 100644 (file)
index 0000000..fa32179
--- /dev/null
@@ -0,0 +1,11 @@
+#PRE-EXEC
+rm -rf ~/.build_tools/build_server/testserver3
+rm -rf buildsvr01
+mkdir buildsvr01
+#EXEC
+cd buildsvr01; ../../build-svr create -n testserver3 -u http://172.21.111.132/testserver3/unstable -d pkgserver -i testserver3
+#POST-EXEC
+../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+reated new build server: "testserver3"
diff --git a/test/buildserver02.testcase b/test/buildserver02.testcase
new file mode 100644 (file)
index 0000000..e490e82
--- /dev/null
@@ -0,0 +1,18 @@
+#PRE-EXEC
+#EXEC
+../build-svr -h
+#POST-EXEC
+#EXPECT
+Usage: build-svr {create|remove|start|build|help} ...
+       build-svr create -n <name> -u <pkg-server-url> -d <pkg-server-domain> -i <pkg-server-id>
+       build-svr remove -n <name>
+       build-svr start -n <name> [-p <port]
+       build-svr stop -n <name> 
+       build-svr add -n <name> [-d <frined-svr-domain> -p <friend-svr port>]
+    -n, --name <name>                build server name
+    -u, --url <pkg-server-url>       package server URL: http://xxx/yyy/zzz
+    -d <pkg/friend-svr domain>       package svr or friend svr ip or ssh alias
+        --domain
+    -i, --id <pkg-server-id>         package server id
+    -p, --port <port>                port
+    -h, --help                       display this information
diff --git a/test/buildserver03.testcase b/test/buildserver03.testcase
new file mode 100644 (file)
index 0000000..de131bf
--- /dev/null
@@ -0,0 +1,13 @@
+#PRE-EXEC
+rm -rf buildsvr01
+mkdir buildsvr01
+cd buildsvr01; ../../build-svr create -n testserver3 -u http://172.21.111.132/testserver3/unstable -d pkgserver -i testserver3
+#EXEC
+../build-svr add -n testserver3 -d 127.0.0.1 -p 2223
+cat ~/.build_tools/build_server/testserver3/friends
+#POST-EXEC
+../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+Friend server is added successfully!
+127.0.0.1,2223
diff --git a/test/buildserver04.testcase b/test/buildserver04.testcase
new file mode 100644 (file)
index 0000000..bdad4d1
--- /dev/null
@@ -0,0 +1,12 @@
+#PRE-EXEC
+rm -rf buildsvr01
+mkdir buildsvr01
+cd buildsvr01; ../../build-svr create -n testserver3 -u http://172.21.111.132/emptyserver/unstable -d pkgserver -i emptyserver
+#EXEC
+echo "TEST_TIME=3" >> ~/.build_tools/build_server/testserver3/server.cfg
+../build-svr start -n testserver3 -p 2223
+#POST-EXEC
+../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+Test time is elapsed!
diff --git a/test/buildserver05.testcase b/test/buildserver05.testcase
new file mode 100644 (file)
index 0000000..d15c978
--- /dev/null
@@ -0,0 +1,14 @@
+#PRE-EXEC
+rm -rf buildsvr01
+mkdir buildsvr01
+cd buildsvr01; ../../build-svr create -n testserver3 -u http://172.21.111.132/emptyserver/unstable -d pkgserver -i emptyserver
+../build-svr start -n testserver3 -p 2223 &
+#EXEC
+sleep 2
+../build-svr stop -n testserver3
+sleep 1
+#POST-EXEC
+../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+Server will be down!
diff --git a/test/buildserver06.testcase b/test/buildserver06.testcase
new file mode 100644 (file)
index 0000000..d95913d
--- /dev/null
@@ -0,0 +1,10 @@
+#PRE-EXEC
+mkdir buildsvr01
+cd buildsvr01; ../../build-svr create -n testserver3 -u http://172.21.111.132/emptyserver/unstable -d pkgserver -i emptyserver
+#EXEC
+../build-svr stop -n testserver3
+#POST-EXEC
+../build-svr remove -n testserver3
+rm -rf buildsvr01
+#EXPECT
+Server is not running!
diff --git a/test/packageserver.testsuite b/test/packageserver.testsuite
new file mode 100644 (file)
index 0000000..d63bc7e
--- /dev/null
@@ -0,0 +1,23 @@
+packageserver01.testcase
+packageserver02.testcase
+packageserver03.testcase
+packageserver04.testcase
+packageserver05.testcase
+packageserver06.testcase
+packageserver07.testcase
+packageserver08.testcase
+packageserver09.testcase
+packageserver10.testcase
+packageserver11.testcase
+packageserver12.testcase
+packageserver13.testcase
+packageserver14.testcase
+packageserver15.testcase
+packageserver16.testcase
+packageserver17.testcase
+packageserver18.testcase
+packageserver19.testcase
+packageserver20.testcase
+packageserver21.testcase
+packageserver22.testcase
+packageserver23.testcase
diff --git a/test/packageserver01.testcase b/test/packageserver01.testcase
new file mode 100644 (file)
index 0000000..d0adec5
--- /dev/null
@@ -0,0 +1,32 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr -h
+#POST-EXEC
+#EXPECT
+Usage: pkg-svr {create|register|gen-snapshot|sync|add-dist|spkg-path|remove|remove-pkg|list|help} ...
+       pkg-svr create -i <id> -d <distribution> [-u <remote_server_url>] [-l <location>] 
+       pkg-svr add-dist -i<id> -d <distribution> [-u <remote_server_url>] [-c] 
+       pkg-svr remove -i <id> 
+       pkg-svr register -i <id> -d <distribution> -p <binary_package_file_path_list> -s <source_package_file_path_list> [-g] [-t] 
+       pkg-svr remove-pkg -i <id> -d <distribution> -p <binary_package_name_list> 
+       pkg-svr gen-snapshot -i<id> -d <distribution> [-n <snapshot name>] [-b <base_snapshot_name>] [-p <binary_package_file_path_list>] 
+       pkg-svr sync -i <id> -d <distribution> [-f] 
+       pkg-svr spkg-path -i <id> -d <distribution> -s <source_package_name> 
+       pkg-svr list [-i <id>] 
+    -i, --id <id>                    package server id
+    -d, --dist <distribution>        package server distribution
+    -u, --url <server_address>       remote server address
+    -o, --os <operating system>      target operating system
+    -p <binary_pakcage_file_path_list>
+        --bpackage                   binary package file path list
+    -s <source_pakcage_file_path_list>
+        --spackage                   source package file path 
+    -g, --generate                   snapshot is generate
+    -n, --sname <snapshot>           snapshot name
+    -b <base_snapshot_name>          base snapshot name
+        --bsnapshot
+    -l, --location <location>        server location
+    -f, --force                      force update pkg file
+    -t, --test                       upload for test
+    -c, --clone                      clone mode
+    -h, --help                       display this information
diff --git a/test/packageserver02.testcase b/test/packageserver02.testcase
new file mode 100644 (file)
index 0000000..dd533bd
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr create -i temp_local -d unstable 
+#POST-EXEC
+#EXPECT
+package server [temp_local] created successfully
diff --git a/test/packageserver03.testcase b/test/packageserver03.testcase
new file mode 100644 (file)
index 0000000..e858351
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr create -i temp_remote -d unstable -u http://172.21.111.177/tmppkgsvr/tmp
+#POST-EXEC
+#EXPECT
+package server [temp_remote] created successfully
diff --git a/test/packageserver04.testcase b/test/packageserver04.testcase
new file mode 100644 (file)
index 0000000..f2539ca
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr create -i temp_remote_dup -d unstable -u temp_remote/unstable
+#POST-EXEC
+#EXPECT
+package server [temp_remote_dup] created successfully
diff --git a/test/packageserver05.testcase b/test/packageserver05.testcase
new file mode 100644 (file)
index 0000000..a66a040
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr add-dist -i temp_local -d stable 
+#POST-EXEC
+#EXPECT
+distribution [stable] added successfully
diff --git a/test/packageserver06.testcase b/test/packageserver06.testcase
new file mode 100644 (file)
index 0000000..9f9e917
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr sync -i temp_remote -d unstable 
+#POST-EXEC
+#EXPECT
+package server [temp_remote]'s distribution [unstable] has the synchronization.
diff --git a/test/packageserver07.testcase b/test/packageserver07.testcase
new file mode 100644 (file)
index 0000000..1b7d84c
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr sync -i temp_remote_dup -d unstable -f
+#POST-EXEC
+#EXPECT
+package server [temp_remote_dup]'s distribution [unstable] has the synchronization.
diff --git a/test/packageserver08.testcase b/test/packageserver08.testcase
new file mode 100644 (file)
index 0000000..9ecc71a
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr gen-snapshot        -i temp_remote
+#POST-EXEC
+#EXPECT
+snapshot is generated : 
diff --git a/test/packageserver09.testcase b/test/packageserver09.testcase
new file mode 100644 (file)
index 0000000..547b101
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr gen-snapshot -i temp_remote -d unstable 
+#POST-EXEC
+#EXPECT
+snapshot is generated : 
diff --git a/test/packageserver10.testcase b/test/packageserver10.testcase
new file mode 100644 (file)
index 0000000..34ca9b6
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr gen-snapshot -i temp_remote -d unstable -n test
+#POST-EXEC
+#EXPECT
+snapshot is generated : 
diff --git a/test/packageserver11.testcase b/test/packageserver11.testcase
new file mode 100644 (file)
index 0000000..a7ba031
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr gen-snapshot -i temp_remote -d unstable -n test2 -b test 
+#POST-EXEC
+#EXPECT
+snapshot is generated : 
diff --git a/test/packageserver12.testcase b/test/packageserver12.testcase
new file mode 100644 (file)
index 0000000..e5db467
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr gen-snapshot -i temp_remote -d unstable -o all -p test_server_pkg_file/smart-build-interface_1.20.1_linux.zip -n test3
+#POST-EXEC
+#EXPECT
+snapshot is generated : 
diff --git a/test/packageserver13.testcase b/test/packageserver13.testcase
new file mode 100644 (file)
index 0000000..017edb2
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr create -i temp_remote_snap -d unstable -u temp_remote/unstable/snapshots/test
+#POST-EXEC
+#EXPECT
+package server [temp_remote_snap] created successfully
diff --git a/test/packageserver14.testcase b/test/packageserver14.testcase
new file mode 100644 (file)
index 0000000..62d6676
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+cp test_server_pkg_file/smart-build-interface* ./
+#EXEC
+../pkg-svr register -i temp_remote -d unstable -p smart-build-interface_1.20.1_linux.zip -s smart-build-interface_1.20.1.tar.gz -g
+#POST-EXEC
+#EXPECT
+package registed successfully
diff --git a/test/packageserver15.testcase b/test/packageserver15.testcase
new file mode 100644 (file)
index 0000000..351d6aa
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr register -i temp_remote -d unstable -p smart-build-interface_1.20.1_linux.zip -s smart-build-interface_1.20.1.tar.gz -g
+#POST-EXEC
+#EXPECT
+existing package's version is higher than register package
diff --git a/test/packageserver16.testcase b/test/packageserver16.testcase
new file mode 100644 (file)
index 0000000..a70d250
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+cp test_server_pkg_file/smart-build-interface* ./
+#EXEC
+../pkg-svr register -i temp_remote_dup -d unstable -p ./temp_remote/unstable/binary/smart-build-interface_1.20.1_linux.zip -s ./temp_remote/unstable/source/smart-build-interface_1.20.1.tar.gz -g -t
+#POST-EXEC
+#EXPECT
+package registed successfully
diff --git a/test/packageserver17.testcase b/test/packageserver17.testcase
new file mode 100644 (file)
index 0000000..75ca498
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+cp test_server_pkg_file/smart-build-interface* ./
+#EXEC
+../pkg-svr remove-pkg -i temp_local -d unstable -p smart-build-interface
+#POST-EXEC
+#EXPECT
+package removed successfully
diff --git a/test/packageserver18.testcase b/test/packageserver18.testcase
new file mode 100644 (file)
index 0000000..431b64d
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+cp test_server_pkg_file/smart-build-interface* ./
+#EXEC
+../pkg-svr list
+#POST-EXEC
+#EXPECT 
+temp_remote_snap
diff --git a/test/packageserver19.testcase b/test/packageserver19.testcase
new file mode 100644 (file)
index 0000000..d144662
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr list -i temp_local
+#POST-EXEC 
+rm smart-build-interface_1.20.1*
+#EXPECT 
+unstable
diff --git a/test/packageserver20.testcase b/test/packageserver20.testcase
new file mode 100644 (file)
index 0000000..4747a48
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr remove -i temp_local -f
+#POST-EXEC 
+YES
+#EXPECT
+package server [temp_local] removed successfully
diff --git a/test/packageserver21.testcase b/test/packageserver21.testcase
new file mode 100644 (file)
index 0000000..2fc8eb9
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr remove -i temp_remote -f
+#POST-EXEC 
+YES
+#EXPECT
+package server [temp_remote] removed successfully
diff --git a/test/packageserver22.testcase b/test/packageserver22.testcase
new file mode 100644 (file)
index 0000000..f63decb
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr remove -i temp_remote_dup -f
+#POST-EXEC 
+YES
+#EXPECT
+package server [temp_remote_dup] removed successfully
diff --git a/test/packageserver23.testcase b/test/packageserver23.testcase
new file mode 100644 (file)
index 0000000..c92b0b9
--- /dev/null
@@ -0,0 +1,7 @@
+#PRE-EXEC
+#EXEC
+../pkg-svr remove -i temp_remote_snap -f
+#POST-EXEC 
+YES
+#EXPECT
+package server [temp_remote_snap] removed successfully
diff --git a/test/pkg-cli-checkupgrade.testcase b/test/pkg-cli-checkupgrade.testcase
new file mode 100644 (file)
index 0000000..f9a19be
--- /dev/null
@@ -0,0 +1,11 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver3/unstable -l pkgcli01
+../pkg-cli check-upgrade -l pkgcli01 -u http://172.21.111.132/testserver2/unstable
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+"base-ide-product" package : 0.20.8 ->
+Info: Checked packages for upgrading.. OK
diff --git a/test/pkg-cli-clean-f.testcase b/test/pkg-cli-clean-f.testcase
new file mode 100644 (file)
index 0000000..fd4543d
--- /dev/null
@@ -0,0 +1,11 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p nativeapp-eplugin -u http://172.21.111.132/testserver3/unstable -t -l pkgcli01
+../pkg-cli clean -l pkgcli01 -f
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+Info: There is no any package.
diff --git a/test/pkg-cli-download-t.testcase b/test/pkg-cli-download-t.testcase
new file mode 100644 (file)
index 0000000..6d7263b
--- /dev/null
@@ -0,0 +1,13 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli download -p nativeapp-eplugin -u http://172.21.111.132/testserver3/unstable -t -l pkgcli01
+ls pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+base-ide-product_0.20.8_linux.zip
+common-eplugin_0.20.6_linux.zip
+nativeapp-eplugin_0.20.4_linux.zip
+nativecommon-eplugin_0.20.1_linux.zip
diff --git a/test/pkg-cli-download.testcase b/test/pkg-cli-download.testcase
new file mode 100644 (file)
index 0000000..e4f6b2c
--- /dev/null
@@ -0,0 +1,10 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+cd pkgcli01; ../../pkg-cli download -p base-ide-product -u http://172.21.111.132/testserver3/unstable
+ls pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+base-ide-product_0.20.8_linux.zip
diff --git a/test/pkg-cli-install-f.testcase b/test/pkg-cli-install-f.testcase
new file mode 100644 (file)
index 0000000..7794646
--- /dev/null
@@ -0,0 +1,11 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver2/unstable -l pkgcli01
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver3/unstable -l pkgcli01 -f
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+base-ide-product  (0.20.8)
diff --git a/test/pkg-cli-install-t.testcase b/test/pkg-cli-install-t.testcase
new file mode 100644 (file)
index 0000000..00d2734
--- /dev/null
@@ -0,0 +1,13 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p nativeapp-eplugin -u http://172.21.111.132/testserver3/unstable -t -l pkgcli01
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+base-ide-product  (0.20.8)
+common-eplugin  (0.20.6)
+nativeapp-eplugin  (0.20.4)
+nativecommon-eplugin  (0.20.1)
diff --git a/test/pkg-cli-install.testcase b/test/pkg-cli-install.testcase
new file mode 100644 (file)
index 0000000..31ac836
--- /dev/null
@@ -0,0 +1,10 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver3/unstable -l pkgcli01
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+base-ide-product  (0.20.8)
diff --git a/test/pkg-cli-installfile-f.testcase b/test/pkg-cli-installfile-f.testcase
new file mode 100644 (file)
index 0000000..810ad2f
--- /dev/null
@@ -0,0 +1,13 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver2/unstable -l pkgcli01
+../pkg-cli download -p base-ide-product -u http://172.21.111.132/testserver3/unstable
+../pkg-cli install-file -p base-ide-product_0.20.8_linux.zip -l pkgcli01 -f
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -f base-ide-product_0.20.8_linux.zip
+rm -rf pkgcli01
+#EXPECT
+base-ide-product  (0.20.8)
diff --git a/test/pkg-cli-installfile.testcase b/test/pkg-cli-installfile.testcase
new file mode 100644 (file)
index 0000000..ebdb5de
--- /dev/null
@@ -0,0 +1,12 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli download -p base-ide-product -u http://172.21.111.132/testserver3/unstable
+../pkg-cli install-file -p base-ide-product_0.20.8_linux.zip -l pkgcli01
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -f base-ide-product_0.20.8_linux.zip
+rm -rf pkgcli01
+#EXPECT
+base-ide-product  (0.20.8)
diff --git a/test/pkg-cli-listlpkg.testcase b/test/pkg-cli-listlpkg.testcase
new file mode 100644 (file)
index 0000000..31ac836
--- /dev/null
@@ -0,0 +1,10 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver3/unstable -l pkgcli01
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+base-ide-product  (0.20.8)
diff --git a/test/pkg-cli-listrpkg.testcase b/test/pkg-cli-listrpkg.testcase
new file mode 100644 (file)
index 0000000..6a74ae7
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-cli list-rpkg -u http://172.21.111.132/testserver3/unstable
+#POST-EXEC
+#EXPECT
+base-ide-product  (0.20.8)
diff --git a/test/pkg-cli-showlpkg.testcase b/test/pkg-cli-showlpkg.testcase
new file mode 100644 (file)
index 0000000..dbee48c
--- /dev/null
@@ -0,0 +1,12 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver3/unstable -l pkgcli01
+../pkg-cli show-lpkg -p base-ide-product -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+Package : base-ide-product
+Version : 0.20.8
+OS : linux
diff --git a/test/pkg-cli-showrpkg.testcase b/test/pkg-cli-showrpkg.testcase
new file mode 100644 (file)
index 0000000..443aa3e
--- /dev/null
@@ -0,0 +1,8 @@
+#PRE-EXEC
+#EXEC
+../pkg-cli show-rpkg -p base-ide-product -u http://172.21.111.132/testserver3/unstable
+#POST-EXEC
+#EXPECT
+Package : base-ide-product
+Version : 0.20.8
+OS : linux
diff --git a/test/pkg-cli-source.testcase b/test/pkg-cli-source.testcase
new file mode 100644 (file)
index 0000000..64053ad
--- /dev/null
@@ -0,0 +1,10 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+cd pkgcli01; ../../pkg-cli source -p base-ide-product -u http://172.21.111.132/testserver3/unstable
+ls pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+product_0.20.8.tar.gz
diff --git a/test/pkg-cli-uninstall-t.testcase b/test/pkg-cli-uninstall-t.testcase
new file mode 100644 (file)
index 0000000..749815f
--- /dev/null
@@ -0,0 +1,11 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p nativeapp-eplugin -u http://172.21.111.132/testserver3/unstable -l pkgcli01 -t
+../pkg-cli uninstall -p base-ide-product -l pkgcli01 -t
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+Info: There is no any package.
diff --git a/test/pkg-cli-uninstall.testcase b/test/pkg-cli-uninstall.testcase
new file mode 100644 (file)
index 0000000..10e7647
--- /dev/null
@@ -0,0 +1,11 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product - http://172.21.111.132/testserver3/unstable -l pkgcli01
+../pkg-cli uninstall -p base-ide-product -l pkgcli01
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+Info: There is no any package.
diff --git a/test/pkg-cli-update.testcase b/test/pkg-cli-update.testcase
new file mode 100644 (file)
index 0000000..3c6fa52
--- /dev/null
@@ -0,0 +1,6 @@
+#PRE-EXEC
+#EXEC
+../pkg-cli update -u http://172.21.111.132/testserver3/unstable
+#POST-EXEC
+#EXPECT
+Update package list from "http://172.21.111.132/testserver3/unstable".. OK
diff --git a/test/pkg-cli-upgrade.testcase b/test/pkg-cli-upgrade.testcase
new file mode 100644 (file)
index 0000000..493d947
--- /dev/null
@@ -0,0 +1,11 @@
+#PRE-EXEC
+rm -rf pkgcli01
+mkdir pkgcli01
+#EXEC
+../pkg-cli install -p base-ide-product -u http://172.21.111.132/testserver3/unstable -l pkgcli01
+../pkg-cli upgrade -l pkgcli01 -u http://172.21.111.132/testserver2/unstable
+../pkg-cli list-lpkg -l pkgcli01
+#POST-EXEC
+rm -rf pkgcli01
+#EXPECT
+base-ide-product  (0.20.14)
diff --git a/test/pkg-cli.testsuite b/test/pkg-cli.testsuite
new file mode 100644 (file)
index 0000000..21c2fe0
--- /dev/null
@@ -0,0 +1,18 @@
+pkg-cli-update.testcase
+pkg-cli-listrpkg.testcase
+pkg-cli-showrpkg.testcase
+pkg-cli-download.testcase
+pkg-cli-download-t.testcase
+pkg-cli-source.testcase
+pkg-cli-install.testcase
+pkg-cli-install-t.testcase
+pkg-cli-install-f.testcase
+pkg-cli-uninstall.testcase
+pkg-cli-uninstall-t.testcase
+pkg-cli-installfile.testcase
+pkg-cli-installfile-f.testcase
+pkg-cli-listlpkg.testcase
+pkg-cli-showlpkg.testcase
+pkg-cli-checkupgrade.testcase
+pkg-cli-upgrade.testcase
+pkg-cli-clean-f.testcase
diff --git a/test/regression.rb b/test/regression.rb
new file mode 100755 (executable)
index 0000000..7085799
--- /dev/null
@@ -0,0 +1,171 @@
+#!/usr/bin/ruby
+$success_cases=[]
+$failure_cases=[]
+$testcases=[]
+
+$total_cnt = 0
+
+testCaseName = ""
+resultCheck = ""
+resultFlag = ""
+resultCmdCount = 0
+
+
+class TestCase
+       attr_accessor :name, :pre_exec_cmds, :exec_cmds, :post_exec_cmds, :expected_results
+       def initialize(name)
+               @name = name
+               @pre_exec_cmds = []
+               @exec_cmds = []
+               @post_exec_cmds = []
+               @expected_results = []
+       end
+
+       def is_succeeded?(results)
+               @expected_results.each do |e|
+                       found = false
+                       results.each do |r|
+                               if r.include? e then
+                                       found = true
+                                       break
+                               end     
+                       end
+                       if not found then return false end
+               end     
+
+               return true
+       end
+end
+
+
+# parse
+def parse_testcase(file_name)
+       # create
+       tcase = TestCase.new( file_name )
+
+       # parse
+       File.open(file_name,"r") do |f|
+               status="START"
+               f.each_line do |l|
+                       ln = l.strip
+                       if ln == "#PRE-EXEC" or ln == "#EXEC"  or 
+                               ln == "#POST-EXEC" or ln == "#EXPECT" then
+
+                               status = ln
+                       else
+                               case status
+                               when "#PRE-EXEC"
+                                       tcase.pre_exec_cmds.push ln                     
+                               when "#EXEC"
+                                       tcase.exec_cmds.push ln                 
+                               when "#POST-EXEC"
+                                       tcase.post_exec_cmds.push ln                    
+                               when "#EXPECT"
+                                       tcase.expected_results.push ln                  
+                               else
+                                       # ignore
+                               end
+                       end
+               end
+       end
+
+       return tcase    
+end
+
+
+# test execution
+def execute( file_name )
+       printf("#{file_name} ... ")
+       STDOUT.flush
+
+       # parse
+       tcase = parse_testcase( file_name )
+
+       # pre-exec
+       tcase.pre_exec_cmds.each do |cmd|
+               fork_p = false
+               if cmd[-1,1] == "&" then
+                       cmd = cmd[0..-2]
+                       fork_p = true   
+               end
+               # get result
+               if not fork_p then
+                       IO.popen("#{cmd} 2>&1") { |io|
+                       }
+               else
+                       IO.popen("#{cmd} 2>&1 &") { |io|
+                       }
+               end
+               #`#{cmd}`
+       end     
+
+       # exec
+       results = []
+       tcase.exec_cmds.each do |cmd|
+               # get result
+               IO.popen("#{cmd} 2>&1") { |io|
+                       io.each do |line|
+                               results.push line.strip
+                       end
+               }
+       end
+
+       # check expected result
+       if tcase.is_succeeded?(results) then
+               puts "SUCCESS"
+               $success_cases.push file_name
+       else    
+       puts "FAIL"
+               $failure_cases.push file_name
+               results.each do |l|
+                       puts ">" + l
+               end
+       end
+
+       # post-exec
+       tcase.post_exec_cmds.each do |cmd|
+               # get result
+               IO.popen("#{cmd} 2>&1") { |io|
+               }
+               #`#{cmd}`
+       end
+end
+
+
+#test_list file open
+if (ARGV.size() == 0)
+  testsuite_name = "list.txt"
+else
+  testsuite_name = ARGV.shift
+end
+
+# execute testsuite
+puts
+puts "Regression Test Start      "
+puts "=================================="
+
+File.open( testsuite_name ) do |f|
+       f.each_line do |line|
+       $testcases.push("#{line.strip}")
+               execute(line.strip)
+    end
+end
+
+# print result 
+puts
+puts "Regression Test Result"
+puts "----------------------"
+puts "Total Test Case : #{$testcases.count}"
+puts "Test Success    : #{$success_cases.count}"
+puts "Test Errors     : #{$failure_cases.count}"
+puts
+
+if $failure_cases.count != 0 then
+    puts "Test Fail Files"
+    puts "---------------"
+    $failure_cases.each do |name|
+        puts name
+    end 
+    puts
+end
+
diff --git a/test/test.sh b/test/test.sh
new file mode 100755 (executable)
index 0000000..e765f43
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+./regression.rb pkg-cli.testsuite
+./regression.rb packageserver.testsuite
+./regression.rb buildserver.testsuite
+./regression.rb buildcli.testsuite
index 64bdb77..cb17835 100755 (executable)
@@ -11,7 +11,7 @@ echo "============ remove 4 =============="
 echo "============ create 1 =============="
 ../pkg-svr create -i temp_local -d unstable 
 echo "============ create 2 =============="
-../pkg-svr create -i temp_remote -d unstable -u http://172.21.17.55/pkgserver/unstable 
+../pkg-svr create -i temp_remote -d unstable -u http://172.21.17.55/dibs/unstable
 echo "============ create 3 =============="
 ../pkg-svr create -i temp_remote_dup -d unstable -u temp_remote/unstable
 echo "============ add dist 1 =============="
@@ -41,19 +41,16 @@ echo "============ gen snapshot 9 =============="
 echo "============ create 4 =============="
 ../pkg-svr create -i temp_remote_snap -d unstable -u temp_remote/unstable/snapshots/test
 echo "============ register 1 =============="
-cp test_server_pkg_file/smart-build-interface_1.20.1_linux.zip ./smart-build-interface_1.20.1_linux.zip 
-cp test_server_pkg_file/smart-build-interface_1.20.1.tar.gz ./smart-build-interface_1.20.1.tar.gz
+cp test_server_pkg_file/smart-build-interface* ./
 ../pkg-svr register -i temp_remote -d unstable -p smart-build-interface_1.20.1_linux.zip -s smart-build-interface_1.20.1.tar.gz -g
 echo "============ spkg path 1 =============="
 ../pkg-svr spkg-path -i temp_remote -d unstable -s smart-build-interface_1.20.1.tar.gz
 echo "============ register 2 =============="
-cp test_server_pkg_file/smart-build-interface_1.20.1_linux.zip ./smart-build-interface_1.20.1_linux.zip 
-cp test_server_pkg_file/smart-build-interface_1.20.1.tar.gz ./smart-build-interface_1.20.1.tar.gz
 ../pkg-svr register -i temp_remote -d unstable -p smart-build-interface_1.20.1_linux.zip -s smart-build-interface_1.20.1.tar.gz -g
 echo "============ register 3 =============="
 ../pkg-svr register -i temp_remote_dup -d unstable -p ./temp_remote/unstable/binary/smart-build-interface_1.20.1_linux.zip -s ./temp_remote/unstable/source/smart-build-interface_1.20.1.tar.gz -g -t
 echo "============ remove 3 ==============" 
-../pkg-svr remove-pkg -i temp_remote_dup -d unstable -p smart-build-interface
+../pkg-svr remove-pkg -i temp_local -d unstable -p smart-build-interface
 echo "============ list 1 =============="
 ../pkg-svr list
 echo "============ list 2 =============="
@@ -61,5 +58,6 @@ echo "============ list 2 =============="
 #../pkg-svr remove -i temp
 
 #cleanup
+rm smart-build-interface_1.20.1_windows.zip 
 rm smart-build-interface_1.20.1_linux.zip 
 rm smart-build-interface_1.20.1.tar.gz
diff --git a/tizen-ide/get_ide_sources.sh b/tizen-ide/get_ide_sources.sh
new file mode 100644 (file)
index 0000000..5f9d7ea
--- /dev/null
@@ -0,0 +1,239 @@
+#!/bin/bash
+
+###############################################################
+## Variables
+###############################################################
+
+START_PATH=~+  ## like `pwd`
+SCRIPT_NAME=$0
+SCRIPT_OPERATION=$1
+ARG1=$2
+ARG2=$3
+ARG3=$4
+GIT_PORT=29419
+CONTINUE=n
+GIT_LIST="
+/sdk/ide/common-eplugin
+/sdk/ide/eventinjector-eplugin
+/sdk/ide/nativecommon-eplugin
+/sdk/ide/nativeapp-eplugin
+/sdk/ide/nativeplatform-eplugin
+/sdk/ide/unittest-eplugin
+/sdk/ide/native-gui-builder-eplugin
+/sdk/gui-builder/native-gui-builder
+/sdk/ide/profiler-eplugin
+/sdk/ide/codecoverage-eplugin
+/sdk/ide/assignmenttracing-eplugin
+/sdk/ide/codehiding-eplugin
+/sdk/ide/telephony-eplugin
+/sdk/ide/webapp-eplugin
+/sdk/ide/product
+"
+
+
+###############################################################
+## Usage output functions
+###############################################################
+
+function usage() {
+       echo "Usage : ${SCRIPT_NAME##*/} <command> [<args>]"; echo
+       echo "The most commonly used script commands are :"
+       echo "  clone           Clone git sources about Tizen SDK"
+       echo "  pull            Pull git sources about Tizen SDK"
+       echo "  checkout        checkout git sources about Tizen SDK"; echo
+       exit 1
+}
+
+function usage_pull() {
+       echo "Usage : ${SCRIPT_NAME##*/} pull : Git pull in current directory";
+       echo "Usage : ${SCRIPT_NAME##*/} pull <source directory> : Git pull in source directory";
+
+       draw_line
+       echo "  Ex1) \$ ${SCRIPT_NAME} pull"; echo
+       echo "  Ex2) \$ ${SCRIPT_NAME} pull $(pwd)/tizen-ide-sources"; echo
+       exit 1
+}
+
+function usage_checkout() {
+       echo "Usage : ${SCRIPT_NAME##*/} checkout <branch name> : Git checkout in current directory";
+       echo "Usage : ${SCRIPT_NAME##*/} checkout <branch name> <source directory> : Git checkout in source directory";
+
+       draw_line
+       echo "  Ex1) \$ ${SCRIPT_NAME} checkout develop"; echo
+       echo "  Ex2) \$ ${SCRIPT_NAME} checkout develop $(pwd)/tizen-ide-sources"; echo
+       exit 1
+}
+
+function usage_clone() {
+       draw_line
+       echo "Usage : 1) ${SCRIPT_NAME##*/} clone <git branch name> <host> : Git clone in curreut directory"; echo
+       echo "        2) ${SCRIPT_NAME##*/} clone <git branch name> <host> <destination directory>: Git clone in destination directory"
+       draw_line
+       echo "  Ex1) \$ ${SCRIPT_NAME} clone develop gerrithost"
+       echo "  Ex2) \$ ${SCRIPT_NAME} clone release http://develop.tizen.org/git:2039 /home/usr/work/git"
+       exit 1
+}
+
+
+###############################################################
+## Processing Functions
+###############################################################
+
+function draw_line() {
+       echo; echo "==========================================================================="; echo;
+}
+
+## Error Check Function
+function isError() {
+       ERROR_CODE=$?
+
+       if [ ${ERROR_CODE} == 0 ]; then
+               echo "[ $1 : Done ]"; 
+       else
+               echo "[ $1 : Fail (ErrorCode : ${ERROR_CODE}) ]"
+               if [ ${CONTINUE} == "n" ]; then
+                       input=0
+                       while [ ${input} != "y" -a ${input} != "n" -a ${input} != "a" ]; do
+                               echo "Continue? y: Yes, n: No, a: Yes to all"
+                               read input
+                               if [ ${input} == "n" ]; then
+                                       exit ${ERROR_CODE}
+                               elif [ ${input} == "a" ]; then
+                                       CONTINUE=y
+                                       echo ${CONTINUE}
+                               fi
+                       done
+               fi
+       fi
+}
+
+## Cloning git
+function git_clone() {
+       GIT_PATH=$1
+       GIT_NAME=${GIT_PATH##*/}
+
+       ## ARG1 : <git branch name>
+       ## ARG2 : <host>
+       ## ARG3 : <destination directory>
+       git clone -b ${ARG1} ${ARG2}:${GIT_PATH} ${ARG3}/${GIT_NAME}
+       isError "Cloned ${GIT_NAME}"
+       scp -p -P ${GIT_PORT} ${ARG2}:hooks/commit-msg ${ARG3}/${GIT_NAME}/.git/hooks/
+       isError "Generate change-id ${GIT_NAME}"
+}
+
+## Cloning git all
+function git_clone_all() {
+       draw_line; echo "Git clone sources"; draw_line
+
+       for GIT_EACH in ${GIT_LIST}
+       do
+               git_clone ${GIT_EACH}
+       done
+}
+
+## Pulling git
+function git_pull() {
+       GIT_PATH=$1
+       GIT_NAME=${GIT_PATH##*/}
+
+       ## ARG1 : <source directory>
+       cd ${ARG1}/${GIT_NAME}
+       isError "Found git directory ( ${ARG1}/${GIT_NAME} )"
+       git pull
+       isError "Pulled ${GIT_NAME}"
+}
+
+## Pulling git all
+function git_pull_all() {
+       draw_line;      echo "Git pull sources"; draw_line
+
+       cd ${ARG1}
+       isError "Checked source directory ( ${ARG1} )"
+
+       for GIT_EACH in ${GIT_LIST}
+       do
+               git_pull ${GIT_EACH}
+       done
+
+       cd ${START_PATH}
+}
+
+## Checking out git
+function git_checkout() {
+       GIT_PATH=$1
+       GIT_NAME=${GIT_PATH##*/}
+
+       ## ARG1 : <source directory>
+       cd ${ARG2}/${GIT_NAME}
+       isError "Found git directory ( ${ARG2}/${GIT_NAME} )"
+       git checkout ${ARG1}
+       isError "Checkout ${GIT_NAME}"
+}
+
+## Checking out git all
+function git_checkout_all() {
+       draw_line;      echo "Git checkout"; draw_line
+
+       cd ${ARG2}
+       isError "Checked source directory ( ${ARG1} )"
+
+       for GIT_EACH in ${GIT_LIST}
+       do
+               git_checkout ${GIT_EACH}
+       done
+
+       cd ${START_PATH}
+}
+
+###############################################################
+## Begin script
+###############################################################
+
+case ${SCRIPT_OPERATION} in
+       ## process "clone" operation
+       clone)
+               if [ "$#" == 4 ]; then
+                       git_clone_all
+               elif [ "$#" == 3 ]; then
+                       ARG3=$(pwd)
+                       git_clone_all                   
+               else
+                       usage_clone
+               fi
+               ;;
+
+       ## process "pull" operation
+       pull)
+               if [ "$#" == 2 ]; then
+                       git_pull_all
+               elif [ "$#" == 1 ]; then
+                       ARG1=$(pwd)
+                       git_pull_all
+               else
+                       usage_pull
+               fi
+               ;;
+
+       ## process "checkout" operation
+       checkout)
+               if [ "$#" == 3 ]; then
+                       git_checkout_all
+               elif [ "$#" == 2 ]; then
+                       ARG2=$(pwd)
+                       git_checkout_all
+               else
+                       usage_checkout
+               fi
+               ;;
+
+       ## process default
+       *)
+               usage
+               ;;
+esac
+
+echo "[ Finished process ]"
+
+###############################################################
+## End script
+###############################################################