1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/TargetImpl.cc
13 #include "zypp/base/Logger.h"
15 #include "zypp/target/TargetImpl.h"
21 ///////////////////////////////////////////////////////////////////
23 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
28 IMPL_PTR_TYPE(TargetImpl);
30 TargetImpl_Ptr TargetImpl::_nullimpl;
32 /** Null implementation */
33 TargetImpl_Ptr TargetImpl::nullimpl()
36 _nullimpl = new TargetImpl;
41 ///////////////////////////////////////////////////////////////////
43 // METHOD NAME : TargetImpl::TargetImpl
46 TargetImpl::TargetImpl(const Pathname & root_r)
50 MIL << "Initialized target on " << _root << endl;
53 ///////////////////////////////////////////////////////////////////
55 // METHOD NAME : TargetImpl::~TargetImpl
58 TargetImpl::~TargetImpl()
61 MIL << "Targets closed" << endl;
64 const ResStore & TargetImpl::resolvables()
68 std::list<Package::Ptr> packages = _rpm.getPackages();
69 for (std::list<Package::Ptr>::const_iterator it = packages.begin();
75 // TODO objects from the XML store
79 void TargetImpl::commit(ResPool & pool_r)
81 #warning FIXME this orderding doesn't honor the dependencies
82 vector<ResObject::constPtr> to_uninstall;
83 vector<ResObject::constPtr> to_install;
84 for (ResPool::const_iterator it = pool_r.begin();
85 it != pool_r.end(); it++)
87 if (it->status().isToBeInstalled())
89 to_install.push_back(it->resolvable());
91 else if (it->status().isToBeUninstalled())
93 to_uninstall.push_back(it->resolvable());
96 // first uninstall what is to be uninstalled
97 for (vector<ResObject::constPtr>::const_iterator it = to_uninstall.begin();
98 it != to_uninstall.end();
101 if (isKind<Package>(*it))
103 Package::constPtr p = dynamic_pointer_cast<const Package>(*it);
104 rpm().removePackage(p);
106 #warning FIXME other resolvables (once more below)
108 // now install what is to be installed
109 for (vector<ResObject::constPtr>::const_iterator it = to_install.begin();
110 it != to_install.end();
113 if (isKind<Package>(*it))
115 Package::constPtr p = dynamic_pointer_cast<const Package>(*it);
116 rpm().installPackage(p->getPlainRpm(), rpm::RpmDb::RPMINST_NOUPGRADE);
121 rpm::RpmDb & TargetImpl::rpm()
124 /////////////////////////////////////////////////////////////////
125 } // namespace target
126 ///////////////////////////////////////////////////////////////////
127 /////////////////////////////////////////////////////////////////
129 ///////////////////////////////////////////////////////////////////