On Dec 14, 2007 2:54 PM, Michael Andres <ma@suse.de> wrote:
On Thu, Dec 13, Michael Andres wrote:
Please take a minute and review the following code:
http://pastebin.ca/812178 [...] Is this what you had in mind? Isn't there an easier way to get this information?
I noticed that this only works for packages that are not installed. Is there a mechanism that would work for packages that are installed?
Attached a small test program. Maybe you want to give it a try and see whether it matches your expectations. It computes 'dependent packages' (whatever this exacly means) for both, installed and available packages.
'NAME [EDITION [ARCH]]:' is a prompt. Enter a name and it looks for the best available package. If you specify an edition, it will first look for an installed one:
NAME [EDITION [ARCH]]: A AdobeICCProfiles (I 2.0-74)(A 2.0-74.1 2.0-74 2.0-74)
NAME [EDITION [ARCH]]: AdobeICCProfiles Package: U__s_[S1:1][package]AdobeICCProfiles-2.0-74.1.noarch depends on (0) {}
NAME [EDITION [ARCH]]: AdobeICCProfiles 2.0-74 Package: I_TsU[S0:0][package]AdobeICCProfiles-2.0-74.noarch depends on (0) {}
U__s_.. - U means uninstalled I_TsU.. - I means installed
A more exiting ;=O example:
NAME [EDITION [ARCH]]: sendmail Package: U__s_[S1:1][package]sendmail-8.14.1-53.1.x86_64 depends on (16) { I__s_[S0:0][package]filesystem-10.3-50.x86_64 I__s_[S0:0][package]sed-4.1.5-64.x86_64 I__s_[S0:0][package]fillup-1.42-179.x86_64 I__s_[S0:0][package]coreutils-6.9-43.x86_64 I__s_[S0:0][package]glibc-2.6.1-18.3.x86_64 I__s_[S0:0][package]libopenssl0_9_8-0.9.8e-45.5.x86_64 I__s_[S0:0][package]libdb-4_5-4.5.20-29.x86_64 I__s_[S0:0][package]openldap2-client-2.3.37-20.x86_64 I__s_[S0:0][package]cyrus-sasl-2.1.22-82.x86_64 I__s_[S0:0][package]tcpd-7.6-791.x86_64 I__s_[S0:0][package]m4-1.4.10-17.x86_64 I__s_[S0:0][package]netcfg-10.3-39.noarch I__s_[S0:0][package]procmail-3.22-139.x86_64 I__s_[S0:0][package]bash-3.2-61.x86_64 I__s_[S0:0][package]perl-base-5.8.8-76.2.x86_64 I__s_[S0:0][package]insserv-1.09.0-46.x86_64 } NAME [EDITION [ARCH]]: postfix Package: U__s_[S1:1][package]postfix-2.4.5-20.1.x86_64 depends on (15) { I__s_[S0:0][package]openldap2-client-2.3.37-20.x86_64 I__s_[S0:0][package]insserv-1.09.0-46.x86_64 I__s_[S0:0][package]sed-4.1.5-64.x86_64 I__s_[S0:0][package]fillup-1.42-179.x86_64 I__s_[S0:0][package]coreutils-6.9-43.x86_64 I__s_[S0:0][package]glibc-2.6.1-18.3.x86_64 I__s_[S0:0][package]libopenssl0_9_8-0.9.8e-45.5.x86_64 I__s_[S0:0][package]pcre-7.2-14.2.x86_64 I__s_[S0:0][package]libdb-4_5-4.5.20-29.x86_64 I__s_[S0:0][package]cyrus-sasl-2.1.22-82.x86_64 I__s_[S0:0][package]netcfg-10.3-39.noarch I__s_[S0:0][package]bash-3.2-61.x86_64 I__s_[S0:0][package]grep-2.5.2-28.x86_64 I__s_[S0:0][package]pwdutils-3.1.4-27.x86_64 I__s_[S0:0][package]gawk-3.1.5g-25.x86_64 }
Compared to http://pastebin.ca/812178:
- I load all the repos AND the target system. This is necessary to process installed packages and IMO gives a better result for available packages.
- In 'FindDependent' I get the interesting PoolItem via 'getPi'. You use the PoolProxy class and get the selectable->candidateObj().
Even if the candidateObj's edition does not match the one you're looking for, it might be that a package with a matching edition is in the Selctable. 'getPi' tries a bit harder to find a package with your edition.
- For solving I use 'setForceResolve( true )' to minimize the cases where the solver fails. Otherwise sendmail in the example above would not succeed, because it conflicts with my postfix installed.
And I don't solve installed items, which is ok provided the system is in a consistent state. But one could as well solve in any case.
- Finaly zypp::forEachPoolItemMatchedBy extracts the dependent packages.
@ // TODO: Figure out how to determine whether a package is installed or not
- You usually have a PoolItem pi - A PoolItem has a status: pi.status() - The status tells (among other things) whether it is installed: pi.status().isInstalled()
In your case: it->item.status().isInstalled()
Thanks Michael for the code, suggestions, and review. I'll let you know how the progress goes. Boyd -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org