libzypp 17.28.8
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/base/NonCopyable.h>
20#include <zypp/base/PtrTypes.h>
21#include <zypp/PoolItem.h>
22#include <zypp/ZYppCommit.h>
23
24#include <zypp/Pathname.h>
25#include <zypp/Target.h>
31#include <zypp/ManagedFile.h>
32#include <zypp/VendorAttr.h>
33
35namespace zypp
36{
38 namespace target
39 {
40
43
45 //
46 // CLASS NAME : TargetImpl
47 //
54 {
55 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
56
57 public:
59 typedef std::list<PoolItem> PoolItemList;
60
62 typedef std::set<PoolItem> PoolItemSet;
63
64 public:
66 TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false );
68 virtual ~TargetImpl();
69
70#ifdef ANONYMOUS_ID
75 void createAnonymousId() const;
76
80 void createLastDistributionFlavorCache() const;
81#endif
82
89 private:
92
96
99 { return ! _tmpSolvfilesPath.empty(); }
100
102
103 public:
104 void load( bool force = true );
105
106 void unload();
107
108 void reload();
109
110 void clearCache();
111
112 bool buildCache();
114
115 public:
116
119 { return _root; }
120
123 { return home( _root ); }
124
125 static Pathname home( const Pathname & root_r )
126 { return root_r / "/var/lib/zypp"; }
127
129 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
130
132 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
133
135 ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r );
136
138 virtual std::ostream & dumpOn( std::ostream & str ) const
139 {
140 return str << "TargetImpl";
141 }
142
144 rpm::RpmDb & rpm();
145
148 bool providesFile (const std::string & path_str, const std::string & name_str) const;
149
152 std::string whoOwnsFile (const std::string & path_str) const
153 { return _rpm.whoOwnsFile (path_str); }
154
157
160 { return _requestedLocalesFile.locales(); }
162 static LocaleSet requestedLocales( const Pathname & root_r );
163
165 void updateAutoInstalled();
166
168 std::string targetDistribution() const;
170 static std::string targetDistribution( const Pathname & root_r );
171
173 std::string targetDistributionRelease() const;
175 static std::string targetDistributionRelease( const Pathname & root_r );
176
178 std::string targetDistributionFlavor() const;
180 static std::string targetDistributionFlavor( const Pathname & root_r );
181
186
188 std::string distributionVersion() const;
190 static std::string distributionVersion( const Pathname & root_r );
191
192#ifdef ANONYMOUS_ID
194 std::string distributionFlavor() const;
196 static std::string distributionFlavor( const Pathname & root_r );
197
199 std::string anonymousUniqueId() const;
201 static std::string anonymousUniqueId( const Pathname & root_r );
202#endif
203
205 const VendorAttr & vendorAttr() const
206 { return _vendorAttr; }
208 void vendorAttr( VendorAttr vendorAttr_r );
210
211 public:
212 private:
214 void commit( const ZYppCommitPolicy & policy_r,
215 CommitPackageCache & packageCache_r,
216 ZYppCommitResult & result_r );
217
219 void commitInSingleTransaction( const ZYppCommitPolicy & policy_r,
220 CommitPackageCache & packageCache_r,
221 ZYppCommitResult & result_r );
222
223
225 void commitFindFileConflicts( const ZYppCommitPolicy & policy_r, ZYppCommitResult & result_r );
226 protected:
238 mutable std::string _distributionVersion;
241 };
243
245 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
246 {
247 return obj.dumpOn( str );
248 }
249
251 } // namespace target
254} // namespace zypp
256#endif // ZYPP_TARGET_TARGETIMPL_H
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:94
TraitsType::constPtrType constPtr
Definition: Product.h:38
Global ResObject pool.
Definition: ResPool.h:61
Definition of vendor equivalence.
Definition: VendorAttr.h:61
Options and policies for ZYpp::commit.
Result returned from ZYpp::commit.
Base class for reference counted objects.
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
Target::commit helper optimizing package provision.
Save and restore hardlocks.
Definition: HardLocksFile.h:37
Save and restore locale set from file.
const LocaleSet & locales() const
Return the loacale set.
Save and restore a list of solvable names (ident IdString)
Definition: SolvIdentFile.h:34
Base class for concrete Target implementations.
Definition: TargetImpl.h:54
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
Definition: TargetImpl.cc:2849
const VendorAttr & vendorAttr() const
The targets current vendor equivalence settings.
Definition: TargetImpl.h:205
std::string targetDistribution() const
This is register.target attribute of the installed base product.
Definition: TargetImpl.cc:2843
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition: TargetImpl.h:159
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize stream output.
Definition: TargetImpl.h:138
friend std::ostream & operator<<(std::ostream &str, const TargetImpl &obj)
void updateAutoInstalled()
Update the database of autoinstalled packages.
Definition: TargetImpl.cc:2834
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
Definition: TargetImpl.cc:2978
Pathname _root
Path to the target.
Definition: TargetImpl.h:228
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
Definition: TargetImpl.h:232
std::set< PoolItem > PoolItemSet
set of pool items
Definition: TargetImpl.h:62
std::string _distributionVersion
Cache distributionVersion.
Definition: TargetImpl.h:238
std::list< PoolItem > PoolItemList
list of pool items
Definition: TargetImpl.h:59
rpm::RpmDb _rpm
RPM database.
Definition: TargetImpl.h:230
rpm::RpmDb & rpm()
The RPM database.
Definition: TargetImpl.cc:2750
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
Definition: TargetImpl.h:94
std::string distributionVersion() const
This is version attribute of the installed base product.
Definition: TargetImpl.cc:2879
static Pathname home(const Pathname &root_r)
Definition: TargetImpl.h:125
SolvIdentFile _autoInstalledFile
user/auto installed database
Definition: TargetImpl.h:234
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
Definition: TargetImpl.cc:2813
Target::DistributionLabel distributionLabel() const
This is shortName and summary attribute of the installed base product.
Definition: TargetImpl.cc:2861
virtual ~TargetImpl()
Dtor.
Definition: TargetImpl.cc:949
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:2755
HardLocksFile _hardLocksFile
Hard-Locks database.
Definition: TargetImpl.h:236
Pathname root() const
The root set for this target.
Definition: TargetImpl.h:118
void load(bool force=true)
Definition: TargetImpl.cc:1130
void commitInSingleTransaction(const ZYppCommitPolicy &policy_r, CommitPackageCache &packageCache_r, ZYppCommitResult &result_r)
Commit ordered changes (internal helper)
Definition: TargetImpl.cc:1868
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:152
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
Definition: TargetImpl.cc:2967
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
Definition: TargetImpl.cc:1270
VendorAttr _vendorAttr
vendor equivalence settings.
Definition: TargetImpl.h:240
Pathname home() const
The directory to store things.
Definition: TargetImpl.h:122
void commitFindFileConflicts(const ZYppCommitPolicy &policy_r, ZYppCommitResult &result_r)
Commit helper checking for file conflicts after download.
Pathname defaultSolvfilesPath() const
The systems default solv file location.
Definition: TargetImpl.cc:962
TargetImpl(const Pathname &root_r="/", bool doRebuild_r=false)
Ctor.
Definition: TargetImpl.cc:816
bool solvfilesPathIsTemp() const
Whether we're using a temp.
Definition: TargetImpl.h:98
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
Definition: TargetImpl.cc:2855
Interface to the rpm program.
Definition: RpmDb.h:48
std::string whoOwnsFile(const std::string &file_r) const
Return name of package owning file or empty string if no installed package owns file.
Definition: RpmDb.cc:993
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
DEFINE_PTR_TYPE(TargetImpl)
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27