From 8d94c582f1198118a134fb893e6dbba367b555cf Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Fri, 11 Jul 2008 16:45:47 +0000 Subject: [PATCH] - Implementation of infrastructure for feature #301904 Whole software management stack should warn about oudated update repo TODO: repo2solv.sh should use repomdxml2solv to insert the expire attributes Testcase for zypp::Repository new API. Use it in any application --- zypp/Repository.cc | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ zypp/Repository.h | 20 ++++++++++++++++++++ zypp/sat/SolvAttr.cc | 5 +++++ zypp/sat/SolvAttr.h | 6 ++++++ 4 files changed, 84 insertions(+) diff --git a/zypp/Repository.cc b/zypp/Repository.cc index 088ed70..46470b6 100644 --- a/zypp/Repository.cc +++ b/zypp/Repository.cc @@ -58,6 +58,59 @@ namespace zypp return _repo->name; } + zypp::Date Repository::generatedTimestamp() const + { + ::Dataiterator di; + ::dataiterator_init(&di, get(), -1, 0, 0, SEARCH_EXTRA | SEARCH_NO_STORAGE_SOLVABLE); + if (::dataiterator_step(&di)) + { + do + { + switch (di.key->name) + { + case REPOSITORY_TIMESTAMP: + { + return di.kv.num; + break; + } + } + } + while (::dataiterator_step(&di)); + } + else + ERR << "the extra does not exist in the repo" << endl; + } + + + zypp::Date Repository::expirationTimestamp() const + { + ::Dataiterator di; + ::dataiterator_init(&di, get(), -1, 0, 0, SEARCH_EXTRA | SEARCH_NO_STORAGE_SOLVABLE); + if (::dataiterator_step(&di)) + { + do + { + switch (di.key->name) + { + case REPOSITORY_EXPIRE: + { + return generatedTimestamp() + di.kv.num; + break; + } + } + } + while (::dataiterator_step(&di)); + } + else + ERR << "the extra does not exist in the repo" << endl; + } + + + bool Repository::maybeOutdated() const + { + return expirationTimestamp() < Date::now(); + } + bool Repository::solvablesEmpty() const { NO_REPOSITORY_RETURN( true ); diff --git a/zypp/Repository.h b/zypp/Repository.h index f69baaa..ce50621 100644 --- a/zypp/Repository.h +++ b/zypp/Repository.h @@ -18,6 +18,11 @@ #include "zypp/sat/detail/PoolMember.h" #include "zypp/sat/Solvable.h" #include "zypp/RepoInfo.h" +#include "zypp/Date.h" +extern "C" +{ +#include "satsolver/repo.h" +} /////////////////////////////////////////////////////////////////// namespace zypp @@ -83,6 +88,21 @@ namespace zypp ZYPP_DEPRECATED std::string name() const { return alias(); } + /** + * Timestamp when this repository was generated + */ + zypp::Date generatedTimestamp() const; + + /** + * Expiration date + */ + zypp::Date expirationTimestamp() const; + + /** + * The expiration date of this repository + * already passed + */ + bool maybeOutdated() const; /** Whether \ref Repository contains solvables. */ bool solvablesEmpty() const; diff --git a/zypp/sat/SolvAttr.cc b/zypp/sat/SolvAttr.cc index 7188d57..069fad2 100644 --- a/zypp/sat/SolvAttr.cc +++ b/zypp/sat/SolvAttr.cc @@ -106,6 +106,11 @@ namespace sat const SolvAttr SolvAttr::productOptionalurls ( PRODUCT_OPTIONALURLS ); const SolvAttr SolvAttr::productFlags ( PRODUCT_FLAGS ); + // repository + const SolvAttr SolvAttr::repositoryTimestamp ( REPOSITORY_TIMESTAMP ); + const SolvAttr SolvAttr::repositoryExpire ( REPOSITORY_EXPIRE ); + + } // namespace sat ///////////////////////////////////////////////////////////////// } // namespace zypp diff --git a/zypp/sat/SolvAttr.h b/zypp/sat/SolvAttr.h index 2b3f94e..e338666 100644 --- a/zypp/sat/SolvAttr.h +++ b/zypp/sat/SolvAttr.h @@ -132,6 +132,12 @@ namespace sat static const SolvAttr productFlags; //@} + /** \name repository */ + //@{ + static const SolvAttr repositoryTimestamp; + static const SolvAttr repositoryExpire; + //@} + //@} public: /** Default ctor: \ref noAttr */ -- 2.7.4