Commit b5aad973 authored by Daniel P. Gettings's avatar Daniel P. Gettings Committed by Ed Reel

Faster dep checks (#3106)

* Check package dependencies more efficiently

Keep track of the names of dependencies that have already been checked
in the expand_dependencies/push_dependencies loop. A quick and dirty way
to break out of dependency cycles and speed up the dependency resolution
step in general.

* Simplify the logic of dependency checking in expand_dependencies

Accomplishes the same goal without needing to explicitly keep a list of
previously-checked dependencies.
parent 511d3b76
......@@ -633,36 +633,28 @@ end
def expand_dependencies
@dependencies = []
def push_dependencies
if @pkg.is_binary?(@device[:architecture]) ||
(!@pkg.in_upgrade && !@pkg.build_from_source && @device[:installed_packages].any? { |pkg| pkg[:name] == @pkg.name })
# retrieve name of dependencies that doesn't contain :build tag
check_deps = @pkg.dependencies.select {|k, v| !v.include?(:build)}.map {|k, v| k}
elsif @pkg.is_fake?
# retrieve name of all dependencies
check_deps = @pkg.dependencies.map {|k, v| k}
else
# retrieve name of all dependencies
check_deps = @pkg.dependencies.map {|k, v| k}
end
# remove a dependent package which is equal to the target
check_deps.select! {|name| @pkgName != name}
# add new dependencies at the beginning of array
@dependencies = check_deps.clone.concat(@dependencies)
# check all dependencies recursively
check_deps.each do |dep|
search dep, true
push_dependencies
# build unique dependencies list
unless @dependencies.include?(dep) || dep == @pkgName
@dependencies << dep
search dep, true
push_dependencies
end
end
end
push_dependencies
@dependencies.uniq
# resolve_dependencies needs expand_dependencies to return @dependencies
return @dependencies
end
def resolve_dependencies
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment