libzypp: zypp/ng/sat/components/architecturecomponent.cc Source File

libzypp 17.38.9

architecturecomponent.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9#include "architecturecomponent.h"
10#include <zypp/ng/sat/pool.h>
11#include <set>
12
13extern "C"
14{
15#include <solv/poolarch.h>
16#include <solv/repo.h>
17}
18
19namespace zyppng::sat {
20
21 void ArchitectureComponent::setProvider( ArchitectureProvider provider )
22 {
23 _provider = std::move(provider);
24 if ( _pool )
25 _pool->setDirty ( PoolInvalidation::Data, {"ArchitectureComponent: resetting the architecture provider"} );
26 }
27
28
29 void ArchitectureComponent::attach( Pool &pool )
30 {
31 _pool = &pool;
32 }
33
34 void ArchitectureComponent::prepare( Pool & pool )
35 {
36 if ( _watcher.remember( pool.serial() ) ) {
37 ::pool_setarch( pool.get(), arch().asString().c_str() );
38 }
39 }
40
41 void ArchitectureComponent::onReset( Pool & )
42 {
43 _watcher = SerialNumberWatcher{};
44 }
45
46 void ArchitectureComponent::onRepoAdded( Pool & pool, detail::RepoIdType id )
47 {
48 detail::CRepo * repo_r = id;
49 if ( ! pool.isSystemRepo( repo_r ) )
50 {
51 // Filter out unwanted archs
52 std::set<detail::IdType> sysids;
53 {
54 zypp::Arch arch = this->arch();
55 zypp::Arch::CompatSet sysarchs( zypp::Arch::compatSet( arch ) );
56 for ( auto it = sysarchs.begin(); it != sysarchs.end(); ++it )
57 sysids.insert( it->id() );
58
59 // unfortunately libsolv treats src/nosrc as architecture:
60 sysids.insert( ARCH_SRC );
61 sysids.insert( ARCH_NOSRC );
62 }
63
64 detail::IdType blockBegin = 0;
65 unsigned blockSize = 0;
66 for ( detail::IdType i = repo_r->start; i < repo_r->end; ++i )
67 {
68 detail::CSolvable * s( pool.get()->solvables + i );
69 if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
70 {
71 // Remember an unwanted arch entry:
72 if ( ! blockBegin )
73 blockBegin = i;
74 ++blockSize;
75 }
76 else if ( blockSize )
77 {
78 // Free remembered entries
79 ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*resusePoolIDs*/false );
80 blockBegin = blockSize = 0;
81 }
82 }
83 if ( blockSize ) {
84 // Free remembered entries
85 ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*resusePoolIDs*/false );
86 }
87 }
88 }
89
90} // namespace zyppng::sat
architecturecomponent.h
zypp::Arch
Architecture.
Definition Arch.h:37
zypp::Arch::compatSet
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
Definition Arch.cc:793
zypp::Arch::CompatSet
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition Arch.h:122
zypp::SerialNumberWatcher
Simple serial number watcher.
Definition SerialNumber.h:123
zyppng::sat::ArchitectureComponent::_watcher
SerialNumberWatcher _watcher
Definition architecturecomponent.h:55
zyppng::sat::ArchitectureComponent::_pool
Pool * _pool
Definition architecturecomponent.h:53
zyppng::sat::ArchitectureComponent::_provider
ArchitectureProvider _provider
Definition architecturecomponent.h:54
zyppng::sat::ArchitectureComponent::ArchitectureProvider
std::function< zypp::Arch()> ArchitectureProvider
Provider function returning an Arch.
Definition architecturecomponent.h:33
zyppng::sat::ArchitectureComponent::onReset
void onReset(Pool &pool) override
Definition architecturecomponent.cc:41
zyppng::sat::ArchitectureComponent::prepare
void prepare(Pool &pool) override
Definition architecturecomponent.cc:34
zyppng::sat::ArchitectureComponent::onRepoAdded
void onRepoAdded(Pool &pool, detail::RepoIdType id) override
Definition architecturecomponent.cc:46
zyppng::sat::ArchitectureComponent::setProvider
void setProvider(ArchitectureProvider provider)
Set a custom architecture provider.
Definition architecturecomponent.cc:21
zyppng::sat::ArchitectureComponent::arch
zypp::Arch arch() const
Get the current architecture.
Definition architecturecomponent.h:41
zyppng::sat::ArchitectureComponent::attach
void attach(Pool &pool) override
Definition architecturecomponent.cc:29
zyppng::sat::Pool
Orchestrator for a libsolv pool instance.
Definition pool.h:37
zypp::pool
Definition ByIdent.h:24
zypp::asString
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition Patch.cc:122
zyppng::sat::detail::CSolvable
zypp::sat::detail::CSolvable CSolvable
Definition poolconstants.h:39
zyppng::sat::detail::RepoIdType
zypp::sat::detail::RepoIdType RepoIdType
Definition poolconstants.h:45
zyppng::sat::detail::IdType
zypp::sat::detail::IdType IdType
Definition poolconstants.h:43
zyppng::sat::detail::CRepo
zypp::sat::detail::CRepo CRepo
Definition poolconstants.h:38
zyppng::sat
This file contains private API, this might break at any time between releases.
Definition capabilities.h:22
zyppng::sat::PoolInvalidation::Data
@ Data
Structural or data change (e.g., Rootfs, Arch, or Repo content).
Definition poolconstants.h:76
pool.h