libzypp: zypp/target/TargetImpl.h Source File

libzypp 17.38.14

TargetImpl.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_TARGET_TARGETIMPL_H
13#define ZYPP_TARGET_TARGETIMPL_H
14
15#include <iosfwd>
16#include <set>
17
18#include <zypp/base/ReferenceCounted.h>
19#include <zypp-core/base/NonCopyable.h>
20#include <zypp-core/base/PtrTypes.h>
21#include <zypp/PoolItem.h>
22#include <zypp/ZYppCommit.h>
23
24#include <zypp-core/Pathname.h>
25#include <zypp-core/fs/WatchFile>
26#include <zypp/Target.h>
27#include <zypp/target/rpm/RpmDb.h>
28#include <zypp/target/TargetException.h>
29#include <zypp/target/RequestedLocalesFile.h>
30#include <zypp/target/SolvIdentFile.h>
31#include <zypp/target/HardLocksFile.h>
32#include <zypp/ManagedFile.h>
33#include <zypp/VendorAttr.h>
34
36namespace zypp
37{
39 namespace target
40 {
41
42 DEFINE_PTR_TYPE(TargetImpl);
43 class CommitPackageCache;
44
46 //
47 // CLASS NAME : TargetImpl
48 //
54 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
55 {
56 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
57
58 public:
60 using PoolItemList = std::list<PoolItem>;
61
63 using PoolItemSet = std::set<PoolItem>;
64
65 public:
67 TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false );
69 ~TargetImpl() override;
70
75 void createAnonymousId() const;
76
80 void createLastDistributionFlavorCache() const;
81
88 private:
90 Pathname defaultSolvfilesPath() const;
91
93 Pathname solvfilesPath() const
94 { return solvfilesPathIsTemp() ? _tmpSolvfilesPath : defaultSolvfilesPath(); }
95
97 bool solvfilesPathIsTemp() const
98 { return ! _tmpSolvfilesPath.empty(); }
99
100 Pathname _tmpSolvfilesPath;
101
102 public:
103 void load( bool force = true );
104
105 void unload();
106
107 void reload();
108
109 void clearCache();
110
111 bool buildCache();
113
114 public:
115
117 Pathname root() const
118 { return _root; }
119
121 Pathname home() const
122 { return home( _root ); }
123
124 static Pathname home( const Pathname & root_r )
125 { return root_r / "/var/lib/zypp"; }
126
128 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
129
131 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
132
134 ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r );
135
137 std::ostream & dumpOn( std::ostream & str ) const override
138 { return str << "Target(" << root() << ")"; }
139
141 rpm::RpmDb & rpm();
142
145 bool providesFile (const std::string & path_str, const std::string & name_str) const;
146
149 std::string whoOwnsFile (const std::string & path_str) const
150 { return _rpm.whoOwnsFile (path_str); }
151
153 Product::constPtr baseProduct() const;
154
156 LocaleSet requestedLocales() const
157 { return _requestedLocalesFile.locales(); }
158
159 static LocaleSet requestedLocales( const Pathname & root_r );
160
162 void updateAutoInstalled();
163
165 std::string targetDistribution() const;
167 static std::string targetDistribution( const Pathname & root_r );
168
170 std::string targetDistributionRelease() const;
172 static std::string targetDistributionRelease( const Pathname & root_r );
173
175 std::string targetDistributionFlavor() const;
177 static std::string targetDistributionFlavor( const Pathname & root_r );
178
180 Target::DistributionLabel distributionLabel() const;
182 static Target::DistributionLabel distributionLabel( const Pathname & root_r );
183
185 std::string distributionVersion() const;
187 static std::string distributionVersion( const Pathname & root_r );
188
190 std::string distributionFlavor() const;
192 static std::string distributionFlavor( const Pathname & root_r );
193
195 std::string anonymousUniqueId() const;
197 static std::string anonymousUniqueId( const Pathname & root_r );
198
200 const VendorAttr & vendorAttr() const
201 { return _vendorAttr; }
202
203 void vendorAttr( VendorAttr vendorAttr_r );
205
206 public:
207 private:
209 void commit( const ZYppCommitPolicy & policy_r,
210 CommitPackageCache & packageCache_r,
211 ZYppCommitResult & result_r );
212
214 void commitInSingleTransaction( const ZYppCommitPolicy & policy_r,
215 CommitPackageCache & packageCache_r,
216 ZYppCommitResult & result_r );
217
218
220 void commitFindFileConflicts( const ZYppCommitPolicy & policy_r, ZYppCommitResult & result_r );
221 protected:
223 Pathname _root;
225 rpm::RpmDb _rpm;
227 RequestedLocalesFile _requestedLocalesFile;
229 SolvIdentFile _autoInstalledFile;
231 HardLocksFile _hardLocksFile;
233 mutable WatchFile _baseproductWatcher;
234 mutable std::string _distributionVersion;
236 VendorAttr _vendorAttr;
237 };
238
239
241 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
242 {
243 return obj.dumpOn( str );
244 }
245
247 } // namespace target
250} // namespace zypp
252#endif // ZYPP_TARGET_TARGETIMPL_H
HardLocksFile.h
NonCopyable.h
Pathname.h
PoolItem.h
PtrTypes.h
DEFINE_PTR_TYPE
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition PtrTypes.h:639
RequestedLocalesFile.h
RpmDb.h
SolvIdentFile.h
TargetException.h
Target.h
VendorAttr.h
ZYppCommit.h
zypp::Product::constPtr
TraitsType::constPtrType constPtr
Definition Product.h:39
zypp::ResPool
Global ResObject pool.
Definition ResPool.h:62
zypp::VendorAttr
Definition of vendor equivalence.
Definition VendorAttr.h:61
zypp::WatchFile
Remember a files attributes to detect content changes.
Definition watchfile.h:50
zypp::ZYppCommitPolicy
Options and policies for ZYpp::commit.
Definition ZYppCommitPolicy.h:34
zypp::ZYppCommitResult
Result returned from ZYpp::commit.
Definition ZYppCommitResult.h:64
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition ReferenceCounted.h:35
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::target::CommitPackageCache
Target::commit helper optimizing package provision.
Definition CommitPackageCache.h:59
zypp::target::HardLocksFile
Save and restore hardlocks.
Definition HardLocksFile.h:38
zypp::target::RequestedLocalesFile
Save and restore locale set from file.
Definition RequestedLocalesFile.h:37
zypp::target::SolvIdentFile
Save and restore a list of solvable names (ident IdString).
Definition SolvIdentFile.h:35
zypp::target::TargetImpl
Base class for concrete Target implementations.
Definition TargetImpl.h:55
zypp::target::TargetImpl::targetDistributionRelease
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
Definition TargetImpl.cc:3069
zypp::target::TargetImpl::clearCache
void clearCache()
Definition TargetImpl.cc:1109
zypp::target::TargetImpl::vendorAttr
const VendorAttr & vendorAttr() const
The targets current vendor equivalence settings.
Definition TargetImpl.h:200
zypp::target::TargetImpl::targetDistribution
std::string targetDistribution() const
This is register.target attribute of the installed base product.
Definition TargetImpl.cc:3063
zypp::target::TargetImpl::PoolItemSet
std::set< PoolItem > PoolItemSet
set of pool items
Definition TargetImpl.h:63
zypp::target::TargetImpl::PoolItemList
std::list< PoolItem > PoolItemList
list of pool items
Definition TargetImpl.h:60
zypp::target::TargetImpl::requestedLocales
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition TargetImpl.h:156
zypp::target::TargetImpl::operator<<
friend std::ostream & operator<<(std::ostream &str, const TargetImpl &obj)
relates: TargetImpl Stream output
Definition TargetImpl.h:241
zypp::target::TargetImpl::updateAutoInstalled
void updateAutoInstalled()
Update the database of autoinstalled packages.
Definition TargetImpl.cc:3054
zypp::target::TargetImpl::provideSrcPackage
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
Definition TargetImpl.cc:3183
zypp::target::TargetImpl::_root
Pathname _root
Path to the target.
Definition TargetImpl.h:223
zypp::target::TargetImpl::_requestedLocalesFile
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
Definition TargetImpl.h:227
zypp::target::TargetImpl::createLastDistributionFlavorCache
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
Definition TargetImpl.cc:1055
zypp::target::TargetImpl::_baseproductWatcher
WatchFile _baseproductWatcher
Cache distributionVersion.
Definition TargetImpl.h:233
zypp::target::TargetImpl::_tmpSolvfilesPath
Pathname _tmpSolvfilesPath
Definition TargetImpl.h:100
zypp::target::TargetImpl::_distributionVersion
std::string _distributionVersion
Definition TargetImpl.h:234
zypp::target::TargetImpl::_rpm
rpm::RpmDb _rpm
RPM database.
Definition TargetImpl.h:225
zypp::target::TargetImpl::~TargetImpl
~TargetImpl() override
Dtor.
Definition TargetImpl.cc:1091
zypp::target::TargetImpl::buildCache
bool buildCache()
Definition TargetImpl.cc:1115
zypp::target::TargetImpl::rpm
rpm::RpmDb & rpm()
The RPM database.
Definition TargetImpl.cc:2954
zypp::target::TargetImpl::solvfilesPath
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
Definition TargetImpl.h:93
zypp::target::TargetImpl::distributionVersion
std::string distributionVersion() const
This is version attribute of the installed base product.
Definition TargetImpl.cc:3099
zypp::target::TargetImpl::createAnonymousId
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
Definition TargetImpl.cc:1033
zypp::target::TargetImpl::unload
void unload()
Definition TargetImpl.cc:1269
zypp::target::TargetImpl::home
static Pathname home(const Pathname &root_r)
Definition TargetImpl.h:124
zypp::target::TargetImpl::_autoInstalledFile
SolvIdentFile _autoInstalledFile
user/auto installed database
Definition TargetImpl.h:229
zypp::target::TargetImpl::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload to realize stream output.
Definition TargetImpl.h:137
zypp::target::TargetImpl::baseProduct
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
Definition TargetImpl.cc:3033
zypp::target::TargetImpl::distributionLabel
Target::DistributionLabel distributionLabel() const
This is shortName and summary attribute of the installed base product.
Definition TargetImpl.cc:3081
zypp::target::TargetImpl::providesFile
bool providesFile(const std::string &path_str, const std::string &name_str) const
If the package is installed and provides the file Needed to evaluate split provides during Resolver::...
Definition TargetImpl.cc:2959
zypp::target::TargetImpl::_hardLocksFile
HardLocksFile _hardLocksFile
Hard-Locks database.
Definition TargetImpl.h:231
zypp::target::TargetImpl::root
Pathname root() const
The root set for this target.
Definition TargetImpl.h:117
zypp::target::TargetImpl::load
void load(bool force=true)
Definition TargetImpl.cc:1276
zypp::target::TargetImpl::distributionFlavor
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
Definition TargetImpl.cc:3127
zypp::target::TargetImpl::commitInSingleTransaction
void commitInSingleTransaction(const ZYppCommitPolicy &policy_r, CommitPackageCache &packageCache_r, ZYppCommitResult &result_r)
Commit ordered changes (internal helper).
Definition TargetImpl.cc:2079
zypp::target::TargetImpl::reload
void reload()
Definition TargetImpl.cc:1264
zypp::target::TargetImpl::whoOwnsFile
std::string whoOwnsFile(const std::string &path_str) const
Return name of package owning path_str or empty string if no installed package owns path_str.
Definition TargetImpl.h:149
zypp::target::TargetImpl::installSrcPackage
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
Definition TargetImpl.cc:3172
zypp::target::TargetImpl::commit
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
Definition TargetImpl.cc:1412
zypp::target::TargetImpl::_vendorAttr
VendorAttr _vendorAttr
vendor equivalence settings.
Definition TargetImpl.h:236
zypp::target::TargetImpl::home
Pathname home() const
The directory to store things.
Definition TargetImpl.h:121
zypp::target::TargetImpl::commitFindFileConflicts
void commitFindFileConflicts(const ZYppCommitPolicy &policy_r, ZYppCommitResult &result_r)
Commit helper checking for file conflicts after download.
Definition TargetImpl.commitFindFileConflicts.cc:122
zypp::target::TargetImpl::defaultSolvfilesPath
Pathname defaultSolvfilesPath() const
The systems default solv file location.
Definition TargetImpl.cc:1104
zypp::target::TargetImpl::anonymousUniqueId
std::string anonymousUniqueId() const
anonymous unique id
Definition TargetImpl.cc:3153
zypp::target::TargetImpl::TargetImpl
TargetImpl(const Pathname &root_r="/", bool doRebuild_r=false)
Ctor.
Definition TargetImpl.cc:962
zypp::target::TargetImpl::solvfilesPathIsTemp
bool solvfilesPathIsTemp() const
Whether we're using a temp.
Definition TargetImpl.h:97
zypp::target::TargetImpl::targetDistributionFlavor
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
Definition TargetImpl.cc:3075
zypp::target::rpm::RpmDb
Interface to the rpm program.
Definition RpmDb.h:51
str
String related utilities and Regular expression matching.
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::target
Definition KeyRing.h:325
zypp::target::operator<<
std::ostream & operator<<(std::ostream &str, const CommitPackageCache &obj)
relates: CommitPackageCache Stream output
Definition CommitPackageCache.cc:155
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
zypp::ManagedFile
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
zypp::Target::DistributionLabel
Definition Target.h:168
ManagedFile.h
ReferenceCounted.h