Gentoo Archives: gentoo-portage-dev

From: Tom Hosiawa <tomek32@×××××.com>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] accessing portage updates through it's data structures
Date: Tue, 18 Apr 2006 23:18:12
Message-Id: c12dd7080604181618h6ea9ad5dyb7a2ae4a82ddd0e0@mail.gmail.com
In Reply to: Re: [gentoo-portage-dev] accessing portage updates through it's data structures by Tom Hosiawa
1 > > > Anybody have any ideas how I can basically do 'emerge -puDNv' directly
2 > > > from my superkaramba python program, and get the updates available
3 > > > directly from the portage data structures?
4 > >
5 > > What is needed for -uDNv is mostly locked away in emerge, unfortunately.
6 > > The following couple of lines should get you everything other than --newuse
7 > > though. As you only seem to be interested in what packages are available
8 > > for updating, the ordering shouldn't really matter.
9 > >
10 > >
11 > > import portage
12 > >
13 > > pdb = portage.db["/"]["porttree"].dbapi
14 > > vdb = portage.db["/"]["vartree"].dbapi
15 > >
16 > > installed_pkgs = dict([(key, vdb.match(key)) for key in vdb.cp_all()])
17 > > latest_pkgs = dict([(key, portage.best(pdb.match(key))) for key in installed_pkgs])
18 > > updatable_pkgs = [latest_pkgs[key] for key in latest_pkgs if latest_pkgs[key] not in installed_pkgs[key]]
19 > > updatable_pkgs = [pkg for pkg in updatable_pkgs if pkg]
20 > >
21 > >
22 > > That last line there is to kill off the None elements that end up in
23 > > updatable_pkgs when there is a package installed that has no versions
24 > > available in the rsync tree. Other than that, portage.catpkgsplit() will
25 > > split a package identifier into [cat, pkg, ver, rev].
26 >
27 > Thanks, I'll need more flexibility thoough. I'll just strip down
28 > emerge for what I need and include it with my program.
29 > --
30 > Tom
31
32 After doing some testing, I just noticed one can't check world updates
33 in a regular account (non root). Funny thing is, emerge doesn't report
34 that it can't, it just gives a partial list of what's actually
35 available if it's done under root.
36
37 Is this by design or a bug?
38 --
39 Tom
40
41 --
42 gentoo-portage-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-portage-dev] accessing portage updates through it's data structures Tom Hosiawa <tomek32@×××××.com>