aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-29 14:53:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-29 14:53:34 +0000
commit77a5e7c20ba9959e3b9cd0cf55aea6c652fcd4c3 (patch)
tree324b5674c07d42080bf71ca21b3c15652388b0ce
parentca5e22d2e472d1ec99db3c2733b7c657d0f63020 (diff)
downloadpaludis-77a5e7c20ba9959e3b9cd0cf55aea6c652fcd4c3.tar.gz
paludis-77a5e7c20ba9959e3b9cd0cf55aea6c652fcd4c3.tar.xz
Fix uninstall world updates
-rw-r--r--paludis/tasks/uninstall_task.cc87
-rw-r--r--paludis/tasks/uninstall_task.hh8
-rwxr-xr-xsrc/clients/paludis/install_TEST13
3 files changed, 99 insertions, 9 deletions
diff --git a/paludis/tasks/uninstall_task.cc b/paludis/tasks/uninstall_task.cc
index 0808bc0..4226110 100644
--- a/paludis/tasks/uninstall_task.cc
+++ b/paludis/tasks/uninstall_task.cc
@@ -231,8 +231,6 @@ UninstallTask::execute()
{
on_update_world_pre();
-#if 0
-
std::tr1::shared_ptr<AllDepSpec> all(new AllDepSpec);
std::map<QualifiedPackageName, std::set<VersionSpec> > being_removed;
@@ -258,14 +256,12 @@ UninstallTask::execute()
std::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(i->first)))));
}
- WorldCallbacks w(this);
- _imp->env->remove_appropriate_from_world(all, &w);
+ world_remove_packages(all);
if (_imp->had_set_targets)
for (std::list<std::string>::const_iterator t(_imp->raw_targets.begin()),
t_end(_imp->raw_targets.end()) ; t != t_end ; ++t)
- _imp->env->remove_set_from_world(SetName(*t), &w);
-#endif
+ world_remove_set(SetName(*t));
on_update_world_post();
}
@@ -347,3 +343,82 @@ UninstallTask::set_all_versions(const bool value)
_imp->all_versions = value;
}
+void
+UninstallTask::world_remove_set(const SetName & s)
+{
+ for (PackageDatabase::RepositoryIterator r(_imp->env->package_database()->begin_repositories()),
+ r_end(_imp->env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->world_interface)
+ (*r)->world_interface->remove_from_world(s);
+
+ on_update_world(s);
+}
+
+namespace
+{
+ struct WorldTargetFinder :
+ DepSpecVisitorTypes::ConstVisitor,
+ DepSpecVisitorTypes::ConstVisitor::VisitChildren<WorldTargetFinder, AllDepSpec>
+ {
+ using DepSpecVisitorTypes::ConstVisitor::VisitChildren<WorldTargetFinder, AllDepSpec>::visit;
+
+ UninstallTask * const task;
+ std::list<const PackageDepSpec *> items;
+ bool inside_any;
+ bool inside_use;
+
+ WorldTargetFinder(UninstallTask * const t) :
+ task(t),
+ inside_any(false),
+ inside_use(false)
+ {
+ }
+
+ void visit(const AnyDepSpec * a)
+ {
+ Save<bool> save_inside_any(&inside_any, true);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const UseDepSpec * a)
+ {
+ Save<bool> save_inside_use(&inside_use, true);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+
+ void visit(const PlainTextDepSpec *)
+ {
+ }
+
+ void visit(const PackageDepSpec * a)
+ {
+ if (! (inside_any || inside_use || a->slot_ptr() || (a->version_requirements_ptr() && ! a->version_requirements_ptr()->empty())))
+ {
+ items.push_back(a);
+ task->on_update_world(*a);
+ }
+ }
+
+ void visit(const BlockDepSpec *)
+ {
+ }
+ };
+}
+
+void
+UninstallTask::world_remove_packages(std::tr1::shared_ptr<const DepSpec> a)
+{
+ WorldTargetFinder w(this);
+ a->accept(&w);
+ for (std::list<const PackageDepSpec *>::const_iterator i(w.items.begin()),
+ i_end(w.items.end()) ; i != i_end ; ++i)
+ {
+ for (PackageDatabase::RepositoryIterator r(_imp->env->package_database()->begin_repositories()),
+ r_end(_imp->env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ if ((*r)->world_interface && (*i)->package_ptr())
+ (*r)->world_interface->remove_from_world(*(*i)->package_ptr());
+ }
+}
+
diff --git a/paludis/tasks/uninstall_task.hh b/paludis/tasks/uninstall_task.hh
index 88405cd..16c7ad5 100644
--- a/paludis/tasks/uninstall_task.hh
+++ b/paludis/tasks/uninstall_task.hh
@@ -153,6 +153,14 @@ namespace paludis
///\}
+ ///\name Logic
+ ///\{
+
+ virtual void world_remove_set(const SetName &);
+ virtual void world_remove_packages(std::tr1::shared_ptr<const DepSpec>);
+
+ ///\}
+
/**
* Run the task.
*/
diff --git a/src/clients/paludis/install_TEST b/src/clients/paludis/install_TEST
index f9abfda..1929ad7 100755
--- a/src/clients/paludis/install_TEST
+++ b/src/clients/paludis/install_TEST
@@ -1,11 +1,18 @@
#!/bin/bash
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
--has-version test-category/target && exit 1
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
--install target || exit 2
./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 3
grep target install_TEST_dir/root/var/db/pkg/world >/dev/null || exit 4
-PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test \
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
--has-version test-category/target || exit 5
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
+ --uninstall target || exit 6
+[[ -f ./install_TEST_dir/root/usr/bin/testbin ]] && exit 7
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
+ --has-version test-category/target && exit 8
+grep target install_TEST_dir/root/var/db/pkg/world >/dev/null && exit 9
+true