[Title] Supported resolving conflicts for remote packages
authordonghyuk.yang <donghyuk.yang@samsung.com>
Tue, 12 Mar 2013 02:05:40 +0000 (11:05 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Tue, 12 Mar 2013 02:47:36 +0000 (11:47 +0900)
src/pkg_server/client.rb

index bb94695e73deb2ffbebc158dcf30170aaf4ac413..b4e338f44aa5b6f3243c0c24529448084e994269 100644 (file)
@@ -723,6 +723,8 @@ class Client
                        uninstall(pkg_name, false)
                end
 
+               # TODO: Resolve conflicts
+
                if trace then
                        install_dep_pkgs = pkg.install_dep_list
                        new_pkg_os = pkg_os
@@ -1227,6 +1229,7 @@ class Client
                when "attribute" then return pkg.attribute
                when "checksum" then return pkg.checksum
                when "size" then return pkg.size
+               when "conflicts" then return pkg.conflicts                              
 
                end
        end
@@ -1403,6 +1406,22 @@ class Client
                return pkg
        end
 
+       private
+       def resolve_conflicts(pkg_name, os)
+               conflicts = get_attr_from_pkg(pkg_name, os, "conflicts")
+               conflicts.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"                                    
+                                       return false
+                               else
+                                       @log.info "Resolved conflict package [#{pkg.package_name}]"                                     
+                               end
+                       end                             
+               end     
+               return true
+       end     
+
        private
        # install a package to @location after uninstalling and downloading
        def install_pkg(pkg_name, os, force)
@@ -1445,6 +1464,12 @@ class Client
                        end
                end
 
+               # resolve conflict packages
+               if not resolve_conflicts(pkg_name, os) then
+                       @log.error "Failed to resolve conflicts [#{pkg_name}]"
+                       return false
+               end
+
                # install package
                cached_filepath = nil
                if Utils.is_linux_like_os( Utils::HOST_OS ) then