libzypp  17.23.6
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 
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/media/MediaAccess.h>
26 #include <zypp/Target.h>
27 #include <zypp/target/rpm/RpmDb.h>
32 #include <zypp/ManagedFile.h>
33 
35 namespace zypp
36 {
37  namespace target
39  {
40 
41  DEFINE_PTR_TYPE(TargetImpl);
42  class CommitPackageCache;
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 
74  void createAnonymousId() const;
75 
80 
87  private:
90 
94 
96  bool solvfilesPathIsTemp() const
97  { return ! _tmpSolvfilesPath.empty(); }
98 
100 
101  public:
102  void load( bool force = true );
103 
104  void unload();
105 
106  void reload();
107 
108  void clearCache();
109 
110  bool buildCache();
112 
113  public:
114 
116  Pathname root() const
117  { return _root; }
118 
120  Pathname home() const
121  { return home( _root ); }
122 
123  static Pathname home( const Pathname & root_r )
124  { return root_r / "/var/lib/zypp"; }
125 
127  ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
128 
130  void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
131 
133  ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r );
134 
136  virtual std::ostream & dumpOn( std::ostream & str ) const
137  {
138  return str << "TargetImpl";
139  }
140 
142  rpm::RpmDb & rpm();
143 
146  bool providesFile (const std::string & path_str, const std::string & name_str) const;
147 
150  std::string whoOwnsFile (const std::string & path_str) const
151  { return _rpm.whoOwnsFile (path_str); }
152 
155 
158  { return _requestedLocalesFile.locales(); }
160  static LocaleSet requestedLocales( const Pathname & root_r );
161 
163  void updateAutoInstalled();
164 
166  std::string targetDistribution() const;
168  static std::string targetDistribution( const Pathname & root_r );
169 
171  std::string targetDistributionRelease() const;
173  static std::string targetDistributionRelease( const Pathname & root_r );
174 
176  std::string targetDistributionFlavor() const;
178  static std::string targetDistributionFlavor( const Pathname & root_r );
179 
183  static Target::DistributionLabel distributionLabel( const Pathname & root_r );
184 
186  std::string distributionVersion() const;
188  static std::string distributionVersion( const Pathname & root_r );
189 
191  std::string distributionFlavor() const;
193  static std::string distributionFlavor( const Pathname & root_r );
194 
196  std::string anonymousUniqueId() const;
198  static std::string anonymousUniqueId( const Pathname & root_r );
199 
200  private:
202  void commit( const ZYppCommitPolicy & policy_r,
203  CommitPackageCache & packageCache_r,
204  ZYppCommitResult & result_r );
205 
207  void commitFindFileConflicts( const ZYppCommitPolicy & policy_r, ZYppCommitResult & result_r );
208  protected:
220  mutable std::string _distributionVersion;
221  };
223 
225  inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
226  {
227  return obj.dumpOn( str );
228  }
229 
231  } // namespace target
234 } // namespace zypp
236 #endif // ZYPP_TARGET_TARGETIMPL_H
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:1923
zypp::target::TargetImpl::buildCache
bool buildCache()
Definition: TargetImpl.cc:896
zypp::target::TargetImpl::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize stream output.
Definition: TargetImpl.h:136
zypp::Target::DistributionLabel
Definition: Target.h:167
zypp::target::TargetImpl::rpm
rpm::RpmDb & rpm()
The RPM database.
Definition: TargetImpl.cc:1753
zypp::target::TargetImpl::commit
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
Definition: TargetImpl.cc:1185
zypp::target::TargetImpl::home
Pathname home() const
The directory to store things.
Definition: TargetImpl.h:120
zypp::Product::constPtr
TraitsType::constPtrType constPtr
Definition: Product.h:38
zypp::target::TargetImpl::_rpm
rpm::RpmDb _rpm
RPM database.
Definition: TargetImpl.h:212
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition: ReferenceCounted.h:33
zypp::target::TargetImpl::anonymousUniqueId
std::string anonymousUniqueId() const
anonymous unique id
Definition: TargetImpl.cc:1949
zypp::target::TargetImpl::~TargetImpl
virtual ~TargetImpl()
Dtor.
Definition: TargetImpl.cc:872
zypp::target::DEFINE_PTR_TYPE
DEFINE_PTR_TYPE(TargetImpl)
zypp::target::TargetImpl::reload
void reload()
Definition: TargetImpl.cc:1039
PtrTypes.h
zypp::target::TargetImpl::_tmpSolvfilesPath
Pathname _tmpSolvfilesPath
Definition: TargetImpl.h:99
zypp::target::TargetImpl::solvfilesPath
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
Definition: TargetImpl.h:92
zypp::target::TargetImpl::home
static Pathname home(const Pathname &root_r)
Definition: TargetImpl.h:123
Pathname.h
zypp::target::SolvIdentFile
Save and restore a list of solvable names (ident IdString)
Definition: SolvIdentFile.h:33
Target.h
zypp::target::TargetImpl::operator<<
std::ostream & operator<<(std::ostream &str, const TargetImpl &obj)
Definition: TargetImpl.h:225
zypp::target::TargetImpl::baseProduct
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
Definition: TargetImpl.cc:1816
zypp::target::TargetImpl::load
void load(bool force=true)
Definition: TargetImpl.cc:1051
zypp::target::TargetImpl::_distributionVersion
std::string _distributionVersion
Cache distributionVersion.
Definition: TargetImpl.h:220
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::PoolItemList
std::list< PoolItem > PoolItemList
list of pool items
Definition: TargetImpl.h:59
zypp::target::TargetImpl
Base class for concrete Target implementations.
Definition: TargetImpl.h:53
zypp::target::TargetImpl::createAnonymousId
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
Definition: TargetImpl.cc:814
zypp::target::TargetImpl::targetDistributionFlavor
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
Definition: TargetImpl.cc:1858
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
TargetException.h
RequestedLocalesFile.h
zypp::target::TargetImpl::distributionLabel
Target::DistributionLabel distributionLabel() const
This is shortName and summary attribute of the installed base product.
Definition: TargetImpl.cc:1864
zypp::target::CommitPackageCache
Target::commit helper optimizing package provision.
Definition: CommitPackageCache.h:58
zypp::target::rpm::RpmDb
Interface to the rpm program.
Definition: RpmDb.h:47
zypp::target::TargetImpl::root
Pathname root() const
The root set for this target.
Definition: TargetImpl.h:116
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::target::TargetImpl::requestedLocales
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition: TargetImpl.h:157
zypp::ZYppCommitResult
Result returned from ZYpp::commit.
Definition: ZYppCommitResult.h:62
zypp::target::TargetImpl::_autoInstalledFile
SolvIdentFile _autoInstalledFile
user/auto installed database
Definition: TargetImpl.h:216
zypp::target::TargetImpl::unload
void unload()
Definition: TargetImpl.cc:1044
zypp::target::TargetImpl::provideSrcPackage
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
Definition: TargetImpl.cc:1972
zypp::target::TargetImpl::distributionVersion
std::string distributionVersion() const
This is version attribute of the installed base product.
Definition: TargetImpl.cc:1882
zypp::target::TargetImpl::clearCache
void clearCache()
Definition: TargetImpl.cc:890
MediaAccess.h
zypp::target::TargetImpl::updateAutoInstalled
void updateAutoInstalled()
Update the database of autoinstalled packages.
Definition: TargetImpl.cc:1837
zypp::target::HardLocksFile
Save and restore hardlocks.
Definition: HardLocksFile.h:36
zypp::target::TargetImpl::operator<<
friend std::ostream & operator<<(std::ostream &str, const TargetImpl &obj)
zypp::ResPool
Global ResObject pool.
Definition: ResPool.h:60
zypp::target::TargetImpl::PoolItemSet
std::set< PoolItem > PoolItemSet
set of pool items
Definition: TargetImpl.h:62
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:1758
zypp::AutoDispose
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:92
zypp::target::TargetImpl::_requestedLocalesFile
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
Definition: TargetImpl.h:214
ReferenceCounted.h
zypp::target::TargetImpl::defaultSolvfilesPath
Pathname defaultSolvfilesPath() const
The systems default solv file location.
Definition: TargetImpl.cc:885
SolvIdentFile.h
zypp::filesystem::Pathname::empty
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
zypp::target::TargetImpl::targetDistributionRelease
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
Definition: TargetImpl.cc:1852
PoolItem.h
zypp::target::TargetImpl::solvfilesPathIsTemp
bool solvfilesPathIsTemp() const
Whether we're using a temp.
Definition: TargetImpl.h:96
zypp::target::RequestedLocalesFile::locales
const LocaleSet & locales() const
Return the loacale set.
Definition: RequestedLocalesFile.h:53
zypp::target::TargetImpl::createLastDistributionFlavorCache
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
Definition: TargetImpl.cc:836
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:150
str
String related utilities and Regular expression matching.
ManagedFile.h
zypp::ZYppCommitPolicy
Options and policies for ZYpp::commit.
Definition: ZYppCommitPolicy.h:33
zypp::target::TargetImpl::_root
Pathname _root
Path to the target.
Definition: TargetImpl.h:210
zypp::target::TargetImpl::_hardLocksFile
HardLocksFile _hardLocksFile
Hard-Locks database.
Definition: TargetImpl.h:218
HardLocksFile.h
zypp::target::TargetImpl::TargetImpl
TargetImpl(const Pathname &root_r="/", bool doRebuild_r=false)
Ctor.
Definition: TargetImpl.cc:745
zypp::target::TargetImpl::targetDistribution
std::string targetDistribution() const
This is register.target attribute of the installed base product.
Definition: TargetImpl.cc:1846
zypp::target::TargetImpl::installSrcPackage
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
Definition: TargetImpl.cc:1961
RpmDb.h
zypp::target::rpm::RpmDb::whoOwnsFile
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:980
NonCopyable.h
zypp::target::RequestedLocalesFile
Save and restore locale set from file.
Definition: RequestedLocalesFile.h:35
ZYppCommit.h