From fb8b289587161ecef21c4d7bb21fd6be2c4e545f Mon Sep 17 00:00:00 2001 From: Klaus Kaempf Date: Wed, 8 Feb 2006 13:06:58 +0000 Subject: [PATCH] limit commits to media, return uncommited PoolItems --- zypp/target/TargetImpl.cc | 81 ++++++++++++++++++++++----------------- zypp/target/TargetImpl.h | 2 +- 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 33143cbd6..cace53abe 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -105,53 +105,62 @@ namespace zypp } - void TargetImpl::commit(ResPool pool_r, int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r) + void TargetImpl::commit(ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r) { MIL << "TargetImpl::commit(, " << medianr << ")" << endl; + errors_r.clear(); + remaining_r.clear(); + srcremaining_r.clear(); + PoolItemList to_uninstall; PoolItemList to_install; - PoolItemList installed; - for (ResPool::const_iterator it = pool_r.begin(); - it != pool_r.end(); it++) - { - if (it->status().isToBeInstalled()) - { - to_install.push_back(*it); - } - else if (it->status().isToBeUninstalled() - && !it->status().isToBeUninstalledDueToObsolete()) // leave out obsoletes - { - to_uninstall.push_back(*it); - } - else if (it->status().staysInstalled()) - { - installed.push_back(*it); - } - } - - if (to_uninstall.size() > 0 ) { + PoolItemList to_srcinstall; + getResolvablesToInsDel( pool_r, to_uninstall, to_install, to_srcinstall ); - // sort delete list... + if ( medianr ) { + MIL << "Restrict to media number " << medianr << endl; + } - InstallOrder order(pool_r, to_uninstall, installed); - order.init(); - const PoolItemList & uninstallorder(order.getTopSorted()); + commit (to_uninstall); - to_uninstall.clear(); - for (PoolItemList::const_reverse_iterator it = uninstallorder.rbegin(); it != uninstallorder.rend(); ++it ) { - to_uninstall.push_back (*it); + if (medianr == 0) { // commit all + commit( to_install ); + commit( to_srcinstall ); + } + else { + PoolItemList current_install; + + for (PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it) { + Resolvable::constPtr res( it->resolvable() ); + Package::constPtr pkg( asKind(res) ); + if (pkg + && medianr != pkg->mediaId()) // check medianr for packages only + { + MIL << "Package " << *pkg << ", wrong media " << pkg->mediaId() << endl; + remaining_r.push_back( *it ); + } + else { + current_install.push_back( *it ); + } } - - // first uninstall what is to be uninstalled - commit(to_uninstall); + for (PoolItemList::iterator it = to_install.begin(); it != to_install.end(); ++it) { + Resolvable::constPtr res( it->resolvable() ); + Package::constPtr pkg( asKind(res) ); + if (pkg + && medianr != pkg->mediaId()) // check medianr for packages only + { + MIL << "Package " << *pkg << ", wrong media " << pkg->mediaId() << endl; + srcremaining_r.push_back( *it ); + } + else { + current_install.push_back( *it ); + } + } + commit (current_install); } - // now install what is to be installed - InstallOrder order(pool_r, to_install, installed); - order.init(); - const PoolItemList & installorder(order.getTopSorted()); - commit(installorder); + return; } diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index d5d5fe626..187d8613c 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -72,7 +72,7 @@ namespace zypp /** Commit changes in the pool media = 0 means any/all medias media > 0 means limit commits to this media */ - void commit( ResPool pool_r, int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r ); + void commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r ); /** Commit ordered changes */ void commit( const PoolItemList & items_r ); -- 2.34.1