Author: schubi2 Date: Tue Jul 15 12:32:05 2008 New Revision: 10582 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10582&view=rev Log: regarding system requirements Modified: trunk/libzypp/zypp/solver/detail/SATResolver.cc trunk/libzypp/zypp/solver/detail/SATResolver.h trunk/libzypp/zypp/solver/detail/SystemCheck.cc trunk/libzypp/zypp/solver/detail/SystemCheck.h Modified: trunk/libzypp/zypp/solver/detail/SATResolver.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/SATResolver.cc?rev=10582&r1=10581&r2=10582&view=diff ============================================================================== --- trunk/libzypp/zypp/solver/detail/SATResolver.cc (original) +++ trunk/libzypp/zypp/solver/detail/SATResolver.cc Tue Jul 15 12:32:05 2008 @@ -38,6 +38,7 @@ #include "zypp/solver/detail/ProblemSolutionIgnore.h" #include "zypp/solver/detail/SolverQueueItemInstall.h" #include "zypp/solver/detail/SolverQueueItemDelete.h" +#include "zypp/solver/detail/SystemCheck.h" extern "C" { #include "satsolver/repo_solv.h" @@ -694,6 +695,9 @@ MIL << "Conflicts " << *iter << endl; } + // set requirements for a running system + setSystemRequirements(); + // set locks for the solver setLocks(); @@ -746,6 +750,9 @@ queue_push( &(_jobQueue), ident); } + // set requirements for a running system + setSystemRequirements(); + // set locks for the solver setLocks(); @@ -771,6 +778,9 @@ PoolItemSet(), ObsoleteStrings()); + // set requirements for a running system + setSystemRequirements(); + // set locks for the solver void setLocks(); @@ -1252,7 +1262,24 @@ } } +void SATResolver::setSystemRequirements() +{ + CapabilitySet system_requires = SystemCheck::instance().requiredSystemCap(); + CapabilitySet system_conflicts = SystemCheck::instance().conflictSystemCap(); + + for (CapabilitySet::const_iterator iter = system_requires.begin(); iter != system_requires.end(); iter++) { + queue_push( &(_jobQueue), SOLVER_INSTALL_SOLVABLE_PROVIDES ); + queue_push( &(_jobQueue), iter->id() ); + MIL << "SYSTEM Requires " << *iter << endl; + } + for (CapabilitySet::const_iterator iter = system_conflicts.begin(); iter != system_conflicts.end(); iter++) { + queue_push( &(_jobQueue), SOLVER_ERASE_SOLVABLE_PROVIDES); + queue_push( &(_jobQueue), iter->id() ); + MIL << "SYSTEM Conflicts " << *iter << endl; + } +} + /////////////////////////////////////////////////////////////////// };// namespace detail Modified: trunk/libzypp/zypp/solver/detail/SATResolver.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/SATResolver.h?rev=10582&r1=10581&r2=10582&view=diff ============================================================================== --- trunk/libzypp/zypp/solver/detail/SATResolver.h (original) +++ trunk/libzypp/zypp/solver/detail/SATResolver.h Tue Jul 15 12:32:05 2008 @@ -102,6 +102,8 @@ void solverEnd(); // set locks for the solver void setLocks(); + // set requirements for a running system + void setSystemRequirements(); public: Modified: trunk/libzypp/zypp/solver/detail/SystemCheck.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/SystemCheck.cc?rev=10582&r1=10581&r2=10582&view=diff ============================================================================== --- trunk/libzypp/zypp/solver/detail/SystemCheck.cc (original) +++ trunk/libzypp/zypp/solver/detail/SystemCheck.cc Tue Jul 15 12:32:05 2008 @@ -29,14 +29,46 @@ namespace zypp { ///////////////////////////////////////////////////////////////// - Pathname _file; + Pathname _file = ""; CapabilitySet _require; CapabilitySet _conflict; - typedef vector<string> CapList; + typedef vector<string> CapList; + + const SystemCheck & SystemCheck::instance() + { + static SystemCheck _val; + return _val; + } + SystemCheck::SystemCheck() { - _file = ZConfig::instance().solver_checkSystemFile(); + if (_file.empty()) { + _file = ZConfig::instance().solver_checkSystemFile(); + loadFile(); + } + } + + bool SystemCheck::setFile(const Pathname & file) const{ + MIL << "Setting checkFile to : " << file << endl; + _file = file; + loadFile(); + return true; + } + + const Pathname & SystemCheck::file() { + return _file; + } + + const CapabilitySet & SystemCheck::requiredSystemCap() const{ + return _require; + } + + const CapabilitySet & SystemCheck::conflictSystemCap() const{ + return _conflict; + } + + bool SystemCheck::loadFile() const{ try { Target_Ptr trg( getZYpp()->target() ); @@ -50,9 +82,13 @@ PathInfo pi( _file ); if ( ! pi.isFile() ) { - WAR << "Can't read " << pi << endl; - return; + WAR << "Can't read " << _file << " " << pi << endl; + return false; } + + _require.clear(); + _conflict.clear(); + std::ifstream infile( _file.c_str() ); for( iostr::EachLine in( infile ); in; in.next() ) { std::string l( str::trim(*in) ); @@ -75,18 +111,7 @@ } } MIL << "Read " << pi << endl; - } - - const Pathname & file() { - return _file; - } - - const CapabilitySet & requiredSystemCap() { - return _require; - } - - const CapabilitySet & conflictSystemCap() { - return _conflict; + return true; } Modified: trunk/libzypp/zypp/solver/detail/SystemCheck.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/SystemCheck.h?rev=10582&r1=10581&r2=10582&view=diff ============================================================================== --- trunk/libzypp/zypp/solver/detail/SystemCheck.h (original) +++ trunk/libzypp/zypp/solver/detail/SystemCheck.h Tue Jul 15 12:32:05 2008 @@ -32,8 +32,16 @@ public: + /** Singleton */ + static const SystemCheck & instance(); + /** Return the file path. */ - const Pathname & file() const; + const Pathname & file(); + + /** Set configuration file of system requirements + * Should be used for testcase only + */ + bool setFile(const Pathname & file) const; /** Returns a list of required system capabilities. */ @@ -46,6 +54,7 @@ private: /** Ctor taking the file to read. */ SystemCheck(); + bool loadFile() const; }; /////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org