aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories
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 /paludis/repositories
parent7e125b4740d8bb50aa06b97d1dc070dfbce8bb3a (diff)
downloadpaludis-169e91b611f2a12b89467e03abb4c76ddbe3fe7e.tar.gz
paludis-169e91b611f2a12b89467e03abb4c76ddbe3fe7e.tar.xz
Replace PackageDepSpec::use_requirements with a more general PackageDepSpec::additional_requirements.
Diffstat (limited to 'paludis/repositories')
-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
5 files changed, 498 insertions, 15 deletions
diff --git a/paludis/repositories/cran/package_dep_spec.cc b/paludis/repositories/cran/package_dep_spec.cc
index b1e71382d..d02cd798c 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 0282a21cf..1001c4f40 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 8204362f1..623f11270 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 000000000..e728c40fb
--- /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 000000000..77080e9fb
--- /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