libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00009 extern "C" 00010 { 00011 #include <solv/knownid.h> 00012 } 00013 00014 #include <iostream> 00015 #include "zypp/base/Logger.h" 00016 #include "zypp/Repository.h" 00017 #include "zypp/repo/DeltaCandidates.h" 00018 #include "zypp/sat/Pool.h" 00019 00020 00021 using std::endl; 00022 using namespace zypp::packagedelta; 00023 00025 namespace zypp 00026 { 00027 00028 namespace repo 00029 { 00030 00032 struct DeltaCandidates::Impl 00033 { 00034 public: 00035 Impl() 00036 {} 00037 00038 Impl( const std::list<Repository> & repos, const std::string & pkgname = "" ) 00039 : repos(repos), pkgname(pkgname) 00040 {} 00041 00042 std::list<Repository> repos; 00043 std::string pkgname; 00044 00045 private: 00046 friend Impl * rwcowClone<Impl>( const Impl * rhs ); 00048 Impl * clone() const 00049 { return new Impl( *this ); } 00050 }; 00052 00054 inline std::ostream & operator<<( std::ostream & str, const DeltaCandidates::Impl & obj ) 00055 { 00056 return str << "DeltaCandidates::Impl"; 00057 } 00058 00060 // 00061 // class DeltaCandidates 00062 // 00064 00065 DeltaCandidates::DeltaCandidates() 00066 : _pimpl( new Impl ) 00067 {} 00068 00069 00070 DeltaCandidates::DeltaCandidates(const std::list<Repository> & repos, 00071 const std::string & pkgname) 00072 : _pimpl( new Impl(repos, pkgname) ) 00073 {} 00074 00075 DeltaCandidates::~DeltaCandidates() 00076 {} 00077 00078 std::list<DeltaRpm> DeltaCandidates::deltaRpms(const Package::constPtr & package) const 00079 { 00080 std::list<DeltaRpm> candidates; 00081 00082 DBG << "package: " << package << endl; 00083 for_( rit, _pimpl->repos.begin(), _pimpl->repos.end() ) 00084 { 00085 sat::LookupRepoAttr q( sat::SolvAttr::repositoryDeltaInfo, *rit ); 00086 for_( it, q.begin(), q.end() ) 00087 { 00088 if ( _pimpl->pkgname.empty() 00089 || it.subFind( sat::SolvAttr(DELTA_PACKAGE_NAME) ).asString() == _pimpl->pkgname ) 00090 { 00091 DeltaRpm delta( it ); 00092 //DBG << "checking delta: " << delta << endl; 00093 if ( ! package 00094 || ( package->name() == delta.name() 00095 && package->edition() == delta.edition() 00096 && package->arch() == delta.arch() ) ) 00097 { 00098 DBG << "got delta candidate: " << delta << endl; 00099 candidates.push_back( delta ); 00100 } 00101 } 00102 } 00103 } 00104 return candidates; 00105 } 00106 00107 std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj ) 00108 { 00109 return str << *obj._pimpl; 00110 } 00111 00113 } // namespace repo 00116 } // namespace zypp