Class: Ports::PortTree

Inherits:
Object
  • Object
show all
Defined in:
lib/port_upgrade.rb

Instance Method Summary collapse

Constructor Details

#initialize(pdb, path = nil) ⇒ PortTree

Returns a new instance of PortTree.



68
69
70
71
72
73
# File 'lib/port_upgrade.rb', line 68

def initialize(pdb,path=nil)
  @path=path
  @edges_seen = []
  @pdb = pdb
  traverse_receipts
end

Instance Method Details

#dump_seq(outdated) ⇒ Object



102
103
104
# File 'lib/port_upgrade.rb', line 102

def dump_seq(outdated)
  #setup_remports(outdated) unless outdated.nil?
end

#dump_treeObject



86
87
88
89
90
91
92
# File 'lib/port_upgrade.rb', line 86

def dump_tree
  ports = nil
  @pdb.db.query("select port,variant from ports order by port") do |results|
    ports = results.to_a
  end
  ports
end

#installedObject



94
95
96
97
98
99
100
# File 'lib/port_upgrade.rb', line 94

def installed
  ports = nil
  @pdb.db.query("select port from ports order by port") do |results|
    ports = results.to_a.flatten
  end
  ports
end

#receipt_pathObject



83
84
85
# File 'lib/port_upgrade.rb', line 83

def receipt_path
  @path || RECEIPT_PATH
end

#setup_remports(outdated) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/port_upgrade.rb', line 106

def setup_remports(outdated)
  begin
    @pdb.db.execute("drop table remports")
  rescue SQLite3::SQLException
  end
  @pdb.db.execute("create table remports(port text, dep text)")
  @pdb.db.execute("create unique index remportsdep on remports(port,dep)")
  outdated.each do |a|
    parents = get_parent_pairs(a)
    begin
      parents.each do |p|
        @pdb.db.execute("insert or ignore into remports values(\"#{p.port}\",\"#{p.dep}\")")
      end
    rescue SQLite3::SQLException => exp
      $stderr.puts "Dup insert into remports:  #{exp}}" if $DEBUG
    end
    @pdb.db.execute("insert or ignore into remports values(\"#{a}\",\"\")")
  end
  #@pdb.db.execute('delete from remports where port="gimp-app" and dep="gimp"')
  #File.open("remtree.dot",'w') do |f|
  #  pt = table_to_tree('remports','remports','port','port','dep')
  #  f.write(pt.to_dot)
  #end
end

#sizeObject



75
76
77
78
79
80
81
# File 'lib/port_upgrade.rb', line 75

def size
  s=nil
  @pdb.db.query("select count(*) from ports") do |results|
    s = results.first[0].to_i
  end
  return s
end