libzypp 8.13.6
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_TARGET_TARGETIMPL_H 00013 #define ZYPP_TARGET_TARGETIMPL_H 00014 00015 #include <iosfwd> 00016 #include <list> 00017 #include <set> 00018 00019 #include "zypp/base/ReferenceCounted.h" 00020 #include "zypp/base/NonCopyable.h" 00021 #include "zypp/base/PtrTypes.h" 00022 #include "zypp/PoolItem.h" 00023 #include "zypp/ZYppCommit.h" 00024 00025 #include "zypp/Pathname.h" 00026 #include "zypp/media/MediaAccess.h" 00027 #include "zypp/Target.h" 00028 #include "zypp/target/rpm/RpmDb.h" 00029 #include "zypp/target/TargetException.h" 00030 #include "zypp/target/RequestedLocalesFile.h" 00031 #include "zypp/target/SoftLocksFile.h" 00032 #include "zypp/target/HardLocksFile.h" 00033 00035 namespace zypp 00036 { 00037 00038 namespace target 00039 { 00040 00041 DEFINE_PTR_TYPE(TargetImpl); 00042 class CommitPackageCache; 00043 00045 // 00046 // CLASS NAME : TargetImpl 00047 // 00053 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable 00054 { 00055 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj ); 00056 00057 public: 00059 typedef std::list<PoolItem> PoolItemList; 00060 00062 typedef std::set<PoolItem> PoolItemSet; 00063 00064 public: 00066 TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false ); 00068 virtual ~TargetImpl(); 00069 00071 static TargetImpl_Ptr nullimpl(); 00072 00077 void createAnonymousId() const; 00078 00082 void createLastDistributionFlavorCache() const; 00083 00090 private: 00092 Pathname defaultSolvfilesPath() const; 00093 00095 Pathname solvfilesPath() const 00096 { return solvfilesPathIsTemp() ? _tmpSolvfilesPath : defaultSolvfilesPath(); } 00097 00099 bool solvfilesPathIsTemp() const 00100 { return ! _tmpSolvfilesPath.empty(); } 00101 00102 Pathname _tmpSolvfilesPath; 00103 00104 public: 00105 void load(); 00106 00107 void unload(); 00108 00109 void clearCache(); 00110 00111 void buildCache(); 00113 00114 public: 00115 00117 Pathname root() const 00118 { return _root; } 00119 00121 Pathname home() const 00122 { return _root / "/var/lib/zypp"; } 00123 00125 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r ); 00126 00128 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r ); 00129 00131 virtual std::ostream & dumpOn( std::ostream & str ) const 00132 { 00133 return str << "TargetImpl"; 00134 } 00135 00137 rpm::RpmDb & rpm(); 00138 00141 bool providesFile (const std::string & path_str, const std::string & name_str) const; 00142 00145 std::string whoOwnsFile (const std::string & path_str) const 00146 { return _rpm.whoOwnsFile (path_str); } 00147 00149 Date timestamp() const; 00150 00152 Product::constPtr baseProduct() const; 00153 00154 00156 std::string targetDistribution() const; 00158 static std::string targetDistribution( const Pathname & root_r ); 00159 00161 std::string targetDistributionRelease() const; 00163 static std::string targetDistributionRelease( const Pathname & root_r ); 00164 00166 Target::DistributionLabel distributionLabel() const; 00168 static Target::DistributionLabel distributionLabel( const Pathname & root_r ); 00169 00171 std::string distributionVersion() const; 00173 static std::string distributionVersion( const Pathname & root_r ); 00174 00176 std::string distributionFlavor() const; 00178 static std::string distributionFlavor( const Pathname & root_r ); 00179 00181 std::string anonymousUniqueId() const; 00183 static std::string anonymousUniqueId( const Pathname & root_r ); 00184 00185 private: 00187 PoolItemList commit( const PoolItemList & items_r, 00188 const ZYppCommitPolicy & policy_r, 00189 ZYppCommitResult & result_r, 00190 CommitPackageCache & packageCache_r ); 00191 00192 protected: 00194 Pathname _root; 00196 rpm::RpmDb _rpm; 00198 RequestedLocalesFile _requestedLocalesFile; 00200 SoftLocksFile _softLocksFile; 00202 HardLocksFile _hardLocksFile; 00204 mutable std::string _distributionVersion; 00205 00206 private: 00208 static TargetImpl_Ptr _nullimpl; 00209 }; 00211 00213 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj ) 00214 { 00215 return obj.dumpOn( str ); 00216 } 00217 00219 } // namespace target 00222 } // namespace zypp 00224 #endif // ZYPP_TARGET_TARGETIMPL_H