[softwaremgmt] python/libzypp: query source repo of installed packages
wanna make a package stat - how many packages are currently installed from a given source: how can I * query for all installed packages * the source a package has been installed from 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-python-...). 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 -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
On Monday 04 May 2009 02:28:02 Elmar Stellnberger wrote:
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.
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@novell.com 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@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
Michael Andres schrieb:
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
* Elmar Stellnberger <estellnb@yahoo.de> [May 05. 2009 17:06]:
What if I wanna parse /var/log/zypp/history myself?
Should be rather easy, its a line of '|' separated values. See http://en.opensuse.org/Libzypp/Package_History for a detailed documentation of the various fields.
The log contains the 'repo alias' as used in zypper.
May I also directly extract this info from a file without having to use any special library?
Sure. It was one of the design criteria to have an easily parseable history log. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
Klaus Kaempf schrieb:
Unfortunately the data in the history file contains a few errors:
i.e. the line of transfig has been merged with the line of ralias. It is the same for another package; i.e. libotr Perhaps I should file a bug report on this.
-- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
On Wednesday 06 May 2009 15:00:44 Elmar Stellnberger wrote:
According to the git logs, this is already fixed (Jan 26 2009). "ralias" and "rurl" entries missed a trailing newline. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com 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@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
* Elmar Stellnberger <estellnb@yahoo.de> [May 06. 2009 14:01]:
Please do. The history log is new in OpenSUSE 11.1 and we don't have the tools to use it to its full potential yet. Thus errors in the history might escape undetected. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
On Wednesday 06 May 2009 15:15:56 Klaus Kaempf wrote:
As I wrote before, it's already fixed. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com 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@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
What about the ominous repo-repo?
I have never added such a repo and repo-repo is as well not displayed by 'zypper repos'. According to the history file almost 300 packages have been drawn from this fake repo, which points to an invalid URL namely file:/usr/src/packages/BUILD/openSUSE-images-11.1/gnome_cd-x11/home/rpmdir. Is this an error of zypper? What shell repo-repo stand for and where does it come from? Klaus Kaempf schrieb:
-- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
* Elmar Stellnberger <estellnb@yahoo.de> [Jun 08. 2009 17:24]:
The path looks like a SUSE internal directory used for ISO creation. So this repo might be your install media. It looks like a history bug to me. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
On Monday 15 June 2009 15:23:58 Klaus Kaempf wrote:
Well, the history file seems to be included in the deployed image, and probably shows how the image was created. If the information is reliable, the repo alias should be more descriptive and maybe the repo should also be deleted at the end. Otherwise we should delete the history. I filed https://bugzilla.novell.com/show_bug.cgi?id=513486 for this. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com 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@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
Michael Andres schrieb:
What kind of image? Do you mean the initial set of preinstalled packages from the initial system installation? That sounds quite convincing since all installations on the beginning and only at the beginning of zypp/history show up with repo-repo. In deed all these packages can be found on the DVD. Perhaps we should mention repo-repo at the official zypp/history description. -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
On Wednesday 17 June 2009 22:22:47 Elmar Stellnberger wrote:
Yes, the initial installation from DVD uses prepared images to speed up installation. You can find them in the /images directory on the media. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com 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@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
* Michael Andres <ma@suse.de> [May 05. 2009 12:24]:
The satsolver provide an alternative for simple package operations. A simple example would be import satsolver pool = satsolver.Pool() pool.set_arch("i686") repo = pool.add_rpmdb( "/" ) print repo.size(), " installed packages" for s in pool: print s, s.vendor() (see sat-solver/bindings/python/tests/rpmdb.py http://git.opensuse.org/?p=projects/zypp/sat-solver.git;a=blob_plain;f=bindi...)
Actually, I question the value of this information because of mirrors. The package origin, usually covered in the package vendor and its signing key, is more valuable. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
Klaus Kaempf schrieb:
Does this code simply query the vendor tag of installed rpms? .. or does it use the info from /var/log/zypp/history or any other source? -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
* Elmar Stellnberger <estellnb@yahoo.de> [May 05. 2009 17:08]:
Does this code simply query the vendor tag of installed rpms? .. or does it use the info from /var/log/zypp/history or any other source?
The libsatsolver only operates on .solv files and the rpm database, it does not use /var/log/zypp/history Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-softwaremgmt+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
On Tuesday 05 May 2009 20:17:14 Klaus Kaempf wrote:
Same for libzypp. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com 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@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
On Tuesday 05 May 2009 12:23:54 Michael Andres wrote:
Jano, I apologize! I found a HistoryLogReader in zypp. I'll see how to add it to the bindings. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com 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@opensuse.org For additional commands, e-mail: opensuse-softwaremgmt+help@opensuse.org
participants (3)
-
Elmar Stellnberger
-
Klaus Kaempf
-
Michael Andres