From e19233bce4ff56ec43c02098e99e6badae037243 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Tue, 12 Feb 2008 15:16:16 +0000 Subject: [PATCH] filter unwanted architectures from pool --- zypp/Arch.h | 11 ++++-- zypp/parser/susetags/PackagesFileReader.cc | 2 +- zypp/sat/Repo.cc | 2 ++ zypp/sat/detail/PoolImpl.cc | 57 ++++++++++++++++++++++++++++-- zypp/sat/detail/PoolImpl.h | 7 ++-- 5 files changed, 68 insertions(+), 11 deletions(-) diff --git a/zypp/Arch.h b/zypp/Arch.h index cc5cb45..8f7b76f 100644 --- a/zypp/Arch.h +++ b/zypp/Arch.h @@ -17,10 +17,12 @@ #include #include -#include "zypp/RelCompare.h" #include "zypp/base/String.h" #include "zypp/base/Iterator.h" +#include "zypp/IdStringType.h" +#include "zypp/RelCompare.h" + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -42,10 +44,13 @@ namespace zypp public: /** String representation of Arch. */ + IdString idStr() const + { return IdString( asString() ); } + /** \overload */ const std::string & asString() const; /** \overload */ - const std::string & string() const - { return asString(); } + const char * c_str() const + { return asString().c_str(); } /** Test for an empty Arch (this is "", not Arch_noarch). */ bool empty() const diff --git a/zypp/parser/susetags/PackagesFileReader.cc b/zypp/parser/susetags/PackagesFileReader.cc index e048a6c..203e388 100644 --- a/zypp/parser/susetags/PackagesFileReader.cc +++ b/zypp/parser/susetags/PackagesFileReader.cc @@ -167,7 +167,7 @@ namespace zypp switch ( str::split( tag_r->value, std::back_inserter(words) ) ) { case 2: // [medianr filename] - _data->repositoryLocation.setLocation( Pathname(_data->arch.string()) / words[1], + _data->repositoryLocation.setLocation( Pathname(_data->arch.asString()) / words[1], str::strtonum(words[0]) ); break; diff --git a/zypp/sat/Repo.cc b/zypp/sat/Repo.cc index 22c21a9..fe8e7ac 100644 --- a/zypp/sat/Repo.cc +++ b/zypp/sat/Repo.cc @@ -138,6 +138,8 @@ namespace zypp { ZYPP_THROW( Exception( _("Error reading solv-file: ")+file_r.asString() ) ); } + + } detail::SolvableIdType Repo::addSolvables( unsigned count_r ) diff --git a/zypp/sat/detail/PoolImpl.cc b/zypp/sat/detail/PoolImpl.cc index 581927d..c8a4704 100644 --- a/zypp/sat/detail/PoolImpl.cc +++ b/zypp/sat/detail/PoolImpl.cc @@ -12,13 +12,15 @@ #include #include -#include "zypp/base/Logger.h" +#include "zypp/base/Easy.h" +#include "zypp/base/LogTools.h" #include "zypp/base/Gettext.h" #include "zypp/base/Exception.h" #include "zypp/ZConfig.h" #include "zypp/sat/detail/PoolImpl.h" +#include "zypp/sat/Repo.h" #include "zypp/Capability.h" using std::endl; @@ -113,7 +115,7 @@ namespace zypp ::pool_free( _pool ); } - /////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// void PoolImpl::setDirty( const char * a1, const char * a2, const char * a3 ) { @@ -136,6 +138,57 @@ namespace zypp } } + /////////////////////////////////////////////////////////////////// + + int PoolImpl::_addSolv( ::_Repo * repo_r, FILE * file_r ) + { + setDirty(__FUNCTION__, repo_r->name ); + int ret = ::repo_add_solv( repo_r , file_r ); + + if ( ret == 0 ) + { + // Filter out unwanted archs + std::set sysids; + { + Arch::CompatSet sysarchs( Arch::compatSet( ZConfig::instance().systemArchitecture() ) ); + for_( it, sysarchs.begin(), sysarchs.end() ) + sysids.insert( it->idStr().id() ); + // unfortunately satsolver treats src/nosrc as architecture: + sysids.insert( ARCH_SRC ); + sysids.insert( ARCH_NOSRC ); + } + + detail::IdType blockBegin = 0; + unsigned blockSize = 0; + for ( detail::IdType i = repo_r->start; i < repo_r->end; ++i ) + { + ::_Solvable * s( _pool->solvables + i ); + if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() ) + { + // Remember an unwanted arch entry: + if ( ! blockBegin ) + blockBegin = i; + ++blockSize; + } + else if ( blockSize ) + { + // Free remembered entries + ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*reuseids*/false ); + blockBegin = blockSize = 0; + } + } + if ( blockSize ) + { + // Free remembered entries + ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*reuseids*/false ); + blockBegin = blockSize = 0; + } + } + + return ret; + } + + ///////////////////////////////////////////////////////////////// } // namespace detail /////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/detail/PoolImpl.h b/zypp/sat/detail/PoolImpl.h index d1c974b..f870c3c 100644 --- a/zypp/sat/detail/PoolImpl.h +++ b/zypp/sat/detail/PoolImpl.h @@ -92,11 +92,8 @@ namespace zypp } /** Adding solv file to a repo. */ - int _addSolv( ::_Repo * repo_r, FILE * file_r ) - { - setDirty(__FUNCTION__, repo_r->name ); - return ::repo_add_solv( repo_r , file_r ); - } + int _addSolv( ::_Repo * repo_r, FILE * file_r ); + /** Adding Solvables to a repo. */ detail::SolvableIdType _addSolvables( ::_Repo * repo_r, unsigned count_r ) { -- 2.7.4