aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-12 12:16:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-12 12:16:00 +0000
commit2cf014880a44a3580e65abbcf8a8fc4340f20108 (patch)
treea1c2cfd7646172fab1620aa0d94d60334b0f26f7
parentf4181db7383cca5eee325c6ce6879016e87bcb3d (diff)
downloadpaludis-2cf014880a44a3580e65abbcf8a8fc4340f20108.tar.gz
paludis-2cf014880a44a3580e65abbcf8a8fc4340f20108.tar.xz
Auto clean support
-rw-r--r--paludis/fake_repository.cc5
-rw-r--r--paludis/fake_repository.hh2
-rw-r--r--paludis/portage_repository.cc34
-rw-r--r--paludis/portage_repository.hh2
-rw-r--r--paludis/repository.hh5
-rw-r--r--paludis/vdb_repository.cc16
-rw-r--r--paludis/vdb_repository.hh2
-rw-r--r--src/install.cc52
8 files changed, 117 insertions, 1 deletions
diff --git a/paludis/fake_repository.cc b/paludis/fake_repository.cc
index 54c5beb..cf3ebec 100644
--- a/paludis/fake_repository.cc
+++ b/paludis/fake_repository.cc
@@ -235,3 +235,8 @@ FakeRepository::do_sync() const
return false;
}
+void
+FakeRepository::invalidate() const
+{
+}
+
diff --git a/paludis/fake_repository.hh b/paludis/fake_repository.hh
index 7e10e85..4d57bd7 100644
--- a/paludis/fake_repository.hh
+++ b/paludis/fake_repository.hh
@@ -134,6 +134,8 @@ namespace paludis
{
return false;
}
+
+ virtual void invalidate() const;
};
}
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 1477a12..ecf90bc 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -183,6 +183,9 @@ namespace paludis
/// Add a profile directory.
void add_profile(const FSEntry & f) const;
+ /// Invalidate our cache.
+ void invalidate() const;
+
private:
void add_profile_r(const FSEntry & f) const;
};
@@ -347,6 +350,30 @@ Implementation<PortageRepository>::add_profile_r(const FSEntry & f) const
}
}
+void
+Implementation<PortageRepository>::invalidate() const
+{
+ has_category_names = false;
+ category_names.clear();
+ package_names.clear();
+ version_specs.clear();
+ metadata.clear();
+ repo_mask.clear();
+ has_repo_mask = false;
+ use_mask.clear();
+ use.clear();
+ has_virtuals = false;
+ virtuals_map.clear();
+ has_profile = false;
+ arch_list.clear();
+ expand_list.clear();
+ has_arch_list = false;
+ has_mirrors = false;
+ mirrors.clear();
+ profile_env.clear();
+ system_packages = AllDepAtom::Pointer(0);
+}
+
PortageRepository::PortageRepository(
const Environment * const e, const PackageDatabase * const d,
const FSEntry & location, const FSEntry & profile,
@@ -1214,3 +1241,10 @@ PortageRepository::do_uninstall(const QualifiedPackageName &, const VersionSpec
{
throw PackageUninstallActionError("PortageRepository doesn't support do_uninstall");
}
+
+void
+PortageRepository::invalidate() const
+{
+ _imp->invalidate();
+}
+
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index 2340a41..bd2d1fd 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -127,6 +127,8 @@ namespace paludis
{
return false;
}
+
+ virtual void invalidate() const;
};
/**
diff --git a/paludis/repository.hh b/paludis/repository.hh
index f3f4d5a..4ef444d 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -423,6 +423,11 @@ namespace paludis
{
return do_package_set(s);
}
+
+ /**
+ * Invalidate any cache.
+ */
+ virtual void invalidate() const = 0;
};
/**
diff --git a/paludis/vdb_repository.cc b/paludis/vdb_repository.cc
index a544ca0..20c9e1e 100644
--- a/paludis/vdb_repository.cc
+++ b/paludis/vdb_repository.cc
@@ -163,6 +163,9 @@ namespace paludis
/// Destructor.
~Implementation();
+
+ /// Invalidate.
+ void invalidate() const;
};
}
@@ -206,6 +209,13 @@ Implementation<VDBRepository>::load_entries() const
}
}
+void
+Implementation<VDBRepository>::invalidate() const
+{
+ entries_valid = false;
+ entries.clear();
+}
+
namespace
{
std::string
@@ -555,3 +565,9 @@ VDBRepository::do_sync() const
return false;
}
+void
+VDBRepository::invalidate() const
+{
+ _imp->invalidate();
+}
+
diff --git a/paludis/vdb_repository.hh b/paludis/vdb_repository.hh
index cda08d3..99ec992 100644
--- a/paludis/vdb_repository.hh
+++ b/paludis/vdb_repository.hh
@@ -104,6 +104,8 @@ namespace paludis
{
return true;
}
+
+ virtual void invalidate() const;
};
/**
diff --git a/src/install.cc b/src/install.cc
index c1baa8d..97328d7 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -208,10 +208,60 @@ do_install()
cerr << xterm_title("(" + p::stringify(++current_count) + " of " +
p::stringify(max_count) + ") Installing " + cpv);
-
env->package_database()->fetch_repository(dep->get<p::dle_repository>())->
install(dep->get<p::dle_name>(), dep->get<p::dle_version>());
+
+ // figure out if we need to unmerge anything
+ cout << endl << colour(cl_heading,
+ "Cleaning stale versions after installing " + cpv) << endl << endl;
+
+ // manually invalidate any installed repos, they're probably
+ // wrong now
+ for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
+ if ((*r)->installed())
+ (*r)->invalidate();
+
+ // look for packages with the same name in the same slot
+ p::PackageDatabaseEntryCollection::Pointer collision_list(env->package_database()->query(
+ p::PackageDepAtom::Pointer(new p::PackageDepAtom(
+ p::stringify(dep->get<p::dle_name>()) + ":" +
+ p::stringify(dep->get<p::dle_metadata>()->get(vmk_slot)))),
+ is_installed_only));
+
+ // don't clean the thing we just installed
+ p::PackageDatabaseEntryCollection clean_list;
+ for (p::PackageDatabaseEntryCollection::Iterator c(collision_list->begin()),
+ c_end(collision_list->end()) ; c != c_end ; ++c)
+ if (dep->get<dle_version>() != c->get<pde_version>())
+ clean_list.insert(*c);
+
+ if (clean_list.empty())
+ {
+ cout << "* No cleaning required" << endl;
+ }
+ else
+ {
+ for (p::PackageDatabaseEntryCollection::Iterator c(clean_list.begin()),
+ c_end(clean_list.end()) ; c != c_end ; ++c)
+ cout << "* " << colour(cl_package_name, *c) << endl;
+ cout << endl;
+
+ for (p::PackageDatabaseEntryCollection::Iterator c(clean_list.begin()),
+ c_end(clean_list.end()) ; c != c_end ; ++c)
+ {
+ cout << endl << colour(cl_heading, "Cleaning " + p::stringify(*c)) << endl << endl;
+
+ // TODO: some way to reset this properly would be nice.
+ cerr << xterm_title("(" + p::stringify(++current_count) + " of " +
+ p::stringify(max_count) + ") Cleaning " + cpv + ": " + stringify(*c));
+
+ env->package_database()->fetch_repository(c->get<p::pde_repository>())->
+ uninstall(c->get<p::pde_name>(), c->get<p::pde_version>());
+ }
+ }
}
+ cout << endl;
}
catch (const p::PackageInstallActionError & e)
{