Mailinglist Archive: opensuse-softwaremgmt (36 mails)

< Previous Next >
Re: [softwaremgmt] python/libzypp: query source repo of installed packages
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Tue, 5 May 2009 12:23:54 +0200
  • Message-id: <200905051223.54697.ma@xxxxxxx>
On Monday 04 May 2009 02:28:02 Elmar Stellnberger wrote:
wanna make a package stat - how many packages are currently installed
from a given source:
how can I
* query for all installed packages

Z = zypp.ZYppFactory_instance().getZYpp()
Z.initializeTarget( zypp.Pathname("/") )
Z.target().load();

for item in Z.pool():
if not item.status().isInstalled():
continue

print "%s:%s-%s.%s\t(%s)" % ( item.kind(),
item.name(),
item.edition(),
item.arch(),
item.repoInfo().alias() )
if zypp.isKindPackage( item ):
print " Group: %s" %(zypp.asKindPackage( item ).group( ) )


(see also examples/python/list_resolvables.py)


* the source a package has been installed from

You could try to lookup the package in /var/log/zypp/history. The 'install'
entry lists at least the alias of the repo the package came from.

2009-05-04 12:07:39|install|xteddy|2.0.1-40.126|i586|root@Fibonacci|
repo-oss|ab35dda25455d04f872ad4bceba72b7aef621195

Unfortunately there seems to be no reader interface for the history file in
libzypp. I suppose Jano implemented the reader for zypper only. There are
HistoryItem datastructures, but I don't see methods to recreate them from the
loglines. Nor any convenience to (reverse) iterate the history file. Maybe
Jano has some code that can be moved to libzypp, so we could offer a history
reader in zypp and also the bindings.

via python

Have found some doc about python/libzypp, but it does not tell me how to
query for the package source of an inst. pkg
(http://lizards.opensuse.org/2008/10/03/developing-with-libyuilibzypp-pytho
n-part3/).

Besides this I have found some promising C++ code which I however could
not translate to python (methods/obj do not seem to exist in
/usr/lib64/python2.6/site-packages/zypp.py): http://pastebin.com/m3d26a44

The code won't help you. Look at the 'item.repoInfo().alias()' output in the
above example. An installed packages repository is the '@system' repository,
aka the rpm database, an not the repository package was installed from.

--

cu,
Michael Andres

+------------------------------------------------------------------+
Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4
+------------------------------------------------------------------+
Michael Andres YaST Development ma@xxxxxxxxxx
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0
+------------------------------------------------------------------+

--
To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-softwaremgmt+help@xxxxxxxxxxxx

< Previous Next >
List Navigation
References