[Title] Supported resolving conflicts for local package
authordonghyuk.yang <donghyuk.yang@samsung.com>
Tue, 12 Mar 2013 05:46:41 +0000 (14:46 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Tue, 12 Mar 2013 05:46:41 +0000 (14:46 +0900)
src/pkg_server/client.rb

index 91e75d446418aa99a962a34d906224f1ea3ddc31..005cbced56fed996fdb7b8904b386c4a96c6f9fe 100644 (file)
@@ -678,6 +678,7 @@ class Client
                        manifest_path = File.join(path, manifest_file)
                        pkg = Parser.read_single_pkginfo_from manifest_path
                        new_pkg_ver = pkg.version
+                       pkg_conflicts = pkg.conflicts
                        FileUtils.remove_dir(path, true)
                rescue Interrupt
                        @log.error "Client: Interrupted.."
@@ -709,6 +710,11 @@ class Client
                end
 
                # TODO: Resolve conflicts
+               if not resolve_conflicts_internal(pkg_conflicts) then
+                       @log.error "Failed to resolve conflicts [#{pkg_name}]"
+                       return false
+               end             
+
 
                if trace then
                        install_dep_pkgs = pkg.install_dep_list
@@ -1343,9 +1349,9 @@ class Client
        end
 
        private
-       def resolve_conflicts(pkg_name, os)
-               conflicts = get_attr_from_pkg(pkg_name, os, "conflicts")
-               conflicts.each do |pkg|
+       def resolve_conflicts_internal(conflicts_pkgs)
+               if conflicts_pkgs.nil? then return true end                     
+               conflicts_pkgs.each do |pkg|
                        if check_installed_pkg(pkg.package_name) then                           
                                if not uninstall(pkg.package_name, true) then
                                        @log.error "Failed to uninstall [#{pkg.package_name}] package for resolving"                                    
@@ -1356,6 +1362,12 @@ class Client
                        end                             
                end     
                return true
+       end                     
+
+       private
+       def resolve_conflicts(pkg_name, os)
+               conflicts = get_attr_from_pkg(pkg_name, os, "conflicts")
+               return resolve_conflicts_internal(conflicts)
        end     
 
        private