From: Michael Andres Date: Sat, 11 Mar 2006 00:27:06 +0000 (+0000) Subject: backup X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~1591 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64cf62a4ff279dd8fc2fb6492f5a9eadd83b55b0;p=platform%2Fupstream%2Flibzypp.git backup --- diff --git a/devel/devel.ma/Main.cc b/devel/devel.ma/Main.cc index 3696277..ec86332 100644 --- a/devel/devel.ma/Main.cc +++ b/devel/devel.ma/Main.cc @@ -2,105 +2,14 @@ #include #include -#include "Printing.h" +#include "Tools.h" #include -#include -#include -#include -#include -#include - -#include +#include using namespace std; using namespace zypp; -using namespace zypp::functor; - -inline const char * compResult( int res ) -{ - return( res ? ( res < 0 ? "<" : ">" ) : "=" ); -} - -template - inline void sym_compare( _Iter begin, _Iter end, _Function fnc ) - { - for ( _Iter l = begin; l != end; ++l ) - for ( _Iter r = begin; r != end; ++r ) - fnc( *l, *r ); - } - -template - inline _BinaryFunction - nest_for_earch( _LIter lbegin, _LIter lend, - _RIter rbegin, _RIter rend, - _BinaryFunction fnc ) - { - for ( ; lbegin != lend; ++lbegin ) - for ( _RIter r = rbegin; r != rend; ++r ) - fnc( *lbegin, *r ); - return fnc; - } - -template - inline _BinaryFunction - nest_for_earch( _Iter begin, _Iter end, - _BinaryFunction fnc ) - { return nest_for_earch( begin, end, begin, end, fnc ); } - - -template - inline void sym_compare( _Iter begin, _Iter end ) - { - sym_compare( begin, end, _Function() ); - } - -inline list archList() -{ - list ret; - ret.push_back( Arch_noarch ); - ret.push_back( Arch_src ); - ret.push_back( Arch_x86_64 ); - ret.push_back( Arch_athlon ); - ret.push_back( Arch_i686 ); - ret.push_back( Arch_i586 ); - ret.push_back( Arch_i486 ); - ret.push_back( Arch_i386 ); - ret.push_back( Arch_s390x ); - ret.push_back( Arch_s390 ); - ret.push_back( Arch_ppc64 ); - ret.push_back( Arch_ppc ); - ret.push_back( Arch_ia64 ); - ret.push_back( Arch( "unknown" ) ); - ret.push_back( Arch( "unknown2" ) ); - ret.push_back( Arch() ); - ret.push_back( Arch("") ); - return ret; -} - -static list archlist( archList() ); -static set archset( archlist.begin(), archlist.end() ); - -struct CompatTest -{ - void operator()( const Arch & lhs, const Arch & rhs ) const - { - DBG << str::form( "%-10s --> %-10s : %6s : %s", - lhs.asString().c_str(), - rhs.asString().c_str(), - ( lhs.compatibleWith( rhs ) ? "COMPAT" : "no" ), - compResult( lhs.compare( rhs ) ) ) - - << std::endl; - } -}; - -struct OrderByCompare : public std::binary_function -{ - bool operator()( const Arch & lhs, const Arch & rhs ) const - { return lhs.compare( rhs ) < 0; } -}; /****************************************************************** ** @@ -111,22 +20,24 @@ int main( int argc, char * argv[] ) { INT << "===[START]==========================================" << endl; - // All archs in test - print( archlist ); + ResStatus stat; + MIL << stat << endl; + + DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW ) + << ' ' << stat << endl; + + DBG << stat.setTransact( false, ResStatus::APPL_LOW ) + << ' ' << stat << endl; - // set ordering - print( archset ); + DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW ) + << ' ' << stat << endl; - // compatibleWith - sym_compare( archset.begin(), archset.end(), CompatTest() ); + DBG << stat.setTransact( false, ResStatus::APPL_HIGH ) + << ' ' << stat << endl; - // compare order - typedef set OrderedArch; + DBG << stat.setSoftTransact( true, ResStatus::SOLVER, ResStatus::APPL_LOW ) + << ' ' << stat << endl; - OrderedArch a( archset.begin(), archset.end() ); - print( a ); - OrderedArch b( archset.rbegin(), archset.rend() ); - print( b ); INT << "===[END]============================================" << endl << endl; return 0; diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index 9173265..200a644 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -23,7 +23,9 @@ #include "zypp/ResPool.h" #include "zypp/ResFilters.h" #include "zypp/CapFilters.h" +#include "zypp/Package.h" +#include #include #include @@ -72,7 +74,7 @@ namespace zypp } // namespace zypp /////////////////////////////////////////////////////////////////// -struct X : public base::ProvideNumericId +struct X : public base::ProvideNumericId { }; @@ -94,15 +96,20 @@ template<> bool operator()( const ui::Selectable::Ptr & obj ) { if ( obj ) { + obj->set_status( ui::S_Install ); USR << *obj << std::endl; std::for_each( obj->availableBegin(), obj->availableEnd(), PrintPtr() ); + if ( obj->availableBegin() != obj->availableEnd() ) + SEC << PrintPtr()(*obj->availableBegin() ) + << " " << asKind(*obj->availableBegin())->vendor() << endl; } else USR << "(NULL)" << std::endl; return true; } }; + /****************************************************************** ** ** FUNCTION NAME : main @@ -117,7 +124,17 @@ int main( int argc, char * argv[] ) if (argc >= 2 ) infile = argv[1]; - Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/SOURCE") ); + DBG << Source_Ref() << endl; + DBG << Source_Ref::noSource << endl; + Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma") ); + DBG << *SourceManager::sourceManager() << endl; + SourceManager::sourceManager()->addSource( src ); + SourceManager::sourceManager()->removeSource( 0 ); + SourceManager::sourceManager()->removeSource( src.numericId() ); + return 0; + + //Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma") ); + //Source_Ref src( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/SOURCE") ); Source_Ref trg( createSource("dir:/Local/ma/zypp/libzypp/devel/devel.ma/TARGET") ); ResPoolManager pool; @@ -129,10 +146,16 @@ int main( int argc, char * argv[] ) std::for_each( query.begin(), query.end(), Print() ); ResPoolProxy y2pm( query ); + y2pm.saveState(); std::for_each( y2pm.byKindBegin(), y2pm.byKindEnd(), PrintPtr() ); + + y2pm.saveState(); + SEC << y2pm.diffState() << endl; + + INT << "===[END]============================================" << endl << endl; return 0; } diff --git a/devel/devel.ma/Test.cc b/devel/devel.ma/Test.cc new file mode 100644 index 0000000..1644e70 --- /dev/null +++ b/devel/devel.ma/Test.cc @@ -0,0 +1,102 @@ +#include + +#include "zypp/base/LogControl.h" + +#include "zypp/Locale.h" + + +using std::endl; +using namespace zypp; + +inline std::string vstr( const char * str ) +{ + std::string ret; + if ( str ) + { + ret+="\""; + ret+=str; + ret+="\""; + } + return ret; +} + +void test( const Locale & val_r ) +{ + DBG << " <<: " << (val_r) << endl; + DBG << " code: " << (val_r.code()) << endl; + DBG << " name: " << (val_r.name()) << endl; + DBG << " ==noCode: " << (val_r == Locale::noCode) << endl; + DBG << " !=noCode: " << (val_r != Locale::noCode) << endl; + DBG << " Language: " << (val_r.language()) << endl; + DBG << " Country: " << (val_r.country()) << endl; +} + +void test( const LanguageCode & val_r ) +{ + DBG << " <<: " << (val_r) << endl; + DBG << " code: " << (val_r.code()) << endl; + DBG << " name: " << (val_r.name()) << endl; + DBG << " ==noCode: " << (val_r == LanguageCode::noCode) << endl; + DBG << " !=noCode: " << (val_r != LanguageCode::noCode) << endl; + DBG << " ==default: " << (val_r == LanguageCode::useDefault) << endl; + DBG << " !=default: " << (val_r != LanguageCode::useDefault) << endl; +} + +void test( const CountryCode & val_r ) +{ + DBG << " <<: " << (val_r) << endl; + DBG << " code: " << (val_r.code()) << endl; + DBG << " name: " << (val_r.name()) << endl; + DBG << " ==noCode: " << (val_r == CountryCode::noCode) << endl; + DBG << " !=noCode: " << (val_r != CountryCode::noCode) << endl; +} + +void testLocale( const char * str = 0 ) +{ + MIL << "Locale(" << vstr(str) << ")" << endl; + test( str ? Locale( str ) : Locale() ); +} + +void testLanguage( const char * str = 0 ) +{ + MIL << "Language(" << vstr(str) << ")" << endl; + test( str ? LanguageCode( str ) : LanguageCode() ); +} + +void testCountry( const char * str = 0 ) +{ + MIL << "Country(" << vstr(str) << ")" << endl; + test( str ? CountryCode( str ) : CountryCode() ); +} + +/****************************************************************** +** +** FUNCTION NAME : main +** FUNCTION TYPE : int +*/ +int main( int argc, char * argv[] ) +{ + //zypp::base::LogControl::instance().logfile( "xxx" ); + INT << "===[START]==========================================" << endl; + + testLocale(); + testLocale( "" ); + testLocale( "en" ); + testLocale( "de_DE" ); + testLocale( "C" ); + testLocale( "POSIX" ); + testLocale( "default" ); + + testLanguage(); + testLanguage( "" ); + testLanguage( "en" ); + testLanguage( "default" ); + + testCountry(); + testCountry( "" ); + testCountry( "US" ); + testCountry( "DE" ); + + INT << "===[END]============================================" << endl; + return 0; +} diff --git a/devel/devel.ma/Tools.h b/devel/devel.ma/Tools.h index 9c5cb72..29b1808 100644 --- a/devel/devel.ma/Tools.h +++ b/devel/devel.ma/Tools.h @@ -68,12 +68,22 @@ template /////////////////////////////////////////////////////////////////// inline Source_Ref createSource( const std::string & url_r ) { + Source_Ref ret; Measure x( "createSource: " + url_r ); - Source_Ref ret( SourceFactory().createFrom( Url(url_r) ) ); + try + { + ret = SourceFactory().createFrom( Url(url_r) ); + } + catch ( const Exception & ) + { + return Source_Ref::noSource; + } x.start( "parseSource: " + url_r ); ret.resolvables(); x.stop(); + MIL << "Content " << ret << "{" << endl; rstats( ret.resolvables() ); + MIL << "}" << endl; return ret; } diff --git a/devel/devel.ma/ma_test b/devel/devel.ma/ma_test index d1f6e33..76b9c13 100755 --- a/devel/devel.ma/ma_test +++ b/devel/devel.ma/ma_test @@ -32,4 +32,5 @@ fi #$MAKE -C ../../zypp || exit 1 $MAKE $PRG || exit 1 +export ZYPP_LOGFILE=- ./$PRG "$@" 2> $LPIPE diff --git a/devel/devel.ma/main.cc b/devel/devel.ma/main.cc index 539e6d2..257e63b 100644 --- a/devel/devel.ma/main.cc +++ b/devel/devel.ma/main.cc @@ -6,41 +6,6 @@ using std::string; using std::map; -struct Resolvable::Impl -{ - string _kind; -}; - -Resolvable::Resolvable( const string kind_r /*NVRA*/ ) -: _impl( new Impl ) -{ - _impl->_kind = kind_r; -} -Resolvable::~Resolvable() -{} -std::ostream & Resolvable::dumpOn( std::ostream & str ) const -{ - return str << '[' << kind() << ']' << name(); -} - -string Resolvable::kind() const { return _impl->_kind; } -string Resolvable::name() const { return "n"; } - - -Object::Object( const string kind_r /*NVRA*/ ) -: Resolvable( kind_r ) -{} -Object::~Object() -{} - -string Object::summary() const { return impl().summary(); } -list Object::description() const { return impl().description(); } - - -Package::Package( /*NVRA*/ ) -: Object( "Package" /*NVRA*/ ) -{} -Package::~Package() {} string Package::packagedata() const { return impl().packagedata(); } diff --git a/devel/devel.ma/testdrafts/Arch.cc b/devel/devel.ma/testdrafts/Arch.cc index 8823525..28d7ad9 100644 --- a/devel/devel.ma/testdrafts/Arch.cc +++ b/devel/devel.ma/testdrafts/Arch.cc @@ -4,7 +4,7 @@ #include "Printing.h" -#include +#include #include #include #include @@ -12,6 +12,8 @@ #include #include +#include +#include using namespace std; using namespace zypp; @@ -29,6 +31,26 @@ template for ( _Iter r = begin; r != end; ++r ) fnc( *l, *r ); } + +template + inline _BinaryFunction + nest_for_earch( _LIter lbegin, _LIter lend, + _RIter rbegin, _RIter rend, + _BinaryFunction fnc ) + { + for ( ; lbegin != lend; ++lbegin ) + for ( _RIter r = rbegin; r != rend; ++r ) + fnc( *lbegin, *r ); + return fnc; + } + +template + inline _BinaryFunction + nest_for_earch( _Iter begin, _Iter end, + _BinaryFunction fnc ) + { return nest_for_earch( begin, end, begin, end, fnc ); } + + template inline void sym_compare( _Iter begin, _Iter end ) { @@ -54,6 +76,7 @@ inline list archList() ret.push_back( Arch( "unknown" ) ); ret.push_back( Arch( "unknown2" ) ); ret.push_back( Arch() ); + ret.push_back( Arch("") ); return ret; } @@ -81,6 +104,14 @@ struct OrderByCompare : public std::binary_function { return lhs.compare( rhs ) < 0; } }; + +void dumpOn( const Arch::CompatSet & s ) +{ + SEC << str::join( make_transform_iterator( s.begin(), std::mem_fun_ref(&Arch::asString) ), + make_transform_iterator( s.end(), std::mem_fun_ref(&Arch::asString) ) ) + << endl; +} + /****************************************************************** ** ** FUNCTION NAME : main @@ -107,6 +138,19 @@ int main( int argc, char * argv[] ) OrderedArch b( archset.rbegin(), archset.rend() ); print( b ); + dumpOn( Arch::compatSet( Arch_noarch ) ); + dumpOn( Arch::compatSet( Arch_i486 ) ); + dumpOn( Arch::compatSet( Arch_x86_64 ) ); + dumpOn( Arch::compatSet( Arch("Foo") ) ); + + typedef set > AS; + Arch::CompatSet x( Arch::compatSet(Arch_x86_64) ); + AS rx( x.begin(), x.end() ); + INT << str::join( make_transform_iterator( rx.begin(), std::mem_fun_ref(&Arch::asString) ), + make_transform_iterator( rx.end(), std::mem_fun_ref(&Arch::asString) ) ) + << endl; + + INT << "===[END]============================================" << endl << endl; return 0; } diff --git a/devel/devel.ma/testdrafts/Locale.cc b/devel/devel.ma/testdrafts/Locale.cc new file mode 100644 index 0000000..1644e70 --- /dev/null +++ b/devel/devel.ma/testdrafts/Locale.cc @@ -0,0 +1,102 @@ +#include + +#include "zypp/base/LogControl.h" + +#include "zypp/Locale.h" + + +using std::endl; +using namespace zypp; + +inline std::string vstr( const char * str ) +{ + std::string ret; + if ( str ) + { + ret+="\""; + ret+=str; + ret+="\""; + } + return ret; +} + +void test( const Locale & val_r ) +{ + DBG << " <<: " << (val_r) << endl; + DBG << " code: " << (val_r.code()) << endl; + DBG << " name: " << (val_r.name()) << endl; + DBG << " ==noCode: " << (val_r == Locale::noCode) << endl; + DBG << " !=noCode: " << (val_r != Locale::noCode) << endl; + DBG << " Language: " << (val_r.language()) << endl; + DBG << " Country: " << (val_r.country()) << endl; +} + +void test( const LanguageCode & val_r ) +{ + DBG << " <<: " << (val_r) << endl; + DBG << " code: " << (val_r.code()) << endl; + DBG << " name: " << (val_r.name()) << endl; + DBG << " ==noCode: " << (val_r == LanguageCode::noCode) << endl; + DBG << " !=noCode: " << (val_r != LanguageCode::noCode) << endl; + DBG << " ==default: " << (val_r == LanguageCode::useDefault) << endl; + DBG << " !=default: " << (val_r != LanguageCode::useDefault) << endl; +} + +void test( const CountryCode & val_r ) +{ + DBG << " <<: " << (val_r) << endl; + DBG << " code: " << (val_r.code()) << endl; + DBG << " name: " << (val_r.name()) << endl; + DBG << " ==noCode: " << (val_r == CountryCode::noCode) << endl; + DBG << " !=noCode: " << (val_r != CountryCode::noCode) << endl; +} + +void testLocale( const char * str = 0 ) +{ + MIL << "Locale(" << vstr(str) << ")" << endl; + test( str ? Locale( str ) : Locale() ); +} + +void testLanguage( const char * str = 0 ) +{ + MIL << "Language(" << vstr(str) << ")" << endl; + test( str ? LanguageCode( str ) : LanguageCode() ); +} + +void testCountry( const char * str = 0 ) +{ + MIL << "Country(" << vstr(str) << ")" << endl; + test( str ? CountryCode( str ) : CountryCode() ); +} + +/****************************************************************** +** +** FUNCTION NAME : main +** FUNCTION TYPE : int +*/ +int main( int argc, char * argv[] ) +{ + //zypp::base::LogControl::instance().logfile( "xxx" ); + INT << "===[START]==========================================" << endl; + + testLocale(); + testLocale( "" ); + testLocale( "en" ); + testLocale( "de_DE" ); + testLocale( "C" ); + testLocale( "POSIX" ); + testLocale( "default" ); + + testLanguage(); + testLanguage( "" ); + testLanguage( "en" ); + testLanguage( "default" ); + + testCountry(); + testCountry( "" ); + testCountry( "US" ); + testCountry( "DE" ); + + INT << "===[END]============================================" << endl; + return 0; +}