Skip to content

Commit

Permalink
Preload all data into @db when using pkgng
Browse files Browse the repository at this point in the history
Issue:	#41
  • Loading branch information
bdrewery committed Jul 17, 2013
1 parent 6a6800c commit 29b512f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/pkgtools/pkgdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,35 @@ def update_db(force = false)
STDERR.printf '[%s the pkgdb <format:%s> in %s ... ',
rebuild ? 'Rebuilding' : 'Updating', @db_driver, db_dir

if with_pkgng?
@installed_pkgs = []
@installed_ports = []
@db = {}
pkg_origins = xbackquote(PkgDB::command(:pkg), 'query', '%n-%v %o').split("\n")
pkg_origins.each do |line|
pkg, origin = line.split(' ')
@installed_pkgs << pkg
add_origin(pkg, origin)
end
@installed_pkgs.freeze

STDERR.printf "- %d packages found ", @installed_pkgs.size

@installed_ports.uniq!
@installed_ports.sort!

@db[':mtime'] = Marshal.dump(Time.now)
@db[':origins'] = @installed_ports.join(' ')
@db[':pkgnames'] = @installed_pkgs.join(' ')
@db[':db_version'] = Marshal.dump(DB_VERSION)

STDERR.puts " done]"

mark_fixme

return true
end

@installed_pkgs = installed_pkgs!.freeze

try_again = false
Expand Down

0 comments on commit 29b512f

Please sign in to comment.