aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-21 06:03:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-21 06:03:34 +0000
commiteed1e659a70604de61e6b27d84ea9b7f88951205 (patch)
tree777c13140b9d22b7ff71b40b33867ded043be0f4
parent270a702f018c5616d7a69072b3c32bef19b1cb36 (diff)
downloadpaludis-eed1e659a70604de61e6b27d84ea9b7f88951205.tar.gz
paludis-eed1e659a70604de61e6b27d84ea9b7f88951205.tar.xz
Implement slow uncached paludis --uninstall --with-dependencies
-rw-r--r--paludis/tasks/uninstall_task.cc12
-rw-r--r--paludis/tasks/uninstall_task.hh1
-rw-r--r--paludis/uninstall_list.cc29
-rw-r--r--paludis/uninstall_list.hh62
-rw-r--r--src/paludis/command_line.cc4
-rw-r--r--src/paludis/command_line.hh3
-rw-r--r--src/paludis/uninstall.cc1
7 files changed, 109 insertions, 3 deletions
diff --git a/paludis/tasks/uninstall_task.cc b/paludis/tasks/uninstall_task.cc
index 4b52cb8..d9ff100 100644
--- a/paludis/tasks/uninstall_task.cc
+++ b/paludis/tasks/uninstall_task.cc
@@ -40,13 +40,15 @@ namespace paludis
bool pretend;
bool preserve_world;
bool with_unused_dependencies;
+ bool with_dependencies;
Implementation<UninstallTask>(Environment * const e) :
env(e),
install_options(false, false),
pretend(false),
preserve_world(false),
- with_unused_dependencies(false)
+ with_unused_dependencies(false),
+ with_dependencies(false)
{
}
};
@@ -123,7 +125,7 @@ UninstallTask::execute()
on_build_unmergelist_pre();
UninstallList list(_imp->env, UninstallListOptions::create()
- .with_dependencies(false)
+ .with_dependencies(_imp->with_dependencies)
.with_unused_dependencies(_imp->with_unused_dependencies));
for (std::list<PackageDepAtom::Pointer>::const_iterator t(_imp->targets.begin()),
@@ -216,3 +218,9 @@ UninstallTask::set_with_unused_dependencies(const bool value)
_imp->with_unused_dependencies = value;
}
+void
+UninstallTask::set_with_dependencies(const bool value)
+{
+ _imp->with_dependencies = value;
+}
+
diff --git a/paludis/tasks/uninstall_task.hh b/paludis/tasks/uninstall_task.hh
index d028b11..339295c 100644
--- a/paludis/tasks/uninstall_task.hh
+++ b/paludis/tasks/uninstall_task.hh
@@ -104,6 +104,7 @@ namespace paludis
void set_pretend(const bool value);
void set_preserve_world(const bool value);
void set_with_unused_dependencies(const bool value);
+ void set_with_dependencies(const bool value);
///\}
diff --git a/paludis/uninstall_list.cc b/paludis/uninstall_list.cc
index 537567f..a78312c 100644
--- a/paludis/uninstall_list.cc
+++ b/paludis/uninstall_list.cc
@@ -85,6 +85,10 @@ UninstallList::add(const PackageDatabaseEntry & e)
Context context("When adding '" + stringify(e) + "' to the uninstall list:");
add_package(e);
+
+ if (_imp->options.with_dependencies)
+ add_dependencies(e);
+
if (_imp->options.with_unused_dependencies)
add_unused_dependencies();
}
@@ -287,3 +291,28 @@ UninstallList::add_unused_dependencies()
}
}
+void
+UninstallList::add_dependencies(const PackageDatabaseEntry & e)
+{
+ Context context("When adding things that depend upon '" + stringify(e) + "':");
+
+ PackageDatabaseEntryCollection::ConstPointer everything(collect_all_installed());
+ for (PackageDatabaseEntryCollection::Iterator i(everything->begin()),
+ i_end(everything->end()) ; i != i_end ; ++i)
+ {
+ Context local_context("When seeing whether '" + stringify(*i) + "' has a dep:");
+
+ DepCollector c(_imp->env, *i);
+ VersionMetadata::ConstPointer metadata(_imp->env->package_database()->fetch_repository(
+ i->repository)->version_metadata(i->name, i->version));
+ metadata->deps.build_depend()->accept(&c);
+ metadata->deps.run_depend()->accept(&c);
+ metadata->deps.post_depend()->accept(&c);
+
+ if (c.matches->end() == c.matches->find(e))
+ continue;
+
+ add(*i);
+ }
+}
+
diff --git a/paludis/uninstall_list.hh b/paludis/uninstall_list.hh
new file mode 100644
index 0000000..9c89d87
--- /dev/null
+++ b/paludis/uninstall_list.hh
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UNUSED_LIST_HH
+#define PALUDIS_GUARD_PALUDIS_UNUSED_LIST_HH 1
+
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/sr.hh>
+#include <paludis/package_database_entry.hh>
+
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+
+namespace paludis
+{
+#include <paludis/uninstall_list-sr.hh>
+
+ class Environment;
+
+ class UninstallList :
+ private PrivateImplementationPattern<UninstallList>,
+ public InstantiationPolicy<UninstallList, instantiation_method::NonCopyableTag>
+ {
+ private:
+ void add_package(const PackageDatabaseEntry &);
+ void add_unused_dependencies();
+ void add_dependencies(const PackageDatabaseEntry &);
+ PackageDatabaseEntryCollection::ConstPointer collect_depped_upon(
+ const PackageDatabaseEntryCollection::ConstPointer targets) const;
+ PackageDatabaseEntryCollection::ConstPointer collect_all_installed() const;
+
+ public:
+ UninstallList(const Environment * const, const UninstallListOptions &);
+ virtual ~UninstallList();
+
+ UninstallListOptions & options;
+
+ void add(const PackageDatabaseEntry &);
+
+ typedef libwrapiter::ForwardIterator<UninstallList, const UninstallListEntry> Iterator;
+ Iterator begin() const;
+ Iterator end() const;
+ };
+}
+
+#endif
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index 25e96c5..7605637 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -83,7 +83,9 @@ CommandLine::CommandLine() :
("full", "Show full output (can be very verbose)"),
"none"),
a_with_unused_dependencies(&install_args, "with-unused-dependencies", '\0',
- "Also uninstall any dependencies that are no longer used"),
+ "Also uninstall any dependencies of the target that are no longer used"),
+ a_with_dependencies(&install_args, "with-dependencies", '\0',
+ "Also uninstall packages that depend upon the target"),
dl_args(this, "DepList behaviour",
"Modify dependency list generation behaviour. Use with caution."),
diff --git a/src/paludis/command_line.hh b/src/paludis/command_line.hh
index 39c8335..6a4acba 100644
--- a/src/paludis/command_line.hh
+++ b/src/paludis/command_line.hh
@@ -185,6 +185,9 @@ class CommandLine :
/// --with-unused-dependencies
paludis::args::SwitchArg a_with_unused_dependencies;
+ /// --with-dependencies
+ paludis::args::SwitchArg a_with_dependencies;
+
/// }
/// \name DepList behaviour arguments
diff --git a/src/paludis/uninstall.cc b/src/paludis/uninstall.cc
index 970071d..856030e 100644
--- a/src/paludis/uninstall.cc
+++ b/src/paludis/uninstall.cc
@@ -141,6 +141,7 @@ do_uninstall()
task.set_no_config_protect(CommandLine::get_instance()->a_no_config_protection.specified());
task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
task.set_with_unused_dependencies(CommandLine::get_instance()->a_with_unused_dependencies.specified());
+ task.set_with_dependencies(CommandLine::get_instance()->a_with_dependencies.specified());
try
{