Author: mlandres Date: Tue Jun 3 19:57:37 2008 New Revision: 10333 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10333&view=rev Log: - Take care satsolver recognizes 'Capability( "srcpackage:zypper" )' as 'source package named zypper'. So these capabilities can be used together with sat::Whatprovides or in resolver requests. (bnc #369893) Modified: branches/SuSE-Linux-11_0-Branch/libzypp/devel/devel.ma/NewPool.cc branches/SuSE-Linux-11_0-Branch/libzypp/zypp/Capability.cc Modified: branches/SuSE-Linux-11_0-Branch/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-11_0-Branch/libzypp/devel/devel.ma/NewPool.cc?rev=10333&r1=10332&r2=10333&view=diff ============================================================================== --- branches/SuSE-Linux-11_0-Branch/libzypp/devel/devel.ma/NewPool.cc (original) +++ branches/SuSE-Linux-11_0-Branch/libzypp/devel/devel.ma/NewPool.cc Tue Jun 3 19:57:37 2008 @@ -249,6 +249,7 @@ bool rres = false; { //zypp::base::LogControl::TmpLineWriter shutUp; + getZYpp()->resolver()->setIgnoreAlreadyRecommended( true ); rres = getZYpp()->resolver()->resolvePool(); } if ( ! rres ) @@ -533,7 +534,7 @@ } } - if ( 1 ) + if ( 0 ) { Measure x( "INIT TARGET" ); { @@ -558,21 +559,47 @@ } /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// + MIL << (*pool.byKindBegin<SrcPackage>())->provides() << endl; + MIL << (Capability( "srcpackage:foo == 1.0" ).detail()) << endl; + MIL << (Capability( "foo == 1.0", ResKind::srcpackage ).detail()) << endl; + MIL << (Capability( "foo.src == 1.0" ).detail()) << endl; + MIL << (Capability( "foo.i386 == 1.0" ).detail()) << endl; + + MIL << (Capability( "srcpackage:foo == 1.0" )) << endl; + MIL << (Capability( "foo == 1.0", ResKind::srcpackage )) << endl; + MIL << (Capability( "foo.src == 1.0" )) << endl; + MIL << (Capability( "foo.i386 == 1.0" )) << endl; + + SEC << sat::WhatProvides( Capability( "srcpackage:zypper" ) ) << endl;; + SEC << sat::WhatProvides( Capability( "zypper", ResKind::srcpackage ) ) << endl;; + SEC << sat::WhatProvides( Capability( "zypper.src" ) ) << endl;; + + /////////////////////////////////////////////////////////////////// + INT << "===[END]============================================" << endl << endl; + zypp::base::LogControl::instance().logNothing(); + return 0; SEC << zypp::getZYpp()->diskUsage() << endl; - for_( it, pool.byKindBegin<SrcPackage>(), pool.byKindEnd<SrcPackage>() ) +// for_( it, pool.byKindBegin<SrcPackage>(), pool.byKindEnd<SrcPackage>() ) { - MIL << *it << endl; +// MIL << *it << endl; } - for_( it, pool.byIdentBegin( ResKind::srcpackage, "zypper" ), pool.byIdentEnd( ResKind::srcpackage, "zypper" ) ) +// for_( it, pool.byIdentBegin( ResKind::srcpackage, "zypper" ), pool.byIdentEnd( ResKind::srcpackage, "zypper" ) ) { - WAR << *it << endl; +// WAR << *it << endl; } - + ui::Selectable::Ptr srcp( zypp::getZYpp()->poolProxy().lookup( ResKind::srcpackage, "zypper" ) ); + MIL << srcp << endl; + MIL << srcp->setStatus( S_Install ) << endl; + MIL << srcp << endl; + solve(); + vdumpPoolStats( USR << "Transacting:"<< endl, + make_filter_beginresfilter::ByTransact(pool), + make_filter_endresfilter::ByTransact(pool) ) << endl; /////////////////////////////////////////////////////////////////// INT << "===[END]============================================" << endl << endl; zypp::base::LogControl::instance().logNothing(); Modified: branches/SuSE-Linux-11_0-Branch/libzypp/zypp/Capability.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-Linux-11_0-Branch/libzypp/zypp/Capability.cc?rev=10333&r1=10332&r2=10333&view=diff ============================================================================== --- branches/SuSE-Linux-11_0-Branch/libzypp/zypp/Capability.cc (original) +++ branches/SuSE-Linux-11_0-Branch/libzypp/zypp/Capability.cc Tue Jun 3 19:57:37 2008 @@ -48,6 +48,13 @@ { nid = IdString( name_r ).id(); } + else if ( kind_r == ResKind::srcpackage ) + { + // map 'kind srcpackage' to 'arch src', the pseudo architecture + // satsolver uses. + nid = IdString( name_r ).id(); + nid = ::rel2id( pool_r, nid, IdString(ARCH_SRC).id(), REL_ARCH, /*create*/true ); + } else { nid = IdString( str::form( "%s:%s", @@ -56,8 +63,8 @@ } - // Extend name by architecture, if provided - if ( ! arch_r.empty() ) + // Extend name by architecture, if provided and not a srcpackage + if ( ! arch_r.empty() && kind_r != ResKind::srcpackage ) { nid = ::rel2id( pool_r, nid, arch_r.id(), REL_ARCH, /*create*/true ); } @@ -71,12 +78,22 @@ return nid; } - /** Build \ref Capability from data, just parsing name for '[.arch]'. + /** Build \ref Capability from data, just parsing name for '[.arch]' and detect + * 'kind srcpackage' (will be mapped to arch \c src). */ sat::detail::IdType relFromStr( ::_Pool * pool_r, const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & kind_r ) { + static const Arch srcArch( IdString(ARCH_SRC).asString() ); + static const std::string srcKindPrefix( ResKind::srcpackage.asString() + ':' ); + + // check for an embedded 'srcpackage:foo' to be mapped to 'foo' and 'ResKind::srcpackage'. + if ( kind_r.empty() && str::hasPrefix( name_r, srcKindPrefix ) ) + { + return relFromStr( pool_r, Arch_empty, name_r.substr( srcKindPrefix.size() ), op_r, ed_r, ResKind::srcpackage ); + } + Arch arch( Arch_empty ); std::string name( name_r ); @@ -84,7 +101,7 @@ if ( asep != std::string::npos ) { Arch ext( name_r.substr( asep+1 ) ); - if ( ext.isBuiltIn() ) + if ( ext.isBuiltIn() || ext == srcArch ) { arch = ext; name.erase( asep ); @@ -325,6 +342,12 @@ _kind = EXPRESSION; return; } + // map back satsolvers pseudo arch 'src' to kind srcpackage + if ( _archIfSimple == ARCH_SRC ) + { + _lhs = IdString( (ResKind::srcpackage.asString() + ":" + IdString(_lhs).c_str()).c_str() ).id(); + _archIfSimple = 0; + } } /****************************************************************** @@ -334,6 +357,7 @@ */ std::ostream & operator<<( std::ostream & str, const CapDetail & obj ) { + static const char archsep = '.'; switch ( obj.kind() ) { case CapDetail::NOCAP: @@ -342,13 +366,13 @@ case CapDetail::NAMED: str << obj.name(); if ( obj.hasArch() ) - str << '.' << obj.arch(); + str << archsep << obj.arch(); return str; break; case CapDetail::VERSIONED: str << obj.name(); if ( obj.hasArch() ) - str << '.' << obj.arch(); + str << archsep << obj.arch(); return str << " " << obj.op() << " " << obj.ed(); break; case CapDetail::EXPRESSION: -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org