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 |
-- |
33 |
gentoo-portage-dev@g.o mailing list |