[Title] Fixed a bug that reverse build + multi build does not install local packages
authordonghee yang <donghee.yang@samsung.com>
Fri, 7 Sep 2012 14:01:46 +0000 (23:01 +0900)
committerdonghee yang <donghee.yang@samsung.com>
Fri, 7 Sep 2012 14:01:46 +0000 (23:01 +0900)
src/build_server/BuildJob.rb
src/builder/Builder.rb
src/pkg_server/client.rb
test/b/b [deleted file]
test/b/package/build.linux [deleted file]
test/b/package/pkginfo.manifest [deleted file]
test/build-cli-01.testcase
test/build-cli-02.testcase
test/c/c [deleted file]
test/c/package/build.linux [deleted file]
test/c/package/pkginfo.manifest [deleted file]

index 7f193009dc1ce4e204afc147c6e5a3b077ea3443..f6a99b6ccaeef8cd83df6b2fefd8cb427dcee137 100644 (file)
@@ -636,7 +636,7 @@ class BuildJob
                        # if not found, check package server
                        ver_svr = nil
                        if not @parent.nil? then
-                               local_pkg = get_local_package_of_dependency( dep, @parent.source_path )
+                               local_pkg = get_local_path_of_dependency( dep, @parent )
                                if not local_pkg.nil? then
                                        ver_svr = Utils.get_version_from_package_file( local_pkg )
                                else
@@ -805,12 +805,8 @@ class BuildJob
                if not @parent.nil? then
                        use_clean = false
                        # get local packages to install
-                       src_path = @parent.source_path
                        deps = @pkginfo.get_build_dependencies(@os)
-                       deps.each do |dep|
-                               pkgs = get_local_required_packages( dep, src_path )
-                               local_pkgs += pkgs
-                       end
+                       local_pkgs += get_local_paths_of_chained_dependencies( deps, @parent )
                end
                local_pkgs.uniq!
 
@@ -1107,16 +1103,16 @@ class BuildJob
        end
 
 
-       def get_local_package_of_dependency( dep, src_path )
-               # use the target os if not specified
-               if dep.target_os_list.count != 0 then
-                       dep_target_os = dep.target_os_list[0]
-               else
-                       dep_target_os = @os
+       protected
+       def get_local_path_of_dependency( dep, parent )
+               dep_target_os = get_os_of_dependency(dep)
+
+               # search my parent job and its parent job 
+               binpkgs = Dir.glob("#{parent.source_path}/#{dep.package_name}_*_#{dep_target_os}.zip")
+               if binpkgs.count == 0 and not parent.get_parent_job().nil? then
+                       binpkgs = Dir.glob("#{parent.get_parent_job().source_path}/#{dep.package_name}_*_#{dep_target_os}.zip")
                end
 
-               # search 
-               binpkgs = Dir.glob("#{src_path}/#{dep.package_name}_*_#{dep_target_os}.zip")
                if binpkgs.count > 0 then
                        pkg = binpkgs[0]
                        version = Utils.get_version_from_package_file(pkg)
@@ -1131,56 +1127,63 @@ class BuildJob
        end
 
 
-       def get_local_required_packages( dep, src_path )
-               pkgs = []
+       protected
+       def get_local_paths_of_chained_dependencies( deps, parent )
+               pkg_paths = []
 
-               # use the target os if not specified
-               if dep.target_os_list.count != 0 then
-                       dep_target_os = dep.target_os_list[0]
-               else
-                       dep_target_os = @os
-               end
+               # get packages names that is related my build dependency
+               chained_deps = get_local_chained_dependencies( deps, parent )
+
+               # get all local path of dependencies
+               chained_deps.each { |dep|
+                       new_path = get_local_path_of_dependency(dep, parent)
+                       if not new_path.nil? then
+                               pkg_paths.push new_path
+                       end
+               }
+
+               # remove duplicates
+               pkg_paths.uniq!
+
+               return pkg_paths
+       end
+
+
+       protected
+       def get_local_chained_dependencies( deps, parent )
+
+               chained_deps = []
+               chained_deps += deps
+       
+               # if parent is multi build job, gether all install dependency of dependency.    
+               if parent.type == "MULTIBUILD" then
+                       begin
+                               old_deps_count = chained_deps.count
+                               new_deps = []
+                               chained_deps.each { |dep|
+                                       dep_target_os = get_os_of_dependency(dep)
 
-               pkg_names = [ dep.package_name ] 
-               if not @parent.nil? and @parent.type == "MULTIBUILD" then
-                       old_count = 0
-                       while pkg_names.count != old_count
-                               old_count = pkg_names.count
-                               new_names = []
-                               pkg_names.each { |p|
-                                       @parent.sub_jobs.each { |j| 
-                                               new_names += j.pkginfo.get_install_dependencies(dep_target_os, p).map {|d| d.package_name}
+                                       parent.sub_jobs.each { |j| 
+                                               new_deps += j.pkginfo.get_install_dependencies(dep_target_os, dep.package_name)
                                        }
                                }
-                               pkg_names += new_names
-                               pkg_names.uniq!
-                       end
+                               chained_deps += new_deps
+                               chained_deps.uniq! {|d| d.package_name }
+                       end while chained_deps.count != old_deps_count
                end
 
-               # search
-               pkg_names.each { |pkg_name|
-                       binpkgs = Dir.glob("#{src_path}/#{pkg_name}_*_#{dep_target_os}.zip")
-                       if binpkgs.count > 0 then
-                               pkg = binpkgs[0]
-                               if pkg_name == dep.package_name then
-                                       version = Utils.get_version_from_package_file(pkg)
-                                       if not dep.match? version then return [] end
-                               end
-                               pkgs.push pkg
-                       end
-               }
+               # check parent of parent
+               if not parent.get_parent_job().nil? then
+                       chained_deps = get_local_chained_dependencies(chained_deps, parent.get_parent_job())
+               end
 
-               return pkgs
+               return chained_deps
        end
 
 
+       protected
        def remote_package_of_dependency_exist?(dep)
-               # use the target os if not specified
-               if dep.target_os_list.count != 0 then
-                       dep_target_os = dep.target_os_list[0]
-               else
-                       dep_target_os = @os
-               end
+               dep_target_os = get_os_of_dependency(dep)
 
                # search 
                ver_svr = @pkgsvr_client.get_attr_from_pkg( dep.package_name, dep_target_os, "version")
@@ -1192,7 +1195,7 @@ class BuildJob
 
 
        # write web url for log
-       private
+       protected
        def write_log_url()
                url,remote_url = get_log_url()
                if not url.empty? then
@@ -1202,4 +1205,17 @@ class BuildJob
                        @log.info( " ** Log2: #{remote_url}", Log::LV_USER)
                end
        end
+
+
+       # get target os of dependency
+       protected
+       def get_os_of_dependency(dep)
+               # use the target os if not specified
+               if dep.target_os_list.count != 0 then
+                       dep_target_os = dep.target_os_list[0]
+               else
+                       dep_target_os = @os
+               end
+       end
+       
 end
index 37ba8f2b98b4bd54e34a0253d74cfa04e4424a7e..844445c5aa44e6cdd14cee97065e5bbc0aa863e3 100644 (file)
@@ -197,6 +197,13 @@ class Builder
                        cl.clean(true)
                end
 
+               # get local repository path list
+               repos_paths = []
+               local_pkgs.each { |path| 
+                       repos_paths.push File.dirname(path)
+               }
+               repos_paths.uniq!
+
                # install build dependencies
                @log.info( "Installing dependent packages...", Log::LV_USER)
                pkginfo.get_build_dependencies( os ).each do |dep|
@@ -223,7 +230,7 @@ class Builder
                                        if not File.exist? l then
                                                @log.error( "File not found!: #{l}", Log::LV_USER )
                                        end
-                       cl.install_local_pkg(l,true,false,File.dirname(l))
+                       cl.install_local_pkg(l,true,false, repos_paths)
                                end
                        end
                end
index 73c91a89f17fc1ba958e1f16125e149a63e33236..a7e203475900b424b01466d944f47d822fc43381 100644 (file)
@@ -592,15 +592,15 @@ class Client
 
     public
     # install local package (ignore dependent packages)
-    def install_local_pkg(pkg_path, trace, force, repos_path = nil)
+    def install_local_pkg(pkg_path, trace, force, repos_paths = nil)
 
-               ret = install_local_pkg_internal(pkg_path, trace, force, repos_path)
+               ret = install_local_pkg_internal(pkg_path, trace, force, repos_paths)
                return ret
        end
 
 
     private
-    def install_local_pkg_internal(pkg_path, trace, force, repos_path)
+    def install_local_pkg_internal(pkg_path, trace, force, repos_paths)
 
         file_name = File.basename(pkg_path)
         pkg_name = file_name.split('_')[0]
@@ -664,10 +664,14 @@ class Client
                        new_pkg_os = pkg.os
                        install_dep_pkgs.each do |p|
                                # check local path first
-                               if not repos_path.nil? then
-                                       binpkgs = Dir.glob("#{repos_path}/#{p.package_name}_*_#{new_pkg_os}.zip")
+                               if not repos_paths.nil? then
+                                       # search
+                                       binpkgs = []
+                                       repos_paths.each { |repos_path|
+                                               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
+                                               if not install_local_pkg_internal(binpkgs[0], true, false, repos_paths) then
                                                        @log.warn "#{p} package is not installed"
                                                end
                                        else                                            
diff --git a/test/b/b b/test/b/b
deleted file mode 100644 (file)
index 6178079..0000000
--- a/test/b/b
+++ /dev/null
@@ -1 +0,0 @@
-b
diff --git a/test/b/package/build.linux b/test/b/package/build.linux
deleted file mode 100755 (executable)
index 83e5a6c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash  -e
-
-clean ()
-{
-    rm -rf $SRCDIR/*.zip
-    rm -rf $SRCDIR/*.tar.gz
-}
-
-build()
-{
-    if [ "`cat $ROOTDIR/c`" = "ca" ] 
-    then 
-        echo "B: `cat $ROOTDIR/c` == ca ... ok"
-    else
-        echo "B: `cat $ROOTDIR/c` != ca ... fail"
-        exit 1
-    fi
-}
-
-install()
-{
-    mkdir -p $SRCDIR/package/b.package.linux/data
-    cp $SRCDIR/b $SRCDIR/package/b.package.linux/data
-}
-
-$1
-echo "$1 success"
diff --git a/test/b/package/pkginfo.manifest b/test/b/package/pkginfo.manifest
deleted file mode 100644 (file)
index a164fd8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-Package: b
-Version: 11
-OS: linux
-Maintainer: xxx
-Build-host-os: linux
-Build-dependency: c [linux]
-Source: b
index 90959a7ef9227567212e4e6ae2aa3cfea2825458..f3c8c50055001d4078d269b1bc37c4c36058b330 100644 (file)
@@ -5,7 +5,7 @@
 #EXPECT
 Requiest service to build-server command-line tool.
 
-Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli -h
+Usage: build-cli <SUBCOMMAND> [OPTS] or build-cli (-h|-v)
 
 Subcommands:
 build         Build and create package.
@@ -32,7 +32,6 @@ Options:
 -d, --address <server address>   build server address: 127.0.0.1:2224
 -o, --os <operating system>      target operating system: ubuntu-32/ubuntu-64/windows-32/windows-64/macos-64
 --async                      asynchronous job
---noreverse                  do not check reverse build
 -j, --job <job number>           job number
 -w, --passwd <password>          password for managing project
 -P, --pkg <package file>         package file path
index a3c6a3e23fb65c0d62d356313e24211b40ca8d01..4b13c124e78566e61177c4048ef83690fec3bdf7 100644 (file)
@@ -15,6 +15,9 @@ FTP_USERNAME:
 ubuntu-32
 windows-32
 
+* FRIEND SERVER LIST (WAIT|WORK/MAX) jobs [transfer count] *
+
+
 * PROJECT(S) *
 testa                     NORMAL
 testa1                    NORMAL
diff --git a/test/c/c b/test/c/c
deleted file mode 100644 (file)
index 16fc679..0000000
--- a/test/c/c
+++ /dev/null
@@ -1 +0,0 @@
-ca
diff --git a/test/c/package/build.linux b/test/c/package/build.linux
deleted file mode 100755 (executable)
index b774e2d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash  -e
-
-clean ()
-{
-    rm -rf $SRCDIR/*.zip
-    rm -rf $SRCDIR/*.tar.gz
-}
-
-build ()
-{
-    echo "C: clean build (no dependency) ok"
-}
-
-install ()
-{
-    mkdir -p $SRCDIR/package/c.package.linux/data
-    cp $SRCDIR/c $SRCDIR/package/c.package.linux/data
-}
-
-$1
-echo "$1 success"
diff --git a/test/c/package/pkginfo.manifest b/test/c/package/pkginfo.manifest
deleted file mode 100644 (file)
index ede7a91..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Package: c
-Version: 11
-OS: linux
-Build-host-os: linux
-Maintainer: xx
-Source: c