1 |
On Tuesday 18 April 2006 13:20, Tom Hosiawa wrote: |
2 |
> Anybody have any ideas how I can basically do 'emerge -puDNv' directly |
3 |
> from my superkaramba python program, and get the updates available |
4 |
> directly from the portage data structures? |
5 |
|
6 |
What is needed for -uDNv is mostly locked away in emerge, unfortunately. |
7 |
The following couple of lines should get you everything other than --newuse |
8 |
though. As you only seem to be interested in what packages are available |
9 |
for updating, the ordering shouldn't really matter. |
10 |
|
11 |
|
12 |
import portage |
13 |
|
14 |
pdb = portage.db["/"]["porttree"].dbapi |
15 |
vdb = portage.db["/"]["vartree"].dbapi |
16 |
|
17 |
installed_pkgs = dict([(key, vdb.match(key)) for key in vdb.cp_all()]) |
18 |
latest_pkgs = dict([(key, portage.best(pdb.match(key))) for key in installed_pkgs]) |
19 |
updatable_pkgs = [latest_pkgs[key] for key in latest_pkgs if latest_pkgs[key] not in installed_pkgs[key]] |
20 |
updatable_pkgs = [pkg for pkg in updatable_pkgs if pkg] |
21 |
|
22 |
|
23 |
That last line there is to kill off the None elements that end up in |
24 |
updatable_pkgs when there is a package installed that has no versions |
25 |
available in the rsync tree. Other than that, portage.catpkgsplit() will |
26 |
split a package identifier into [cat, pkg, ver, rev]. |
27 |
|
28 |
-- |
29 |
Jason Stubbs |
30 |
-- |
31 |
gentoo-portage-dev@g.o mailing list |