[zypp-devel] Initialisation of Target
Hi, I am stuck at trying to initialise the target, so as to proceed with the installation of packages. I am getting a null zypp::ui::Selectable::Ptr, when I use zypp::ui::Selectable::get(). Because of this, I am not able to carry out installation of packages. Also, I did not understand what parameter is to be passed ti initialiseTarget. My Code : https://github.com/openSUSE/one-click-installer/blob/master/playground/parse... Regards,. Saurabh -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org To contact the owner, e-mail: zypp-devel+owner@opensuse.org
On Sunday 03 June 2012 13:43:05 Saurabh Sood wrote:
Hi, I am stuck at trying to initialise the target, so as to proceed with the installation of packages. I am getting a null zypp::ui::Selectable::Ptr, when I use zypp::ui::Selectable::get().
Then the name 'packageList.at( 0 )->name().toStdString()' you are looking for is not available in the pool. You can list your pools content e.g. using: for ( const zypp::PoolItem & pi : zypp::ResPool::instance() ) { std::cout << pi << endl; }
Because of this, I am not able to carry out installation of packages. Also, I did not understand what parameter is to be passed ti initialiseTarget.
The 'Target' represents the system and the packages already installed on it. initializeTarget() takes your systems root directory as argument. Usually this is "/" (unless you prepare some system chroot). Remember the Target does _not_ provide the packages available for installation. This is done by Repositories. Unless '( addrepo == true )' your code seems to load the installed packages only. But you probably you want to load all enabled repositories (probably plus some temp. repo defined by the ymp file). Otherwise it might be hard to install or resolve dependencies. When adding your (temp.?) ymp file repos: (- consider using RepoManager::makeStupidAlias to derive an alias from the url string.) - rman.addRepository(repoinfo): This call makes the repoinfo persistent; i.e. it's written to /etc/zypp/repos.d. Don't call it if your repo is just temporary. But this does not load the repos data into the pool. - rman.refreshMetadata/buildCache/loadFromCache(repoinfo): This loads a repoinfos data into the pool, so they are available for installation. - Remember one of the first mails I sent. defaultLoadSystem initializes the target and all per default enabled repositories: #include <zypp/misc/DefaultLoadSystem.h> zypp::misc::defaultLoadSystem( "/" ); This will load all Repoinfos from /etc/zypp/repos.d into the Repomanager, and for all 'enabled' Repoinfos it will refresh the metadata and load them into the pool. So your workflow could be something like this: zypp::misc::defaultLoadSystem( "/" ); for ( ymp file urls ) { if ( url is known to repomanager ) { if ( repo is NOT enabled ) manually load the repo into the pool as defaultLoadSystem didn't; } else { build RepoInfo; if ( repo should become persistent ) rman.addRepository(repoinfo); manually load the repo into the pool; } } - Later, when selecting your package for installation: Remember that Selectable("foo") will contain all "foo"s (all versions, all archs and from all repos) in it's availableObj list. Be sure to pick the right one for being installed. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres SUSE LINUX Products GmbH, Development, ma@suse.de GF:Jeff Hawn,Jennifer Guild,Felix Imendörffer, HRB16746(AG Nürnberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org To contact the owner, e-mail: zypp-devel+owner@opensuse.org
participants (2)
-
Michael Andres
-
Saurabh Sood