# 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
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!
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)
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")
# write web url for log
- private
+ protected
def write_log_url()
url,remote_url = get_log_url()
if not url.empty? then
@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
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]
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