libzypp  13.10.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 
71  static TargetImpl_Ptr nullimpl();
72 
77  void createAnonymousId() const;
78 
83 
90  private:
92  Pathname defaultSolvfilesPath() const;
93 
95  Pathname solvfilesPath() const
97 
99  bool solvfilesPathIsTemp() const
100  { return ! _tmpSolvfilesPath.empty(); }
101 
103 
104  public:
105  void load( bool force = true );
106 
107  void unload();
108 
109  void reload();
110 
111  void clearCache();
112 
113  bool buildCache();
115 
116  public:
117 
119  Pathname root() const
120  { return _root; }
121 
123  Pathname home() const
124  { return home( _root ); }
125 
126  static Pathname home( const Pathname & root_r )
127  { return root_r / "/var/lib/zypp"; }
128 
130  ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
131 
133  void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
134 
136  ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r );
137 
139  virtual std::ostream & dumpOn( std::ostream & str ) const
140  {
141  return str << "TargetImpl";
142  }
143 
145  rpm::RpmDb & rpm();
146 
149  bool providesFile (const std::string & path_str, const std::string & name_str) const;
150 
153  std::string whoOwnsFile (const std::string & path_str) const
154  { return _rpm.whoOwnsFile (path_str); }
155 
157  Date timestamp() const;
158 
161 
164  { return _requestedLocalesFile.locales(); }
166  static LocaleSet requestedLocales( const Pathname & root_r );
167 
169  std::string targetDistribution() const;
171  static std::string targetDistribution( const Pathname & root_r );
172 
174  std::string targetDistributionRelease() const;
176  static std::string targetDistributionRelease( const Pathname & root_r );
177 
181  static Target::DistributionLabel distributionLabel( const Pathname & root_r );
182 
184  std::string distributionVersion() const;
186  static std::string distributionVersion( const Pathname & root_r );
187 
189  std::string distributionFlavor() const;
191  static std::string distributionFlavor( const Pathname & root_r );
192 
194  std::string anonymousUniqueId() const;
196  static std::string anonymousUniqueId( const Pathname & root_r );
197 
198  private:
200  void commit( const ZYppCommitPolicy & policy_r,
201  CommitPackageCache & packageCache_r,
202  ZYppCommitResult & result_r );
203 
204  protected:
206  Pathname _root;
216  mutable std::string _distributionVersion;
217 
218  private:
220  static TargetImpl_Ptr _nullimpl;
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
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
Definition: TargetImpl.cc:1025
Interface to the rpm program.
Definition: RpmDb.h:47
Save and restore locale set from file.
Target::DistributionLabel distributionLabel() const
This is version attribute of the installed base product.
Definition: TargetImpl.cc:1635
Result returned from ZYpp::commit.
Pathname home() const
The directory to store things.
Definition: TargetImpl.h:123
TargetImpl(const Pathname &root_r="/", bool doRebuild_r=false)
Ctor.
Definition: TargetImpl.cc:632
Target::commit helper optimizing package provision.
Pathname root() const
The root set for this target.
Definition: TargetImpl.h:119
static TargetImpl_Ptr nullimpl()
Null implementation.
Definition: TargetImpl.cc:620
static TargetImpl_Ptr _nullimpl
Null implementation.
Definition: TargetImpl.h:220
std::string _distributionVersion
Cache distributionVersion.
Definition: TargetImpl.h:216
DEFINE_PTR_TYPE(TargetImpl)
TraitsType::constPtrType constPtr
Definition: Product.h:38
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
Definition: TargetImpl.cc:1718
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition: TargetImpl.h:163
std::string distributionVersion() const
This is version attribute of the installed base product.
Definition: TargetImpl.cc:1653
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize stream output.
Definition: TargetImpl.h:139
rpm::RpmDb _rpm
RPM database.
Definition: TargetImpl.h:208
Date timestamp() const
return the last modification date of the target
Definition: TargetImpl.cc:1544
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
Store and operate on date (time_t).
Definition: Date.h:31
Base class for concrete Target implementations.
Definition: TargetImpl.h:53
Pathname _root
Path to the target.
Definition: TargetImpl.h:206
Pathname defaultSolvfilesPath() const
The systems default solv file location.
Definition: TargetImpl.cc:769
Options and policies for ZYpp::commit.
bool solvfilesPathIsTemp() const
Whether we&#39;re using a temp.
Definition: TargetImpl.h:99
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
Definition: TargetImpl.h:210
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:1538
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
Definition: TargetImpl.cc:721
SoftLocksFile _softLocksFile
Soft-locks database.
Definition: TargetImpl.h:212
std::set< PoolItem > PoolItemSet
set of pool items
Definition: TargetImpl.h:62
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
Definition: TargetImpl.h:95
static Pathname home(const Pathname &root_r)
Definition: TargetImpl.h:126
std::list< PoolItem > PoolItemList
list of pool items
Definition: TargetImpl.h:59
std::string anonymousUniqueId() const
anonymous unique id
Definition: TargetImpl.cc:1706
Base class for reference counted objects.
HardLocksFile _hardLocksFile
Hard-Locks database.
Definition: TargetImpl.h:214
Save and restore soft locks.
Definition: SoftLocksFile.h:35
std::string targetDistribution() const
This is register.target attribute of the installed base product.
Definition: TargetImpl.cc:1623
const LocaleSet & locales() const
Return the loacale set.
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:1694
Global ResObject pool.
Definition: ResPool.h:48
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
Definition: TargetImpl.cc:1602
virtual ~TargetImpl()
Dtor.
Definition: TargetImpl.cc:757
Reference counted access to a _Tp object calling a custom Dispose function when the last AutoDispose ...
Definition: AutoDispose.h:92
std::ostream & operator<<(std::ostream &str, const TargetImpl &obj)
Definition: TargetImpl.h:225
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:1326
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
Definition: TargetImpl.cc:1726
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:153
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
Definition: TargetImpl.cc:1629
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
Definition: TargetImpl.cc:701
Save and restore hardlocks.
Definition: HardLocksFile.h:36
friend std::ostream & operator<<(std::ostream &str, const TargetImpl &obj)
rpm::RpmDb & rpm()
The RPM database.
Definition: TargetImpl.cc:1533
void load(bool force=true)
Definition: TargetImpl.cc:935