Mailinglist Archive: zypp-commit (233 mails)

< Previous Next >
[zypp-commit] <libzypp> master : Selectable: Consider allowed arch/noarch changes when comuting candiadates.
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Fri, 6 Nov 2009 22:15:27 +0100
  • Message-id: <E1N6WCU-0006CI-Lt@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit d3654a7b5cb9b3921e07e213a8b30ae11a271f0f
Author: Michael Andres <ma@xxxxxxx>
Date: Fri Nov 6 22:15:27 2009 +0100

Selectable: Consider allowed arch/noarch changes when comuting candiadates.
---
tests/data/TCSelectable/RepoHIGH.xml | 39 ++++++++++++++++++++-
tests/data/TCSelectable/RepoMID.xml | 37 ++++++++++++++++++++
tests/data/TCSelectable/solver-system.xml | 9 +++++
tests/zypp/Selectable_test.cc | 27 ++++++++++++++-
zypp/ui/SelectableImpl.h | 53 +++++++++++++++++++++++------
zypp/ui/SelectableTraits.h | 39 ++++++++++++---------
6 files changed, 175 insertions(+), 29 deletions(-)

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 @@
</package>
<package>
<name>candidate</name>
- <vendor>unkown</vendor>
+ <vendor>unknown</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>4</version>
+ <release>1</release>
+ </update></history>
+</package>
+
+<package>
+ <name>candidatenoarch</name>
+ <vendor>unknown</vendor>
+ <history><update>
+ <arch>noarch</arch>
+ <version>5</version>
+ <release>1</release>
+ </update></history>
+</package>
+<package>
+ <name>candidatenoarch</name>
+ <vendor>unknown</vendor>
+ <history><update>
+ <arch>x86_64</arch>
+ <version>4</version>
+ <release>1</release>
+ </update></history>
+</package>
+<package>
+ <name>candidatenoarch</name>
+ <vendor>unknown</vendor>
<history><update>
<arch>i586</arch>
<version>4</version>
<release>1</release>
</update></history>
</package>
+<package>
+ <name>candidatenoarch</name>
+ <vendor>unknown</vendor>
+ <history><update>
+ <arch>noarch</arch>
+ <version>4</version>
+ <release>1</release>
+ </update></history>
+</package>
</subchannel></channel>
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 @@
<release>1</release>
</update></history>
</package>
+
+<package>
+ <name>candidatenoarch</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>noarch</arch>
+ <version>0</version>
+ <release>2</release>
+ </update></history>
+</package>
+<package>
+ <name>candidatenoarch</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>x86_64</arch>
+ <version>0</version>
+ <release>1</release>
+ </update></history>
+</package>
+<package>
+ <name>candidatenoarch</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>0</version>
+ <release>1</release>
+ </update></history>
+</package>
+<package>
+ <name>candidatenoarch</name>
+ <vendor>openSUSE</vendor>
+ <history><update>
+ <arch>noarch</arch>
+ <version>0</version>
+ <release>1</release>
+ </update></history>
+</package>
</subchannel></channel>
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 @@
<release>1</release>
</update></history>
</package>
+<package>
+ <name>candidatenoarch</name>
+ <vendor>unknown</vendor>
+ <history><update>
+ <arch>i586</arch>
+ <version>1</version>
+ <release>1</release>
+ </update></history>
+</package>
</subchannel></channel>
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();
}
};

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages