Change crew to upgrade packages belong to the dependency order

parent dc95d1c2
......@@ -299,8 +299,25 @@ def upgrade
puts "#{@pkg.name} is already up to date.".lightgreen
end
else
toBeUpdated = []
# Make a installed packages list belong to the dependency order
dependencies = []
@device[:installed_packages].each do |package|
# skip package if it is dependent other packages previously checked
next if dependencies.include? package[:name]
# add package itself
dependencies = [ package[:name] ].concat(dependencies)
# expand depencencies and add it to the dependencies list
search package[:name], true
exp_dep = expand_dependencies
dependencies = exp_dep.concat(dependencies)
end
dependencies.uniq!
# Check version number of installed package and make a target list
toBeUpdated = []
dependencies.each do |dep|
package = @device[:installed_packages].find {|pkg| pkg[:name] == dep}
next unless package
search package[:name], true
if package[:version] != @pkg.version
toBeUpdated.push(package[:name])
......
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