From 8c2c6d6c136cb42d1228c6520a0027ca88793110 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Fri, 9 May 2008 21:19:13 +0000 Subject: [PATCH] Product now retrieves all attributes from the solv file. --- VERSION.cmake | 2 +- devel/devel.ma/NewPool.cc | 27 ++++++++------- package/libzypp.changes | 7 ++++ zypp/Product.cc | 83 +++++++++++++++++++++++++++++++++++++---------- zypp/sat/SolvAttr.cc | 13 +++++++- zypp/sat/SolvAttr.h | 29 ++++++++++++++--- 6 files changed, 125 insertions(+), 36 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index 395b143..41013c0 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -47,4 +47,4 @@ SET(LIBZYPP_MAJOR "4") SET(LIBZYPP_MINOR "21") SET(LIBZYPP_COMPATMINOR "21") -SET(LIBZYPP_PATCH "0") +SET(LIBZYPP_PATCH "1") diff --git a/devel/devel.ma/NewPool.cc b/devel/devel.ma/NewPool.cc index c451c0c..a7cf65b 100644 --- a/devel/devel.ma/NewPool.cc +++ b/devel/devel.ma/NewPool.cc @@ -459,12 +459,6 @@ namespace zypp { } -bool PCDC( const parser::ProductConfData & d ) -{ - SEC << d << endl; - return true; -} - /****************************************************************** ** ** FUNCTION NAME : main @@ -478,12 +472,6 @@ try { INT << "===[START]==========================================" << endl; ZConfig::instance(); - parser::ProductConfReader::scanDir( &PCDC, ZConfig::instance().productsPath() ); - /////////////////////////////////////////////////////////////////// - INT << "===[END]============================================" << endl << endl; - zypp::base::LogControl::instance().logNothing(); - return 0; - ResPool pool( ResPool::instance() ); sat::Pool satpool( sat::Pool::instance() ); @@ -571,6 +559,21 @@ try { /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// + for_( it, pool.byKindBegin(), pool.byKindEnd() ) + { + Product::constPtr p( asKind( *it ) ); + USR << p << endl; + MIL << p->type() << endl; + MIL << p->releaseNotesUrl() << endl; + MIL << p->updateUrls() << endl; + MIL << p->extraUrls() << endl; + MIL << p->optionalUrls() << endl; + MIL << p->flags() << endl; + MIL << p->shortName() << endl; + MIL << p->distributionName() << endl; + MIL << p->distributionEdition() << endl; + } + /////////////////////////////////////////////////////////////////// INT << "===[END]============================================" << endl << endl; diff --git a/package/libzypp.changes b/package/libzypp.changes index d07e6a0..2e95741 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri May 9 23:15:53 CEST 2008 - ma@suse.de + +- Product now retrieves all attributes from the solv file. +- version 4.21.1 +- revision 10031 + +------------------------------------------------------------------- Fri May 9 21:28:42 CEST 2008 - ma@suse.de - Add zypp.conf option configdir (/etc/zypp) and arrange diff --git a/zypp/Product.cc b/zypp/Product.cc index 3fdb728..80c7d00 100644 --- a/zypp/Product.cc +++ b/zypp/Product.cc @@ -9,15 +9,48 @@ /** \file zypp/Product.cc * */ +#include +#include "zypp/base/LogTools.h" + #include "zypp/Product.h" #include "zypp/Url.h" +#include "zypp/sat/LookupAttr.h" + +using std::endl; + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// IMPL_PTR_TYPE(Product); + namespace + { + void fillList( std::list & ret_r, sat::Solvable solv_r, sat::SolvAttr attr_r ) + { + sat::LookupAttr query( attr_r, solv_r ); + for_( it, query.begin(), query.end() ) + { + try // ignore malformed urls + { + ret_r.push_back( Url( it.asString() ) ); + } + catch( const url::UrlException & ) + {} + } + } + + void fillList( std::list & ret_r, sat::Solvable solv_r, sat::SolvAttr attr_r ) + { + sat::LookupAttr query( attr_r, solv_r ); + for_( it, query.begin(), query.end() ) + { + ret_r.push_back( it.asString() ); + } + } + } + /////////////////////////////////////////////////////////////////// // // METHOD NAME : Product::Product @@ -40,44 +73,58 @@ namespace zypp // Package interface forwarded to implementation // /////////////////////////////////////////////////////////////////// -#warning DUMMY type + std::string Product::type() const - { return std::string(); } + { return lookupStrAttribute( sat::SolvAttr::productType ); } -#warning DUMMY releaseNotesUrl Url Product::releaseNotesUrl() const - { return Url(); } + { + std::list ret; + fillList( ret, satSolvable(), sat::SolvAttr::productRelnotesurl ); + if ( ! ret.empty() ) + return ret.front(); + return Url(); + } -#warning DUMMY updateUrls std::list Product::updateUrls() const - { return std::list(); } + { + std::list ret; + fillList( ret, satSolvable(), sat::SolvAttr::productUpdateurls ); + return ret; + } -#warning DUMMY extraUrls std::list Product::extraUrls() const - { return std::list(); } + { + std::list ret; + fillList( ret, satSolvable(), sat::SolvAttr::productExtraurls ); + return ret; + } -#warning DUMMY optionalUrls std::list Product::optionalUrls() const - { return std::list(); } + { + std::list ret; + fillList( ret, satSolvable(), sat::SolvAttr::productOptionalurls ); + return ret; + } -#warning DUMMY flags std::list Product::flags() const - { return std::list(); } + { + std::list ret; + fillList( ret, satSolvable(), sat::SolvAttr::productFlags ); + return ret; + } -#warning DUMMY shortName std::string Product::shortName() const - { return std::string(); } + { return lookupStrAttribute( sat::SolvAttr::productShortlabel ); } std::string Product::longName( const Locale & lang_r ) const { return summary( lang_r ); } -#warning DUMMY distributionName std::string Product::distributionName() const - { return std::string(); } + { return lookupStrAttribute( sat::SolvAttr::productDistproduct ); } -#warning DUMMY distributionEdition Edition Product::distributionEdition() const - { return Edition(); } + { return Edition( lookupStrAttribute( sat::SolvAttr::productDistversion ) ); } ///////////////////////////////////////////////////////////////// diff --git a/zypp/sat/SolvAttr.cc b/zypp/sat/SolvAttr.cc index f9d212d..99700c3 100644 --- a/zypp/sat/SolvAttr.cc +++ b/zypp/sat/SolvAttr.cc @@ -69,7 +69,7 @@ namespace sat // patch const SolvAttr SolvAttr::patchcategory ( SOLVABLE_PATCHCATEGORY ); const SolvAttr SolvAttr::rebootSuggested ( UPDATE_REBOOT ); - const SolvAttr SolvAttr::restartSuggested ( UPDATE_RESTART ); + const SolvAttr SolvAttr::restartSuggested ( UPDATE_RESTART ); const SolvAttr SolvAttr::updateCollectionName ( UPDATE_COLLECTION_NAME ); const SolvAttr SolvAttr::updateCollectionEvr ( UPDATE_COLLECTION_EVR ); const SolvAttr SolvAttr::updateCollectionArch ( UPDATE_COLLECTION_ARCH ); @@ -90,6 +90,17 @@ namespace sat const SolvAttr SolvAttr::includes ( SOLVABLE_INCLUDES ); const SolvAttr SolvAttr::extends ( SOLVABLE_EXTENDS ); + // product + const SolvAttr SolvAttr::productShortlabel ( PRODUCT_SHORTLABEL ); + const SolvAttr SolvAttr::productDistproduct ( PRODUCT_DISTPRODUCT ); + const SolvAttr SolvAttr::productDistversion ( PRODUCT_DISTVERSION ); + const SolvAttr SolvAttr::productType ( PRODUCT_TYPE ); + const SolvAttr SolvAttr::productRelnotesurl ( PRODUCT_RELNOTESURL ); + const SolvAttr SolvAttr::productUpdateurls ( PRODUCT_UPDATEURLS ); + const SolvAttr SolvAttr::productExtraurls ( PRODUCT_EXTRAURLS ); + const SolvAttr SolvAttr::productOptionalurls ( PRODUCT_OPTIONALURLS ); + const SolvAttr SolvAttr::productFlags ( PRODUCT_FLAGS ); + } // namespace sat ///////////////////////////////////////////////////////////////// } // namespace zypp diff --git a/zypp/sat/SolvAttr.h b/zypp/sat/SolvAttr.h index eac8655..51de463 100644 --- a/zypp/sat/SolvAttr.h +++ b/zypp/sat/SolvAttr.h @@ -41,6 +41,8 @@ namespace sat /** Value representing \c noAttr ("")*/ static const SolvAttr noAttr; + /** \name common */ + //@{ static const SolvAttr name; static const SolvAttr summary; static const SolvAttr description; @@ -52,8 +54,10 @@ namespace sat static const SolvAttr installsize; static const SolvAttr downloadsize; static const SolvAttr diskusage; + //@} - //package + /** \name package */ + //@{ static const SolvAttr checksum; static const SolvAttr mediadir; static const SolvAttr medianr; @@ -73,8 +77,10 @@ namespace sat static const SolvAttr sourcename; static const SolvAttr sourceevr; static const SolvAttr headerend; + //@} - // patch + /** \name patch */ + //@{ static const SolvAttr patchcategory; static const SolvAttr rebootSuggested; static const SolvAttr restartSuggested; @@ -87,8 +93,10 @@ namespace sat static const SolvAttr updateReferenceHref; static const SolvAttr updateReferenceId; static const SolvAttr updateReferenceTitle; - - // pattern + //@} + + /** \name pattern */ + //@{ static const SolvAttr isvisible; static const SolvAttr icon; static const SolvAttr order; @@ -97,9 +105,22 @@ namespace sat static const SolvAttr script; static const SolvAttr includes; static const SolvAttr extends; + //@} + /** \name product */ + //@{ + static const SolvAttr productShortlabel; + static const SolvAttr productDistproduct; + static const SolvAttr productDistversion; + static const SolvAttr productType; + static const SolvAttr productRelnotesurl; + static const SolvAttr productUpdateurls; + static const SolvAttr productExtraurls; + static const SolvAttr productOptionalurls; + static const SolvAttr productFlags; //@} + //@} public: /** Default ctor: \ref noAttr */ SolvAttr() {} -- 2.7.4