libzypp  17.38.7
architecturecomponent.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 ----------------------------------------------------------------------*/
10 #include <zypp/ng/sat/pool.h>
11 #include <set>
12 
13 extern "C"
14 {
15 #include <solv/poolarch.h>
16 #include <solv/repo.h>
17 }
18 
19 namespace zyppng::sat {
20 
22  {
23  _provider = std::move(provider);
24  if ( _pool )
25  _pool->setDirty ( PoolInvalidation::Data, {"ArchitectureComponent: resetting the architecture provider"} );
26  }
27 
28 
30  {
31  _pool = &pool;
32  }
33 
35  {
36  if ( _watcher.remember( pool.serial() ) ) {
37  ::pool_setarch( pool.get(), arch().asString().c_str() );
38  }
39  }
40 
42  {
44  }
45 
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();
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
Simple serial number watcher.
Definition: SerialNumber.h:122
bool remember(unsigned serial_r) const
Return isDirty, storing serial_r as new value.
Definition: SerialNumber.h:160
zypp::sat::detail::CSolvable CSolvable
Definition: poolconstants.h:39
Architecture.
Definition: Arch.h:36
std::function< zypp::Arch()> ArchitectureProvider
Provider function returning an Arch.
bool isSystemRepo(detail::CRepo *repo_r) const
Definition: pool.h:132
Orchestrator for a libsolv pool instance.
Definition: pool.h:36
Structural or data change (e.g., Rootfs, Arch, or Repo content).
detail::CPool * get() const
Expert backdoor.
Definition: pool.h:59
This file contains private API, this might break at any time between releases.
Definition: capabilities.h:22
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition: Arch.h:122
void onRepoAdded(Pool &pool, detail::RepoIdType id) override
void setDirty(PoolInvalidation invalidation, std::initializer_list< std::string_view > reasons)
Invalidate everything.
Definition: pool.cc:152
zypp::sat::detail::IdType IdType
Definition: poolconstants.h:43
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch&#39;s compatibleWith a targetArch_r.
Definition: Arch.cc:793
zypp::sat::detail::CRepo CRepo
Definition: poolconstants.h:38
zypp::Arch arch() const
Get the current architecture.
const std::string & asString() const
Definition: Arch.cc:724
const SerialNumber & serial() const
Serial number changing whenever the content changes.
Definition: pool.h:63
zypp::sat::detail::RepoIdType RepoIdType
Definition: poolconstants.h:45
void setProvider(ArchitectureProvider provider)
Set a custom architecture provider.