libzypp: zypp/ng/sat/namespaces/filesystem.cc Source File

libzypp 17.38.14

filesystem.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9#include "filesystem.h"
10
11#include <zypp-core/parser/sysconfig.h>
12#include <zypp-core/base/String.h>
13#include <zypp-core/base/LogTools.h>
14#include <zypp-core/fs/watchfile.h>
15
16#include <zypp/ng/sat/pool.h>
17
18 namespace zyppng::sat::namespaces {
19
20 namespace {
21 const zypp::Pathname & sysconfigStoragePath()
22 {
23 static const zypp::Pathname _val( "/etc/sysconfig/storage" );
24 return _val;
25 }
26 }
27
28 bool FilesystemNamespaceProvider::isSatisfied(detail::IdType value ) const
29 {
30 const auto &req = requiredFilesystems ();
31 return req.count( zypp::IdString(value).asString() ) > 0;
32 }
33
34 void FilesystemNamespaceProvider::checkDirty( Pool & pool )
35 {
36 static zypp::WatchFile sysconfigFile( sysconfigStoragePath(), zypp::WatchFile::NO_INIT );
37 if ( _requiredFilesystems && sysconfigFile.hasChanged() ) {
38 _requiredFilesystems.reset(); // recreated on demand
39 pool.setDirty( PoolInvalidation::Data, { "/etc/sysconfig/storage change" } );
40 }
41 }
42
43 const std::set<std::string> & FilesystemNamespaceProvider::requiredFilesystems() const
44 {
45 if ( !_requiredFilesystems )
46 {
47 _requiredFilesystems = std::set<std::string>();
48 std::set<std::string> & requiredFilesystems( *_requiredFilesystems );
49 zypp::str::split( zypp::base::sysconfig::read( sysconfigStoragePath() )["USED_FS_LIST"],
50 std::inserter( requiredFilesystems, requiredFilesystems.end() ) );
51 }
52 return *_requiredFilesystems;
53 }
54
55
56} // namespace zyppng::sat
LogTools.h
String.h
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::WatchFile
Remember a files attributes to detect content changes.
Definition watchfile.h:50
zypp::WatchFile::hasChanged
bool hasChanged()
Definition watchfile.h:80
zypp::WatchFile::NO_INIT
@ NO_INIT
Definition watchfile.h:52
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zyppng::sat::Pool
Orchestrator for a libsolv pool instance.
Definition pool.h:37
zyppng::sat::namespaces::FilesystemNamespaceProvider::checkDirty
void checkDirty(Pool &pool) override
checkDirty
Definition filesystem.cc:34
zyppng::sat::namespaces::FilesystemNamespaceProvider::_requiredFilesystems
std::optional< std::set< std::string > > _requiredFilesystems
filesystems mentioned in /etc/sysconfig/storage, mutable for lazy init
Definition filesystem.h:40
zyppng::sat::namespaces::FilesystemNamespaceProvider::requiredFilesystems
const std::set< std::string > & requiredFilesystems() const
Definition filesystem.cc:43
zyppng::sat::namespaces::FilesystemNamespaceProvider::isSatisfied
bool isSatisfied(detail::IdType value) const override
Check if a specific value satisfies this namespace condition.
Definition filesystem.cc:28
filesystem.h
zypp::base::sysconfig::read
std::map< std::string, std::string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
Definition sysconfig.cc:34
zypp::pool
Definition ByIdent.h:24
zypp::str::split
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Definition String.h:602
zypp::asString
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition Patch.cc:122
zyppng::sat::detail::IdType
zypp::sat::detail::IdType IdType
Definition poolconstants.h:43
zyppng::sat::namespaces
Definition filesystem.cc:18
zyppng::sat::PoolInvalidation::Data
@ Data
Structural or data change (e.g., Rootfs, Arch, or Repo content).
Definition poolconstants.h:76
pool.h
sysconfig.h
watchfile.h