libzypp  17.14.0
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 
74  void createAnonymousId() const;
75 
80 
87  private:
89  Pathname defaultSolvfilesPath() const;
90 
92  Pathname solvfilesPath() const
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 
154  Date timestamp() const;
155 
158 
161  { return _requestedLocalesFile.locales(); }
163  static LocaleSet requestedLocales( const Pathname & root_r );
164 
166  void updateAutoInstalled();
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 
179  std::string targetDistributionFlavor() const;
181  static std::string targetDistributionFlavor( const Pathname & root_r );
182 
186  static Target::DistributionLabel distributionLabel( const Pathname & root_r );
187 
189  std::string distributionVersion() const;
191  static std::string distributionVersion( const Pathname & root_r );
192 
194  std::string distributionFlavor() const;
196  static std::string distributionFlavor( const Pathname & root_r );
197 
199  std::string anonymousUniqueId() const;
201  static std::string anonymousUniqueId( const Pathname & root_r );
202 
203  private:
205  void commit( const ZYppCommitPolicy & policy_r,
206  CommitPackageCache & packageCache_r,
207  ZYppCommitResult & result_r );
208 
210  void commitFindFileConflicts( const ZYppCommitPolicy & policy_r, ZYppCommitResult & result_r );
211  protected:
213  Pathname _root;
223  mutable std::string _distributionVersion;
224  };
226 
228  inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
229  {
230  return obj.dumpOn( str );
231  }
232 
234  } // namespace target
237 } // namespace zypp
239 #endif // ZYPP_TARGET_TARGETIMPL_H