Skip to content

Instantly share code, notes, and snippets.

@nagachika
Created June 7, 2009 09:10
Show Gist options
  • Save nagachika/125252 to your computer and use it in GitHub Desktop.
Save nagachika/125252 to your computer and use it in GitHub Desktop.
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