aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-27 17:18:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-27 17:18:44 +0000
commit0605cc2c1a38a2d6fac929f28f83a8a5e38853a1 (patch)
tree3dfae2f86ccd7a1935abdf5d284d2b0603c647d1
parentf3c987fc7647fdabb346abd45fd6f0892514d497 (diff)
downloadpaludis-0605cc2c1a38a2d6fac929f28f83a8a5e38853a1.tar.gz
paludis-0605cc2c1a38a2d6fac929f28f83a8a5e38853a1.tar.xz
Treat system packages as used.
Fixes: ticket:710
-rw-r--r--paludis/uninstall_list.cc55
-rw-r--r--paludis/uninstall_list.hh7
-rw-r--r--paludis/uninstall_list.se3
-rw-r--r--paludis/uninstall_task.cc5
-rw-r--r--src/clients/paludis/uninstall.cc13
5 files changed, 73 insertions, 10 deletions
diff --git a/paludis/uninstall_list.cc b/paludis/uninstall_list.cc
index 6fb74af..de7df46 100644
--- a/paludis/uninstall_list.cc
+++ b/paludis/uninstall_list.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* 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
@@ -45,6 +45,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
+#include <paludis/dep_spec_flattener.hh>
#include <tr1/unordered_map>
#include <list>
#include <algorithm>
@@ -135,7 +136,7 @@ UninstallList::real_add(const std::tr1::shared_ptr<const PackageID> & e, const s
Context context("When adding '" + stringify(*e) + "' to the uninstall list:");
if ((! error) || (! e->virtual_for_key()))
- add_package(e, t, error ? ulk_required : (e->virtual_for_key() ? ulk_virtual : ulk_package));
+ add_package(e, t, error ? ulk_requires : (e->virtual_for_key() ? ulk_virtual : ulk_package));
if (! error)
{
@@ -153,6 +154,53 @@ UninstallList::real_add(const std::tr1::shared_ptr<const PackageID> & e, const s
}
void
+UninstallList::add_errors_for_system()
+{
+ Context context("When finding system packages:");
+
+ std::tr1::shared_ptr<const SetSpecTree> system(_imp->env->set(SetName("system")));
+ if (! system)
+ return;
+
+ std::tr1::shared_ptr<Set<std::tr1::shared_ptr<DepTag> > > tags(new Set<std::tr1::shared_ptr<DepTag> >);
+ tags->insert(make_shared_ptr(new GeneralSetDepTag(SetName("system"), "")));
+
+ for (std::list<UninstallListEntry>::iterator l(_imp->uninstall_list.begin()), l_end(_imp->uninstall_list.end()) ;
+ l != l_end ; ++l)
+ {
+ if (l->kind() == ulk_requires)
+ continue;
+
+ bool needed(false);
+ if (match_package_in_set(*_imp->env, *system, *l->package_id(), MatchPackageOptions()))
+ needed = true;
+
+ if ((! needed) && l->package_id()->provide_key())
+ {
+ DepSpecFlattener<ProvideSpecTree, PackageDepSpec> f(_imp->env);
+ l->package_id()->provide_key()->value()->root()->accept(f);
+ for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator v(f.begin()), v_end(f.end()) ;
+ v != v_end && ! needed ; ++v)
+ {
+ const std::tr1::shared_ptr<const PackageIDSequence> virtuals((*_imp->env)[selection::AllVersionsUnsorted(
+ generator::Matches(**v, MatchPackageOptions()))]);
+ for (PackageIDSequence::ConstIterator i(virtuals->begin()), i_end(virtuals->end()) ;
+ i != i_end && ! needed ; ++i)
+ if (match_package_in_set(*_imp->env, *system, **i, MatchPackageOptions()))
+ needed = true;
+ }
+ }
+
+ if (needed)
+ _imp->uninstall_list.insert(l, make_named_values<UninstallListEntry>(
+ value_for<n::kind>(ulk_required_by),
+ value_for<n::package_id>(l->package_id()),
+ value_for<n::tags>(tags)
+ ));
+ }
+}
+
+void
UninstallList::add_unused()
{
Context context("When finding unused packages:");
@@ -521,7 +569,8 @@ namespace
case ulk_package:
return false;
- case ulk_required:
+ case ulk_requires:
+ case ulk_required_by:
return true;
case last_ulk:
diff --git a/paludis/uninstall_list.hh b/paludis/uninstall_list.hh
index 9911447..a098cfe 100644
--- a/paludis/uninstall_list.hh
+++ b/paludis/uninstall_list.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* 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
@@ -128,6 +128,11 @@ namespace paludis
const std::tr1::shared_ptr<DepTag> & = std::tr1::shared_ptr<DepTag>());
/**
+ * Add errors for any package on our uninstall list that is required by system.
+ */
+ void add_errors_for_system();
+
+ /**
* Add any unused packages that are dependencies of packages to uninstall.
*/
void add_unused();
diff --git a/paludis/uninstall_list.se b/paludis/uninstall_list.se
index 8736eaa..6903fbf 100644
--- a/paludis/uninstall_list.se
+++ b/paludis/uninstall_list.se
@@ -6,7 +6,8 @@ make_enum_UninstallListEntryKind()
prefix ulk
key ulk_package "A package to be uninstalled"
- key ulk_required "A package that is still required"
+ key ulk_requires "A package that requires its tags"
+ key ulk_required_by "A package that is required by its tags"
key ulk_virtual "A virtual"
doxygen_comment <<"END"
diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc
index 6fb6f3d..2962d99 100644
--- a/paludis/uninstall_task.cc
+++ b/paludis/uninstall_task.cc
@@ -240,6 +240,7 @@ UninstallTask::execute()
if (_imp->unused)
list.add_unused();
else
+ {
for (std::list<std::tr1::shared_ptr<const PackageDepSpec> >::const_iterator t(_imp->targets.begin()),
t_end(_imp->targets.end()) ; t != t_end ; ++t)
{
@@ -274,6 +275,10 @@ UninstallTask::execute()
list.add(*r->begin());
}
+ if (_imp->check_safety)
+ list.add_errors_for_system();
+ }
+
on_build_unmergelist_post();
on_display_unmerge_list_pre();
diff --git a/src/clients/paludis/uninstall.cc b/src/clients/paludis/uninstall.cc
index 923fdae..82732bb 100644
--- a/src/clients/paludis/uninstall.cc
+++ b/src/clients/paludis/uninstall.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* 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
@@ -110,7 +110,8 @@ namespace
cout << "* " << colour(cl_unimportant, stringify(*d.package_id()));
break;
- case ulk_required:
+ case ulk_requires:
+ case ulk_required_by:
cout << "* " << colour(cl_error, stringify(*d.package_id()));
++_error_count;
break;
@@ -121,7 +122,7 @@ namespace
if ((CommandLine::get_instance()->install_args.a_show_reasons.argument() == "summary") ||
(CommandLine::get_instance()->install_args.a_show_reasons.argument() == "full") ||
- ulk_required == d.kind())
+ ulk_requires == d.kind() || ulk_required_by == d.kind())
{
std::string deps;
unsigned count(0), max_count;
@@ -135,7 +136,7 @@ namespace
tag_end(d.tags()->end()) ;
tag != tag_end ; ++tag)
{
- if ((*tag)->category() != "dependency")
+ if ((*tag)->category() != "dependency" && (*tag)->category() != "general")
continue;
if (++count < max_count)
@@ -150,8 +151,10 @@ namespace
deps.append(stringify(count - max_count + 1) + " more, ");
deps.erase(deps.length() - 2);
- if (d.kind() == ulk_required)
+ if (d.kind() == ulk_requires)
cout << " requires";
+ else if (d.kind() == ulk_required_by)
+ cout << " required by";
cout << " " << colour(d.kind() == ulk_virtual ? cl_unimportant : cl_tag,
"<" + deps + ">");
}