From: Michael Andres Date: Fri, 6 Nov 2009 21:15:27 +0000 (+0100) Subject: Selectable: Consider allowed arch/noarch changes when comuting candiadates. X-Git-Tag: 6.22.0~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3654a7b5cb9b3921e07e213a8b30ae11a271f0f;p=platform%2Fupstream%2Flibzypp.git Selectable: Consider allowed arch/noarch changes when comuting candiadates. --- diff --git a/tests/data/TCSelectable/RepoHIGH.xml b/tests/data/TCSelectable/RepoHIGH.xml index 6cfccd6..924fff9 100644 --- a/tests/data/TCSelectable/RepoHIGH.xml +++ b/tests/data/TCSelectable/RepoHIGH.xml @@ -10,11 +10,48 @@ candidate - unkown + unknown + + i586 + 4 + 1 + + + + + candidatenoarch + unknown + + noarch + 5 + 1 + + + + candidatenoarch + unknown + + x86_64 + 4 + 1 + + + + candidatenoarch + unknown i586 4 1 + + candidatenoarch + unknown + + noarch + 4 + 1 + + diff --git a/tests/data/TCSelectable/RepoMID.xml b/tests/data/TCSelectable/RepoMID.xml index f1b6d1d..3537414 100644 --- a/tests/data/TCSelectable/RepoMID.xml +++ b/tests/data/TCSelectable/RepoMID.xml @@ -17,4 +17,41 @@ 1 + + + candidatenoarch + openSUSE + + noarch + 0 + 2 + + + + candidatenoarch + openSUSE + + x86_64 + 0 + 1 + + + + candidatenoarch + openSUSE + + i586 + 0 + 1 + + + + candidatenoarch + openSUSE + + noarch + 0 + 1 + + diff --git a/tests/data/TCSelectable/solver-system.xml b/tests/data/TCSelectable/solver-system.xml index 4fe7341..7e1a908 100644 --- a/tests/data/TCSelectable/solver-system.xml +++ b/tests/data/TCSelectable/solver-system.xml @@ -8,4 +8,13 @@ 1 + + candidatenoarch + unknown + + i586 + 1 + 1 + + diff --git a/tests/zypp/Selectable_test.cc b/tests/zypp/Selectable_test.cc index a878f42..8d49f80 100644 --- a/tests/zypp/Selectable_test.cc +++ b/tests/zypp/Selectable_test.cc @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(candiadate) // U__s_(2)candidate-4-1.x86_64(RepoHIGH)(unkown) // U__s_(3)candidate-4-1.i586(RepoHIGH)(unkown) // U__s_(6)candidate-0-1.x86_64(RepoMID)(SUSE) - // U__s_(7)candidate-0-1.i586(RepoMID)(SUSE) <- candidate (highrst prio matching arch and vendor) + // U__s_(7)candidate-0-1.i586(RepoMID)(SUSE) <- candidate (highest prio matching arch and vendor) // U__s_(4)candidate-2-1.x86_64(RepoLOW)(openSUSE) // U__s_(5)candidate-2-1.i586(RepoLOW)(openSUSE) // } @@ -39,3 +39,28 @@ BOOST_AUTO_TEST_CASE(candiadate) // no updateCandidate due to low version BOOST_CHECK_EQUAL( s->updateCandidateObj(), PoolItem() ); } + +BOOST_AUTO_TEST_CASE(candiadatenoarch) +{ + ResPoolProxy poolProxy( test.poolProxy() ); + ui::Selectable::Ptr s( poolProxy.lookup( ResKind::package, "candidatenoarch" ) ); +/*[package]candidatenoarch: S_KeepInstalled + (I 1) { + I__s_(17)candidatenoarch-1-1.i586(@System) +} (A 8) { + C U__s_(4)candidatenoarch-5-1.noarch(RepoHIGH) <- candidate (arch/noarch change) + U__s_(5)candidatenoarch-4-1.x86_64(RepoHIGH) + U__s_(6)candidatenoarch-4-1.i586(RepoHIGH) + U__s_(7)candidatenoarch-4-1.noarch(RepoHIGH) + U__s_(12)candidatenoarch-0-2.noarch(RepoMID) + U__s_(13)candidatenoarch-0-1.x86_64(RepoMID) + U__s_(14)candidatenoarch-0-1.i586(RepoMID) + U__s_(15)candidatenoarch-0-1.noarch(RepoMID) +} */ + std::cout << dump(s) << endl; + BOOST_CHECK_EQUAL( s->candidateObj()->repoInfo().alias(), "RepoHIGH" ); + BOOST_CHECK_EQUAL( s->candidateObj()->edition(), Edition("5-1") ); + BOOST_CHECK_EQUAL( s->candidateObj()->arch(), Arch_noarch ); + // no updateCandidate due to low version + BOOST_CHECK_EQUAL( s->updateCandidateObj(), s->candidateObj() ); +} diff --git a/zypp/ui/SelectableImpl.h b/zypp/ui/SelectableImpl.h index 7d211b4..86f1ecc 100644 --- a/zypp/ui/SelectableImpl.h +++ b/zypp/ui/SelectableImpl.h @@ -154,8 +154,9 @@ namespace zypp || VendorAttr::instance().equivalent( _defaultCandidate->vendor(), installed->vendor() ) ) ) return PoolItem(); - // check arch change - if ( _defaultCandidate->arch() != installed->arch() ) + // check arch change (arch noarch changes are allowed) + if ( _defaultCandidate->arch() != installed->arch() + && ! ( _defaultCandidate->arch() == Arch_noarch || installed->arch() == Arch_noarch ) ) return PoolItem(); // check greater edition @@ -280,11 +281,12 @@ namespace zypp for ( installed_const_iterator iit = installedBegin(); iit != installedEnd(); ++iit ) { - PoolItem sameArch; // in case there's no same vendor at least stay with same arch + PoolItem sameArch; // in case there's no same vendor at least stay with same arch. for ( available_const_iterator it = availableBegin(); it != availableEnd(); ++it ) { - if ( (*iit)->arch() == (*it)->arch() ) + // 'same arch' includes allowed changes to/from noarch. + if ( (*iit)->arch() == (*it)->arch() || (*iit)->arch() == Arch_noarch || (*it)->arch() == Arch_noarch ) { if ( ! solver_allowVendorChange ) { @@ -345,14 +347,43 @@ namespace zypp inline std::ostream & dumpOn( std::ostream & str, const Selectable::Impl & obj ) { str << '[' << obj.kind() << ']' << obj.name() << ": " << obj.status() << endl; - if ( obj.candidateObj() ) - str << "(C " << obj.candidateObj() << ")" << endl; - else - str << "(C NONE )" << endl; - dumpRange( str << " (I " << obj.installedSize() << ") ", obj.installedBegin(), obj.installedEnd() ); + if ( obj.installedEmpty() ) - str << endl << " "; - dumpRange( str << " (A " << obj.availableSize() << ") ", obj.availableBegin(), obj.availableEnd() ) << endl; + str << " (I 0) {}" << endl << " "; + else + { + str << " (I " << obj.installedSize() << ") {" << endl; + for_( it, obj.installedBegin(), obj.installedEnd() ) + { + str << " " << *it << endl; + } + str << "} "; + } + + if ( obj.availableEmpty() ) + { + str << "(A 0) {}"; + } + else + { + PoolItem cand( obj.candidateObj() ); + PoolItem up( obj.updateCandidateObj() ); + str << "(A " << obj.availableSize() << ") {" << endl; + for_( it, obj.availableBegin(), obj.availableEnd() ) + { + char t = ' '; + if ( *it == cand ) + { + t = *it == up ? 'C' : 'c'; + } + else if ( *it == up ) + { + t = 'u'; + } + str << " " << t << " " << *it << endl; + } + str << "} "; + } return str; } diff --git a/zypp/ui/SelectableTraits.h b/zypp/ui/SelectableTraits.h index b994bf7..298994f 100644 --- a/zypp/ui/SelectableTraits.h +++ b/zypp/ui/SelectableTraits.h @@ -34,7 +34,7 @@ namespace zypp { /** Oder on AvailableItemSet. * \li repository priority - * \li best Arch + * \li best Arch (arch/noarch changes are ok) * \li best Edition * \li ResObject::constPtr as fallback. */ @@ -47,21 +47,30 @@ namespace zypp // bool operator()( const PoolItem & lhs, const PoolItem & rhs ) const { - unsigned lprio = lhs->satSolvable().repository().info().priority(); - unsigned rprio = rhs->satSolvable().repository().info().priority(); + int lprio = lhs->satSolvable().repository().satInternalPriority(); + int rprio = rhs->satSolvable().repository().satInternalPriority(); if ( lprio != rprio ) - return( lprio < rprio ); // lower value meands higher priority :( - int res = lhs->arch().compare( rhs->arch() ); - if ( res ) - return res > 0; - res = lhs->edition().compare( rhs->edition() ); + return( lprio > rprio ); + + // arch/noarch changes are ok. + if ( lhs->arch() != Arch_noarch && rhs->arch() != Arch_noarch ) + { + int res = lhs->arch().compare( rhs->arch() ); + if ( res ) + return res > 0; + } + + int res = lhs->edition().compare( rhs->edition() ); if ( res ) return res > 0; - // no more criteria, still equal: - // use the ResObject::constPtr (the poiner value) - // (here it's arbitrary whether < or > ) - return lhs.resolvable() < rhs.resolvable(); + lprio = lhs->satSolvable().repository().satInternalSubPriority(); + rprio = rhs->satSolvable().repository().satInternalSubPriority(); + if ( lprio != rprio ) + return( lprio > rprio ); + + // no more criteria, still equal: sort by id + return lhs.satSolvable().id() < rhs.satSolvable().id(); } }; @@ -90,10 +99,8 @@ namespace zypp if ( ldate != rdate ) return( ldate > rdate ); - // no more criteria, still equal: - // use the ResObject::constPtr (the poiner value) - // (here it's arbitrary whether < or > ) - return lhs.resolvable() < rhs.resolvable(); + // no more criteria, still equal: sort by id + return lhs.satSolvable().id() < rhs.satSolvable().id(); } };