Michael Andres schrieb:
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.
What if I wanna parse /var/log/zypp/history myself? 2008-12-09 21:42:08|install|translation-update|10.3-46.41|noarch| root@build23|repo|3b64255a6e035a146d9da1fc6584133dbba5c81c i.e. date|install|package.name|version|target/arch|?|?|? Where can I find the repo tag? How do I resolve the repo tag in order to get what would be put into the Alias or Name column of zypper lr? May I also directly extract this info from a file without having to use any special library? -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org