[Title] bug fix : package server sync command
authorhataejun <taejun.ha@samsung.com>
Wed, 22 Aug 2012 07:53:10 +0000 (16:53 +0900)
committerhataejun <taejun.ha@samsung.com>
Wed, 22 Aug 2012 07:53:10 +0000 (16:53 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/pkg_server/distribution.rb
src/pkg_server/packageServer.rb

index e5a0c89430b98284c69a6d534830b7966b28a9dc..cc3825e0357812f54290bb7693bdc68a7626b607 100644 (file)
@@ -188,6 +188,8 @@ class Distribution
 
        def sync(force) 
                pkg_list_update_flag = false
+               archive_update_flag = false
+               distribution_update_flag = false
 
                # check distribution's server_url
                if @server_url.empty? then 
@@ -235,11 +237,14 @@ class Distribution
                        end
                end
                
+               # sync archive package 
+               update_archive_list = sync_archive_pkg()
+
                # lock
-               Utils.file_lock(@lock_file_path)
+               lock_file = Utils.file_lock(@lock_file_path)
 
                # reload pkg list from newest pkg list file
-               reload_binary_pkg_list
+               reload_distribution_information()
 
                # update pkg_list hash
                update_pkg_list.each do |update_option, os, pkg|
@@ -252,10 +257,16 @@ class Distribution
                        when "ADD"
                                new_pkg = @pkg_hash_os[os][pkg.package_name]
                                
-                               if (not force) and (not new_pkg.nil?) and 
-                                               Utils.compare_version(new_pkg.version, pkg.version).eql?(-1) then
-                                       # if package is update then skip
-                                       next
+                               if (not force) and (not new_pkg.nil?) then
+                                       # if updated package 'local' package then skip
+                                       if new_pkg.origin.eql? "local" then 
+                                               next
+                                       end
+
+                                       # if package is update when sync time then skip
+                                       if Utils.compare_version(new_pkg.version, pkg.version).eql?(-1) then
+                                               next
+                                       end
                                end
                                        
                                @pkg_hash_os[os][pkg.package_name] = pkg
@@ -273,65 +284,30 @@ class Distribution
                        end
                end
 
-               # check install dependency integrity
-               if @integrity.eql? "YES" then
-                       @log.info "integrity check"
-                       check_integrity 
-               else
-                       @log.info "skip integrity check"
-               end 
+               update_archive_list.each do |pkg|
+                       if not @archive_pkg_list.include? pkg then
+                               @archive_pkg_list.push pkg
+                               archive_update_flag = true
+                       end
+               end
 
                # update pkg_list file
                if pkg_list_update_flag then
                        write_all_pkg_list()
-                       return true
-               else
-                       return false
+                       distribution_update_flag = true
                end
 
-               # uplock 
-               Utils.file_unlock(@lock_file_path)
-       end
-
-    def sync_archive_pkg
-        client = Client.new( @server_url, "#{@location}/source", @log )
-
-        download_list = client.archive_pkg_list - @archive_pkg_list
-
-               # if update list is empty then return false
-               if download_list.empty? then return false end 
-
-               updated_file_list = []
-
-        download_list.each do |pkg|
-                       file = client.download_dep_source(pkg)
-               if file.nil?
-                       @log.error("Can't download archive package [#{pkg}]", Log::LV_USER)
-                       else
-                               updated_file_list.push pkg
-               end
-        end
-
-               # lock
-               Utils.file_lock(@lock_file_path)
-
-               # reload archive pkg list
-               @archive_pkg_list = read_archive_pkg_list( "" )
-
-               # update archive pkg list
-               updated_file_list.each do |pkg|
-                       if not @archive_pkg_list.include? pkg then
-                               @archive_pkg_list.push pkg
-                       end
+               # update archive list file
+               if archive_update_flag then
+               write_archive_pkg_list()
+                       distribution_update_flag = true
                end
 
-        write_archive_pkg_list()
-
-               # uplock 
-               Utils.file_unlock(@lock_file_path)
+               # unlock 
+               Utils.file_unlock(lock_file)
 
-               return true
-    end
+               return distribution_update_flag
+       end
 
        def add_os(os)
                if @support_os_list.include? os then
@@ -349,40 +325,6 @@ class Distribution
                File.open( "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}", "w" ) do |f| end
        end
 
-       def remove_os(os)
-               if not @support_os_list.include? os then
-                       @log.error("Can't remove os : #{os} does not exist ", Log::LV_USER)
-               end
-
-               # update os information
-               @support_os_list.delete os
-               @pkg_hash_os.delete os
-
-               # generate temp file
-               tmp_file_name = ""
-               while ( tmp_file_name.empty? )
-                       tmp_file_name = @location + "/temp/." + Utils.create_uniq_name
-
-                       if File.exist? tmp_file_name then 
-                               tmp_file_name = ""
-                       end 
-               end
-
-               info_file = File.readlines("#{@location}/#{OS_INFO_FILE}")
-               File.open(tmp_file_name, "w") do |f|
-                       info_file.each do |line|
-                               if not line.strip.eql? os then 
-                                       f.puts line 
-                               end
-                       end
-               end
-
-               FileUtils.mv( tmp_file_name, "#{@location}/#{OS_INFO_FILE}", :force => true )
-
-               # delete pkg_list_#{os} file 
-               File.delete( "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}" ) 
-       end
-
        def clean( remain_snapshot_list )
                file_list = []
                used_archive_list = []
@@ -861,7 +803,7 @@ class Distribution
                return rdepends_list
        end  
 
-       def reload_binary_pkg_list
+       def reload_distribution_information
                if not File.exist?("#{@location}/#{OS_INFO_FILE}") then
                        return
                end 
@@ -873,7 +815,7 @@ class Distribution
                        end
                end
 
-               # read package_list file
+               # read binary package_list file
         for os in @support_os_list 
                        @pkg_hash_os[os] = {}
                        pkg_list_file = "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}" 
@@ -887,5 +829,65 @@ class Distribution
                                end
                        end
                end
+
+               # read archive package_list file
+               @archive_pkg_list = read_archive_pkg_list( "" )
+       end
+
+       def remove_os(os)
+               if not @support_os_list.include? os then
+                       @log.error("Can't remove os : #{os} does not exist ", Log::LV_USER)
+               end
+
+               # update os information
+               @support_os_list.delete os
+               @pkg_hash_os.delete os
+
+               # generate temp file
+               tmp_file_name = ""
+               while ( tmp_file_name.empty? )
+                       tmp_file_name = @location + "/temp/." + Utils.create_uniq_name
+
+                       if File.exist? tmp_file_name then 
+                               tmp_file_name = ""
+                       end 
+               end
+
+               info_file = File.readlines("#{@location}/#{OS_INFO_FILE}")
+               File.open(tmp_file_name, "w") do |f|
+                       info_file.each do |line|
+                               if not line.strip.eql? os then 
+                                       f.puts line 
+                               end
+                       end
+               end
+
+               FileUtils.mv( tmp_file_name, "#{@location}/#{OS_INFO_FILE}", :force => true )
+
+               # delete pkg_list_#{os} file 
+               File.delete( "#{@location}/#{PKG_LIST_FILE_PREFIX}#{os}" ) 
        end
+
+    def sync_archive_pkg
+        client = Client.new( @server_url, "#{@location}/source", @log )
+
+        download_list = client.archive_pkg_list - @archive_pkg_list
+
+               updated_file_list = []
+
+               # if update list is empty then return empty array
+               if download_list.empty? then return updated_file_list end 
+
+        download_list.each do |pkg|
+                       file = client.download_dep_source(pkg)
+               if file.nil?
+                       @log.error("Can't download archive package [#{pkg}]", Log::LV_USER)
+                       else
+                               updated_file_list.push pkg
+               end
+        end
+
+               return updated_file_list
+    end
+
 end
index cf081d865ca7cf333895410e050b810020a902da..9338085e6a92787b9b2e2f2c69a56dbe0ea5f001 100644 (file)
@@ -270,9 +270,8 @@ class PackageServer
                        return
                end 
 
-               ret1 = distribution.sync(mode)
-               ret2 = distribution.sync_archive_pkg
-               if ret1 or ret2 then 
+               ret = distribution.sync(mode)
+               if ret then 
                        distribution.generate_snapshot("", "", false)
                end
                
@@ -640,9 +639,8 @@ class PackageServer
                                @log.info "[#{dist_name}] distribution creation. using local server [#{server_url}]"
                        end
 
-                       ret1 = distribution.sync(false)
-                       ret2 = distribution.sync_archive_pkg
-                       if ret1 or ret2 then 
+                       ret = distribution.sync(false)
+                       if ret then 
                                distribution.generate_snapshot("", "", false)
                        end
                else