Dne 4.5.2012 09:16, Saurabh Sood napsal(a):
Hi, I have managed to add repositories (presently without error handling), and now am looking at Installation of packages. I have looked so far at the documentation of the ResPool, ResObject, Solvable classes, but I could not find much information in the docs to help me on this. Please guide me in this regard.
Before installation you need to initialize the target (to read the installed packages and imported GPG keys) and the sources (to read the existing known repos and theirs objects). (This order is important as the repos are signed by GPG keys which needs to be known in advance, otherwise you would get many "Untrusted GPG Key" callbacks.) Then it depends what do you want to install, you can search packages by name, by provides, additionally by repository, architecture, version... The easiest way is to use zypp::ui::Selectable which automatically selects the best candidate for installation (the latest version, the best architecture...) Example code from pkg-bindings ("name" is a package name): zypp::ui::Selectable::Ptr selectable = zypp::ui::Selectable::get(name); if (selectable) { ret = selectable->setToInstall(whoWantsIt); } (whoWantsIt is set to zypp::ResStatus::APPL_HIGH in pkg-bindings as Yast works on a lower level so user can manually override yast changes. I guess you could use zypp::ResStatus::USER in your case). After selecting a package (actually after any change) you should run the solver and solve the dependencies for selected packages (and solve possible conflicts). Before installing you also need to check whether any package selected for installation has an extra license which needs to be confirmed by user before installation (usually used for closed source packages like Flash Player, Acrobar Reader etc...) Then you can actually start the installation by result = zypp_ptr()->commit(zypp::ZYppCommitPolicy policy); To display the installation progress you need to register libzypp callbacks which will trigger your handler when e.g. package download/installation starts/finishes, or you can abort the installation if needed. For more examples you could look at pkg-bindings sources (http://svn.opensuse.org/viewvc/yast/trunk/pkg-bindings/src/, package search/manipulation is coded in http://svn.opensuse.org/viewvc/yast/trunk/pkg-bindings/src/Package.cc?view=m...) or could could check zypper sources (https://github.com/openSUSE/zypper) HTH -- Ladislav Slezák Appliance department / YaST Developer Lihovarská 1060/12 190 00 Prague 9 / Czech Republic tel: +420 284 028 960 lslezak@suse.com SUSE -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org To contact the owner, e-mail: zypp-devel+owner@opensuse.org