From b98a94cbcd775bd338631c6e8cbfa2ff6287c8d4 Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Mon, 30 Jan 2006 09:24:25 +0000 Subject: [PATCH] split commit into 2 functions --- zypp/target/TargetImpl.cc | 34 +++++++++++++++++++--------------- zypp/target/TargetImpl.h | 4 ++++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 8abc83097..d30d4f34d 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -101,31 +101,35 @@ namespace zypp } // first uninstall what is to be uninstalled #warning FIXME this orderding doesn't honor the dependencies for removals - for (PoolItemList::const_iterator it = to_uninstall.begin(); - it != to_uninstall.end(); - it++) - { - if (isKind(it->resolvable())) - { - Package::constPtr p = dynamic_pointer_cast(it->resolvable()); - rpm().removePackage(p); - } -#warning FIXME other resolvables (once more below) - } + commit(to_uninstall); // now install what is to be installed InstallOrder order(pool_r, to_install, installed); order.init(); const PoolItemList & installorder(order.getTopSorted()); - for (PoolItemList::const_iterator it = installorder.begin(); - it != installorder.end(); it++) + commit(installorder); + } + + void TargetImpl::commit(const PoolItemList & items_r) + { + for (PoolItemList::const_iterator it = items_r.begin(); + it != items_r.end(); it++) { if (isKind(it->resolvable())) { Package::constPtr p = dynamic_pointer_cast(it->resolvable()); - rpm().installPackage(p->getPlainRpm(), - p->installOnly() ? rpm::RpmDb::RPMINST_NOUPGRADE : 0); + if (it->status().isToBeInstalled()) + { + rpm().installPackage(p->getPlainRpm(), + p->installOnly() ? rpm::RpmDb::RPMINST_NOUPGRADE : 0); + } + else + { + rpm().removePackage(p); + } } +#warning FIXME other resolvables } + } rpm::RpmDb & TargetImpl::rpm() diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index ff85ca13a..2c6f77021 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -23,6 +23,7 @@ #include "zypp/media/MediaAccess.h" #include "zypp/Target.h" #include "zypp/target/rpm/RpmDb.h" +#include "zypp/solver/detail/Types.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -64,6 +65,9 @@ namespace zypp #warning Add support for multiple medias - eg. limit only to CD1 void commit(ResPool pool_r); + /** Comomit ordered changes */ + void commit(const PoolItemList & items_r); + /** Overload to realize stream output. */ virtual std::ostream & dumpOn( std::ostream & str ) const { return str << "TargetImpl"; } -- 2.34.1