aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-15 14:13:39 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-15 14:13:39 +0000
commit169e91b611f2a12b89467e03abb4c76ddbe3fe7e (patch)
tree2663836792a36cb4b8c05305b3edbdb247edd07b
parent7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a (diff)
downloadpaludis-169e91b611f2a12b89467e03abb4c76ddbe3fe7e.tar.gz
paludis-169e91b611f2a12b89467e03abb4c76ddbe3fe7e.tar.xz
Replace PackageDepSpec::use_requirements with a more general PackageDepSpec::additional_requirements.
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec.cc64
-rw-r--r--paludis/dep_list.cc12
-rw-r--r--paludis/dep_list_exceptions.cc10
-rw-r--r--paludis/dep_list_exceptions.hh16
-rw-r--r--paludis/dep_spec-fwd.hh18
-rw-r--r--paludis/dep_spec.cc141
-rw-r--r--paludis/dep_spec.hh49
-rw-r--r--paludis/dep_spec.se2
-rw-r--r--paludis/dep_spec_TEST.cc23
-rw-r--r--paludis/environments/paludis/use_conf.cc4
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/install_task.cc4
-rw-r--r--paludis/install_task.hh2
-rw-r--r--paludis/match_package.cc9
-rw-r--r--paludis/range_rewriter.cc6
-rw-r--r--paludis/repositories/cran/package_dep_spec.cc6
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/package_dep_spec.cc26
-rw-r--r--paludis/repositories/e/use_requirements.cc223
-rw-r--r--paludis/repositories/e/use_requirements.hh256
-rw-r--r--paludis/use_requirements-fwd.hh39
-rw-r--r--paludis/use_requirements.cc249
-rw-r--r--paludis/use_requirements.hh339
-rw-r--r--python/Makefile.am2
-rw-r--r--python/dep_list.cc6
-rw-r--r--python/dep_spec.cc37
-rw-r--r--python/dep_spec.hh4
-rwxr-xr-xpython/dep_spec_TEST.py16
-rw-r--r--python/paludis_python.hh1
-rw-r--r--python/paludis_python_so.cc1
-rw-r--r--python/use_requirements.cc212
-rwxr-xr-xpython/use_requirements_TEST.py71
-rw-r--r--ruby/dep_spec.cc10
-rw-r--r--ruby/dep_spec_TEST.rb8
-rw-r--r--ruby/paludis_ruby.cc12
-rw-r--r--src/output/console_install_task.cc13
-rw-r--r--src/output/console_install_task.hh2
-rw-r--r--src/output/console_query_task.cc4
38 files changed, 713 insertions, 1187 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc
index c819d7f..54fc877 100644
--- a/doc/api/cplusplus/examples/example_dep_spec.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec.cc
@@ -33,56 +33,6 @@ using std::endl;
using std::setw;
using std::left;
-namespace
-{
- /* Used to print out more information about a UseRequirement. */
- struct UseRequirementPrinter :
- ConstVisitor<UseRequirementVisitorTypes>
- {
- std::ostringstream s;
-
- void visit(const EnabledUseRequirement & r)
- {
- s << "[" << r.flag() << "]";
- }
-
- void visit(const DisabledUseRequirement & r)
- {
- s << "[!" << r.flag() << "]";
- }
-
- void visit(const IfMineThenUseRequirement & r)
- {
- s << "[" << r.flag() << "?] (using '" << *r.package_id() << "')";
- }
-
- void visit(const IfNotMineThenUseRequirement & r)
- {
- s << "[" << r.flag() << "!?] (using '" << *r.package_id() << "')";
- }
-
- void visit(const IfMineThenNotUseRequirement & r)
- {
- s << "[-" << r.flag() << "?] (using '" << *r.package_id() << "')";
- }
-
- void visit(const IfNotMineThenNotUseRequirement & r)
- {
- s << "[-" << r.flag() << "!?] (using '" << *r.package_id() << "')";
- }
-
- void visit(const EqualUseRequirement & r)
- {
- s << "[" << r.flag() << "=] (using '" << *r.package_id() << "')";
- }
-
- void visit(const NotEqualUseRequirement & r)
- {
- s << "[" << r.flag() << "!=] (using '" << *r.package_id() << "')";
- }
- };
-}
-
int main(int argc, char * argv[])
{
try
@@ -154,21 +104,17 @@ int main(int argc, char * argv[])
if (spec.repository_ptr())
cout << " " << left << setw(24) << "Repository:" << " " << *spec.repository_ptr() << endl;
- if (spec.use_requirements_ptr() && ! spec.use_requirements_ptr()->empty())
+ if (spec.additional_requirements_ptr() && ! spec.additional_requirements_ptr()->empty())
{
- cout << " " << left << setw(24) << "Use requirements:" << " ";
+ cout << " " << left << setw(24) << "Additional requirements:" << " ";
bool need_join(false);
- for (UseRequirements::ConstIterator u(spec.use_requirements_ptr()->begin()),
- u_end(spec.use_requirements_ptr()->end()) ; u != u_end ; ++u)
+ for (AdditionalPackageDepSpecRequirements::ConstIterator u(spec.additional_requirements_ptr()->begin()),
+ u_end(spec.additional_requirements_ptr()->end()) ; u != u_end ; ++u)
{
if (need_join)
cout << " and ";
- /* A UseRequirement could be one of various subclasses. We
- * use a visitor to do the right thing. */
- UseRequirementPrinter p;
- (*u)->accept(p);
- cout << p.s.str();
+ cout << (*u)->as_raw_string() + " (meaning: " + (*u)->as_human_string() + ")";
need_join = true;
}
cout << endl;
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 5a00bb3..8152d38 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -476,16 +476,16 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
if (already_installed->empty() || ! can_fall_back)
{
- if (! a.use_requirements_ptr())
+ if (! a.additional_requirements_ptr())
throw AllMaskedError(a);
tr1::shared_ptr<const PackageIDSequence> match_except_reqs(d->_imp->env->package_database()->query(
- query::Matches(*a.without_use_requirements()), qo_whatever));
+ query::Matches(*a.without_additional_requirements()), qo_whatever));
for (PackageIDSequence::ConstIterator i(match_except_reqs->begin()),
i_end(match_except_reqs->end()) ; i != i_end ; ++i)
if (! (*i)->masked())
- throw UseRequirementsNotMetError(stringify(a));
+ throw AdditionalRequirementsNotMetError(a);
throw AllMaskedError(a);
}
@@ -810,7 +810,7 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_ptr()
- || a.blocked_spec()->use_requirements_ptr() || a.blocked_spec()->repository_ptr())
+ || a.blocked_spec()->additional_requirements_ptr() || a.blocked_spec()->repository_ptr())
&& d->_imp->current_package_id())
{
if ((*aa)->name() == d->_imp->current_package_id()->name())
@@ -851,7 +851,7 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_ptr()
- || a.blocked_spec()->use_requirements_ptr() || a.blocked_spec()->repository_ptr())
+ || a.blocked_spec()->additional_requirements_ptr() || a.blocked_spec()->repository_ptr())
&& d->_imp->current_package_id())
{
if ((*r)->package_id->name() == d->_imp->current_package_id()->name())
@@ -876,7 +876,7 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_ptr()
- || a.blocked_spec()->use_requirements_ptr() || a.blocked_spec()->repository_ptr())
+ || a.blocked_spec()->additional_requirements_ptr() || a.blocked_spec()->repository_ptr())
&& d->_imp->current_package_id())
{
if (r->package_id->name() == d->_imp->current_package_id()->name())
diff --git a/paludis/dep_list_exceptions.cc b/paludis/dep_list_exceptions.cc
index 085a365..05ee324 100644
--- a/paludis/dep_list_exceptions.cc
+++ b/paludis/dep_list_exceptions.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 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
@@ -34,12 +34,16 @@ AllMaskedError::AllMaskedError(const PackageDepSpec & q) throw () :
{
}
-UseRequirementsNotMetError::UseRequirementsNotMetError(const std::string & q) throw () :
- DepListError("Error searching for '" + q + "': use requirements are not met"),
+AdditionalRequirementsNotMetError::AdditionalRequirementsNotMetError(const PackageDepSpec & q) throw () :
+ DepListError("Error searching for '" + stringify(q) + "': additional requirements are not met"),
_query(q)
{
}
+AdditionalRequirementsNotMetError::~AdditionalRequirementsNotMetError() throw ()
+{
+}
+
BlockError::BlockError(const std::string & msg) throw () :
DepListError("Block: " + msg)
{
diff --git a/paludis/dep_list_exceptions.hh b/paludis/dep_list_exceptions.hh
index 948e46c..671bc3f 100644
--- a/paludis/dep_list_exceptions.hh
+++ b/paludis/dep_list_exceptions.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008 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
@@ -89,33 +89,31 @@ namespace paludis
/**
* Thrown if all versions of a particular spec are masked,
- * but would not be if use requirements were not in effect.
+ * but would not be if additional requirements were not in effect.
*
* \ingroup g_dep_list
* \ingroup g_exceptions
* \nosubgrouping
*/
- class PALUDIS_VISIBLE UseRequirementsNotMetError : public DepListError
+ class PALUDIS_VISIBLE AdditionalRequirementsNotMetError : public DepListError
{
private:
- std::string _query;
+ PackageDepSpec _query;
public:
///\name Basic operations
///\{
- UseRequirementsNotMetError(const std::string & query) throw ();
+ AdditionalRequirementsNotMetError(const PackageDepSpec & query) throw ();
- virtual ~UseRequirementsNotMetError() throw ()
- {
- }
+ virtual ~AdditionalRequirementsNotMetError() throw ();
///\}
/**
* Our query.
*/
- const std::string & query() const
+ const PackageDepSpec query() const
{
return _query;
}
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index b8f28ce..5201df1 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -27,6 +27,7 @@
#include <paludis/formatter-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/options-fwd.hh>
+#include <paludis/util/sequence-fwd.hh>
#include <paludis/util/tr1_memory.hh>
/** \file
@@ -71,6 +72,23 @@ namespace paludis
class PartiallyMadePackageDepSpec;
class ConditionalDepSpecData;
+ class AdditionalPackageDepSpecRequirement;
+
+ /**
+ * An AdditionalPackageDepSpecRequirement can be written to an ostream.
+ *
+ * \ingroup g_dep_spec
+ */
+ std::ostream & operator<< (std::ostream &, const AdditionalPackageDepSpecRequirement &) PALUDIS_VISIBLE;
+
+ /**
+ * A collection of additional requirements for a PackageDepSpec.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ typedef Sequence<tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> > AdditionalPackageDepSpecRequirements;
+
#include <paludis/dep_spec-se.hh>
/**
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index 187eb86..5136708 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -18,17 +18,17 @@
*/
#include <paludis/dep_spec.hh>
+#include <paludis/environment.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
#include <paludis/version_requirements.hh>
-#include <paludis/use_requirements.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/log.hh>
#include <paludis/util/join.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/mutex.hh>
-#include <paludis/util/sequence.hh>
+#include <paludis/util/sequence-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/iterator_funcs.hh>
@@ -538,14 +538,14 @@ PackageDepSpec::repository_ptr() const
return _imp->data->repository_ptr();
}
-tr1::shared_ptr<const UseRequirements>
-PackageDepSpec::use_requirements_ptr() const
+tr1::shared_ptr<const AdditionalPackageDepSpecRequirements>
+PackageDepSpec::additional_requirements_ptr() const
{
- return _imp->data->use_requirements_ptr();
+ return _imp->data->additional_requirements_ptr();
}
tr1::shared_ptr<PackageDepSpec>
-PackageDepSpec::without_use_requirements() const
+PackageDepSpec::without_additional_requirements() const
{
using namespace tr1::placeholders;
@@ -593,6 +593,41 @@ PackageDepSpec::_as_string() const
return _imp->data->as_string();
}
+AdditionalPackageDepSpecRequirement::~AdditionalPackageDepSpecRequirement()
+{
+}
+
+namespace
+{
+ struct UserUseRequirement :
+ AdditionalPackageDepSpecRequirement
+ {
+ bool inverse;
+ UseFlagName f;
+
+ UserUseRequirement(const std::string & s) :
+ inverse((! s.empty()) && ('-' == s.at(0))),
+ f(inverse ? UseFlagName(s.substr(1)) : UseFlagName(s))
+ {
+ }
+
+ virtual bool requirement_met(const Environment * const env, const PackageID & id) const
+ {
+ return env->query_use(f, id) ^ inverse;
+ }
+
+ virtual const std::string as_human_string() const
+ {
+ return "Use flag '" + stringify(f) + "' " + (inverse ? "enabled" : "disabled");
+ }
+
+ virtual const std::string as_raw_string() const
+ {
+ return "[" + std::string(inverse ? "-" : "") + stringify(f) + "]";
+ }
+ };
+}
+
PackageDepSpec
paludis::parse_user_package_dep_spec(const std::string & ss, const UserPackageDepSpecOptions & options)
{
@@ -686,18 +721,8 @@ paludis::parse_user_package_dep_spec(const std::string & ss, const UserPackageDe
default:
{
- tr1::shared_ptr<UseRequirement> req;
- if ('-' == flag.at(0))
- {
- flag.erase(0, 1);
- if (flag.empty())
- throw PackageDepSpecError("Invalid [] contents");
- req.reset(new DisabledUseRequirement(UseFlagName(flag)));
- }
- else
- req.reset(new EnabledUseRequirement(UseFlagName(flag)));
-
- result.use_requirement(req);
+ tr1::shared_ptr<UserUseRequirement> req(new UserUseRequirement(flag));
+ result.additional_requirement(req);
}
break;
};
@@ -818,52 +843,6 @@ paludis::make_package_dep_spec()
namespace
{
- struct UseRequirementPrinter :
- ConstVisitor<UseRequirementVisitorTypes>
- {
- std::ostringstream s;
-
- void visit(const EnabledUseRequirement & r)
- {
- s << "[" << r.flag() << "]";
- }
-
- void visit(const DisabledUseRequirement & r)
- {
- s << "[-" << r.flag() << "]";
- }
-
- void visit(const IfMineThenUseRequirement & r)
- {
- s << "[" << r.flag() << "?]";
- }
-
- void visit(const IfNotMineThenUseRequirement & r)
- {
- s << "[" << r.flag() << "!?]";
- }
-
- void visit(const IfMineThenNotUseRequirement & r)
- {
- s << "[-" << r.flag() << "?]";
- }
-
- void visit(const IfNotMineThenNotUseRequirement & r)
- {
- s << "[-" << r.flag() << "!?]";
- }
-
- void visit(const EqualUseRequirement & r)
- {
- s << "[" << r.flag() << "=]";
- }
-
- void visit(const NotEqualUseRequirement & r)
- {
- s << "[" << r.flag() << "!=]";
- }
- };
-
struct PartiallyMadePackageDepSpecData :
PackageDepSpecData
{
@@ -874,7 +853,7 @@ namespace
VersionRequirementsMode version_requirements_mode_v;
tr1::shared_ptr<SlotName> slot;
tr1::shared_ptr<RepositoryName> repository;
- tr1::shared_ptr<UseRequirements> use_requirements;
+ tr1::shared_ptr<AdditionalPackageDepSpecRequirements> additional_requirements;
PartiallyMadePackageDepSpecData() :
PackageDepSpecData(),
@@ -891,7 +870,7 @@ namespace
version_requirements_mode_v(other.version_requirements_mode_v),
slot(other.slot),
repository(other.repository),
- use_requirements(other.use_requirements)
+ additional_requirements(other.additional_requirements)
{
}
@@ -1000,16 +979,10 @@ namespace
}
}
- if (use_requirements_ptr())
- {
- for (UseRequirements::ConstIterator u(use_requirements_ptr()->begin()),
- u_end(use_requirements_ptr()->end()) ; u != u_end ; ++u)
- {
- UseRequirementPrinter p;
- (*u)->accept(p);
- s << p.s.str();
- }
- }
+ if (additional_requirements_ptr())
+ for (AdditionalPackageDepSpecRequirements::ConstIterator u(additional_requirements_ptr()->begin()),
+ u_end(additional_requirements_ptr()->end()) ; u != u_end ; ++u)
+ s << (*u)->as_raw_string();
return s.str();
}
@@ -1049,9 +1022,9 @@ namespace
return repository;
}
- virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const
+ virtual tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const
{
- return use_requirements;
+ return additional_requirements;
}
};
}
@@ -1141,11 +1114,11 @@ PartiallyMadePackageDepSpec::version_requirements_mode(const VersionRequirements
}
PartiallyMadePackageDepSpec &
-PartiallyMadePackageDepSpec::use_requirement(const tr1::shared_ptr<const UseRequirement> & req)
+PartiallyMadePackageDepSpec::additional_requirement(const tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> & req)
{
- if (! _imp->data->use_requirements)
- _imp->data->use_requirements.reset(new UseRequirements);
- _imp->data->use_requirements->insert(req);
+ if (! _imp->data->additional_requirements)
+ _imp->data->additional_requirements.reset(new AdditionalPackageDepSpecRequirements);
+ _imp->data->additional_requirements->push_back(req);
return *this;
}
@@ -1160,8 +1133,6 @@ PartiallyMadePackageDepSpec::to_package_dep_spec() const
return operator const PackageDepSpec();
}
-template class WrappedForwardIterator<UseRequirements::ConstIteratorTag, const std::pair<const UseFlagName, UseFlagState> >;
-
template class LabelsDepSpec<URILabelVisitorTypes>;
template class WrappedForwardIterator<LabelsDepSpec<URILabelVisitorTypes>::ConstIteratorTag,
const tr1::shared_ptr<const URILabelVisitorTypes::BasicNode> >;
@@ -1170,3 +1141,5 @@ template class LabelsDepSpec<DependencyLabelVisitorTypes>;
template class WrappedForwardIterator<LabelsDepSpec<DependencyLabelVisitorTypes>::ConstIteratorTag,
const tr1::shared_ptr<const DependencyLabelVisitorTypes::BasicNode> >;
+template class Sequence<tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> >;
+
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index c02bc59..4182fcf 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -25,6 +25,7 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/tr1_memory.hh>
+#include <paludis/util/tr1_functional.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/dep_label.hh>
@@ -35,7 +36,8 @@
#include <paludis/version_operator-fwd.hh>
#include <paludis/version_requirements-fwd.hh>
#include <paludis/version_spec-fwd.hh>
-#include <paludis/use_requirements-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
/** \file
* Declarations for dependency spec classes.
@@ -262,6 +264,34 @@ namespace paludis
};
/**
+ * An additional requirement for a PackageDepSpec.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE AdditionalPackageDepSpecRequirement :
+ private InstantiationPolicy<AdditionalPackageDepSpecRequirement, instantiation_method::NonCopyableTag>
+ {
+ public:
+ virtual ~AdditionalPackageDepSpecRequirement();
+
+ /**
+ * Is our requirement met for a given PackageID?
+ */
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Return a human readable string representation of ourself.
+ */
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Return a raw string representation of ourself.
+ */
+ virtual const std::string as_raw_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ /**
* A PartiallyMadePackageDepSpec is returned by make_package_dep_spec()
* and is used to incrementally build a PackageDepSpec.
*
@@ -317,9 +347,10 @@ namespace paludis
PartiallyMadePackageDepSpec & version_requirements_mode(const VersionRequirementsMode &);
/**
- * Add a use requirement, return ourself.
+ * Add an additional requirement, return ourself.
*/
- PartiallyMadePackageDepSpec & use_requirement(const tr1::shared_ptr<const UseRequirement> &);
+ PartiallyMadePackageDepSpec & additional_requirement(
+ const tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> &);
/**
* Turn ourselves into a PackageDepSpec.
@@ -418,9 +449,9 @@ namespace paludis
tr1::shared_ptr<const RepositoryName> repository_ptr() const;
/**
- * Fetch the use requirements (may be a zero pointer).
+ * Fetch any additional requirements (may be a zero pointer).
*/
- tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const;
+ tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const;
/**
* Fetch our tag.
@@ -433,9 +464,9 @@ namespace paludis
void set_tag(const tr1::shared_ptr<const DepTag> & s);
/**
- * Fetch a copy of ourself without the USE requirements.
+ * Fetch a copy of ourself without additional requirements.
*/
- tr1::shared_ptr<PackageDepSpec> without_use_requirements() const;
+ tr1::shared_ptr<PackageDepSpec> without_additional_requirements() const;
virtual const PackageDepSpec * as_package_dep_spec() const;
};
@@ -497,9 +528,9 @@ namespace paludis
virtual tr1::shared_ptr<const RepositoryName> repository_ptr() const = 0;
/**
- * Fetch the use requirements (may be a zero pointer).
+ * Fetch the additional requirements (may be a zero pointer).
*/
- virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const = 0;
+ virtual tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const = 0;
};
/**
diff --git a/paludis/dep_spec.se b/paludis/dep_spec.se
index 79d6a73..da551b5 100644
--- a/paludis/dep_spec.se
+++ b/paludis/dep_spec.se
@@ -5,7 +5,7 @@ make_enum_UserPackageDepSpecOption()
{
prefix updso
- key updso_allow_wildcards "Allow wildcards for category, package"
+ key updso_allow_wildcards "Allow wildcards for category, package"
doxygen_comment << "END"
/**
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index 26d4c3b..88f7ea8 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -27,7 +27,6 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/version_requirements.hh>
-#include <paludis/use_requirements.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -119,12 +118,7 @@ namespace test_cases
TEST_CHECK(! i.version_requirements_ptr());
TEST_CHECK(! i.repository_ptr());
TEST_CHECK(! i.slot_ptr());
- TEST_CHECK(i.use_requirements_ptr());
- TEST_CHECK(i.use_requirements_ptr()->find(UseFlagName("one")) != i.use_requirements_ptr()->end());
- TEST_CHECK(i.use_requirements_ptr()->find(UseFlagName("two")) != i.use_requirements_ptr()->end());
- TEST_CHECK(i.use_requirements_ptr()->find(UseFlagName("three")) == i.use_requirements_ptr()->end());
- TEST_CHECK(visitor_cast<const EnabledUseRequirement>(**i.use_requirements_ptr()->find(UseFlagName("one"))));
- TEST_CHECK(visitor_cast<const DisabledUseRequirement>(**i.use_requirements_ptr()->find(UseFlagName("two"))));
+ TEST_CHECK(i.additional_requirements_ptr());
PackageDepSpec j(parse_user_package_dep_spec("=foo/bar-scm-r3", UserPackageDepSpecOptions()));
TEST_CHECK_STRINGIFY_EQUAL(j, "=foo/bar-scm-r3");
@@ -150,12 +144,6 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(next(l.version_requirements_ptr()->begin())->version_spec, "2.0");
TEST_CHECK_EQUAL(next(l.version_requirements_ptr()->begin())->version_operator, vo_less);
TEST_CHECK(! l.slot_ptr());
- TEST_CHECK(l.use_requirements_ptr());
- TEST_CHECK(l.use_requirements_ptr()->find(UseFlagName("one")) != l.use_requirements_ptr()->end());
- TEST_CHECK(l.use_requirements_ptr()->find(UseFlagName("two")) != l.use_requirements_ptr()->end());
- TEST_CHECK(l.use_requirements_ptr()->find(UseFlagName("three")) == l.use_requirements_ptr()->end());
- TEST_CHECK(visitor_cast<const EnabledUseRequirement>(**l.use_requirements_ptr()->find(UseFlagName("one"))));
- TEST_CHECK(visitor_cast<const DisabledUseRequirement>(**l.use_requirements_ptr()->find(UseFlagName("two"))));
PackageDepSpec m(parse_user_package_dep_spec("foo/bar[=1.2|=1.3*|~1.4]", UserPackageDepSpecOptions()));
TEST_CHECK_STRINGIFY_EQUAL(m, "foo/bar[=1.2|=1.3*|~1.4]");
@@ -169,15 +157,6 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(next(next(m.version_requirements_ptr()->begin()))->version_spec, "1.4");
TEST_CHECK_EQUAL(next(next(m.version_requirements_ptr()->begin()))->version_operator, vo_tilde);
TEST_CHECK(! m.slot_ptr());
-
- PackageDepSpec n(make_package_dep_spec()
- .use_requirement(make_shared_ptr(new IfMineThenUseRequirement(UseFlagName("if-mine-then"), tr1::shared_ptr<const PackageID>())))
- .use_requirement(make_shared_ptr(new IfNotMineThenUseRequirement(UseFlagName("if-not-mine-then"), tr1::shared_ptr<const PackageID>())))
- .use_requirement(make_shared_ptr(new IfMineThenNotUseRequirement(UseFlagName("if-mine-then-not"), tr1::shared_ptr<const PackageID>())))
- .use_requirement(make_shared_ptr(new IfNotMineThenNotUseRequirement(UseFlagName("if-not-mine-then-not"), tr1::shared_ptr<const PackageID>())))
- .use_requirement(make_shared_ptr(new EqualUseRequirement(UseFlagName("equal"), tr1::shared_ptr<const PackageID>())))
- .use_requirement(make_shared_ptr(new NotEqualUseRequirement(UseFlagName("not-equal"), tr1::shared_ptr<const PackageID>()))));
- TEST_CHECK_STRINGIFY_EQUAL(n, "*/*[if-mine-then?][if-not-mine-then!?][-if-mine-then-not?][-if-not-mine-then-not!?][equal=][not-equal!=]");
}
} test_package_dep_spec;
diff --git a/paludis/environments/paludis/use_conf.cc b/paludis/environments/paludis/use_conf.cc
index 0d96317..0ed0439 100644
--- a/paludis/environments/paludis/use_conf.cc
+++ b/paludis/environments/paludis/use_conf.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 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
@@ -133,7 +133,7 @@ UseConf::add(const FSEntry & filename)
tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(parse_user_package_dep_spec(
tokens.at(0), UserPackageDepSpecOptions() + updso_allow_wildcards)));
- if (d->use_requirements_ptr())
+ if (d->additional_requirements_ptr())
{
Log::get_instance()->message(ll_warning, lc_context) << "Dependency specification '" << stringify(*d)
<< "' includes use requirements, which cannot be used in use.conf";
diff --git a/paludis/files.m4 b/paludis/files.m4
index d428ed2..93eec59 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -68,7 +68,6 @@ add(`tasks_exceptions', `hh', `cc')
add(`uninstall_list', `hh', `cc', `se', `sr', `test')
add(`uninstall_task', `hh', `cc')
add(`unmerger', `hh', `cc', `sr')
-add(`use_requirements', `hh', `cc', `fwd')
add(`version_operator', `hh', `cc', `fwd', `se', `test')
add(`version_requirements', `hh', `cc', `fwd', `sr')
add(`version_spec', `hh', `cc', `fwd', `test')
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 99120cb..36fce93 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -822,10 +822,10 @@ InstallTask::execute()
_imp->had_resolution_failures = true;
on_all_masked_error(e);
}
- catch (const UseRequirementsNotMetError & e)
+ catch (const AdditionalRequirementsNotMetError & e)
{
_imp->had_resolution_failures = true;
- on_use_requirements_not_met_error(e);
+ on_additional_requirements_not_met_error(e);
}
catch (const DepListError & e)
{
diff --git a/paludis/install_task.hh b/paludis/install_task.hh
index 89d49d9..5839492 100644
--- a/paludis/install_task.hh
+++ b/paludis/install_task.hh
@@ -191,7 +191,7 @@ namespace paludis
virtual void on_ambiguous_package_name_error(const AmbiguousPackageNameError &) = 0;
virtual void on_no_such_package_error(const NoSuchPackageError &) = 0;
virtual void on_all_masked_error(const AllMaskedError &) = 0;
- virtual void on_use_requirements_not_met_error(const UseRequirementsNotMetError &) = 0;
+ virtual void on_additional_requirements_not_met_error(const AdditionalRequirementsNotMetError &) = 0;
virtual void on_dep_list_error(const DepListError &) = 0;
virtual void on_had_both_package_and_set_targets_error(const HadBothPackageAndSetTargets &) = 0;
virtual void on_multiple_set_targets_specified(const MultipleSetTargetsSpecified &) = 0;
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index 23d1a52..caad407 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -22,7 +22,6 @@
#include <paludis/dep_spec_flattener.hh>
#include <paludis/environment.hh>
#include <paludis/version_requirements.hh>
-#include <paludis/use_requirements.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
#include <paludis/util/visitor-impl.hh>
@@ -84,11 +83,11 @@ paludis::match_package(
if (*spec.slot_ptr() != entry.slot())
return false;
- if (spec.use_requirements_ptr())
+ if (spec.additional_requirements_ptr())
{
- for (UseRequirements::ConstIterator u(spec.use_requirements_ptr()->begin()),
- u_end(spec.use_requirements_ptr()->end()) ; u != u_end ; ++u)
- if (! (*u)->satisfied_by(&env, entry))
+ for (AdditionalPackageDepSpecRequirements::ConstIterator u(spec.additional_requirements_ptr()->begin()),
+ u_end(spec.additional_requirements_ptr()->end()) ; u != u_end ; ++u)
+ if (! (*u)->requirement_met(&env, entry))
return false;
}
diff --git a/paludis/range_rewriter.cc b/paludis/range_rewriter.cc
index 2faba0b..b230aeb 100644
--- a/paludis/range_rewriter.cc
+++ b/paludis/range_rewriter.cc
@@ -126,9 +126,9 @@ namespace
return tr1::shared_ptr<const RepositoryName>();
}
- virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const
+ virtual tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const
{
- return tr1::shared_ptr<const UseRequirements>();
+ return tr1::shared_ptr<const AdditionalPackageDepSpecRequirements>();
}
void add_spec(const PackageDepSpec & spec)
@@ -206,7 +206,7 @@ RangeRewriter::visit_leaf(const PackageDepSpec & a)
if (_imp->invalid)
return;
- if (a.use_requirements_ptr() || a.slot_ptr() || a.repository_ptr() || a.package_name_part_ptr()
+ if (a.additional_requirements_ptr() || a.slot_ptr() || a.repository_ptr() || a.package_name_part_ptr()
|| a.category_name_part_ptr() || ! a.version_requirements_ptr() || ! a.package_ptr())
{
_imp->invalid = true;
diff --git a/paludis/repositories/cran/package_dep_spec.cc b/paludis/repositories/cran/package_dep_spec.cc
index b1e7138..d02cd79 100644
--- a/paludis/repositories/cran/package_dep_spec.cc
+++ b/paludis/repositories/cran/package_dep_spec.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 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
@@ -100,9 +100,9 @@ namespace
return tr1::shared_ptr<const RepositoryName>();
}
- virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const
+ virtual tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const
{
- return tr1::shared_ptr<const UseRequirements>();
+ return tr1::shared_ptr<const AdditionalPackageDepSpecRequirements>();
}
CRANPackageDepSpecData & version_requirement(const VersionRequirement & v)
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 0282a21..1001c4f 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -88,6 +88,7 @@ paludis_repositories_e_include_HEADERS = \
source_uri_finder.hh \
traditional_layout.hh \
use_desc.hh \
+ use_requirements.hh \
vdb_contents_tokeniser.hh \
vdb_id.hh \
vdb_merger-sr.hh \
@@ -141,6 +142,7 @@ libpaludiserepository_la_SOURCES = \
source_uri_finder.cc \
traditional_layout.cc \
use_desc.cc \
+ use_requirements.cc \
vdb_id.cc \
vdb_merger.cc \
vdb_repository.cc \
diff --git a/paludis/repositories/e/package_dep_spec.cc b/paludis/repositories/e/package_dep_spec.cc
index 8204362..623f112 100644
--- a/paludis/repositories/e/package_dep_spec.cc
+++ b/paludis/repositories/e/package_dep_spec.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 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
@@ -19,13 +19,13 @@
#include <paludis/repositories/e/package_dep_spec.hh>
#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/use_requirements.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/log.hh>
#include <paludis/dep_spec.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
#include <paludis/version_requirements.hh>
-#include <paludis/use_requirements.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -134,7 +134,9 @@ paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAP
default:
{
- tr1::shared_ptr<const UseRequirement> req;
+ std::string raw_flag(flag);
+
+ tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> req;
if ('=' == flag.at(flag.length() - 1))
{
if (! id)
@@ -148,10 +150,10 @@ paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAP
flag.erase(flag.length() - 1);
if (flag.empty())
throw PackageDepSpecError("Invalid [] contents");
- req.reset(new NotEqualUseRequirement(UseFlagName(flag), id));
+ req.reset(new NotEqualUseRequirement(raw_flag, UseFlagName(flag), id));
}
else
- req.reset(new EqualUseRequirement(UseFlagName(flag), id));
+ req.reset(new EqualUseRequirement(raw_flag, UseFlagName(flag), id));
}
else if ('?' == flag.at(flag.length() - 1))
{
@@ -172,10 +174,10 @@ paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAP
if (flag.empty())
throw PackageDepSpecError("Invalid [] contents");
- req.reset(new IfNotMineThenNotUseRequirement(UseFlagName(flag), id));
+ req.reset(new IfNotMineThenNotUseRequirement(raw_flag, UseFlagName(flag), id));
}
else
- req.reset(new IfNotMineThenUseRequirement(UseFlagName(flag), id));
+ req.reset(new IfNotMineThenUseRequirement(raw_flag, UseFlagName(flag), id));
}
else
{
@@ -185,10 +187,10 @@ paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAP
if (flag.empty())
throw PackageDepSpecError("Invalid [] contents");
- req.reset(new IfMineThenNotUseRequirement(UseFlagName(flag), id));
+ req.reset(new IfMineThenNotUseRequirement(raw_flag, UseFlagName(flag), id));
}
else
- req.reset(new IfMineThenUseRequirement(UseFlagName(flag), id));
+ req.reset(new IfMineThenUseRequirement(raw_flag, UseFlagName(flag), id));
}
}
else if ('-' == flag.at(0))
@@ -196,11 +198,11 @@ paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAP
flag.erase(0, 1);
if (flag.empty())
throw PackageDepSpecError("Invalid [] contents");
- req.reset(new DisabledUseRequirement(UseFlagName(flag)));
+ req.reset(new DisabledUseRequirement(raw_flag, UseFlagName(flag)));
}
else
- req.reset(new EnabledUseRequirement(UseFlagName(flag)));
- result.use_requirement(req);
+ req.reset(new EnabledUseRequirement(raw_flag, UseFlagName(flag)));
+ result.additional_requirement(req);
}
break;
};
diff --git a/paludis/repositories/e/use_requirements.cc b/paludis/repositories/e/use_requirements.cc
new file mode 100644
index 0000000..e728c40
--- /dev/null
+++ b/paludis/repositories/e/use_requirements.cc
@@ -0,0 +1,223 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007, 2008 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/repositories/e/use_requirements.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/environment.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+UseRequirement::UseRequirement(const std::string & r, const UseFlagName & f) :
+ _raw(r),
+ _name(f)
+{
+}
+
+const std::string
+UseRequirement::as_raw_string() const
+{
+ return _raw;
+}
+
+EnabledUseRequirement::EnabledUseRequirement(const std::string & s, const UseFlagName & n) :
+ UseRequirement(s, n)
+{
+}
+
+EnabledUseRequirement::~EnabledUseRequirement()
+{
+}
+
+bool
+EnabledUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return env->query_use(flag(), pkg);
+}
+
+const std::string
+EnabledUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' enabled";
+}
+
+DisabledUseRequirement::DisabledUseRequirement(const std::string & s, const UseFlagName & n) :
+ UseRequirement(s, n)
+{
+}
+
+DisabledUseRequirement::~DisabledUseRequirement()
+{
+}
+
+bool
+DisabledUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return ! env->query_use(flag(), pkg);
+}
+
+const std::string
+DisabledUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' disabled";
+}
+
+ConditionalUseRequirement::ConditionalUseRequirement(const std::string & s,
+ const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ UseRequirement(s, n),
+ _id(i)
+{
+}
+
+ConditionalUseRequirement::~ConditionalUseRequirement()
+{
+}
+
+IfMineThenUseRequirement::IfMineThenUseRequirement(const std::string & s,
+ const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(s, n, i)
+{
+}
+
+IfMineThenUseRequirement::~IfMineThenUseRequirement()
+{
+}
+
+bool
+IfMineThenUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return ! env->query_use(flag(), *package_id()) || env->query_use(flag(), pkg);
+}
+
+const std::string
+IfMineThenUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' enabled if it is enabled for '" + stringify(*package_id()) + "'";
+}
+
+IfNotMineThenUseRequirement::IfNotMineThenUseRequirement(const std::string & s,
+ const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(s, n, i)
+{
+}
+
+IfNotMineThenUseRequirement::~IfNotMineThenUseRequirement()
+{
+}
+
+bool
+IfNotMineThenUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return env->query_use(flag(), *package_id()) || env->query_use(flag(), pkg);
+}
+
+const std::string
+IfNotMineThenUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' enabled if it is disabled for '" + stringify(*package_id()) + "'";
+}
+
+IfMineThenNotUseRequirement::IfMineThenNotUseRequirement(const std::string & s,
+ const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(s, n, i)
+{
+}
+
+IfMineThenNotUseRequirement::~IfMineThenNotUseRequirement()
+{
+}
+
+const std::string
+IfMineThenNotUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' disabled if it is enabled for '" + stringify(*package_id()) + "'";
+}
+
+bool
+IfMineThenNotUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return ! env->query_use(flag(), *package_id()) || ! env->query_use(flag(), pkg);
+}
+
+IfNotMineThenNotUseRequirement::IfNotMineThenNotUseRequirement(const std::string & s,
+ const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(s, n, i)
+{
+}
+
+IfNotMineThenNotUseRequirement::~IfNotMineThenNotUseRequirement()
+{
+}
+
+bool
+IfNotMineThenNotUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return env->query_use(flag(), *package_id()) || ! env->query_use(flag(), pkg);
+}
+
+const std::string
+IfNotMineThenNotUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' disabled if it is disabled for '" + stringify(*package_id()) + "'";
+}
+
+EqualUseRequirement::EqualUseRequirement(const std::string & s,
+ const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(s, n, i)
+{
+}
+
+EqualUseRequirement::~EqualUseRequirement()
+{
+}
+
+bool
+EqualUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return env->query_use(flag(), pkg) == env->query_use(flag(), *package_id());
+}
+
+const std::string
+EqualUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' enabled or disabled like it is for '" + stringify(*package_id()) + "'";
+}
+
+NotEqualUseRequirement::NotEqualUseRequirement(const std::string & s,
+ const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
+ ConditionalUseRequirement(s, n, i)
+{
+}
+
+NotEqualUseRequirement::~NotEqualUseRequirement()
+{
+}
+
+bool
+NotEqualUseRequirement::requirement_met(const Environment * const env, const PackageID & pkg) const
+{
+ return env->query_use(flag(), pkg) != env->query_use(flag(), *package_id());
+}
+
+const std::string
+NotEqualUseRequirement::as_human_string() const
+{
+ return "Flag '" + stringify(flag()) + "' enabled or disabled opposite to how it is for '" + stringify(*package_id()) + "'";
+}
+
diff --git a/paludis/repositories/e/use_requirements.hh b/paludis/repositories/e/use_requirements.hh
new file mode 100644
index 0000000..77080e9
--- /dev/null
+++ b/paludis/repositories/e/use_requirements.hh
@@ -0,0 +1,256 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007, 2008 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_USE_REQUIREMENTS_HH
+#define PALUDIS_GUARD_PALUDIS_USE_REQUIREMENTS_HH 1
+
+#include <paludis/dep_spec.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/name.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class PALUDIS_VISIBLE UseRequirement :
+ public AdditionalPackageDepSpecRequirement
+ {
+ private:
+ const std::string _raw;
+ const UseFlagName _name;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ UseRequirement(const std::string &, const UseFlagName &);
+
+ ///\}
+
+ /// Our use flag.
+ const UseFlagName flag() const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ return _name;
+ }
+
+ virtual const std::string as_raw_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * An enabled requirement for a use flag.
+ *
+ * \since 0.26
+ */
+ class PALUDIS_VISIBLE EnabledUseRequirement :
+ public UseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ EnabledUseRequirement(const std::string &, const UseFlagName &);
+ ~EnabledUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE DisabledUseRequirement :
+ public UseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ DisabledUseRequirement(const std::string &, const UseFlagName &);
+ ~DisabledUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * A use requirement that depends on the use flags of the package
+ * it appears in.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE ConditionalUseRequirement :
+ public UseRequirement
+ {
+ private:
+ const tr1::shared_ptr<const PackageID> _id;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ ConditionalUseRequirement(const std::string &, const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
+ ~ConditionalUseRequirement();
+
+ ///\}
+
+ /// Our package.
+ const tr1::shared_ptr<const PackageID> package_id() const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ return _id;
+ }
+ };
+
+ /**
+ * An if-then requirement for a use flag.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE IfMineThenUseRequirement :
+ public ConditionalUseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ IfMineThenUseRequirement(const std::string &, const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
+ ~IfMineThenUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * An if-not-then requirement for a use flag.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE IfNotMineThenUseRequirement :
+ public ConditionalUseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ IfNotMineThenUseRequirement(const std::string &, const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
+ ~IfNotMineThenUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * An if-then-not requirement for a use flag.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE IfMineThenNotUseRequirement :
+ public ConditionalUseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ IfMineThenNotUseRequirement(const std::string &, const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
+ ~IfMineThenNotUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * An if-not-then-not requirement for a use flag.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE IfNotMineThenNotUseRequirement :
+ public ConditionalUseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ IfNotMineThenNotUseRequirement(const std::string &, const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
+ ~IfNotMineThenNotUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * An equal requirement for a use flag.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE EqualUseRequirement :
+ public ConditionalUseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ EqualUseRequirement(const std::string &, const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
+ ~EqualUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * A not equal requirement for a use flag.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE NotEqualUseRequirement :
+ public ConditionalUseRequirement
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ NotEqualUseRequirement(const std::string &, const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
+ ~NotEqualUseRequirement();
+
+ ///\}
+
+ virtual bool requirement_met(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_human_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+ }
+}
+
+#endif
diff --git a/paludis/use_requirements-fwd.hh b/paludis/use_requirements-fwd.hh
deleted file mode 100644
index 23a2aad..0000000
--- a/paludis/use_requirements-fwd.hh
+++ /dev/null
@@ -1,39 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 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_USE_REQUIREMENTS_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_USE_REQUIREMENTS_FWD_HH 1
-
-namespace paludis
-{
- class UseRequirements;
- class UseRequirement;
-
- class UseRequirementVisitorTypes;
- class EnabledUseRequirement;
- class DisabledUseRequirement;
- class IfMineThenUseRequirement;
- class IfNotMineThenUseRequirement;
- class IfMineThenNotUseRequirement;
- class IfNotMineThenNotUseRequirement;
- class EqualUseRequirement;
- class NotEqualUseRequirement;
-}
-
-#endif
diff --git a/paludis/use_requirements.cc b/paludis/use_requirements.cc
deleted file mode 100644
index d2a235b..0000000
--- a/paludis/use_requirements.cc
+++ /dev/null
@@ -1,249 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007, 2008 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/use_requirements.hh>
-#include <paludis/environment.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/tr1_memory.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/visitor-impl.hh>
-#include <functional>
-#include <list>
-
-using namespace paludis;
-
-template class ConstVisitor<UseRequirementVisitorTypes>;
-template class ConstAcceptInterface<UseRequirementVisitorTypes>;
-
-template class ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, EnabledUseRequirement>;
-template class ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, DisabledUseRequirement>;
-template class ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, EqualUseRequirement>;
-template class ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, NotEqualUseRequirement>;
-
-template class Visits<const EnabledUseRequirement>;
-template class Visits<const DisabledUseRequirement>;
-template class Visits<const EqualUseRequirement>;
-template class Visits<const NotEqualUseRequirement>;
-
-template class WrappedForwardIterator<UseRequirements::ConstIteratorTag, const tr1::shared_ptr<const UseRequirement> >;
-
-namespace paludis
-{
- template <>
- struct Implementation<UseRequirements>
- {
- std::list<tr1::shared_ptr<const UseRequirement> > reqs;
- };
-}
-
-UseRequirements::UseRequirements() :
- PrivateImplementationPattern<UseRequirements>(new Implementation<UseRequirements>)
-{
-}
-
-UseRequirements::UseRequirements(const UseRequirements & other) :
- PrivateImplementationPattern<UseRequirements>(new Implementation<UseRequirements>(*other._imp.operator-> ()))
-{
-}
-
-UseRequirements::~UseRequirements()
-{
-}
-
-UseRequirements::ConstIterator
-UseRequirements::begin() const
-{
- return ConstIterator(_imp->reqs.begin());
-}
-
-UseRequirements::ConstIterator
-UseRequirements::end() const
-{
- return ConstIterator(_imp->reqs.end());
-}
-
-namespace
-{
- template <typename T_>
- T_ * desptr(const tr1::shared_ptr<T_> & p)
- {
- return p.get();
- }
-}
-
-UseRequirements::ConstIterator
-UseRequirements::find(const UseFlagName & u) const
-{
- using namespace tr1::placeholders;
- return ConstIterator(std::find_if(_imp->reqs.begin(), _imp->reqs.end(),
- tr1::bind(std::equal_to<UseFlagName>(), u, tr1::bind(tr1::mem_fn(&UseRequirement::flag),
- tr1::bind(&desptr<const UseRequirement>, _1)))));
-}
-
-void
-UseRequirements::insert(const tr1::shared_ptr<const UseRequirement> & req)
-{
- _imp->reqs.push_back(req);
-}
-
-bool
-UseRequirements::empty() const
-{
- return _imp->reqs.empty();
-}
-
-UseRequirement::UseRequirement(const UseFlagName & n) :
- _name(n)
-{
-}
-
-UseRequirement::~UseRequirement()
-{
-}
-
-EnabledUseRequirement::EnabledUseRequirement(const UseFlagName & n) :
- UseRequirement(n)
-{
-}
-
-EnabledUseRequirement::~EnabledUseRequirement()
-{
-}
-
-bool
-EnabledUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return env->query_use(flag(), pkg);
-}
-
-DisabledUseRequirement::DisabledUseRequirement(const UseFlagName & n) :
- UseRequirement(n)
-{
-}
-
-DisabledUseRequirement::~DisabledUseRequirement()
-{
-}
-
-bool
-DisabledUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return ! env->query_use(flag(), pkg);
-}
-
-ConditionalUseRequirement::ConditionalUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- UseRequirement(n),
- _id(i)
-{
-}
-
-ConditionalUseRequirement::~ConditionalUseRequirement()
-{
-}
-
-IfMineThenUseRequirement::IfMineThenUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- ConditionalUseRequirement(n, i)
-{
-}
-
-IfMineThenUseRequirement::~IfMineThenUseRequirement()
-{
-}
-
-bool
-IfMineThenUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return ! env->query_use(flag(), *package_id()) || env->query_use(flag(), pkg);
-}
-
-IfNotMineThenUseRequirement::IfNotMineThenUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- ConditionalUseRequirement(n, i)
-{
-}
-
-IfNotMineThenUseRequirement::~IfNotMineThenUseRequirement()
-{
-}
-
-bool
-IfNotMineThenUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return env->query_use(flag(), *package_id()) || env->query_use(flag(), pkg);
-}
-
-IfMineThenNotUseRequirement::IfMineThenNotUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- ConditionalUseRequirement(n, i)
-{
-}
-
-IfMineThenNotUseRequirement::~IfMineThenNotUseRequirement()
-{
-}
-
-bool
-IfMineThenNotUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return ! env->query_use(flag(), *package_id()) || ! env->query_use(flag(), pkg);
-}
-
-IfNotMineThenNotUseRequirement::IfNotMineThenNotUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- ConditionalUseRequirement(n, i)
-{
-}
-
-IfNotMineThenNotUseRequirement::~IfNotMineThenNotUseRequirement()
-{
-}
-
-bool
-IfNotMineThenNotUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return env->query_use(flag(), *package_id()) || ! env->query_use(flag(), pkg);
-}
-
-EqualUseRequirement::EqualUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- ConditionalUseRequirement(n, i)
-{
-}
-
-EqualUseRequirement::~EqualUseRequirement()
-{
-}
-
-bool
-EqualUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return env->query_use(flag(), pkg) == env->query_use(flag(), *package_id());
-}
-
-NotEqualUseRequirement::NotEqualUseRequirement(const UseFlagName & n, const tr1::shared_ptr<const PackageID> & i) :
- ConditionalUseRequirement(n, i)
-{
-}
-
-NotEqualUseRequirement::~NotEqualUseRequirement()
-{
-}
-
-bool
-NotEqualUseRequirement::satisfied_by(const Environment * const env, const PackageID & pkg) const
-{
- return env->query_use(flag(), pkg) != env->query_use(flag(), *package_id());
-}
-
diff --git a/paludis/use_requirements.hh b/paludis/use_requirements.hh
deleted file mode 100644
index 73065ae..0000000
--- a/paludis/use_requirements.hh
+++ /dev/null
@@ -1,339 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006, 2007 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_USE_REQUIREMENTS_HH
-#define PALUDIS_GUARD_PALUDIS_USE_REQUIREMENTS_HH 1
-
-#include <paludis/use_requirements-fwd.hh>
-#include <paludis/environment-fwd.hh>
-#include <paludis/package_id-fwd.hh>
-#include <paludis/name.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/visitor.hh>
-#include <paludis/util/wrapped_output_iterator.hh>
-
-namespace paludis
-{
- /**
- * A selection of USE flag requirements.
- *
- * \ingroup g_dep_spec
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE UseRequirements :
- private PrivateImplementationPattern<UseRequirements>
- {
- public:
- ///\name Basic operations
- ///\{
-
- UseRequirements();
- UseRequirements(const UseRequirements &);
- ~UseRequirements();
-
- ///\}
-
- ///\name Iterate over our USE requirements
- ///\{
-
- struct ConstIteratorTag;
- typedef WrappedForwardIterator<ConstIteratorTag, const tr1::shared_ptr<const UseRequirement> > ConstIterator;
-
- ConstIterator begin() const;
- ConstIterator end() const;
-
- ///\}
-
- /// Find the requirement for a particular USE flag.
- ConstIterator find(const UseFlagName & u) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /// Insert a new requirement.
- void insert(const tr1::shared_ptr<const UseRequirement> &);
-
- /// Are we empty?
- bool empty() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- /**
- * Visitor types for a UseRequirement.
- *
- * \ingroup g_dep_spec
- * \since 0.26
- */
- struct UseRequirementVisitorTypes :
- VisitorTypes<
- UseRequirementVisitorTypes,
- UseRequirement,
- EnabledUseRequirement,
- DisabledUseRequirement,
- IfMineThenUseRequirement,
- IfNotMineThenUseRequirement,
- IfMineThenNotUseRequirement,
- IfNotMineThenNotUseRequirement,
- EqualUseRequirement,
- NotEqualUseRequirement
- >
- {
- };
-
- /**
- * A requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE UseRequirement :
- public virtual ConstAcceptInterface<UseRequirementVisitorTypes>
- {
- private:
- const UseFlagName _name;
-
- public:
- ///\name Basic operations
- ///\{
-
- UseRequirement(const UseFlagName &);
- virtual ~UseRequirement() = 0;
-
- ///\}
-
- /// Our use flag.
- const UseFlagName flag() const PALUDIS_ATTRIBUTE((warn_unused_result))
- {
- return _name;
- }
-
- /// Does the package meet the requirement?
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- };
-
- /**
- * An enabled requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE EnabledUseRequirement :
- public UseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, EnabledUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- EnabledUseRequirement(const UseFlagName &);
- ~EnabledUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- /**
- * A disabled requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE DisabledUseRequirement :
- public UseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, DisabledUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- DisabledUseRequirement(const UseFlagName &);
- ~DisabledUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- /**
- * A use requirement that depends on the use flags of the package
- * it appears in.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE ConditionalUseRequirement :
- public UseRequirement
- {
- private:
- const tr1::shared_ptr<const PackageID> _id;
-
- public:
- ///\name Basic operations
- ///\{
-
- ConditionalUseRequirement(const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
- ~ConditionalUseRequirement();
-
- ///\}
-
- /// Our package.
- const tr1::shared_ptr<const PackageID> package_id() const PALUDIS_ATTRIBUTE((warn_unused_result))
- {
- return _id;
- }
- };
-
- /**
- * An if-then requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE IfMineThenUseRequirement :
- public ConditionalUseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, IfMineThenUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- IfMineThenUseRequirement(const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
- ~IfMineThenUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- };
-
- /**
- * An if-not-then requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE IfNotMineThenUseRequirement :
- public ConditionalUseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, IfNotMineThenUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- IfNotMineThenUseRequirement(const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
- ~IfNotMineThenUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- };
-
- /**
- * An if-then-not requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE IfMineThenNotUseRequirement :
- public ConditionalUseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, IfMineThenNotUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- IfMineThenNotUseRequirement(const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
- ~IfMineThenNotUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- };
-
- /**
- * An if-not-then-not requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE IfNotMineThenNotUseRequirement :
- public ConditionalUseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, IfNotMineThenNotUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- IfNotMineThenNotUseRequirement(const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
- ~IfNotMineThenNotUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- };
-
- /**
- * An equal requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE EqualUseRequirement :
- public ConditionalUseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, EqualUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- EqualUseRequirement(const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
- ~EqualUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- };
-
- /**
- * A not equal requirement for a use flag.
- *
- * \since 0.26
- * \ingroup g_dep_spec
- */
- class PALUDIS_VISIBLE NotEqualUseRequirement :
- public ConditionalUseRequirement,
- public ConstAcceptInterfaceVisitsThis<UseRequirementVisitorTypes, NotEqualUseRequirement>
- {
- public:
- ///\name Basic operations
- ///\{
-
- NotEqualUseRequirement(const UseFlagName &, const tr1::shared_ptr<const PackageID> &);
- ~NotEqualUseRequirement();
-
- ///\}
-
- virtual bool satisfied_by(const Environment * const, const PackageID &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-}
-
-#endif
diff --git a/python/Makefile.am b/python/Makefile.am
index b2dbd9a..61129bf 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -27,7 +27,6 @@ IF_PYTHON_TESTS = \
version_operator_TEST.py \
version_requirements_TEST.py \
contents_TEST.py \
- use_requirements_TEST.py \
dep_spec_TEST.py \
dep_tag_TEST.py \
dep_label_TEST.py \
@@ -73,7 +72,6 @@ IF_PYTHON_SOURCES = \
package_id.cc \
query.cc \
repository.cc \
- use_requirements.cc \
version_operator.cc \
version_requirements.cc \
version_spec.cc
diff --git a/python/dep_list.cc b/python/dep_list.cc
index 29f111c..631b275 100644
--- a/python/dep_list.cc
+++ b/python/dep_list.cc
@@ -57,10 +57,10 @@ void expose_dep_list()
ExceptionRegister::get_instance()->add_exception<AllMaskedError>
("AllMaskedError", "DepListError",
"Thrown if all versions of a particular spec are masked.");
- ExceptionRegister::get_instance()->add_exception<UseRequirementsNotMetError>
- ("UseRequirementsNotMetError", "DepListError",
+ ExceptionRegister::get_instance()->add_exception<AdditionalRequirementsNotMetError>
+ ("AdditionalRequirementsNotMetError", "DepListError",
"Thrown if all versions of a particular spec are masked, "
- "but would not be if use requirements were not in effect.");
+ "but would not be if additional requirements were not in effect.");
ExceptionRegister::get_instance()->add_exception<DowngradeNotAllowedError>
("DowngradeNotAllowedError", "DepListError",
"Thrown if a downgrade is forced and we're not allowed to downgrade.");
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index e58da2b..f9a605f 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -25,7 +25,6 @@
#include <paludis/dep_tag.hh>
#include <paludis/version_requirements.hh>
-#include <paludis/use_requirements.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
@@ -111,7 +110,7 @@ namespace paludis
VersionRequirementsMode version_requirements_mode;
tr1::shared_ptr<const SlotName> slot;
tr1::shared_ptr<const RepositoryName> repository;
- tr1::shared_ptr<const UseRequirements> use_requirements;
+ tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements;
tr1::shared_ptr<const DepTag> tag;
const std::string str;
@@ -123,7 +122,7 @@ namespace paludis
const VersionRequirementsMode m,
const tr1::shared_ptr<const SlotName> & s,
const tr1::shared_ptr<const RepositoryName> & r,
- const tr1::shared_ptr<const UseRequirements> & u,
+ const tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> & u,
const tr1::shared_ptr<const DepTag> & t,
const std::string & st) :
package_ptr(q),
@@ -133,7 +132,7 @@ namespace paludis
version_requirements_mode(m),
slot(s),
repository(r),
- use_requirements(u),
+ additional_requirements(u),
tag(t),
str(st)
{
@@ -259,7 +258,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
p.version_requirements_mode(),
deep_copy(p.slot_ptr()),
deep_copy(p.repository_ptr()),
- deep_copy(p.use_requirements_ptr()),
+ p.additional_requirements_ptr(),
p.tag(),
stringify(p)))
{
@@ -280,7 +279,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) :
p.version_requirements_mode(),
deep_copy(p.slot_ptr()),
deep_copy(p.repository_ptr()),
- deep_copy(p.use_requirements_ptr()),
+ p.additional_requirements_ptr(),
p.tag(),
p.py_str()))
{
@@ -313,11 +312,11 @@ PythonPackageDepSpec::operator PackageDepSpec() const
if (repository_ptr())
p.repository(*repository_ptr());
- if (use_requirements_ptr())
+ if (additional_requirements_ptr())
{
- for (UseRequirements::ConstIterator i(use_requirements_ptr()->begin()),
- i_end(use_requirements_ptr()->end()) ; i != i_end ; ++i)
- p.use_requirement(*i);
+ for (AdditionalPackageDepSpecRequirements::ConstIterator i(additional_requirements_ptr()->begin()),
+ i_end(additional_requirements_ptr()->end()) ; i != i_end ; ++i)
+ p.additional_requirement(*i);
}
if (version_requirements_ptr())
@@ -343,11 +342,11 @@ PythonPackageDepSpec::as_package_dep_spec() const
}
const tr1::shared_ptr<const PythonPackageDepSpec>
-PythonPackageDepSpec::without_use_requirements() const
+PythonPackageDepSpec::without_additional_requirements() const
{
PackageDepSpec p(*this);
- return make_shared_ptr(new PythonPackageDepSpec(*p.without_use_requirements()));
+ return make_shared_ptr(new PythonPackageDepSpec(*p.without_additional_requirements()));
}
tr1::shared_ptr<const QualifiedPackageName>
@@ -398,10 +397,10 @@ PythonPackageDepSpec::repository_ptr() const
return _imp->repository;
}
-tr1::shared_ptr<const UseRequirements>
-PythonPackageDepSpec::use_requirements_ptr() const
+tr1::shared_ptr<const AdditionalPackageDepSpecRequirements>
+PythonPackageDepSpec::additional_requirements_ptr() const
{
- return _imp->use_requirements;
+ return _imp->additional_requirements;
}
tr1::shared_ptr<const DepTag>
@@ -1230,14 +1229,16 @@ void expose_dep_spec()
"Repository name (may be None)."
)
+#if 0
.add_property("use_requirements", &PythonPackageDepSpec::use_requirements_ptr,
"[ro] UseRequirements\n"
"Use requirements (may be None)."
)
+#endif
- .def("without_use_requirements", &PythonPackageDepSpec::without_use_requirements,
- "without_use_requirements() -> PackageDepSpec\n"
- "Fetch a copy of ourself without the USE requirements."
+ .def("without_additional_requirements", &PythonPackageDepSpec::without_additional_requirements,
+ "without_additional_requirements() -> PackageDepSpec\n"
+ "Fetch a copy of ourself without additional requirements."
)
.def("__str__", &PythonPackageDepSpec::py_str)
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index 687dad3..2d279bc 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -176,10 +176,10 @@ namespace paludis
void set_version_requirements_mode(const VersionRequirementsMode m);
tr1::shared_ptr<const SlotName> slot_ptr() const;
tr1::shared_ptr<const RepositoryName> repository_ptr() const;
- tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const;
+ tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const;
tr1::shared_ptr<const DepTag> tag() const;
void set_tag(const tr1::shared_ptr<const DepTag> & s);
- const tr1::shared_ptr<const PythonPackageDepSpec> without_use_requirements() const;
+ const tr1::shared_ptr<const PythonPackageDepSpec> without_additional_requirements() const;
std::string py_str() const;
diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py
index b16f68d..d4dc53b 100755
--- a/python/dep_spec_TEST.py
+++ b/python/dep_spec_TEST.py
@@ -79,16 +79,16 @@ class TestCase_1_DepSpecs(unittest.TestCase):
self.get_depspecs()
self.assertEquals(self.pds.version_requirements_mode, VersionRequirementsMode.AND)
- def test_09_use_requirements(self):
- spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions())
- ur = iter(spec.use_requirements).next()
- self.assert_(isinstance(ur, EnabledUseRequirement))
+### def test_09_additional_requirements(self):
+### spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions())
+### ur = iter(spec.additional_requirements).next()
+### self.assert_(isinstance(ur, EnabledUseRequirement))
- def test_10_without_use_requirements(self):
+ def test_10_without_additional_requirements(self):
spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions())
- pds = spec.without_use_requirements()
- self.assertEquals(pds.use_requirements, None)
- self.assertEquals(str(pds), "foo/monkey")
+ pds = spec.without_additional_requirements()
+### self.assertEquals(pds.additional_requirements, None)
+### self.assertEquals(str(pds), "foo/monkey")
def test_11_name(self):
self.get_depspecs()
diff --git a/python/paludis_python.hh b/python/paludis_python.hh
index 26da695..25fa6b8 100644
--- a/python/paludis_python.hh
+++ b/python/paludis_python.hh
@@ -191,7 +191,6 @@ void expose_package_id() PALUDIS_VISIBLE;
void expose_qa() PALUDIS_VISIBLE;
void expose_query() PALUDIS_VISIBLE;
void expose_repository() PALUDIS_VISIBLE;
-void expose_use_requirements() PALUDIS_VISIBLE;
void expose_version_operator() PALUDIS_VISIBLE;
void expose_version_requirements() PALUDIS_VISIBLE;
void expose_version_spec() PALUDIS_VISIBLE;
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index c24d51c..016f7df 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -36,7 +36,6 @@ BOOST_PYTHON_MODULE(paludis)
expose_version_requirements();
expose_fs_entry();
expose_contents();
- expose_use_requirements();
expose_dep_spec();
expose_dep_tag();
expose_dep_label();
diff --git a/python/use_requirements.cc b/python/use_requirements.cc
deleted file mode 100644
index 4599cb5..0000000
--- a/python/use_requirements.cc
+++ /dev/null
@@ -1,212 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Piotr Jaroszyński
- *
- * 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 <python/paludis_python.hh>
-
-#include <paludis/use_requirements.hh>
-#include <paludis/environment.hh>
-#include <paludis/package_id.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/visitor-impl.hh>
-
-using namespace paludis;
-using namespace paludis::python;
-namespace bp = boost::python;
-
-struct UseRequirementsWrapper
-{
- static PyObject *
- find(const UseRequirements & self, const UseFlagName & u)
- {
- UseRequirements::ConstIterator i(self.find(u));
- if (i != self.end())
- return bp::incref(bp::object(*i).ptr());
- else
- return Py_None;
- }
-};
-
-void expose_use_requirements()
-{
- /**
- * UseRequirements
- */
- register_shared_ptrs_to_python<UseRequirements>();
- bp::class_<UseRequirements>
- (
- "UseRequirements",
- "A selection of USE flag requirements.",
- bp::no_init
- )
-
- .def("empty", &UseRequirements::empty,
- "empty() -> bool\n"
- "Are we empty?"
- )
-
- .def("find", UseRequirementsWrapper::find,
- "find(UseFlagName) -> UseRequirement\n"
- "Find the requirement for a particular USE flag."
- )
-
- .def("insert", &UseRequirements::insert,
- "insert(UseRequirement)\n"
- "Insert a new requirement."
- )
-
- .def("__iter__", bp::range(&UseRequirements::begin, &UseRequirements::end))
- ;
-
- /**
- * UseRequirement
- */
- register_shared_ptrs_to_python<UseRequirement>();
- bp::class_<UseRequirement, boost::noncopyable>
- (
- "UseRequirement",
- "A requirement for a use flag.",
- bp::no_init
- )
-
- .def("flag", &UseRequirement::flag,
- "flag() -> UseFlagName\n"
- "Our use flag."
- )
-
- .def("satisfied_by", &UseRequirement::satisfied_by,
- "satisfied_by(Environment, PackageID) -> bool\n"
- "Does the package meet the requirement?"
- )
- ;
-
- /**
- * EnabledUseRequirement
- */
- bp::class_<EnabledUseRequirement, bp::bases<UseRequirement>, tr1::shared_ptr<EnabledUseRequirement> >
- (
- "EnabledUseRequirement",
- "An enabled requirement for a use flag.",
- bp::init<const UseFlagName &>("__init__(UseFlagName)")
- );
-
- /**
- * DisabledUseRequirement
- */
- bp::class_<DisabledUseRequirement, bp::bases<UseRequirement> >
- (
- "DisabledUseRequirement",
- "A disabled requirement for a use flag.",
- bp::init<const UseFlagName &>("__init__(UseFlagName)")
- );
-
- /**
- * ConditionalUseRequirement
- */
- bp::class_<ConditionalUseRequirement, bp::bases<UseRequirement>, boost::noncopyable>
- (
- "ConditionalUseRequirement",
- "A use requirement that depends on the use flags of the package it appears in.",
- bp::no_init
- )
-
- .def("package_id", &ConditionalUseRequirement::package_id,
- "package_id() -> PackageID\n"
- "Out package."
- )
- ;
-
- /**
- * IfMineThenUseRequirement
- */
- bp::class_<IfMineThenUseRequirement, bp::bases<ConditionalUseRequirement> >
- (
- "IfMineThenUseRequirement",
- "An if-then requirement for a use flag.",
- bp::init<const UseFlagName &, const tr1::shared_ptr<const PackageID> &>(
- "__init__(UseFlagName, PackageID)"
- )
- )
- ;
-
- /**
- * IfNotMineThenUseRequirement
- */
- bp::class_<IfNotMineThenUseRequirement, bp::bases<ConditionalUseRequirement> >
- (
- "IfNotMineThenUseRequirement",
- "An if-not-then requirement for a use flag.",
- bp::init<const UseFlagName &, const tr1::shared_ptr<const PackageID> &>(
- "__init__(UseFlagName, PackageID)"
- )
- )
- ;
-
- /**
- * IfMineThenNotUseRequirement
- */
- bp::class_<IfMineThenNotUseRequirement, bp::bases<ConditionalUseRequirement> >
- (
- "IfMineThenNotUseRequirement",
- "An if-then-not requirement for a use flag.",
- bp::init<const UseFlagName &, const tr1::shared_ptr<const PackageID> &>(
- "__init__(UseFlagName, PackageID)"
- )
- )
- ;
-
- /**
- * IfNotMineThenNotUseRequirement
- */
- bp::class_<IfNotMineThenNotUseRequirement, bp::bases<ConditionalUseRequirement> >
- (
- "IfNotMineThenNotUseRequirement",
- "An if-not-then-not requirement for a use flag.",
- bp::init<const UseFlagName &, const tr1::shared_ptr<const PackageID> &>(
- "__init__(UseFlagName, PackageID)"
- )
- )
- ;
-
- /**
- * EqualUseRequirement
- */
- bp::class_<EqualUseRequirement, bp::bases<ConditionalUseRequirement> >
- (
- "EqualUseRequirement",
- "An equal requirement for a use flag.",
- bp::init<const UseFlagName &, const tr1::shared_ptr<const PackageID> &>(
- "__init__(UseFlagName, PackageID)"
- )
- )
- ;
-
- /**
- * NotEqualUseRequirement
- */
- bp::class_<NotEqualUseRequirement, bp::bases<ConditionalUseRequirement> >
- (
- "NotEqualUseRequirement",
- "A not equal requirement for a use flag.",
- bp::init<const UseFlagName &, const tr1::shared_ptr<const PackageID> &>(
- "__init__(UseFlagName, PackageID)"
- )
- )
- ;
-
-}
diff --git a/python/use_requirements_TEST.py b/python/use_requirements_TEST.py
deleted file mode 100755
index 82c6ad8..0000000
--- a/python/use_requirements_TEST.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env python
-# vim: set fileencoding=utf-8 sw=4 sts=4 et :
-
-#
-# Copyright (c) 2007 Piotr Jaroszyński
-#
-# 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
-#
-
-from paludis import *
-import unittest
-
-class TestCase_1_UseRequirements(unittest.TestCase):
- def setUp(self):
- self.e = TestEnvironment()
- self.r = FakeRepository(self.e, "fake")
- self.pid = self.r.add_version("cat/pkg", "1")
-
- self.ur1 = EnabledUseRequirement("enabled")
- self.ur2 = DisabledUseRequirement("enabled")
- self.ur3 = IfMineThenUseRequirement("foo", self.pid)
- self.ur4 = IfNotMineThenUseRequirement("foo", self.pid)
- self.ur5 = IfMineThenNotUseRequirement("foo", self.pid)
- self.ur6 = IfNotMineThenNotUseRequirement("foo", self.pid)
- self.ur7 = EqualUseRequirement("foo", self.pid)
- self.ur8 = NotEqualUseRequirement("foo", self.pid)
-
- def test_01_create(self):
- self.assertRaises(Exception, UseRequirement)
- self.assertRaises(Exception, ConditionalUseRequirement)
-
- def test_02_flag(self):
- self.assertEquals(self.ur1.flag(), UseFlagName("enabled"))
- self.assertEquals(self.ur2.flag(), UseFlagName("enabled"))
- self.assertEquals(self.ur3.flag(), UseFlagName("foo"))
- self.assertEquals(self.ur4.flag(), UseFlagName("foo"))
-
- def test_03_package_id(self):
- self.assertEquals(self.ur3.package_id(), self.pid)
- self.assertEquals(self.ur4.package_id(), self.pid)
-
- def test_04_satisfied_by(self):
- self.assert_(self.ur1.satisfied_by(self.e, self.pid))
- self.assert_(not self.ur2.satisfied_by(self.e, self.pid))
-
- def test_05_hierarchy(self):
- self.assert_(isinstance(self.ur1, UseRequirement))
- self.assert_(not isinstance(self.ur1, ConditionalUseRequirement))
- self.assert_(isinstance(self.ur2, UseRequirement))
- self.assert_(not isinstance(self.ur2, ConditionalUseRequirement))
- self.assert_(isinstance(self.ur3, UseRequirement))
- self.assert_(isinstance(self.ur3, ConditionalUseRequirement))
- self.assert_(isinstance(self.ur4, ConditionalUseRequirement))
- self.assert_(isinstance(self.ur5, ConditionalUseRequirement))
- self.assert_(isinstance(self.ur6, ConditionalUseRequirement))
- self.assert_(isinstance(self.ur7, ConditionalUseRequirement))
- self.assert_(isinstance(self.ur8, ConditionalUseRequirement))
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 8d27c54..eb3bbcb 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -22,7 +22,6 @@
#include <paludis/dep_spec.hh>
#include <paludis/version_requirements.hh>
#include <paludis/version_operator.hh>
-#include <paludis/use_requirements.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/visitor-impl.hh>
@@ -573,16 +572,17 @@ namespace
/*
* call-seq:
- * without_use_requirements -> PackageDepSpec
+ * without_additional_requirements -> PackageDepSpec
*
* Fetch us without our use requirements.
*/
VALUE
- package_dep_spec_without_use_requirements(VALUE self)
+ package_dep_spec_without_additional_requirements(VALUE self)
{
tr1::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, tr1::shared_ptr<WrappedSpecBase>, ptr);
- return package_dep_spec_to_value(tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->without_use_requirements());
+ return package_dep_spec_to_value(tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(
+ *ptr)->spec()->without_additional_requirements());
}
/*
@@ -1052,7 +1052,7 @@ namespace
#endif
rb_define_method(c_package_dep_spec, "tag", RUBY_FUNC_CAST(&package_dep_spec_tag), 0);
rb_define_method(c_package_dep_spec, "tag=", RUBY_FUNC_CAST(&package_dep_spec_set_tag), 1);
- rb_define_method(c_package_dep_spec, "without_use_requirements", RUBY_FUNC_CAST(&package_dep_spec_without_use_requirements), 0);
+ rb_define_method(c_package_dep_spec, "without_additional_requirements", RUBY_FUNC_CAST(&package_dep_spec_without_additional_requirements), 0);
VALUE (* package_dep_spec_to_s) (VALUE) = &dep_spec_to_s<PackageDepSpec>;
rb_define_method(c_package_dep_spec, "to_s", RUBY_FUNC_CAST(package_dep_spec_to_s), 0);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 410cd8a..9b47b59 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
# Copyright (c) 2007 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -134,9 +134,9 @@ module Paludis
### assert_equal false, pda.use_requirements[1][:state]
### end
- def test_without_use_requirements
- assert_equal ">=foo/bar-1:100::testrepo", pda.without_use_requirements.to_s
- assert_equal "*/bar", pdb.without_use_requirements.to_s
+ def test_without_additional_requirements
+ assert_equal ">=foo/bar-1:100::testrepo", pda.without_additional_requirements.to_s
+ assert_equal "*/bar", pdb.without_additional_requirements.to_s
end
def test_tag
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index ff61ba0..834ea56 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -65,7 +65,7 @@ namespace
static VALUE c_all_masked_error;
static VALUE c_block_error;
static VALUE c_circular_dependency_error;
- static VALUE c_use_requirements_not_met_error;
+ static VALUE c_additional_requirements_not_met_error;
static VALUE c_downgrade_not_allowed_error;
static VALUE c_no_destination_error;
static VALUE c_fetch_action_error;
@@ -222,8 +222,8 @@ void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
rb_raise(c_block_error, dynamic_cast<const paludis::BlockError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::CircularDependencyError *>(&ee))
rb_raise(c_circular_dependency_error, dynamic_cast<const paludis::CircularDependencyError *>(&ee)->message().c_str());
- else if (0 != dynamic_cast<const paludis::UseRequirementsNotMetError *>(&ee))
- rb_raise(c_use_requirements_not_met_error, dynamic_cast<const paludis::UseRequirementsNotMetError *>(&ee)->message().c_str());
+ else if (0 != dynamic_cast<const paludis::AdditionalRequirementsNotMetError *>(&ee))
+ rb_raise(c_additional_requirements_not_met_error, dynamic_cast<const paludis::AdditionalRequirementsNotMetError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::DowngradeNotAllowedError *>(&ee))
rb_raise(c_downgrade_not_allowed_error, dynamic_cast<const paludis::DowngradeNotAllowedError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::NoDestinationError *>(&ee))
@@ -413,9 +413,9 @@ void PALUDIS_VISIBLE paludis::ruby::init()
*
* Thrown if all versions of a particular spec are masked, but would not be if use requirements were not in effect.
*/
- c_use_requirements_not_met_error = rb_define_class_under(c_paludis_module, "UseRequirementsNotMetError", c_dep_list_error);
- rb_define_method(c_use_requirements_not_met_error, "initialize", RUBY_FUNC_CAST(&has_query_property_error_init), -1);
- rb_define_method(c_use_requirements_not_met_error, "query", RUBY_FUNC_CAST(&has_query_property_error_query), 0);
+ c_additional_requirements_not_met_error = rb_define_class_under(c_paludis_module, "UseRequirementsNotMetError", c_dep_list_error);
+ rb_define_method(c_additional_requirements_not_met_error, "initialize", RUBY_FUNC_CAST(&has_query_property_error_init), -1);
+ rb_define_method(c_additional_requirements_not_met_error, "query", RUBY_FUNC_CAST(&has_query_property_error_query), 0);
c_downgrade_not_allowed_error = rb_define_class_under(c_paludis_module, "DowngradeNotAllowedError", c_dep_list_error);
c_no_destination_error = rb_define_class_under(c_paludis_module, "NoDestinationError", c_dep_list_error);
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index f922faf..5231835 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -1595,12 +1595,21 @@ ConsoleInstallTask::on_all_masked_error(const AllMaskedError & e)
}
void
-ConsoleInstallTask::on_use_requirements_not_met_error(const UseRequirementsNotMetError & e)
+ConsoleInstallTask::on_additional_requirements_not_met_error(const AdditionalRequirementsNotMetError & e)
{
output_stream() << endl;
- output_stream() << "DepList USE requirements not met error:" << endl;
+ output_stream() << "DepList additional requirements not met error:" << endl;
output_stream() << " * " << e.backtrace("\n * ") << e.message() << endl;
output_stream() << endl;
+ if (e.query().additional_requirements_ptr())
+ {
+ output_stream() << "Additional requirements are as follows:" << endl;
+ for (AdditionalPackageDepSpecRequirements::ConstIterator i(e.query().additional_requirements_ptr()->begin()),
+ i_end(e.query().additional_requirements_ptr()->end()) ;
+ i != i_end ; ++i)
+ output_stream() << " * " << (*i)->as_human_string() << endl;
+ output_stream() << endl;
+ }
output_stream() << "This error usually indicates that one of the packages you are trying to" << endl;
output_stream() << "install requires that another package be built with particular USE flags" << endl;
output_stream() << "enabled or disabled. You may be able to work around this restriction by" << endl;
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index 538c6bf..46a24f1 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -188,7 +188,7 @@ namespace paludis
virtual void on_ambiguous_package_name_error(const AmbiguousPackageNameError &);
virtual void on_no_such_package_error(const NoSuchPackageError &);
virtual void on_all_masked_error(const AllMaskedError &);
- virtual void on_use_requirements_not_met_error(const UseRequirementsNotMetError &);
+ virtual void on_additional_requirements_not_met_error(const AdditionalRequirementsNotMetError &);
virtual void on_dep_list_error(const DepListError &);
virtual void on_had_both_package_and_set_targets_error(const HadBothPackageAndSetTargets &);
virtual void on_multiple_set_targets_specified(const MultipleSetTargetsSpecified &);
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index cb1cf53..688e16d 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -107,7 +107,7 @@ ConsoleQueryTask::show(const PackageDepSpec & a, tr1::shared_ptr<const PackageID
void
ConsoleQueryTask::display_header(const PackageDepSpec & a, const tr1::shared_ptr<const PackageID> & e) const
{
- if (a.version_requirements_ptr() || a.slot_ptr() || a.use_requirements_ptr() ||
+ if (a.version_requirements_ptr() || a.slot_ptr() || a.additional_requirements_ptr() ||
a.repository_ptr())
output_starred_item(render_as_package_name(stringify(a)));
else
@@ -117,7 +117,7 @@ ConsoleQueryTask::display_header(const PackageDepSpec & a, const tr1::shared_ptr
void
ConsoleQueryTask::display_compact(const PackageDepSpec & a, const tr1::shared_ptr<const PackageID> & e) const
{
- if (a.version_requirements_ptr() || a.slot_ptr() || a.use_requirements_ptr() ||
+ if (a.version_requirements_ptr() || a.slot_ptr() || a.additional_requirements_ptr() ||
a.repository_ptr())
{
std::string pad(std::max<long>(1, 30 - stringify(a).length()), ' ');