aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Danny van Dyk <dvandyk@exherbo.org> 2006-11-22 17:19:09 +0000
committerAvatar Danny van Dyk <dvandyk@exherbo.org> 2006-11-22 17:19:09 +0000
commit301254edee94e7125a4c1197030114b380c23022 (patch)
treead99aac1b5ec89a3d8f51b3d9318bcec3945be64
parentca7f18711655835c1b71939e074add128a9f8ccd (diff)
downloadpaludis-301254edee94e7125a4c1197030114b380c23022.tar.gz
paludis-301254edee94e7125a4c1197030114b380c23022.tar.xz
Implement do_installed_time method for CRANInstalledRepository.
-rw-r--r--paludis/repositories/cran/cran_description.hh3
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc41
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh4
3 files changed, 47 insertions, 1 deletions
diff --git a/paludis/repositories/cran/cran_description.hh b/paludis/repositories/cran/cran_description.hh
index 45f354e..850004e 100644
--- a/paludis/repositories/cran/cran_description.hh
+++ b/paludis/repositories/cran/cran_description.hh
@@ -39,6 +39,9 @@ namespace paludis
/// Our metadata, may be zero.
VersionMetadata::Pointer metadata;
+ /// Our installed date.
+ time_t installed_time;
+
/// Turn a CRAN package name into a paludis package name.
static void normalise_name(std::string & s)
{
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 723645b..e5a2802 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -318,7 +318,7 @@ CRANInstalledRepository::do_contents(
if (! _imp->entries_valid)
_imp->load_entries();
- if (! has_version(q, v))
+ if (! has_version(q, v))
return result;
std::string pn = stringify(q.package);
@@ -382,6 +382,45 @@ CRANInstalledRepository::do_contents(
return result;
}
+time_t
+CRANInstalledRepository::do_installed_time(const QualifiedPackageName & q,
+ const VersionSpec & v) const
+{
+ Context context("When finding installed time for '" + stringify(q) +
+ "-" + stringify(v) + "':");
+
+ if (! _imp->entries_valid)
+ _imp->load_entries();
+
+ std::pair<std::vector<CRANDescription>::iterator, std::vector<CRANDescription>::iterator>
+ r(std::equal_range(_imp->entries.begin(), _imp->entries.end(), std::make_pair(
+ q, v), CRANDescription::CompareVersion()));
+ std::string pn = stringify(q.package);
+ CRANDescription::normalise_name(pn);
+
+ if (r.first == r.second)
+ throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
+ else
+ {
+ if (0 == r.first->installed_time)
+ {
+ FSEntry f(_imp->location / "paludis" / pn / "CONTENTS");
+ try
+ {
+ r.first->installed_time = f.ctime();
+ }
+ catch (const FSError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "Can't get ctime of '"
+ + stringify(f) + "' due to exception '" + e.message() + "' (" + e.what()
+ + ")");
+ r.first->installed_time = 1;
+ }
+ }
+ return r.first->installed_time;
+ }
+}
+
CountedPtr<Repository>
CRANInstalledRepository::make_cran_installed_repository(
const Environment * const env,
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index e783e04..fc4eae6 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -75,6 +75,10 @@ namespace paludis
const QualifiedPackageName &,
const VersionSpec &) const;
+ virtual time_t do_installed_time(
+ const QualifiedPackageName &,
+ const VersionSpec &) const;
+
virtual bool do_is_licence(const std::string &) const;
virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,