#include "zypp/base/String.h"
#include "zypp/base/Logger.h"
#include "zypp/base/Gettext.h"
-
-#include "zypp/RepoInfo.h"
-
#include "zypp/Pathname.h"
+
#include "zypp/parser/xml/Reader.h"
#include "zypp/parser/ParseException.h"
+#include "zypp/RepoInfo.h"
+#include "zypp/Target.h"
+#include "zypp/ZYppFactory.h"
+
#include "zypp/parser/RepoindexFileReader.h"
private:
/** Function for processing collected data. Passed-in through constructor. */
ProcessResource _callback;
+ string _target_distro;
};
///////////////////////////////////////////////////////////////////////
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 ) );
}
if ( reader_r->name() == "repo" )
{
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