libzypp  11.13.5
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 
34 namespace zypp
35 {
36 
37  namespace target
38  {
39 
40  DEFINE_PTR_TYPE(TargetImpl);
41  class CommitPackageCache;
42 
44  //
45  // CLASS NAME : TargetImpl
46  //
53  {
54  friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
55 
56  public:
58  typedef std::list<PoolItem> PoolItemList;
59 
61  typedef std::set<PoolItem> PoolItemSet;
62 
63  public:
65  TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false );
67  virtual ~TargetImpl();
68 
70  static TargetImpl_Ptr nullimpl();
71 
76  void createAnonymousId() const;
77 
82 
89  private:
91  Pathname defaultSolvfilesPath() const;
92 
94  Pathname solvfilesPath() const
96 
98  bool solvfilesPathIsTemp() const
99  { return ! _tmpSolvfilesPath.empty(); }
100 
102 
103  public:
104  void load();
105 
106  void unload();
107 
108  void clearCache();
109 
110  void 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  virtual std::ostream & dumpOn( std::ostream & str ) const
134  {
135  return str << "TargetImpl";
136  }
137 
139  rpm::RpmDb & rpm();
140 
143  bool providesFile (const std::string & path_str, const std::string & name_str) const;
144 
147  std::string whoOwnsFile (const std::string & path_str) const
148  { return _rpm.whoOwnsFile (path_str); }
149 
151  Date timestamp() const;
152 
155 
158  { return _requestedLocalesFile.locales(); }
160  static LocaleSet requestedLocales( const Pathname & root_r );
161 
163  std::string targetDistribution() const;
165  static std::string targetDistribution( const Pathname & root_r );
166 
168  std::string targetDistributionRelease() const;
170  static std::string targetDistributionRelease( const Pathname & root_r );
171 
175  static Target::DistributionLabel distributionLabel( const Pathname & root_r );
176 
178  std::string distributionVersion() const;
180  static std::string distributionVersion( const Pathname & root_r );
181 
183  std::string distributionFlavor() const;
185  static std::string distributionFlavor( const Pathname & root_r );
186 
188  std::string anonymousUniqueId() const;
190  static std::string anonymousUniqueId( const Pathname & root_r );
191 
192  private:
194  void commit( const ZYppCommitPolicy & policy_r,
195  CommitPackageCache & packageCache_r,
196  ZYppCommitResult & result_r );
197 
198  protected:
200  Pathname _root;
210  mutable std::string _distributionVersion;
211 
212  private:
214  static TargetImpl_Ptr _nullimpl;
215  };
217 
219  inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
220  {
221  return obj.dumpOn( str );
222  }
223 
225  } // namespace target
228 } // namespace zypp
230 #endif // ZYPP_TARGET_TARGETIMPL_H