From 63843169afa0bbead677e188f5403a123dc0252d Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 3 Aug 2007 18:28:22 +0000 Subject: [PATCH] - Add product attribute 'type' (aka 'category' which is now deprecated). Adapted sustags and yum parsers to parse and provide this value. --- VERSION.cmake | 2 +- devel/devel.ma/Parse.cc | 36 ++++++- devel/devel.ma/Test.cc | 152 ------------------------------ zypp/Product.cc | 8 +- zypp/Product.h | 19 ++-- zypp/cache/CacheAttributes.h | 1 + zypp/cache/CacheStore.cc | 9 +- zypp/data/ResolvableData.h | 3 + zypp/detail/ProductImplIf.cc | 7 +- zypp/detail/ProductImplIf.h | 14 +-- zypp/parser/susetags/ContentFileReader.cc | 4 + zypp/parser/yum/ProductFileReader.cc | 32 +++---- zypp/repo/cached/ProductImpl.cc | 10 +- zypp/repo/cached/ProductImpl.h | 10 +- zypp/repo/memory/ProductImpl.cc | 4 +- zypp/repo/memory/ProductImpl.h | 8 +- zypp/target/store/XMLFilesBackend.cc | 2 +- zypp/target/store/serialize.cc | 2 +- zypp/target/store/xml/XMLProductImpl.cc | 8 +- zypp/target/store/xml/XMLProductImpl.h | 14 ++- 20 files changed, 112 insertions(+), 233 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index db59b11..a17be34 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -47,4 +47,4 @@ SET(LIBZYPP_MAJOR "3") SET(LIBZYPP_MINOR "13") SET(LIBZYPP_COMPATMINOR "13") -SET(LIBZYPP_PATCH "10") +SET(LIBZYPP_PATCH "11") diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index 287168b..6165778 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -48,18 +48,35 @@ struct Xprint { bool operator()( const PoolItem & obj_r ) { - handle( asKind( obj_r ) ); + //handle( asKind( obj_r ) ); + //handle( asKind( obj_r ) ); + handle( asKind( obj_r ) ); return true; } + void handle( const Package_constPtr & p ) + { + if ( !p ) + return; + + MIL << p->mediaNr() << endl; + } + void handle( const Pattern_constPtr & p ) { if ( !p ) return; MIL << p << endl; - if ( ! p->includes().empty() ) DBG << p->includes() << endl; - if ( ! p->extends().empty() ) DBG << p->extends() << endl; + } + + void handle( const Product_constPtr & p ) + { + if ( !p ) + return; + + ERR << p << endl; + ERR << p->type() << endl; } template @@ -308,8 +325,8 @@ int main( int argc, char * argv[] ) SEC << "cleanCache" << endl; repoManager.cleanCache( nrepo ); } - SEC << "refreshMetadat" << endl; - repoManager.refreshMetadata( nrepo ); + //SEC << "refreshMetadat" << endl; + //repoManager.refreshMetadata( nrepo ); SEC << "buildCache" << endl; repoManager.buildCache( nrepo ); } @@ -335,6 +352,15 @@ int main( int argc, char * argv[] ) MIL << "Added target: " << pool << endl; } + Capability _cap( CapFactory().parse( "de" ) ); + SEC << "F" << endl; + forEachMatchIn( pool, Dep::FRESHENS, _cap, Print() ); + SEC << "S" << endl; + forEachMatchIn( pool, Dep::SUPPLEMENTS, _cap, Print() ); + SEC << "P" << endl; + forEachMatchIn( pool, Dep::PROVIDES, _cap, Print() ); + SEC << endl; + std::for_each( pool.begin(), pool.end(), Xprint() ); /////////////////////////////////////////////////////////////////// diff --git a/devel/devel.ma/Test.cc b/devel/devel.ma/Test.cc index 9cc9af3..0c60c7c 100644 --- a/devel/devel.ma/Test.cc +++ b/devel/devel.ma/Test.cc @@ -19,165 +19,13 @@ #include #include -#include "zypp/parser/TagParser.h" -#include "zypp/parser/susetags/PackagesFileReader.h" -#include "zypp/parser/susetags/PackagesLangFileReader.h" -#include "zypp/parser/susetags/PatternFileReader.h" -#include "zypp/parser/susetags/ContentFileReader.h" -#include "zypp/parser/susetags/RepoIndex.h" -#include "zypp/parser/susetags/RepoParser.h" #include "zypp/cache/CacheStore.h" using namespace std; using namespace zypp; -using namespace zypp::parser; -using namespace zypp::parser::susetags; /////////////////////////////////////////////////////////////////// -struct DummyConsumer : public zypp::data::ResolvableDataConsumer - , private base::NonCopyable -{ - std::string idString( const data::ResObject_Ptr & res_r, ResolvableTraits::KindType kind_r ) - { - std::string ret( kind_r.asString() ); - ret += ":"; - ret += res_r->name; - ret += "-"; - ret += res_r->edition.asString(); - ret += "."; - ret += res_r->arch.asString(); - return ret; - } - - data::RecordId _lastId; - std::map _idMap; - std::map _reverseMap; - - bool hasEntry( const std::string & id_r ) - { - return _idMap.find( id_r ) != _idMap.end(); - } - - data::RecordId newId( const data::ResObject_Ptr & res_r, ResolvableTraits::KindType kind_r ) - { - std::string id( idString( res_r, kind_r ) ); - if ( hasEntry( id ) ) - ZYPP_THROW(Exception(id)); - _idMap[id] = ++_lastId; - _reverseMap[_lastId] = id; - MIL << "NEW_ID " << _lastId << " - " << id << endl; - logNew( res_r, kind_r ); - return _lastId; - } - - data::RecordId getId( const data::ResObject_Ptr & res_r, ResolvableTraits::KindType kind_r ) - { - std::string id( idString( res_r, kind_r ) ); - if ( ! hasEntry( id ) ) - ZYPP_THROW(Exception(id)); - data::RecordId ret = _idMap[id]; - DBG << ret << " " << id << endl; - return ret; - } - - std::string lookup( data::RecordId id_r ) - { - if ( id_r == data::noRecordId ) - { - return ""; - } - - if ( _reverseMap.find( id_r ) != _reverseMap.end() ) - { - return _reverseMap[id_r]; - } - - WAR << "Lookup id " << id_r << "failed" << endl; - return std::string(); - } - - void logNew( const data::ResObject_Ptr & res_r, ResolvableTraits::KindType kind_r ) - { - std::string shr( lookup( res_r->shareDataWith ) ); - if ( ! shr.empty() ) - { - DBG << " SHR: " << shr << endl; - } - //DBG << " SUM: " << res_r->summary << endl; - if ( 0&&kind_r == ResTraits::kind ) - { - data::Package_Ptr p = dynamic_pointer_cast(res_r); - DBG << " PKG: " << p << endl; - DBG << " LOC: " << p->repositoryLocation << endl; - } - static unsigned n = 20; - if ( 0&&! --n ) - throw; - } - - public: - - virtual data::RecordId consumePackage( const data::RecordId & repository_id, const data::Package_Ptr & res_r ) - { - return newId( res_r, ResTraits::kind ); - } - - virtual data::RecordId consumeSourcePackage( const data::RecordId & repository_id, const data::SrcPackage_Ptr & res_r ) - { - return newId( res_r, ResTraits::kind ); - } - - virtual data::RecordId consumeProduct ( const data::RecordId & repository_id, const data::Product_Ptr & res_r ) - { - return newId( res_r, ResTraits::kind ); - } - - virtual data::RecordId consumePatch ( const data::RecordId & repository_id, const data::Patch_Ptr & res_r ) - { - return newId( res_r, ResTraits::kind ); - } - - virtual data::RecordId consumePackageAtom ( const data::RecordId & repository_id, const data::PackageAtom_Ptr & res_r ) - { - return newId( res_r, ResTraits::kind ); - } - - virtual data::RecordId consumeMessage ( const data::RecordId & repository_id, const data::Message_Ptr & res_r ) - { - return newId( res_r, ResTraits::kind ); - } - - virtual data::RecordId consumeScript ( const data::RecordId & repository_id, const data::Script_Ptr & res_r ) - { - return newId( res_r, ResTraits