aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-31 16:31:55 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-31 16:31:55 +0100
commiteefa945bb28ca2ec409161a0520a1f92787ada84 (patch)
tree409864a70679c16cb48f366f9eaaea8e2873d111
parent368ffe6421de8efb8c90923ccc0f6411629cdeee (diff)
downloadpaludis-eefa945bb28ca2ec409161a0520a1f92787ada84.tar.gz
paludis-eefa945bb28ca2ec409161a0520a1f92787ada84.tar.xz
moar
-rw-r--r--paludis/resolver/Makefile.am20
-rw-r--r--paludis/resolver/constraint.cc1
-rw-r--r--paludis/resolver/constraint.hh3
-rw-r--r--paludis/resolver/desire_strength-fwd.hh34
-rw-r--r--paludis/resolver/desire_strength.cc29
-rw-r--r--paludis/resolver/desire_strength.hh25
-rw-r--r--paludis/resolver/desire_strength.se17
-rw-r--r--paludis/resolver/resolver.cc19
-rw-r--r--paludis/resolver/resolver.hh4
-rw-r--r--paludis/resolver/sanitised_dependencies.cc2
-rw-r--r--src/clients/cave/cmd_resolve.cc61
11 files changed, 194 insertions, 21 deletions
diff --git a/paludis/resolver/Makefile.am b/paludis/resolver/Makefile.am
index 7bf1d9c..5946cd1 100644
--- a/paludis/resolver/Makefile.am
+++ b/paludis/resolver/Makefile.am
@@ -1,9 +1,15 @@
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.loT *.epicfail
MAINTAINERCLEANFILES = Makefile.in
-DISTCLEANFILES = use_installed-se.hh use_installed-se.cc
+DISTCLEANFILES = \
+ desire_strength-se.hh desire_strength-se.cc \
+ use_installed-se.hh use_installed-se.cc
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
-EXTRA_DIST = use_installed-se.hh use_installed-se.cc use_installed.se
-BUILT_SOURCES = use_installed-se.hh use_installed-se.cc
+EXTRA_DIST = \
+ desire_strength-se.hh desire_strength-se.cc desire_strength.se \
+ use_installed-se.hh use_installed-se.cc use_installed.se
+BUILT_SOURCES = \
+ desire_strength-se.hh desire_strength-se.cc \
+ use_installed-se.hh use_installed-se.cc
TESTS =
@@ -11,6 +17,7 @@ noinst_HEADERS = \
arrow.hh arrow-fwd.hh \
constraint.hh constraint-fwd.hh \
decision.hh decision-fwd.hh \
+ desire_strength.hh desire_strength-fwd.hh desire_strength-se.hh
qpn_s.hh qpn_s-fwd.hh \
reason.hh reason-fwd.hh \
resolution.hh resolution-fwd.hh \
@@ -22,6 +29,7 @@ libpaludisresolver_a_SOURCES = \
arrow.cc \
constraint.cc \
decision.cc \
+ desire_strength.cc \
qpn_s.cc \
reason.cc \
resolution.cc \
@@ -54,6 +62,12 @@ distcheck-deps-subdirs :
for s in $(SUBDIRS) . ; do if test x$$s = x. ; then $(MAKE) distcheck-deps-local || exit 1 ; \
else $(MAKE) -C $$s distcheck-deps || exit 1 ; fi ; done
+desire_strength-se.hh : desire_strength.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/desire_strength.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
+desire_strength-se.cc : desire_strength.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --source $(srcdir)/desire_strength.se > $@ ; then rm -f $@ ; exit 1 ; fi
+
use_installed-se.hh : use_installed.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/use_installed.se > $@ ; then rm -f $@ ; exit 1 ; fi
diff --git a/paludis/resolver/constraint.cc b/paludis/resolver/constraint.cc
index 1b1e638..910be49 100644
--- a/paludis/resolver/constraint.cc
+++ b/paludis/resolver/constraint.cc
@@ -33,6 +33,7 @@ paludis::resolver::operator<< (std::ostream & s, const Constraint & c)
{
std::stringstream ss;
ss << "Constraint(spec: " << c.spec()
+ << "; desire_strength: " << stringify(c.desire_strength())
<< "; use_installed: " << stringify(c.use_installed())
<< "; reason: " << (c.reason() ? stringify(*c.reason()) : "none")
<< ")";
diff --git a/paludis/resolver/constraint.hh b/paludis/resolver/constraint.hh
index a13d15b..8fe4729 100644
--- a/paludis/resolver/constraint.hh
+++ b/paludis/resolver/constraint.hh
@@ -23,6 +23,7 @@
#include <paludis/resolver/constraint-fwd.hh>
#include <paludis/resolver/reason-fwd.hh>
#include <paludis/resolver/use_installed-fwd.hh>
+#include <paludis/resolver/desire_strength-fwd.hh>
#include <paludis/util/named_value.hh>
#include <paludis/dep_spec.hh>
#include <tr1/memory>
@@ -31,6 +32,7 @@ namespace paludis
{
namespace n
{
+ struct desire_strength;
struct reason;
struct spec;
struct use_installed;
@@ -40,6 +42,7 @@ namespace paludis
{
struct Constraint
{
+ NamedValue<n::desire_strength, DesireStrength> desire_strength;
NamedValue<n::reason, std::tr1::shared_ptr<const Reason> > reason;
NamedValue<n::spec, PackageDepSpec> spec;
NamedValue<n::use_installed, UseInstalled> use_installed;
diff --git a/paludis/resolver/desire_strength-fwd.hh b/paludis/resolver/desire_strength-fwd.hh
new file mode 100644
index 0000000..6c3a515
--- /dev/null
+++ b/paludis/resolver/desire_strength-fwd.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_DESIRE_STRENGTH_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESIRE_STRENGTH_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ namespace resolver
+ {
+#include <paludis/resolver/desire_strength-se.hh>
+ }
+}
+
+#endif
diff --git a/paludis/resolver/desire_strength.cc b/paludis/resolver/desire_strength.cc
new file mode 100644
index 0000000..49c0003
--- /dev/null
+++ b/paludis/resolver/desire_strength.cc
@@ -0,0 +1,29 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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/desire_strength.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/exception.hh>
+#include <ostream>
+
+using namespace paludis;
+using namespace paludis::resolver;
+
+#include <paludis/resolver/desire_strength-se.cc>
+
diff --git a/paludis/resolver/desire_strength.hh b/paludis/resolver/desire_strength.hh
new file mode 100644
index 0000000..fe3b9f0
--- /dev/null
+++ b/paludis/resolver/desire_strength.hh
@@ -0,0 +1,25 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_DESIRE_STRENGTH_HH
+#define PALUDIS_GUARD_PALUDIS_RESOLVER_DESIRE_STRENGTH_HH 1
+
+#include <paludis/resolver/desire_strength-fwd.hh>
+
+#endif
diff --git a/paludis/resolver/desire_strength.se b/paludis/resolver/desire_strength.se
new file mode 100644
index 0000000..d194854
--- /dev/null
+++ b/paludis/resolver/desire_strength.se
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_DesireStrength()
+{
+ prefix ds
+ namespace paludis::resolver
+
+ # must be kept in strictness order
+ key ds_none "Not desired"
+ key ds_suggestion "A suggestion"
+ key ds_recommendation "A recommended dependency"
+ key ds_requirement "A required dependency"
+ key ds_target "Was a target"
+}
+
+
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 87a31c2..61bdbd7 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -29,6 +29,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/log.hh>
#include <paludis/util/join.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/environment.hh>
#include <paludis/notifier_callback.hh>
#include <paludis/dep_spec_flattener.hh>
@@ -276,7 +277,7 @@ const std::tr1::shared_ptr<Constraint>
Resolver::_make_constraint_from_target(const PackageDepSpec & spec, const UseInstalled use_installed) const
{
return make_shared_ptr(new Constraint(make_named_values<Constraint>(
- // value_for<n::desire_strength>(ds_requirement),
+ value_for<n::desire_strength>(ds_target),
value_for<n::reason>(make_shared_ptr(new TargetReason)),
value_for<n::spec>(spec),
value_for<n::use_installed>(use_installed)
@@ -287,7 +288,7 @@ const std::tr1::shared_ptr<Constraint>
Resolver::_make_constraint_from_dependency(const QPN_S & qpn_s, const SanitisedDependency & dep) const
{
return make_shared_ptr(new Constraint(make_named_values<Constraint>(
- // value_for<n::desire_strength>(_desire_strength_from_sanitised_dependency(qpn_s, dep)),
+ value_for<n::desire_strength>(_desire_strength_from_sanitised_dependency(qpn_s, dep)),
value_for<n::reason>(make_shared_ptr(new DependencyReason(qpn_s, dep))),
value_for<n::spec>(dep.spec()),
value_for<n::use_installed>(ui_if_same)
@@ -487,11 +488,10 @@ Resolver::_add_dependencies(const QPN_S & our_qpn_s, const std::tr1::shared_ptr<
}
bool
-Resolver::_care_about_dependency_spec(const QPN_S &,
- const std::tr1::shared_ptr<const Resolution> &, const SanitisedDependency &) const
+Resolver::_care_about_dependency_spec(const QPN_S & qpn_s,
+ const std::tr1::shared_ptr<const Resolution> &, const SanitisedDependency & dep) const
{
- return true;
- // return _desire_strength_from_sanitised_dependency(qpn_s, dep) >= ds_recommendation;
+ return _desire_strength_from_sanitised_dependency(qpn_s, dep) >= ds_recommendation;
}
void
@@ -785,7 +785,7 @@ Resolver::_make_constraint_for_preloading(
const std::tr1::shared_ptr<const Decision> & d) const
{
return make_shared_ptr(new Constraint(make_named_values<Constraint>(
- // value_for<n::desire_strength>(ds_none),
+ value_for<n::desire_strength>(ds_none),
value_for<n::reason>(make_shared_ptr(new TargetReason)),
value_for<n::spec>(d->package_id()->uniquely_identifying_spec()),
value_for<n::use_installed>(ui_if_possible)
@@ -810,8 +810,6 @@ Resolver::add_initial_constraint(const QPN_S & q, const std::tr1::shared_ptr<con
i->second->add(c);
}
-#if 0
-
namespace
{
struct DesireStrengthFinder
@@ -851,7 +849,6 @@ Resolver::_desire_strength_from_sanitised_dependency(const QPN_S &, const Saniti
return result;
}
-#endif
Resolver::ConstIterator
Resolver::begin() const
@@ -1008,3 +1005,5 @@ Resolver::find_any_score(const QPN_S & our_qpn_s, const SanitisedDependency & de
return 0;
}
+template class WrappedForwardIterator<Resolver::ConstIteratorTag, const std::tr1::shared_ptr<const Resolution> >;
+
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index c82f25c..610f624 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -28,6 +28,7 @@
#include <paludis/resolver/decision-fwd.hh>
#include <paludis/resolver/reason-fwd.hh>
#include <paludis/resolver/use_installed-fwd.hh>
+#include <paludis/resolver/desire_strength-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/package_id-fwd.hh>
@@ -125,6 +126,9 @@ namespace paludis
const std::tr1::shared_ptr<const Constraint> _make_constraint_for_preloading(
const std::tr1::shared_ptr<const Decision> &) const;
+ DesireStrength _desire_strength_from_sanitised_dependency(
+ const QPN_S &, const SanitisedDependency &) const;
+
public:
Resolver(const Environment * const);
~Resolver();
diff --git a/paludis/resolver/sanitised_dependencies.cc b/paludis/resolver/sanitised_dependencies.cc
index a176899..9cc86e6 100644
--- a/paludis/resolver/sanitised_dependencies.cc
+++ b/paludis/resolver/sanitised_dependencies.cc
@@ -433,7 +433,7 @@ namespace
);
}
- void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type &)
+ void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type &) PALUDIS_ATTRIBUTE((noreturn))
{
throw InternalError(PALUDIS_HERE, "not implemented");
}
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index 14ebed6..907ef60 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -27,6 +27,8 @@
#include <paludis/util/stringify.hh>
#include <paludis/args/do_help.hh>
#include <paludis/resolver/resolver.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/notifier_callback.hh>
@@ -368,7 +370,7 @@ namespace
~DisplayCallback()
{
- std::cout << std::endl;
+ std::cout << std::endl << std::endl;
}
void operator() (const NotifierCallbackEvent & event) const
@@ -443,6 +445,35 @@ namespace
}
}
}
+
+ void display_resolution(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<Resolver> & resolver,
+ const ResolveCommandLine &)
+ {
+ Context context("When displaying chosen resolution:");
+
+ for (Resolver::ConstIterator c(resolver->begin()), c_end(resolver->end()) ;
+ c != c_end ; ++c)
+ {
+ const std::tr1::shared_ptr<const PackageID> id((*c)->decision()->package_id());
+ std::cout << "* " << id->canonical_form(idcf_no_version) << " " << id->canonical_form(idcf_version)
+ << " replacing { }" << std::endl;
+ }
+
+ std::cout << std::endl;
+ }
+
+ void dump_if_requested(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<Resolver> & resolver,
+ const ResolveCommandLine & cmdline)
+ {
+ Context context("When dumping the resolver:");
+
+ if (cmdline.a_dump.specified())
+ resolver->dump(std::cerr);
+ }
}
bool
@@ -471,18 +502,34 @@ ResolveCommand::run(
std::tr1::shared_ptr<Resolver> resolver(new Resolver(env.get()));
try
{
- DisplayCallback display_callback;
- ScopedNotifierCallback display_callback_holder(env.get(),
- NotifierCallbackFunction(std::tr1::cref(display_callback)));
- add_resolver_targets(env, resolver, cmdline);
- resolver->resolve();
+ while (true)
+ {
+ try
+ {
+ DisplayCallback display_callback;
+ ScopedNotifierCallback display_callback_holder(env.get(),
+ NotifierCallbackFunction(std::tr1::cref(display_callback)));
+ add_resolver_targets(env, resolver, cmdline);
+ resolver->resolve();
+ break;
+ }
+ catch (...)
+ {
+ /* handle restarts etc */
+ throw;
+ }
+ }
+
+ display_resolution(env, resolver, cmdline);
}
catch (...)
{
- // dump_if_requested(resolver);
+ dump_if_requested(env, resolver, cmdline);
throw;
}
+ dump_if_requested(env, resolver, cmdline);
+
return retcode;
}