libzypp 17.25.7
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
20#include <zypp/base/PtrTypes.h>
21#include <zypp/PoolItem.h>
22#include <zypp/ZYppCommit.h>
23
24#include <zypp/Pathname.h>
26#include <zypp/Target.h>
32#include <zypp/ManagedFile.h>
33#include <zypp/VendorAttr.h>
34
36namespace zypp
37{
39 namespace target
40 {
41
44
46 //
47 // CLASS NAME : TargetImpl
48 //
55 {
56 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
57
58 public:
60 typedef std::list<PoolItem> PoolItemList;
61
63 typedef std::set<PoolItem> PoolItemSet;
64
65 public:
67 TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false );
69 virtual ~TargetImpl();
70
75 void createAnonymousId() const;
76
81
88 private:
91
95
98 { return ! _tmpSolvfilesPath.empty(); }
99
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
118 { return _root; }
119
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 virtual std::ostream & dumpOn( std::ostream & str ) const
138 {
139 return str << "TargetImpl";
140 }
141
143 rpm::RpmDb & rpm();
144
147 bool providesFile (const std::string & path_str, const std::string & name_str) const;
148
151 std::string whoOwnsFile (const std::string & path_str) const
152 { return _rpm.whoOwnsFile (path_str); }
153
156
159 { return _requestedLocalesFile.locales(); }
161 static LocaleSet requestedLocales( const Pathname & root_r );
162
164 void updateAutoInstalled();
165
167 std::string targetDistribution() const;
169 static std::string targetDistribution( const Pathname & root_r );
170
172 std::string targetDistributionRelease() const;
174 static std::string targetDistributionRelease( const Pathname & root_r );
175
177 std::string targetDistributionFlavor() const;
179 static std::string targetDistributionFlavor( const Pathname & root_r );
180
185
187 std::string distributionVersion() const;
189 static std::string distributionVersion( const Pathname & root_r );
190
192 std::string distributionFlavor() const;
194 static std::string distributionFlavor( const Pathname & root_r );
195
197 std::string anonymousUniqueId() const;
199 static std::string anonymousUniqueId( const Pathname & root_r );
200
202 const VendorAttr & vendorAttr() const
203 { return _vendorAttr; }
205 void vendorAttr( VendorAttr vendorAttr_r );
207
208 public:
209 private:
211 void commit( const ZYppCommitPolicy & policy_r,
212 CommitPackageCache & packageCache_r,
213 ZYppCommitResult & result_r );
214
216 void commitFindFileConflicts( const ZYppCommitPolicy & policy_r, ZYppCommitResult & result_r );
217 protected:
229 mutable std::string _distributionVersion;
232 };
234
236 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
237 {
238 return obj.dumpOn( str );
239 }
240
242 } // namespace target
245} // namespace zypp
247#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:93
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:55
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
Definition: TargetImpl.cc:1867
const VendorAttr & vendorAttr() const
The targets current vendor equivalence settings.
Definition: TargetImpl.h:202
std::string targetDistribution() const
This is register.target attribute of the installed base product.
Definition: TargetImpl.cc:1861
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition: TargetImpl.h:158
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize stream output.
Definition: TargetImpl.h:137
friend std::ostream & operator<<(std::ostream &str, const TargetImpl &obj)
void updateAutoInstalled()
Update the database of autoinstalled packages.
Definition: TargetImpl.cc:1852
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
Definition: TargetImpl.cc:1994
Pathname _root
Path to the target.
Definition: TargetImpl.h:219
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
Definition: TargetImpl.h:223
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
Definition: TargetImpl.cc:837
std::set< PoolItem > PoolItemSet
set of pool items
Definition: TargetImpl.h:63
std::string _distributionVersion
Cache distributionVersion.
Definition: TargetImpl.h:229
std::list< PoolItem > PoolItemList
list of pool items
Definition: TargetImpl.h:60
rpm::RpmDb _rpm
RPM database.
Definition: TargetImpl.h:221
rpm::RpmDb & rpm()
The RPM database.
Definition: TargetImpl.cc:1768
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
Definition: TargetImpl.h:93
std::string distributionVersion() const
This is version attribute of the installed base product.
Definition: TargetImpl.cc:1897
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
Definition: TargetImpl.cc:815
static Pathname home(const Pathname &root_r)
Definition: TargetImpl.h:124
SolvIdentFile _autoInstalledFile
user/auto installed database
Definition: TargetImpl.h:225
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
Definition: TargetImpl.cc:1831
Target::DistributionLabel distributionLabel() const
This is shortName and summary attribute of the installed base product.
Definition: TargetImpl.cc:1879
virtual ~TargetImpl()
Dtor.
Definition: TargetImpl.cc:873
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:1773
HardLocksFile _hardLocksFile
Hard-Locks database.
Definition: TargetImpl.h:227
Pathname root() const
The root set for this target.
Definition: TargetImpl.h:117
void load(bool force=true)
Definition: TargetImpl.cc:1054
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:1938
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:151
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
Definition: TargetImpl.cc:1983
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
Definition: TargetImpl.cc:1189
VendorAttr _vendorAttr
vendor equivalence settings.
Definition: TargetImpl.h:231
Pathname home() const
The directory to store things.
Definition: TargetImpl.h:121
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:886
std::string anonymousUniqueId() const
anonymous unique id
Definition: TargetImpl.cc:1964
TargetImpl(const Pathname &root_r="/", bool doRebuild_r=false)
Ctor.
Definition: TargetImpl.cc:745
bool solvfilesPathIsTemp() const
Whether we're using a temp.
Definition: TargetImpl.h:97
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
Definition: TargetImpl.cc:1873
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:991
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:28