Created
June 7, 2009 09:10
-
-
Save nagachika/125252 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outdated = `port outdated`.split("¥n") | |
if /No installed ports are outdated./ =~ outdated[0] | |
puts outdated[0] | |
exit 0 | |
end | |
unless /The following installed ports are outdated:/ =~ outdated[0] | |
$stderr.puts "port outdated failed, maybe..." | |
$stderr.puts *outdated | |
exit 1 | |
end | |
outdated.shift | |
outdated.map!{|l| l.split(/¥s/,2).first } | |
ports = {} | |
outdated.each{|port| | |
ports[port] = `port deps #{port}`.split("¥n").select do |l| | |
/^¥t/ =~ l | |
end.map{|l| l.split("¥t")[1]} | |
} | |
nodeps = ports.select do |port, deps| | |
not deps.any?{|dp| ports.include?(dp)} | |
end | |
nodeps = nodeps.map{|ndp| ndp[0] } | |
if nodeps.empty? | |
puts "Program Logic Error: no outdated port." | |
exit 1 | |
end | |
puts "upgrade deps #{nodeps.join(" ")}" | |
system("sudo port -fun upgrade #{nodeps.join(" ")}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment