aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-01 22:01:17 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-01 22:01:17 +0000
commitfc0d76fbabe4bc8d71a4b0a38fb1c8cec70223d1 (patch)
tree854151a756f5fd9cdce0250c6a7e89c32c4e3b72
parent4147b8a7c1f4671d34da779bd2926a9413f72d80 (diff)
downloadpaludis-fc0d76fbabe4bc8d71a4b0a38fb1c8cec70223d1.tar.gz
paludis-fc0d76fbabe4bc8d71a4b0a38fb1c8cec70223d1.tar.xz
Remove packages from world if they'll no longer be installed after a --uninstall. Fixes: ticket:64
-rw-r--r--paludis/tasks/uninstall_task.cc24
1 files changed, 21 insertions, 3 deletions
diff --git a/paludis/tasks/uninstall_task.cc b/paludis/tasks/uninstall_task.cc
index 6e2fbae..d5a9e4d 100644
--- a/paludis/tasks/uninstall_task.cc
+++ b/paludis/tasks/uninstall_task.cc
@@ -196,9 +196,27 @@ UninstallTask::execute()
on_update_world_pre();
std::tr1::shared_ptr<AllDepAtom> all(new AllDepAtom);
- for (std::list<std::tr1::shared_ptr<PackageDepAtom> >::const_iterator t(_imp->targets.begin()),
- t_end(_imp->targets.end()) ; t != t_end ; ++t)
- all->add_child(*t);
+
+ std::map<QualifiedPackageName, std::set<VersionSpec> > being_removed;
+ for (UninstallList::Iterator i(list.begin()), i_end(list.end()) ; i != i_end ; ++i)
+ if (! i->skip_uninstall)
+ being_removed[i->package.name].insert(i->package.version);
+
+ for (std::map<QualifiedPackageName, std::set<VersionSpec> >::const_iterator
+ i(being_removed.begin()), i_end(being_removed.end()) ; i != i_end ; ++i)
+ {
+ bool remove(true);
+ std::tr1::shared_ptr<PackageDatabaseEntryCollection> installed(
+ _imp->env->package_database()->query(PackageDepAtom(i->first),
+ is_installed_only, qo_whatever));
+ for (PackageDatabaseEntryCollection::Iterator r(installed->begin()), r_end(installed->end()) ;
+ r != r_end && remove ; ++r)
+ if (i->second.end() == i->second.find(r->version))
+ remove = false;
+
+ if (remove)
+ all->add_child(std::tr1::shared_ptr<PackageDepAtom>(new PackageDepAtom(i->first)));
+ }
WorldCallbacks w(this);
_imp->env->remove_appropriate_from_world(all, &w);