[Title] Modified printing log more detail and fixed error for installing local package
authordonghyuk.yang <donghyuk.yang@samsung.com>
Thu, 30 Aug 2012 15:50:48 +0000 (00:50 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Thu, 30 Aug 2012 15:50:48 +0000 (00:50 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

src/pkg_server/client.rb
src/pkg_server/downloader.rb
src/pkg_server/installer.rb

index 8bd431e6f5cfbdafe24735fc079c4a336f691c33..27948059c898d0e794b9ceb93efe12a7ad96ebdb 100644 (file)
@@ -210,7 +210,7 @@ class Client
 
         # get dependent list
         if trace then
-            dependent_pkg_list = get_install_dependent_packages(pkg_name, os, true, false)
+            dependent_pkg_list = get_install_dependent_packages(pkg_name, os, true, true)
             if dependent_pkg_list.nil? then
                 @log.error "Failed to get dependency for \"#{pkg_name}\" package"
                 return nil
@@ -218,7 +218,6 @@ class Client
         else dependent_pkg_list = [pkg_name] end
 
                surl = @server_addr
-
         # download files
         file_local_path = []
         dependent_pkg_list.each do |p|
@@ -235,8 +234,6 @@ class Client
             filename = pkg_path.split('/')[-1]
                        
             if not FileDownLoader.download(url, loc, @log) then
-                @log.error "Failed download #{pkg_name} [#{pkg_ver}]"
-                return nil
             end
 
                file_path = File.join(loc, filename)
@@ -245,10 +242,8 @@ class Client
 
         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(", ")}]"
+        @log.info "  [path: #{file_local_path.join(", ")}]"
 
         return file_local_path
        end
@@ -271,6 +266,8 @@ class Client
                filename = filepath.split('/')[-1]
                if not File.exist? distpath then FileUtils.mkdir_p "#{distpath}" end
                distfile = File.join(distpath, filename)
+               @log.info "Moving \"#{filename}\" to download cache directory"
+               @log.info "  [path: #{distpath}]"
                $filemove_mutex.synchronize {
                        if not File.exist? distfile then
                                Utils.execute_shell("mv #{filepath} #{distfile}")
@@ -281,7 +278,11 @@ class Client
                }
 
                if File.exist? distfile then return distfile
-               else return nil end
+               else 
+                       @log.info "Failed to move [#{filenamae}] to "
+                       @log.info "  [#{distpath}]"
+                       return nil 
+               end
        end                     
 
        private
@@ -321,7 +322,7 @@ class Client
         end
         file_local_path = File.join(@location, file_name)
         @log.info "Downloaded \"#{file_name}\" source file.. OK"
-        @log.info "  [path : #{file_local_path}]"
+        @log.info "  [path: #{file_local_path}]"
 
         return file_local_path
     end
@@ -542,10 +543,10 @@ class Client
         if not force then
                case compare_result
                when -1 then
-                       @log.warn "\"#{pkg_name}\" package version is bigger then remote package version"
+                       @log.warn "Checked \"#{pkg_name}\" package version : it is bigger then remote package version"
                        return true
                when 0 then
-                       @log.warn "\"#{pkg_name}\" package version is same with remote package version"
+                       @log.warn "Checked \"#{pkg_name}\" package version : it is same with remote package version"
                        return true
                when 1, 2 then
                end
@@ -588,7 +589,7 @@ class Client
 
     public
     # install local package (ignore dependent packages)
-    def install_local_pkg(pkg_path, trace, force, repos_path)
+    def install_local_pkg(pkg_path, trace, force, repos_path = nil)
 
                ret = install_local_pkg_internal(pkg_path, trace, force, repos_path)
                return ret
@@ -642,10 +643,10 @@ class Client
                if not force then
                        case compare_result
                        when -1 then
-                               @log.warn "installed \"#{pkg_name}\" package version is bigger.."
+                               @log.warn "Installed \"#{pkg_name}\" package version is bigger.."
                                return true
                        when 0 then
-                               @log.warn "\"#{pkg_name}\" package version is same with installed package version.."
+                               @log.warn "Checked \"#{pkg_name}\" package version : it is same with installed package version"
                                return true
                        when 1, 2 then
                        end
@@ -660,16 +661,22 @@ class Client
                        new_pkg_os = pkg.os
                        install_dep_pkgs.each do |p|
                                # check local path first
-                               binpkgs = Dir.glob("#{repos_path}/#{p.package_name}_*_#{new_pkg_os}.zip")
-                               if not binpkgs.empty? then
-                                       if not install_local_pkg_internal(binpkgs[0], true, false, repos_path) then
-                                               @log.warn "#{p} package is not installed"
+                               if not repos_path.nil? then
+                                       binpkgs = Dir.glob("#{repos_path}/#{p.package_name}_*_#{new_pkg_os}.zip")
+                                       if not binpkgs.empty? then
+                                               if not install_local_pkg_internal(binpkgs[0], true, false, repos_path) then
+                                                       @log.warn "#{p} package is not installed"
+                                               end
+                                       else                                            
+                                               if not install_internal(p.package_name, new_pkg_os, true, false) then
+                                                       @log.warn "#{p} package is not installed"
+                                               end
                                        end
-                               else
+                               else                                    
                                        if not install_internal(p.package_name, new_pkg_os, true, false) then
                                                @log.warn "#{p} package is not installed"
                                        end
-                               end
+                               end                                     
                        end
                end
 
@@ -1020,7 +1027,7 @@ class Client
             i = i + 1
         end
         
-        @log.info "Get install dependent packages for #{pkg_name} package.. OK"
+        @log.info "Get install dependent packages for \"#{pkg_name}\" package.. OK"
         if reverse then return result.reverse.uniq.push(pkg_name)
         else return result.uniq.insert(0, pkg_name) end
     end
@@ -1343,10 +1350,10 @@ class Client
         if not force then
             case compare_result
             when -1 then
-               @log.warn "\"#{pkg_name}\" package version is bigger then remote package version"
+               @log.warn "Checked \"#{pkg_name}\" package version : it is bigger then remote package version"
                return true
             when 0 then
-               @log.warn "\"#{pkg_name}\" package version is same with remote package version"
+               @log.warn "Checked \"#{pkg_name}\" package version : it is same with remote package version"
                return true
             end
         end
@@ -1362,27 +1369,20 @@ class Client
         # install package
                cached_filepath = nil
                if Utils.is_linux_like_os( Utils::HOST_OS ) then
-                       @log.info "Checking cached #{pkg_name} package file"                            
                        cached_filepath = get_cached_filepath(filename, pkg_checksum, pkg_size)
                end                     
                if not cached_filepath.nil? then
-                       @log.info "Installing #{pkg_name} package to [#{@location}] (using cached file)"
+                       @log.info "Cached #{pkg_name} package file.. OK"                                
             ret = FileInstaller.install(pkg_name, cached_filepath, type, @location, @log)
                else
-                       @log.info "Downloading #{pkg_name} package to [#{@tmp_path}]"                           
                        filepath = download(pkg_name, os, false, @tmp_path)
                        if filepath.nil? then
-                               @log.info "Failed to download #{pkg_name}"
                                return false
                        end                                     
-                       @log.info "Moving package file [#{@download_path}]"                             
                        filepath = move_downloaded_pkg(filepath[0], @download_path) 
                        if filepath.nil? then
-                               @log.info "Failed to move [#{filepath[0]}] to "
-                               @log.info "  [#{@download_path}]"
                                return false                            
                        end     
-                       @log.info "Installing #{pkg_name} package to [#{@location}]"                    
             ret = FileInstaller.install(pkg_name, filepath, type, @location, @log)
                        remove_downloaded_pkgs(pkg_name, os)                            
                end                     
@@ -1432,14 +1432,14 @@ class Client
         else pkg_hash[pkg_name] = get_pkg_from_list(pkg_name, os) end
         @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
 
-        @log.info "Added information for \"#{pkg_name}\" package.. OK"
+        #@log.info "Added information for \"#{pkg_name}\" package.. OK"
         return pkg_hash
     end
 
     private
     # add package manifest info
     def add_local_pkg_info(pkg_name)
-        
+
         config_path = File.join(@location, PACKAGE_INFO_DIR, "#{pkg_name}")
         pkg = read_pkginfo_file(pkg_name, config_path)
 
@@ -1456,7 +1456,7 @@ class Client
         else pkg_hash[pkg_name] = pkg end
         @installed_pkg_hash_loc[installed_pkg_hash_key] = pkg_hash
 
-        @log.info "Added information for \"#{pkg_name}\" package.. OK"
+        #@log.info "Added information for \"#{pkg_name}\" package.. OK"
         return pkg_hash
     end
 
index 98c81213c7fc3a74237370e2117f7bf6d1041557..7e5a8c885a626addaba5dc5806a0b1a6e9bb6cf5 100644 (file)
@@ -41,11 +41,12 @@ class FileDownLoader
 
         is_remote = Utils.is_url_remote(url)
         filename = url.split('/')[-1]
-
         fullpath = File.join(path, filename)
 
+               logger.info "Downloading #{url}"
         if is_remote then
             ret = Utils.execute_shell_with_log( "wget #{url} -O #{fullpath} -nv", logger )
+            #ret = Utils.execute_shell( "wget #{url} -O #{fullpath} -q")
         else
             if not File.exist? url then
                 logger.error "\"#{url}\" file does not exist"
@@ -56,6 +57,12 @@ class FileDownLoader
         end
 
         # need verify
+               if ret then
+                       logger.info "Downloaded #{filename}.. OK"
+               else 
+                       logger.info "Failed to download #{filename}"                    
+                       logger.info "  [dist: #{path}]"
+               end                             
         return ret
     end
 end
index 5c6790212f2840778356dc5d23738baa2c5142da..6571d7cf61bc9a3ac5fe125da8479ea0b6b787d6 100644 (file)
@@ -68,6 +68,8 @@ class FileInstaller
             end
 
             begin
+                               logger.info "Installing \"#{package_name}\" package.."
+                               logger.info "  [src: #{package_file_path}]"                                     
                 log = log + "##### extract file : #{package_file_path} #####\n"
                 log = log + extract_file(package_name, package_file_path, path, target_path, logger)
                                if not move_dir(package_name, path, target_path, logger) then
@@ -103,6 +105,8 @@ class FileInstaller
         end
 
         # need verify
+               logger.info "Installed \"#{package_name}\" package.. OK"
+               logger.info "  [dist: #{target_path}]"
         return true;
     end