From 4c9bf4d2528888ed5a6b85e62d2a70a194cfbc47 Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Mon, 30 Jan 2006 07:57:37 +0000 Subject: [PATCH] added preliminary commit function for target --- zypp/Target.cc | 3 +++ zypp/Target.h | 8 +++++--- zypp/target/TargetImpl.cc | 46 +++++++++++++++++++++++++++++++++++++++++++++- zypp/target/TargetImpl.h | 4 ++++ 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/zypp/Target.cc b/zypp/Target.cc index abdc614..c0f6e51 100644 --- a/zypp/Target.cc +++ b/zypp/Target.cc @@ -70,6 +70,9 @@ namespace zypp target::rpm::RpmDb & Target::rpmDb() { return _pimpl->rpm(); } + void Target::commit(ResPool & pool_r) + { return _pimpl->commit(pool_r); } + std::ostream & Target::dumpOn( std::ostream & str ) const { return _pimpl->dumpOn( str ); } diff --git a/zypp/Target.h b/zypp/Target.h index 38aff03..45d6686 100644 --- a/zypp/Target.h +++ b/zypp/Target.h @@ -18,7 +18,7 @@ #include "zypp/ResStore.h" #include "zypp/Pathname.h" -#include "zypp/target/TargetImpl.h" +#include "zypp/ResPool.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -53,11 +53,13 @@ namespace zypp static Target_Ptr nullimpl(); /** Refference to the RPM database */ target::rpm::RpmDb & rpmDb(); + /** Comomit changes in the pool */ + void commit(ResPool & pool_r); public: - /** Factory ctor */ + /** Ctor */ Target( const Pathname & root = "/" ); - /** Factory ctor */ + /** Ctor */ explicit Target( const Impl_Ptr & impl_r ); diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 279dadd..2b4be7d 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -14,7 +14,9 @@ #include "zypp/target/TargetImpl.h" -using std::endl; +#include + +using namespace std; /////////////////////////////////////////////////////////////////// namespace zypp @@ -74,6 +76,48 @@ namespace zypp return _store; } + void TargetImpl::commit(ResPool & pool_r) + { +#warning FIXME this orderding doesn't honor the dependencies + vector to_uninstall; + vector to_install; + for (ResPool::const_iterator it = pool_r.begin(); + it != pool_r.end(); it++) + { + if (it->status().isToBeInstalled()) + { + to_install.push_back(it->resolvable()); + } + else if (it->status().isToBeUninstalled()) + { + to_uninstall.push_back(it->resolvable()); + } + } + // first uninstall what is to be uninstalled + for (vector::const_iterator it = to_uninstall.begin(); + it != to_uninstall.end(); + it++) + { + if (isKind(*it)) + { + Package::constPtr p = dynamic_pointer_cast(*it); + rpm().removePackage(p); + } +#warning FIXME other resolvables (once more below) + } + // now install what is to be installed + for (vector::const_iterator it = to_install.begin(); + it != to_install.end(); + it++) + { + if (isKind(*it)) + { + Package::constPtr p = dynamic_pointer_cast(*it); + rpm().installPackage(p->getPlainRpm(), rpm::RpmDb::RPMINST_NOUPGRADE); + } + } + } + rpm::RpmDb & TargetImpl::rpm() { return _rpm; } diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index ee63bbb..3167ce8 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -60,6 +60,10 @@ namespace zypp /** All resolvables in the target. */ const ResStore & resolvables(); + /** Comomit changes in the pool */ +#warning Add support for multiple medias - eg. limit only to CD1 + void commit(ResPool & pool_r); + /** Overload to realize stream output. */ virtual std::ostream & dumpOn( std::ostream & str ) const { return str << "TargetImpl"; } -- 2.7.4