[zypp-devel] List unnecessary dependencies

Hi guys, zypp has recently added support for removing any unnecessary dependencies associated with a package the user removed: zypp::getZYpp()->resolver()->setCleandepsOnRemove(true); I wonder if you can use this feature retroactively? That is, to remove all loose dependencies -- those being defined as a package installed by the solver (not by explicit user install), and that is not a requisite of any other installed package. It would be especially cool to get those unneeded packages in the form of a list. Thanks, Ricardo ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

Hi there, So, another approach would be to manually do something like: l = [] for p in pool: if p.installedBySolver(): needed = False for q in pool: if q.requires (p): needed = True break if not needed: l.append (p) Is there some p.installedBySolver() method though? If not, is there a cheaper way to implement then, than digging up the respective log in parser::HistoryLogReader. Thanks, Ricardo Quoting "Ricardo Cruz" <rpmcruz@alunos.dcc.fc.up.pt>:
Hi guys,
zypp has recently added support for removing any unnecessary dependencies associated with a package the user removed: zypp::getZYpp()->resolver()->setCleandepsOnRemove(true);
I wonder if you can use this feature retroactively? That is, to remove all loose dependencies -- those being defined as a package installed by the solver (not by explicit user install), and that is not a requisite of any other installed package.
It would be especially cool to get those unneeded packages in the form of a list.
Thanks, Ricardo
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

Hi there, So, another approach would be to manually do something like: l = [] for p in pool: if p.installedBySolver(): needed = False for q in pool: if q.requires (p): needed = True break if not needed: l.append (p) Is there some p.installedBySolver() method though? If not, is there a cheaper way to implement then, than digging up the respective log in parser::HistoryLogReader. Thanks, Ricardo Quoting "Ricardo Cruz" <rpmcruz@alunos.dcc.fc.up.pt>:
Hi guys,
zypp has recently added support for removing any unnecessary dependencies associated with a package the user removed: zypp::getZYpp()->resolver()->setCleandepsOnRemove(true);
I wonder if you can use this feature retroactively? That is, to remove all loose dependencies -- those being defined as a package installed by the solver (not by explicit user install), and that is not a requisite of any other installed package.
It would be especially cool to get those unneeded packages in the form of a list.
Thanks, Ricardo
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
-- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

Hi there, I was coding a python test case for this, but I can't seem to be able to initialize zypp with the local RPM database. import zypp _zypp = zypp.ZYppFactory_instance().getZYpp() _target = _zypp.initializeTarget(zypp.Pathname(" ? ")) (...) _pool = _zypp.pool() print "pool size:", _pool.size() # zero :-( What string should I pass to _zypp.initializeTarget() ? I have tried to dig up yast2 code on this, but couldn't pin down where initialization of the local database gets done, and other sources weren't more successful. Thanks, Ricardo Quoting "Ricardo Cruz" <rpmcruz@alunos.dcc.fc.up.pt>:
Hi there,
So, another approach would be to manually do something like:
l = [] for p in pool: if p.installedBySolver(): needed = False for q in pool: if q.requires (p): needed = True break if not needed: l.append (p)
Is there some p.installedBySolver() method though?
If not, is there a cheaper way to implement then, than digging up the respective log in parser::HistoryLogReader.
Thanks, Ricardo
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

On Wednesday 08 September 2010 16:01:36 Ricardo Cruz wrote:
Hi there,
I was coding a python test case for this, but I can't seem to be able to initialize zypp with the local RPM database.
import zypp _zypp = zypp.ZYppFactory_instance().getZYpp() _target = _zypp.initializeTarget(zypp.Pathname(" ? ")) (...) _pool = _zypp.pool() print "pool size:", _pool.size() # zero :-(
What string should I pass to _zypp.initializeTarget() ?
The root of your system. Usually '/', unless you use --root.
I have tried to dig up yast2 code on this, but couldn't
Yast is too confuising ;). Try zypper or some of the tests/examples in the libzypp git.
pin down where initialization of the local database gets done, and other sources weren't more successful.
See the attached example. Slightly modified from git://gitorious.org/opensuse/libzypp-bindings.git (examples/python). Beware, the examples are pretty outdated but at least list_resolvables works. (patches/suggestions are wellcome ;) I added an onSystemByUser call as you asked for some 'p.installedBySolver' in the previous mail. Since libzypp-7.5.0: + /** Whether this is known to be installed on behalf of a user request. + * \note This is a hint guessed by evaluating an available install history. + * Returns \c false for non-system (uninstalled) solvables, or if no history + * is available. + */ + bool onSystemByUser() const; -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres ZYPP Development ma@suse.de SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+

Quoting "Michael Andres" <ma@suse.de>:
On Wednesday 08 September 2010 16:01:36 Ricardo Cruz wrote:
What string should I pass to _zypp.initializeTarget() ?
The root of your system. Usually '/', unless you use --root.
That was one of my first tries, but it's of no use. pool.size() still returns 0, and I know I have packages installed in my system. :) Anyhow, digging up some of mountain zypp, it seems I may have to also issue a: zyppPtr->target()->load(); But I still have to give it a try.
I have tried to dig up yast2 code on this, but couldn't
Yast is too confuising ;). Try zypper or some of the tests/examples in the libzypp git.
I've looked at libzypp's test directory, and they seemed to make use of temporary databases.
Beware, the examples are pretty outdated but at least list_resolvables works.
There aren't many of them either. rick2@andor:~/Documentos/yast/libzypp/examples$ ls CMakeLists.txt COW_debug.cc EditionCompare.cc README whatprovides.cc
(patches/suggestions are wellcome ;) I added an onSystemByUser call as you asked for some 'p.installedBySolver' in the previous mail. Since libzypp-7.5.0: + /** Whether this is known to be installed on behalf of a user request. + * \note This is a hint guessed by evaluating an available install history. + * Returns \c false for non-system (uninstalled) solvables, or if no history + * is available. + */ + bool onSystemByUser() const;
Very nice, thanks. Please just add there a comment on the performance of the function, otherwise people may unnecessarily abuse it. I assume it's O(N): you iterate through the logs every time the function is called. Much appreciated, Ricardo ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

On Thursday 09 September 2010 17:06:18 Ricardo Cruz wrote:
Very nice, thanks. Please just add there a comment on the performance of the function, otherwise people may unnecessarily abuse it. I assume it's O(N): you iterate through the logs every time the function is called.
No, the history file is parsed once on demand, and the cache (hash<int>) is invalidated after a commit. So it should not perform that bad. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres ZYPP Development ma@suse.de 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: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

Quoting "Michael Andres" <ma@suse.de>:
On Thursday 09 September 2010 17:06:18 Ricardo Cruz wrote:
Very nice, thanks. Please just add there a comment on the performance of the function, otherwise people may unnecessarily abuse it. I assume it's O(N): you iterate through the logs every time the function is called.
No, the history file is parsed once on demand, and the cache (hash<int>) is invalidated after a commit. So it should not perform that bad.
Very cool. But it's not obvious from the comment, so I'd append to the comment something like "(cached after first run)". Cheers, Ricardo ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org

Hi Michael, Just noted you attached that example. (Damn webmail.) Very cool, thanks. The problem was lacking a call to zypp.target().load() Cheers, Ricardo ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (2)
-
Michael Andres
-
Ricardo Cruz