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 ); }
#include "zypp/ResStore.h"
#include "zypp/Pathname.h"
-#include "zypp/target/TargetImpl.h"
+#include "zypp/ResPool.h"
///////////////////////////////////////////////////////////////////
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 );
#include "zypp/target/TargetImpl.h"
-using std::endl;
+#include <vector>
+
+using namespace std;
///////////////////////////////////////////////////////////////////
namespace zypp
return _store;
}
+ void TargetImpl::commit(ResPool & pool_r)
+ {
+#warning FIXME this orderding doesn't honor the dependencies
+ vector<ResObject::constPtr> to_uninstall;
+ vector<ResObject::constPtr> 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<ResObject::constPtr>::const_iterator it = to_uninstall.begin();
+ it != to_uninstall.end();
+ it++)
+ {
+ if (isKind<Package>(*it))
+ {
+ Package::constPtr p = dynamic_pointer_cast<const Package>(*it);
+ rpm().removePackage(p);
+ }
+#warning FIXME other resolvables (once more below)
+ }
+ // now install what is to be installed
+ for (vector<ResObject::constPtr>::const_iterator it = to_install.begin();
+ it != to_install.end();
+ it++)
+ {
+ if (isKind<Package>(*it))
+ {
+ Package::constPtr p = dynamic_pointer_cast<const Package>(*it);
+ rpm().installPackage(p->getPlainRpm(), rpm::RpmDb::RPMINST_NOUPGRADE);
+ }
+ }
+ }
+
rpm::RpmDb & TargetImpl::rpm()
{ return _rpm; }
/** 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"; }