Author: kkaempf Date: Thu Apr 10 12:22:44 2008 New Revision: 9502 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9502&view=rev Log: initial try on filling Patch::contents Modified: trunk/libzypp/zypp/Patch.cc Modified: trunk/libzypp/zypp/Patch.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Patch.cc?rev=9502&r1=9501&r2=9502&view=diff ============================================================================== --- trunk/libzypp/zypp/Patch.cc (original) +++ trunk/libzypp/zypp/Patch.cc Thu Apr 10 12:22:44 2008 @@ -74,8 +74,67 @@ Patch::Contents Patch::contents() const { -#warning FILL contents - return Contents(); + Contents result; + const sat::LookupAttr::iterator _col_name_it = sat::LookupAttr( sat::SolvAttr::updateCollectionName, *this ).begin(); + const sat::LookupAttr::iterator _col_evr_it = sat::LookupAttr( sat::SolvAttr::updateCollectionEvr, *this ).begin(); + const sat::LookupAttr::iterator _col_arch_it = sat::LookupAttr( sat::SolvAttr::updateCollectionArch, *this ).begin(); + + while (_col_name_it != sat::LookupAttr( sat::SolvAttr::updateCollectionName, *this ).end()) + { + /* safety checks, shouldn't happen (tm) */ + if (_col_evr_it == sat::LookupAttr( sat::SolvAttr::updateCollectionEvr, *this ).end() + || _col_arch_it == sat::LookupAttr( sat::SolvAttr::updateCollectionArch, *this ).end()) + { + /* FIXME: Raise exception ?! */ + break; + } + IdString nameid( _col_name_it.asString() ); /* IdString for fast compare */ + Arch arch( _col_arch_it.asString() ); + + /* search providers of name */ + sat::WhatProvides providers( Capability( _col_name_it.asString() ) ); + if (providers.empty()) + continue; + bool is_relevant = false; + for_( it, providers.begin(), providers.end() ) + { + if (it->ident() != nameid) /* package _name_ must match */ + continue; + + if (it->isSystem() /* only look at installed providers with same arch */ + && it->arch() == arch) + { + is_relevant = true; + } + } + if (!is_relevant) + continue; /* skip if name.arch is not installed */ + + /* find exact providers first (this matches the _real_ 'collection content' of the patch */ + sat::WhatProvides exact_providers( Capability( _col_name_it.asString(), Rel::EQ, _col_evr_it.asString(), ResKind::package ) ); + if (exact_providers.empty()) + { + /* no exact providers: find 'best' providers */ + sat::WhatProvides best_providers( Capability( _col_name_it.asString(), Rel::GT, _col_evr_it.asString(), ResKind::package ) ); + if (best_providers.empty()) + { + // Hmm, this patch is not installable, noone is providing the package in the collection + // raise execption ? fake a solvable ? + } + else + { + // FIXME ?! loop over providers and try to find installed ones ? + result.get().insert( *(best_providers.begin()) ); + } + } + else + { + // FIXME ?! loop over providers and try to find installed ones ? + result.get().insert( *(exact_providers.begin()) ); + } + } /* while (attribute array) */ + + return result; } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org