From 6f6dd8bbcfdd76095d58747b2e98cd5fe44c1f11 Mon Sep 17 00:00:00 2001 From: Jiri Srain Date: Fri, 27 Jan 2006 09:24:25 +0000 Subject: [PATCH] Added methods to provide package to local filesystem to Package interface --- zypp/BaseVersion.h | 3 +++ zypp/DeltaRpm.h | 12 ++++++------ zypp/Package.cc | 39 +++++++++++++++++++++++++++++++++++++++ zypp/Package.h | 12 ++++++++++++ zypp/PatchRpm.h | 12 ++++++------ 5 files changed, 66 insertions(+), 12 deletions(-) diff --git a/zypp/BaseVersion.h b/zypp/BaseVersion.h index 0adba4f..3c64f45 100644 --- a/zypp/BaseVersion.h +++ b/zypp/BaseVersion.h @@ -38,6 +38,9 @@ namespace zypp Date _buildtime; }; + inline bool operator==(const BaseVersion & bv1, const BaseVersion & bv2) + { return bv1.edition() == bv2.edition(); } + } // namespace zypp /////////////////////////////////////////////////////////////////// #endif // ZYPP_BASEVERSION_H diff --git a/zypp/DeltaRpm.h b/zypp/DeltaRpm.h index 4683ef8..8e8e3db 100644 --- a/zypp/DeltaRpm.h +++ b/zypp/DeltaRpm.h @@ -37,12 +37,12 @@ namespace zypp , _buildtime(buildtime) , _base_version(base_version) {} - Arch arch() { return _arch; } - Pathname filename() { return _filename; } - ByteCount downloadsize() { return _downloadsize; } - CheckSum checksum() { return _checksum; } - Date buildtime() { return _buildtime; } - BaseVersion baseVersion() { return _base_version; } + Arch arch() const { return _arch; } + Pathname filename() const { return _filename; } + ByteCount downloadsize() const { return _downloadsize; } + CheckSum checksum() const { return _checksum; } + Date buildtime() const { return _buildtime; } + BaseVersion baseVersion() const { return _base_version; } private: Arch _arch; Pathname _filename; diff --git a/zypp/Package.cc b/zypp/Package.cc index cf2642d..2243c07 100644 --- a/zypp/Package.cc +++ b/zypp/Package.cc @@ -10,6 +10,7 @@ * */ #include "zypp/Package.h" +#include "zypp/base/Exception.h" using namespace std; @@ -133,6 +134,44 @@ namespace zypp std::list Package::deltaRpms() const { return pimpl().deltaRpms(); } + /** */ + Pathname Package::getPlainRpm() const + { return source().provideFile(plainRpm()); } + + /** */ + Pathname Package::getDeltaRpm(BaseVersion & base_r) const + { +#warning (2x): TODO: BaseVersion compare checks only Edition + std::list deltas = deltaRpms(); + for (std::list::const_iterator it = deltas.begin(); + it != deltas.end(); it++) + { + if (base_r == it->baseVersion()) + return source().provideFile(it->filename()); + } + ZYPP_THROW(Exception("No matching delta RPM found")); + return source().provideFile(plainRpm()); // never reached + } + + /** */ + Pathname Package::getPatchRpm(BaseVersion & base_r) const + { + std::list patches = patchRpms(); + for (std::list::const_iterator it = patches.begin(); + it != patches.end(); it++) + { + std::list bases = it->baseVersions(); + for (std::list::const_iterator bvit = bases.begin(); + bvit != bases.end(); bvit++) + { + if (base_r == *bvit) + return source().provideFile(it->filename()); + } + } + ZYPP_THROW(Exception("No matching patch RPM found")); + return source().provideFile(plainRpm()); // never reached + } + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/Package.h b/zypp/Package.h index 34eb641..50c01dc 100644 --- a/zypp/Package.h +++ b/zypp/Package.h @@ -82,6 +82,18 @@ namespace zypp std::list patchRpms() const; /** */ std::list deltaRpms() const; + /** + * \throws Exception + */ + Pathname getPlainRpm() const; + /** + * \throws Exception + */ + Pathname getDeltaRpm(BaseVersion & base_r) const; + /** + * \throws Exception + */ + Pathname getPatchRpm(BaseVersion & base_r) const; // data here: diff --git a/zypp/PatchRpm.h b/zypp/PatchRpm.h index f81c5fe..e13d754 100644 --- a/zypp/PatchRpm.h +++ b/zypp/PatchRpm.h @@ -37,12 +37,12 @@ namespace zypp , _buildtime(buildtime) , _base_versions(base_versions) {} - Arch arch() { return _arch; } - Pathname filename() { return _filename; } - ByteCount downloadsize() { return _downloadsize; } - CheckSum checksum() { return _checksum; } - Date buildtime() { return _buildtime; } - std::list baseVersions() { return _base_versions; } + Arch arch() const { return _arch; } + Pathname filename() const { return _filename; } + ByteCount downloadsize() const { return _downloadsize; } + CheckSum checksum() const { return _checksum; } + Date buildtime() const { return _buildtime; } + std::list baseVersions() const { return _base_versions; } private: Arch _arch; Pathname _filename; -- 2.7.4