-
Notifications
You must be signed in to change notification settings - Fork 0
/
port_upgrade.rb
executable file
·47 lines (45 loc) · 1.4 KB
/
port_upgrade.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env ruby
#
# port_upgrade.rb: Main PortUpgrade class and command line interface code.
#
# ====================================================================
# Copyright (c) 2008 Tony Doan <tdoan@tdoan.com>. All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://github.com/tdoan/port_upgrade/tree/master/COPYING.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
# ====================================================================
#
require "rubygems"
require "sqlite3"
require "yaml"
require File.dirname(__FILE__) + "/lib/ports_helpers.rb"
include Ports
def choose_variant(portname,variants)
answer=false
while(!answer)
$stderr.puts "Please choose from list:"
variants.each_with_index{|v,i| $stderr.puts "#{i}: #{v=="" ? "(none)" : v}"}
$stderr.print "> "
reply = $stdin.gets
clean = (reply.strip =~ /-?[0-9]+/)
if (clean == 0)
answer = true
else
$stderr.puts "ERROR, try again."
end
end
return reply.to_i
end
if __FILE__ == $PROGRAM_NAME
path = nil
path = ARGV[0] unless ARGV.size < 1
pdb = PortsDB.new(path)
#puts pdb.outdated
to_remove = pdb.to_remove
$stderr.puts "#{to_remove.size} ports to remove: #{to_remove.join(',')}"
pdb.upgrade
pdb.close
end