libzypp  12.16.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 #include "zypp/ManagedFile.h"
33 
35 namespace zypp
36 {
37 
38  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