Author: jkupec Date: Wed Sep 3 18:23:05 2008 New Revision: 10926 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10926&view=rev Log: - filtering of repos with non-matching repos moved to RepoManager - desired targetDistribution can be set explicitly via RepoManagerOptions Modified: trunk/libzypp/zypp/RepoManager.cc trunk/libzypp/zypp/RepoManager.h trunk/libzypp/zypp/parser/RepoindexFileReader.cc Modified: trunk/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=10926&r1=10925&r2=10926&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.cc (original) +++ trunk/libzypp/zypp/RepoManager.cc Wed Sep 3 18:23:05 2008 @@ -41,6 +41,9 @@ #include "zypp/repo/susetags/Downloader.h" #include "zypp/parser/plaindir/RepoParser.h" +#include "zypp/Target.h" // for Target::targetDistribution() for repo index services +#include "zypp/ZYppFactory.h" // to get the Target from ZYpp instance + #include "zypp/ZYppCallbacks.h" #include "sat/Pool.h" @@ -74,6 +77,14 @@ knownReposPath = Pathname::assertprefix( root_r, ZConfig::instance().knownReposPath() ); knownServicesPath = Pathname::assertprefix( root_r, ZConfig::instance().knownServicesPath() ); probe = ZConfig::instance().repo_add_probe(); + try + { + servicesTargetDistro = getZYpp()->target()->targetDistribution(); + } + catch (const Exception & e) + { + DBG << "Target not initialized, using an empty servicesTargetDistro." << endl; + } } RepoManagerOptions RepoManagerOptions::makeTestSetup( const Pathname & root_r ) @@ -97,24 +108,46 @@ * once per each repo in a file. * * Passing this functor as callback, you can collect - * all resuls at the end, without dealing with async + * all results at the end, without dealing with async * code. + * + * If targetDistro is set, all repos with non-empty RepoInfo::targetDistribution() + * will be skipped. + * \todo do this through a separate filter */ struct RepoCollector { RepoCollector() {} + + RepoCollector(const string & targetDistro_) + : targetDistro(targetDistro_) + {} ~RepoCollector() {} bool collect( const RepoInfo &repo ) { + // skip repositories meant for other distros than specified + if (!targetDistro.empty() + && !repo.targetDistribution().empty() + && repo.targetDistribution() != targetDistro) + { + MIL + << "Skipping repository meant for '" << targetDistro + << "' distribution (current distro is '" + << repo.targetDistribution() << "')." << endl; + + return true; + } + repos.push_back(repo); return true; } RepoInfoList repos; + string targetDistro; }; //////////////////////////////////////////////////////////////////////////// @@ -1457,8 +1490,8 @@ mediamanager.provideFile( mid, "repo/repoindex.xml" ); Pathname path = mediamanager.localPath(mid, "repo/repoindex.xml" ); - //parse it - RepoCollector collector; + // parse it + RepoCollector collector(_pimpl->options.servicesTargetDistro); parser::RepoindexFileReader reader( path, bind( &RepoCollector::collect, &collector, _1 ) ); mediamanager.release( mid ); Modified: trunk/libzypp/zypp/RepoManager.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.h?rev=10926&r1=10925&r2=10926&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.h (original) +++ trunk/libzypp/zypp/RepoManager.h Wed Sep 3 18:23:05 2008 @@ -81,6 +81,17 @@ Pathname knownReposPath; Pathname knownServicesPath; bool probe; + /** + * Target distro ID to be used when refreshing repo index services. + * Repositories not maching this ID will be skipped/removed. + * + * The value is initialized upon construction to + * \ref Target::targetDistribution() if the Target is already initialized, + * otherwise the value is initially empty. + * + * If empty, no repositories contained in the index will be skipped. + */ + std::string servicesTargetDistro; }; Modified: trunk/libzypp/zypp/parser/RepoindexFileReader.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/RepoindexFileReader.cc?rev=10926&r1=10925&r2=10926&view=diff ============================================================================== --- trunk/libzypp/zypp/parser/RepoindexFileReader.cc (original) +++ trunk/libzypp/zypp/parser/RepoindexFileReader.cc Wed Sep 3 18:23:05 2008 @@ -68,11 +68,9 @@ RepoindexFileReader::Impl::Impl( const Pathname &repoindex_file, const ProcessResource & callback) : _callback(callback) - , _target_distro(getZYpp()->target()->targetDistribution()) { Reader reader( repoindex_file ); MIL << "Reading " << repoindex_file << endl; - MIL << "Target distro: '" << _target_distro << "'" << endl; reader.foreachNode( bind( &RepoindexFileReader::Impl::consumeNode, this, _1 ) ); } @@ -104,18 +102,6 @@ { XmlString s; - // skip repositories with unknown or not matching target distribution - s = reader_r->getAttribute("distro_target"); - if (!s.get() || _target_distro != s.asString()) - { - MIL - << "Skipping repository meant for '" - << (s.get() ? s.asString() : "(not specified)") - << "' distribution (current distro is '" << _target_distro << "')." - << endl; - return true; - } - RepoInfo info; // url and/or path @@ -151,6 +137,11 @@ if (s.get()) info.setName(s.asString()); + // optional targetDistro + s = reader_r->getAttribute("distro_target"); + if (s.get()) + info.setTargetDistribution(s.asString()); + DBG << info << endl; // ignore the rest -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org