From f51b3c95b717093961bcd1e19643a26682163aae Mon Sep 17 00:00:00 2001 From: Klaus Kaempf Date: Thu, 23 Feb 2006 13:18:52 +0000 Subject: [PATCH] handle locale provides (still disabled) --- zypp/detail/ResolvableImpl.cc | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/zypp/detail/ResolvableImpl.cc b/zypp/detail/ResolvableImpl.cc index 092efea..3681239 100644 --- a/zypp/detail/ResolvableImpl.cc +++ b/zypp/detail/ResolvableImpl.cc @@ -12,6 +12,7 @@ #include #include "zypp/base/Algorithm.h" +#include "zypp/base/Logger.h" #include "zypp/detail/ResolvableImpl.h" using namespace std; @@ -39,6 +40,59 @@ namespace zypp } } + namespace + { + struct FilterLocaleProvides + { + Dependencies & deps; + + FilterLocaleProvides( Dependencies & d ) + : deps( d ) + { } + + bool operator()( const Capability & cap_r ) const + { + if (cap_r.index().substr( 0, 7 ) != "locale(") + return false; + + CapFactory f; + + string provides( cap_r.index(), 7 ); // strip "locale(" + string::size_type pos = provides.find( ":" ); // colon given ? + if (pos != string::npos) { + deps[Dep::SUPPLEMENTS].insert( f.parse( ResTraits::kind, string( provides, 0, pos ) ) ); + provides.erase( 0, pos+1 ); + } + pos = 0; + string::size_type next = pos; + while (pos < provides.size()) { + next = provides.find( ",", pos ); // look for , separator + if (next == string::npos) + next = provides.size(); // none left, set next to end (will strip trailing ')' ) + + deps[Dep::FRESHENS].insert( f.parse( ResTraits::kind, string( provides, pos, next-pos+1 ) ) ); + pos = next + 1; + } + return true; + } + }; + + void filterLocaleProvides( const Dependencies & from, Dependencies & to ) + { + + MIL << "filterLocaleProvides(" << from << ")" << endl; + CapSet provides; + FilterLocaleProvides flp( to ); + + std::remove_copy_if( from[Dep::PROVIDES].begin(), from[Dep::PROVIDES].end(), + std::inserter( provides, provides.end() ), + flp ); + to[Dep::PROVIDES] = provides; + + MIL << "=> (" << to << ")" << endl; + } + } + Resolvable::Impl::Impl( const Kind & kind_r, const NVRAD & nvrad_r ) : _kind( kind_r ) @@ -47,6 +101,11 @@ namespace zypp , _arch( nvrad_r.arch ) , _deps( nvrad_r ) { + // check if we provide any 'locale(...)' tags and split them + // up to freshens/supplements + +// filterLocaleProvides( nvrad_r, _deps ); + // assert self provides _deps[Dep::PROVIDES].insert( CapFactory() .parse( _kind, _name, Rel::EQ, _edition ) ); -- 2.7.4