aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-10 20:16:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-10 21:56:15 +0000
commit5a2a63d5769eecc1c3d2c7768f4e62b5bbe06315 (patch)
tree35edbb17d29c8ba910bf79900a41c8d888014ad2
parentb8c496e6a94bb6add2bfc94b0d1616f8aae904a9 (diff)
downloadpaludis-5a2a63d5769eecc1c3d2c7768f4e62b5bbe06315.tar.gz
paludis-5a2a63d5769eecc1c3d2c7768f4e62b5bbe06315.tar.xz
Common code for making uninstall blockers
-rw-r--r--paludis/resolver/Makefile.am2
-rw-r--r--paludis/resolver/decider.cc6
-rw-r--r--paludis/resolver/get_constraints_for_dependent_helper.cc3
-rw-r--r--paludis/resolver/get_constraints_for_purge_helper.cc3
-rw-r--r--paludis/resolver/make_uninstall_blocker-fwd.hh33
-rw-r--r--paludis/resolver/make_uninstall_blocker.cc43
-rw-r--r--paludis/resolver/make_uninstall_blocker.hh33
-rw-r--r--paludis/resolver/spec_rewriter.cc4
-rw-r--r--src/clients/cave/resolve_common.cc3
9 files changed, 122 insertions, 8 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 2ff0082..0e38b03 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -70,6 +70,7 @@ noinst_HEADERS = \
labels_classifier.hh labels_classifier-fwd.hh \
make_destination_filtered_generator_helper.hh make_destination_filtered_generator_helper-fwd.hh \
make_origin_filtered_generator_helper.hh make_origin_filtered_generator_helper-fwd.hh \
+ make_uninstall_blocker.hh make_uninstall_blocker-fwd.hh \
make_unmaskable_filter_helper.hh make_unmaskable_filter_helper-fwd.hh \
match_qpns.hh match_qpns-fwd.hh \
nag.hh nag-fwd.hh \
@@ -141,6 +142,7 @@ libpaludisresolver_a_SOURCES = \
labels_classifier.cc \
make_destination_filtered_generator_helper.cc \
make_origin_filtered_generator_helper.cc \
+ make_uninstall_blocker.cc \
make_unmaskable_filter_helper.cc \
match_qpns.cc \
nag.cc \
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 65e4281..9575433 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -39,6 +39,7 @@
#include <paludis/resolver/why_changed_choices.hh>
#include <paludis/resolver/same_slot.hh>
#include <paludis/resolver/reason_utils.hh>
+#include <paludis/resolver/make_uninstall_blocker.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
@@ -1056,10 +1057,7 @@ Decider::_make_constraint_for_preloading(
else
{
PackageDepSpec s(_make_spec_for_preloading(result->spec().if_block()->blocking(), changed_choices));
- result->spec().if_block() = std::make_shared<BlockDepSpec>(
- "!" + stringify(s),
- s,
- result->spec().if_block()->block_kind());
+ result->spec().if_block() = make_shared_copy(make_uninstall_blocker(s));
}
return result;
diff --git a/paludis/resolver/get_constraints_for_dependent_helper.cc b/paludis/resolver/get_constraints_for_dependent_helper.cc
index 129a7f7..89ea8b9 100644
--- a/paludis/resolver/get_constraints_for_dependent_helper.cc
+++ b/paludis/resolver/get_constraints_for_dependent_helper.cc
@@ -23,6 +23,7 @@
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/make_uninstall_blocker.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_copy.hh>
@@ -99,7 +100,7 @@ GetConstraintsForDependentHelper::operator() (
n::from_id() = id,
n::nothing_is_fine_too() = true,
n::reason() = reason,
- n::spec() = BlockDepSpec("!" + stringify(*spec), *spec, bk_weak),
+ n::spec() = make_uninstall_blocker(*spec),
n::untaken() = false,
n::use_existing() = ue_if_possible
)));
diff --git a/paludis/resolver/get_constraints_for_purge_helper.cc b/paludis/resolver/get_constraints_for_purge_helper.cc
index 8d48da0..c410c78 100644
--- a/paludis/resolver/get_constraints_for_purge_helper.cc
+++ b/paludis/resolver/get_constraints_for_purge_helper.cc
@@ -23,6 +23,7 @@
#include <paludis/resolver/resolvent.hh>
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/make_uninstall_blocker.hh>
#include <paludis/util/pimp-impl.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/make_shared_copy.hh>
@@ -90,7 +91,7 @@ GetConstraintsForPurgeHelper::operator() (
n::from_id() = id,
n::nothing_is_fine_too() = true,
n::reason() = reason,
- n::spec() = BlockDepSpec("!" + stringify(spec), spec, bk_weak),
+ n::spec() = make_uninstall_blocker(spec),
n::untaken() = ! _imp->purge_specs.match_any(_imp->env, id, { }),
n::use_existing() = ue_if_possible
)));
diff --git a/paludis/resolver/make_uninstall_blocker-fwd.hh b/paludis/resolver/make_uninstall_blocker-fwd.hh
new file mode 100644
index 0000000..e430b26
--- /dev/null
+++ b/paludis/resolver/make_uninstall_blocker-fwd.hh
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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
+ * 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_RESOLVER_MAKE_UNINSTALL_BLOCKER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_UNINSTALL_BLOCKER_FWD_HH 1
+
+#include <paludis/dep_spec-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+ BlockDepSpec make_uninstall_blocker(const PackageDepSpec &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ }
+}
+
+#endif
diff --git a/paludis/resolver/make_uninstall_blocker.cc b/paludis/resolver/make_uninstall_blocker.cc
new file mode 100644
index 0000000..24f1b47
--- /dev/null
+++ b/paludis/resolver/make_uninstall_blocker.cc
@@ -0,0 +1,43 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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
+ * 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
+ */
+
+#include <paludis/resolver/make_uninstall_blocker.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/dep_spec_annotations.hh>
+#include <paludis/dep_spec.hh>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+BlockDepSpec
+paludis::resolver::make_uninstall_blocker(const PackageDepSpec & spec)
+{
+ BlockDepSpec result("!" + stringify(spec), spec, bk_weak);
+ auto annotations(std::make_shared<DepSpecAnnotations>());
+ annotations->add(make_named_values<DepSpecAnnotation>(
+ n::key() = "<resolution>",
+ n::kind() = dsak_synthetic,
+ n::role() = dsar_blocker_weak,
+ n::value() = "<implicit-weak>"
+ ));
+ result.set_annotations(annotations);
+ return result;
+}
+
diff --git a/paludis/resolver/make_uninstall_blocker.hh b/paludis/resolver/make_uninstall_blocker.hh
new file mode 100644
index 0000000..34e4a11
--- /dev/null
+++ b/paludis/resolver/make_uninstall_blocker.hh
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 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
+ * 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_RESOLVER_MAKE_UNINSTALL_BLOCKER_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_MAKE_UNINSTALL_BLOCKER_HH 1
+
+#include <paludis/resolver/make_uninstall_blocker-fwd.hh>
+
+namespace paludis
+{
+ namespace resolver
+ {
+
+ }
+}
+
+#endif
diff --git a/paludis/resolver/spec_rewriter.cc b/paludis/resolver/spec_rewriter.cc
index 4b06747..cdcba31 100644
--- a/paludis/resolver/spec_rewriter.cc
+++ b/paludis/resolver/spec_rewriter.cc
@@ -136,7 +136,9 @@ SpecRewriter::rewrite_if_special(const PackageOrBlockDepSpec & s, const std::sha
std::string::size_type p(prefix.find_first_not_of('!'));
if (std::string::npos != p)
prefix.erase(p);
- result->specs()->push_back(BlockDepSpec(prefix + stringify(spec), spec, s.if_block()->block_kind()));
+ BlockDepSpec b(prefix + stringify(spec), spec, s.if_block()->block_kind());
+ b.set_annotations(s.if_block()->maybe_annotations());
+ result->specs()->push_back(b);
}
return result;
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index a42a369..00d2e43 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -67,6 +67,7 @@
#include <paludis/resolver/resolution.hh>
#include <paludis/resolver/resolutions_by_resolvent.hh>
#include <paludis/resolver/required_confirmations.hh>
+#include <paludis/resolver/make_uninstall_blocker.hh>
#include <paludis/resolver/allow_choice_changes_helper.hh>
#include <paludis/resolver/allowed_to_remove_helper.hh>
@@ -148,7 +149,7 @@ namespace
p_suggesion.erase(0, 1);
seen_packages = true;
PackageDepSpec s(parse_spec_with_nice_error(p->first.substr(1), env.get(), { }, filter::All()));
- BlockDepSpec bs("!" + stringify(s), s, bk_weak);
+ BlockDepSpec bs(make_uninstall_blocker(s));
result->push_back(stringify(bs));
resolver->add_target(bs, p->second);
}