aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-05 10:50:58 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-03-05 10:50:58 +0000
commitd0508b5817568ca9bbe742bfd848467716edc9ab (patch)
tree927ebd3fa199d63ab5d68b38008f8997c6f253d5
parenta814a9530164c0214a952654a864e0ae516c1f08 (diff)
downloadpaludis-d0508b5817568ca9bbe742bfd848467716edc9ab.tar.gz
paludis-d0508b5817568ca9bbe742bfd848467716edc9ab.tar.xz
Add :*/:= slot support
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec.cc4
-rw-r--r--paludis/dep_list.cc10
-rw-r--r--paludis/dep_list_TEST.hh3
-rw-r--r--paludis/dep_spec-fwd.hh19
-rw-r--r--paludis/dep_spec.cc262
-rw-r--r--paludis/dep_spec.hh9
-rw-r--r--paludis/dep_spec_TEST.cc165
-rw-r--r--paludis/environments/paludis/keywords_conf.cc3
-rw-r--r--paludis/environments/paludis/licenses_conf.cc3
-rw-r--r--paludis/environments/paludis/package_mask_conf.cc3
-rw-r--r--paludis/environments/paludis/paludis_environment.cc1
-rw-r--r--paludis/environments/paludis/paludis_environment_TEST.cc3
-rw-r--r--paludis/environments/paludis/use_conf.cc1
-rw-r--r--paludis/environments/portage/portage_environment.cc1
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc3
-rw-r--r--paludis/files.m44
-rw-r--r--paludis/fuzzy_finder.cc1
-rw-r--r--paludis/install_task.cc10
-rw-r--r--paludis/match_package.cc40
-rw-r--r--paludis/package_database_TEST.cc3
-rw-r--r--paludis/range_rewriter.cc19
-rw-r--r--paludis/range_rewriter_TEST.cc3
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc1
-rw-r--r--paludis/repositories/cran/package_dep_spec.cc4
-rw-r--r--paludis/repositories/e/Makefile.am18
-rw-r--r--paludis/repositories/e/dep_parser.se2
-rw-r--r--paludis/repositories/e/e_installed_repository.cc1
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc1
-rw-r--r--paludis/repositories/e/e_repository_sets.cc7
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf3
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf3
-rw-r--r--paludis/repositories/e/ebuild/binary_functions.bash2
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash1
-rwxr-xr-xpaludis/repositories/e/ebuild/pipe_functions.bash8
-rwxr-xr-xpaludis/repositories/e/ebuild/write_vdb_entry.bash4
-rw-r--r--paludis/repositories/e/fetch_visitor_TEST.cc1
-rw-r--r--paludis/repositories/e/fix_locked_dependencies.cc217
-rw-r--r--paludis/repositories/e/fix_locked_dependencies.hh41
-rw-r--r--paludis/repositories/e/fix_locked_dependencies_TEST.cc84
-rw-r--r--paludis/repositories/e/package_dep_spec.cc86
-rw-r--r--paludis/repositories/e/package_dep_spec.hh35
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc35
-rw-r--r--paludis/repositories/e/qa/visibility.cc4
-rw-r--r--paludis/repositories/e/qa/visibility_TEST.cc3
-rw-r--r--paludis/repositories/e/vdb_repository.cc1
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc1
-rw-r--r--paludis/repositories/unpackaged/dep_parser.cc3
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc1
-rw-r--r--paludis/repositories/virtuals/package_id.cc3
-rw-r--r--paludis/repositories/virtuals/virtuals_repository_TEST.cc1
-rw-r--r--paludis/set_file_TEST.cc3
-rw-r--r--paludis/slot_requirement-fwd.hh37
-rw-r--r--paludis/slot_requirement.cc37
-rw-r--r--paludis/slot_requirement.hh68
-rw-r--r--paludis/stringify_formatter_TEST.cc1
-rw-r--r--paludis/uninstall_list.cc9
-rw-r--r--paludis/uninstall_list_TEST.cc91
-rw-r--r--paludis/uninstall_task.cc5
-rw-r--r--paludis/user_dep_spec-fwd.hh52
-rw-r--r--paludis/user_dep_spec.cc286
-rw-r--r--paludis/user_dep_spec.hh48
-rw-r--r--paludis/user_dep_spec.se (renamed from paludis/dep_spec.se)1
-rw-r--r--paludis/user_dep_spec_TEST.cc201
-rw-r--r--python/additional_tests.cc1
-rw-r--r--python/dep_spec.cc22
-rw-r--r--python/dep_spec.hh2
-rwxr-xr-xpython/dep_spec_TEST.py6
-rw-r--r--ruby/dep_spec.cc5
-rw-r--r--ruby/dep_spec_TEST.rb8
-rw-r--r--src/clients/adjutrix/downgrade_check.cc4
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc1
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc1
-rw-r--r--src/clients/contrarius/stage.cc1
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc7
-rw-r--r--src/clients/paludis/info.cc1
-rw-r--r--src/clients/reconcilio/fix_linkage.cc5
-rw-r--r--src/output/console_install_task.cc14
-rw-r--r--src/output/console_query_task.cc4
78 files changed, 1536 insertions, 526 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc
index 54fc877..89a38a0 100644
--- a/doc/api/cplusplus/examples/example_dep_spec.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec.cc
@@ -98,8 +98,8 @@ int main(int argc, char * argv[])
cout << endl;
}
- if (spec.slot_ptr())
- cout << " " << left << setw(24) << "Slot:" << " " << *spec.slot_ptr() << endl;
+ if (spec.slot_requirement_ptr())
+ cout << " " << left << setw(24) << "Slot:" << " " << *spec.slot_requirement_ptr() << endl;
if (spec.repository_ptr())
cout << " " << left << setw(24) << "Repository:" << " " << *spec.repository_ptr() << endl;
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 976418c..037294e 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -26,6 +26,7 @@
#include <paludis/handled_information.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/action.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/distribution.hh>
@@ -559,7 +560,8 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
query::SupportsAction<InstalledAction>() &
query::Matches(make_package_dep_spec()
.package(best_visible_candidate->name())
- .slot(best_visible_candidate->slot())),
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(best_visible_candidate->slot())))
+ ),
qo_order_by_version));
if (are_we_downgrading->empty())
@@ -809,7 +811,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()
+ if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_requirement_ptr()
|| a.blocked_spec()->additional_requirements_ptr() || a.blocked_spec()->repository_ptr())
&& d->_imp->current_package_id())
{
@@ -850,7 +852,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()
+ if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_requirement_ptr()
|| a.blocked_spec()->additional_requirements_ptr() || a.blocked_spec()->repository_ptr())
&& d->_imp->current_package_id())
{
@@ -875,7 +877,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()
+ if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_requirement_ptr()
|| a.blocked_spec()->additional_requirements_ptr() || a.blocked_spec()->repository_ptr())
&& d->_imp->current_package_id())
{
diff --git a/paludis/dep_list_TEST.hh b/paludis/dep_list_TEST.hh
index 5be6686..74a8ee3 100644
--- a/paludis/dep_list_TEST.hh
+++ b/paludis/dep_list_TEST.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
@@ -28,6 +28,7 @@
#include <paludis/repositories/virtuals/installed_virtuals_repository.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/environments/test/test_environment.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index 5201df1..381083f 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -26,7 +26,6 @@
#include <paludis/dep_spec-fwd.hh>
#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>
@@ -89,24 +88,6 @@ namespace paludis
*/
typedef Sequence<tr1::shared_ptr<const AdditionalPackageDepSpecRequirement> > AdditionalPackageDepSpecRequirements;
-#include <paludis/dep_spec-se.hh>
-
- /**
- * Options for parse_user_package_dep_spec.
- *
- * \ingroup g_dep_spec
- * \since 0.26
- */
- typedef Options<UserPackageDepSpecOption> UserPackageDepSpecOptions;
-
- /**
- * Create a PackageDepSpec from user input.
- *
- * \ingroup g_dep_spec
- * \since 0.26
- */
- PackageDepSpec parse_user_package_dep_spec(const std::string &, const UserPackageDepSpecOptions &) PALUDIS_VISIBLE;
-
/**
* Create a PackageDepSpec from various rules.
*
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index d5006e6..70698dc 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -43,8 +43,6 @@
using namespace paludis;
-#include <paludis/dep_spec-se.cc>
-
DepSpec::DepSpec()
{
}
@@ -526,10 +524,10 @@ PackageDepSpec::version_requirements_mode() const
return _imp->data->version_requirements_mode();
}
-tr1::shared_ptr<const SlotName>
-PackageDepSpec::slot_ptr() const
+tr1::shared_ptr<const SlotRequirement>
+PackageDepSpec::slot_requirement_ptr() const
{
- return _imp->data->slot_ptr();
+ return _imp->data->slot_requirement_ptr();
}
tr1::shared_ptr<const RepositoryName>
@@ -566,8 +564,8 @@ PackageDepSpec::without_additional_requirements() const
result.version_requirements_mode(version_requirements_mode());
- if (slot_ptr())
- result.slot(*slot_ptr());
+ if (slot_requirement_ptr())
+ result.slot_requirement(slot_requirement_ptr());
if (repository_ptr())
result.repository(*repository_ptr());
@@ -597,244 +595,6 @@ 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 ? "disabled" : "enabled");
- }
-
- 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)
-{
- Context context("When parsing package dep spec '" + ss + "':");
-
- if (ss.empty())
- throw PackageDepSpecError("Got empty dep spec");
-
- std::string s(ss);
- PartiallyMadePackageDepSpec result;
- bool had_bracket_version_requirements(false);
-
- std::string::size_type use_group_p;
- while (std::string::npos != ((use_group_p = s.rfind('['))))
- {
- if (s.at(s.length() - 1) != ']')
- throw PackageDepSpecError("Mismatched []");
-
- std::string flag(s.substr(use_group_p + 1));
- if (flag.length() < 2)
- throw PackageDepSpecError("Invalid [] contents");
-
- flag.erase(flag.length() - 1);
-
- switch (flag.at(0))
- {
- case '<':
- case '>':
- case '=':
- case '~':
- {
- char needed_mode(0);
-
- while (! flag.empty())
- {
- Context cc("When parsing [] segment '" + flag + "':");
-
- std::string op;
- std::string::size_type opos(0);
- while (opos < flag.length())
- if (std::string::npos == std::string("><=~").find(flag.at(opos)))
- break;
- else
- ++opos;
-
- op = flag.substr(0, opos);
- flag.erase(0, opos);
-
- if (op.empty())
- throw PackageDepSpecError("Missing operator inside []");
-
- VersionOperator vop(op);
-
- std::string ver;
- opos = flag.find_first_of("|&");
- if (std::string::npos == opos)
- {
- ver = flag;
- flag.clear();
- }
- else
- {
- if (0 == needed_mode)
- needed_mode = flag.at(opos);
- else if (needed_mode != flag.at(opos))
- throw PackageDepSpecError("Mixed & and | inside []");
-
- result.version_requirements_mode(flag.at(opos) == '|' ? vr_or : vr_and);
- ver = flag.substr(0, opos++);
- flag.erase(0, opos);
- }
-
- if (ver.empty())
- throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []");
-
- if ('*' == ver.at(ver.length() - 1))
- {
- ver.erase(ver.length() - 1);
- if (vop == vo_equal)
- vop = vo_equal_star;
- else
- throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []");
- }
-
- VersionSpec vs(ver);
- result.version_requirement(VersionRequirement(vop, vs));
- had_bracket_version_requirements = true;
- }
- }
- break;
-
- default:
- {
- tr1::shared_ptr<UserUseRequirement> req(new UserUseRequirement(flag));
- result.additional_requirement(req);
- }
- break;
- };
-
- s.erase(use_group_p);
- }
-
- std::string::size_type repo_p;
- if (std::string::npos != ((repo_p = s.rfind("::"))))
- {
- result.repository(RepositoryName(s.substr(repo_p + 2)));
- s.erase(repo_p);
- }
-
- std::string::size_type slot_p;
- if (std::string::npos != ((slot_p = s.rfind(':'))))
- {
- result.slot(SlotName(s.substr(slot_p + 1)));
- s.erase(slot_p);
- }
-
- if (std::string::npos != std::string("<>=~").find(s.at(0)))
- {
- if (had_bracket_version_requirements)
- throw PackageDepSpecError("Cannot mix [] and traditional version specifications");
-
- std::string::size_type p(1);
- if (s.length() > 1 && std::string::npos != std::string("<>=~").find(s.at(1)))
- ++p;
- VersionOperator op(s.substr(0, p));
- std::string::size_type q(p);
-
- while (true)
- {
- if (p >= s.length())
- throw PackageDepSpecError("Couldn't parse dep spec '" + ss + "'");
- q = s.find('-', q + 1);
- if ((std::string::npos == q) || (++q >= s.length()))
- throw PackageDepSpecError("Couldn't parse dep spec '" + ss + "'");
- if ((s.at(q) >= '0' && s.at(q) <= '9') || (0 == s.compare(q, 3, "scm")))
- break;
- }
-
- std::string::size_type new_q(q);
- while (true)
- {
- if (new_q >= s.length())
- break;
- new_q = s.find('-', new_q + 1);
- if ((std::string::npos == new_q) || (++new_q >= s.length()))
- break;
- if (s.at(new_q) >= '0' && s.at(new_q) <= '9')
- q = new_q;
- }
-
- std::string t(s.substr(p, q - p - 1));
- if (t.length() >= 3 && (0 == t.compare(0, 2, "*/")))
- {
- if (! options[updso_allow_wildcards])
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
-
- if (0 != t.compare(t.length() - 2, 2, "/*"))
- result.package_name_part(PackageNamePart(t.substr(2)));
- }
- else if (t.length() >= 3 && (0 == t.compare(t.length() - 2, 2, "/*")))
- {
- if (! options[updso_allow_wildcards])
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
-
- result.category_name_part(CategoryNamePart(t.substr(0, t.length() - 2)));
- }
- else
- result.package(QualifiedPackageName(t));
-
- if ('*' == s.at(s.length() - 1))
- {
- if (op != vo_equal)
- Log::get_instance()->message(ll_qa, lc_context,
- "Package dep spec '" + ss + "' uses * "
- "with operator '" + stringify(op) +
- "', pretending it uses the equals operator instead");
- op = vo_equal_star;
-
- result.version_requirement(VersionRequirement(op, VersionSpec(s.substr(q, s.length() - q - 1))));
- }
- else
- result.version_requirement(VersionRequirement(op, VersionSpec(s.substr(q))));
- }
- else
- {
- if (s.length() >= 3 && (0 == s.compare(0, 2, "*/")))
- {
- if (! options[updso_allow_wildcards])
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
-
- if (0 != s.compare(s.length() - 2, 2, "/*"))
- result.package_name_part(PackageNamePart(s.substr(2)));
- }
- else if (s.length() >= 3 && (0 == s.compare(s.length() - 2, 2, "/*")))
- {
- if (! options[updso_allow_wildcards])
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
-
- result.category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
- }
- else
- result.package(QualifiedPackageName(s));
- }
-
- return result;
-}
-
PartiallyMadePackageDepSpec
paludis::make_package_dep_spec()
{
@@ -851,7 +611,7 @@ namespace
tr1::shared_ptr<CategoryNamePart> category_name_part;
tr1::shared_ptr<VersionRequirements> version_requirements;
VersionRequirementsMode version_requirements_mode_v;
- tr1::shared_ptr<SlotName> slot;
+ tr1::shared_ptr<const SlotRequirement> slot;
tr1::shared_ptr<RepositoryName> repository;
tr1::shared_ptr<AdditionalPackageDepSpecRequirements> additional_requirements;
@@ -922,8 +682,8 @@ namespace
}
}
- if (slot_ptr())
- s << ":" << *slot_ptr();
+ if (slot_requirement_ptr())
+ s << stringify(*slot_requirement_ptr());
if (repository_ptr())
s << "::" << *repository_ptr();
@@ -1012,7 +772,7 @@ namespace
return version_requirements_mode_v;
}
- virtual tr1::shared_ptr<const SlotName> slot_ptr() const
+ virtual tr1::shared_ptr<const SlotRequirement> slot_requirement_ptr() const
{
return slot;
}
@@ -1070,9 +830,9 @@ PartiallyMadePackageDepSpec::package(const QualifiedPackageName & name)
}
PartiallyMadePackageDepSpec &
-PartiallyMadePackageDepSpec::slot(const SlotName & s)
+PartiallyMadePackageDepSpec::slot_requirement(const tr1::shared_ptr<const SlotRequirement> & s)
{
- _imp->data->slot.reset(new SlotName(s));
+ _imp->data->slot = s;
return *this;
}
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 4182fcf..2a6119a 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -36,6 +36,7 @@
#include <paludis/version_operator-fwd.hh>
#include <paludis/version_requirements-fwd.hh>
#include <paludis/version_spec-fwd.hh>
+#include <paludis/slot_requirement-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/environment-fwd.hh>
@@ -319,7 +320,7 @@ namespace paludis
/**
* Set our slot requirements, return ourself.
*/
- PartiallyMadePackageDepSpec & slot(const SlotName &);
+ PartiallyMadePackageDepSpec & slot_requirement(const tr1::shared_ptr<const SlotRequirement> &);
/**
* Set our repository requirements, return ourself.
@@ -439,9 +440,9 @@ namespace paludis
VersionRequirementsMode version_requirements_mode() const;
/**
- * Fetch the slot name (may be a zero pointer).
+ * Fetch the slot requirement (may be a zero pointer).
*/
- tr1::shared_ptr<const SlotName> slot_ptr() const;
+ tr1::shared_ptr<const SlotRequirement> slot_requirement_ptr() const;
/**
* Fetch the repo name (may be a zero pointer).
@@ -520,7 +521,7 @@ namespace paludis
/**
* Fetch the slot name (may be a zero pointer).
*/
- virtual tr1::shared_ptr<const SlotName> slot_ptr() const = 0;
+ virtual tr1::shared_ptr<const SlotRequirement> slot_requirement_ptr() const = 0;
/**
* Fetch the repo name (may be a zero pointer).
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index 88f7ea8..38d5c40 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -41,125 +42,11 @@ namespace test_cases
void run()
{
- tr1::shared_ptr<PackageDepSpec> x(new PackageDepSpec(parse_user_package_dep_spec("foo/bar", UserPackageDepSpecOptions())));
+ tr1::shared_ptr<PackageDepSpec> x(new PackageDepSpec(make_package_dep_spec()));
TEST_CHECK(0 == x->as_conditional_dep_spec());
}
} test_dep_spec_as;
- struct PackageDepSpecTest : TestCase
- {
- PackageDepSpecTest() : TestCase("package dep spec") { }
-
- void run()
- {
- PackageDepSpec a(parse_user_package_dep_spec("foo/bar", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(a, "foo/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*a.package_ptr(), "foo/bar");
- TEST_CHECK(! a.slot_ptr());
- TEST_CHECK(! a.version_requirements_ptr());
-
- PackageDepSpec b(parse_user_package_dep_spec(">=foo/bar-1.2.3", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(b, ">=foo/bar-1.2.3");
- TEST_CHECK_STRINGIFY_EQUAL(*b.package_ptr(), "foo/bar");
- TEST_CHECK(! b.slot_ptr());
- TEST_CHECK(b.version_requirements_ptr());
- TEST_CHECK_EQUAL(std::distance(b.version_requirements_ptr()->begin(),
- b.version_requirements_ptr()->end()), 1);
- TEST_CHECK_STRINGIFY_EQUAL(b.version_requirements_ptr()->begin()->version_spec, "1.2.3");
- TEST_CHECK_EQUAL(b.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
-
- PackageDepSpec c(parse_user_package_dep_spec("foo/bar:baz", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(c, "foo/bar:baz");
- TEST_CHECK_STRINGIFY_EQUAL(*c.package_ptr(), "foo/bar");
- TEST_CHECK(c.slot_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(*c.slot_ptr(), "baz");
- TEST_CHECK(! c.version_requirements_ptr());
-
- PackageDepSpec d(parse_user_package_dep_spec("=foo/bar-1.2*:1.2.1", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(d, "=foo/bar-1.2*:1.2.1");
- TEST_CHECK_STRINGIFY_EQUAL(*d.package_ptr(), "foo/bar");
- TEST_CHECK(d.slot_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(*d.slot_ptr(), "1.2.1");
- TEST_CHECK(d.version_requirements_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(d.version_requirements_ptr()->begin()->version_spec, "1.2");
- TEST_CHECK_EQUAL(d.version_requirements_ptr()->begin()->version_operator, vo_equal_star);
-
- PackageDepSpec e(parse_user_package_dep_spec("foo/bar:1.2.1", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(e, "foo/bar:1.2.1");
- TEST_CHECK_STRINGIFY_EQUAL(*e.package_ptr(), "foo/bar");
- TEST_CHECK(e.slot_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(*e.slot_ptr(), "1.2.1");
- TEST_CHECK(! e.version_requirements_ptr());
-
- PackageDepSpec f(parse_user_package_dep_spec("foo/bar:0", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(f, "foo/bar:0");
- TEST_CHECK_STRINGIFY_EQUAL(*f.package_ptr(), "foo/bar");
- TEST_CHECK(f.slot_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(*f.slot_ptr(), "0");
- TEST_CHECK(! f.version_requirements_ptr());
-
- PackageDepSpec g(parse_user_package_dep_spec("foo/bar-100dpi", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(g, "foo/bar-100dpi");
- TEST_CHECK_STRINGIFY_EQUAL(*g.package_ptr(), "foo/bar-100dpi");
-
- PackageDepSpec h(parse_user_package_dep_spec(">=foo/bar-100dpi-1.23", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(h, ">=foo/bar-100dpi-1.23");
- TEST_CHECK_STRINGIFY_EQUAL(*h.package_ptr(), "foo/bar-100dpi");
- TEST_CHECK(h.version_requirements_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(h.version_requirements_ptr()->begin()->version_spec, "1.23");
- TEST_CHECK_EQUAL(h.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
-
- TEST_CHECK_THROWS(parse_user_package_dep_spec("", UserPackageDepSpecOptions()), PackageDepSpecError);
- TEST_CHECK_THROWS(parse_user_package_dep_spec("=foo/bar-1.2[=1.3]", UserPackageDepSpecOptions()), PackageDepSpecError);
-
- PackageDepSpec i(parse_user_package_dep_spec("foo/bar[one][-two]", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(i, "foo/bar[-two][one]");
- TEST_CHECK_STRINGIFY_EQUAL(*i.package_ptr(), "foo/bar");
- TEST_CHECK(! i.version_requirements_ptr());
- TEST_CHECK(! i.repository_ptr());
- TEST_CHECK(! i.slot_ptr());
- 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");
- TEST_CHECK_STRINGIFY_EQUAL(*j.package_ptr(), "foo/bar");
- TEST_CHECK(j.version_requirements_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(j.version_requirements_ptr()->begin()->version_spec, "scm-r3");
- TEST_CHECK_EQUAL(j.version_requirements_ptr()->begin()->version_operator, vo_equal);
-
- PackageDepSpec k(parse_user_package_dep_spec("=foo/bar-scm", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(k, "=foo/bar-scm");
- TEST_CHECK_STRINGIFY_EQUAL(*k.package_ptr(), "foo/bar");
- TEST_CHECK(k.version_requirements_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(k.version_requirements_ptr()->begin()->version_spec, "scm");
- TEST_CHECK_EQUAL(k.version_requirements_ptr()->begin()->version_operator, vo_equal);
-
- PackageDepSpec l(parse_user_package_dep_spec("foo/bar[one][-two][>=1.2&<2.0]", UserPackageDepSpecOptions()));
- TEST_CHECK_STRINGIFY_EQUAL(l, "foo/bar[>=1.2&<2.0][-two][one]");
- TEST_CHECK_STRINGIFY_EQUAL(*l.package_ptr(), "foo/bar");
- TEST_CHECK(l.version_requirements_ptr());
- TEST_CHECK(! l.repository_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(l.version_requirements_ptr()->begin()->version_spec, "1.2");
- TEST_CHECK_EQUAL(l.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
- 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());
-
- 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]");
- TEST_CHECK_STRINGIFY_EQUAL(*m.package_ptr(), "foo/bar");
- TEST_CHECK(m.version_requirements_ptr());
- TEST_CHECK(! m.repository_ptr());
- TEST_CHECK_STRINGIFY_EQUAL(m.version_requirements_ptr()->begin()->version_spec, "1.2");
- TEST_CHECK_EQUAL(m.version_requirements_ptr()->begin()->version_operator, vo_equal);
- TEST_CHECK_STRINGIFY_EQUAL(next(m.version_requirements_ptr()->begin())->version_spec, "1.3");
- TEST_CHECK_EQUAL(next(m.version_requirements_ptr()->begin())->version_operator, vo_equal_star);
- 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());
- }
- } test_package_dep_spec;
-
struct FetchableURIDepSpecTest : TestCase
{
FetchableURIDepSpecTest() : TestCase("fetchable uri dep spec") { }
@@ -181,54 +68,6 @@ namespace test_cases
}
} test_fetchable_uri_dep_spec;
- struct PackageDepSpecUnspecificTest : TestCase
- {
- PackageDepSpecUnspecificTest() : TestCase("package dep spec unspecific") { }
-
- void run()
- {
- PackageDepSpec a(parse_user_package_dep_spec("*/*", UserPackageDepSpecOptions() + updso_allow_wildcards));
- TEST_CHECK_STRINGIFY_EQUAL(a, "*/*");
- TEST_CHECK(! a.package_ptr());
- TEST_CHECK(! a.package_name_part_ptr());
- TEST_CHECK(! a.category_name_part_ptr());
-
- PackageDepSpec b(parse_user_package_dep_spec("foo/*", UserPackageDepSpecOptions() + updso_allow_wildcards));
- TEST_CHECK_STRINGIFY_EQUAL(b, "foo/*");
- TEST_CHECK(! b.package_ptr());
- TEST_CHECK(! b.package_name_part_ptr());
- TEST_CHECK(b.category_name_part_ptr());
- TEST_CHECK_EQUAL(*b.category_name_part_ptr(), CategoryNamePart("foo"));
-
- PackageDepSpec c(parse_user_package_dep_spec("*/foo", UserPackageDepSpecOptions() + updso_allow_wildcards));
- TEST_CHECK_STRINGIFY_EQUAL(c, "*/foo");
- TEST_CHECK(! c.package_ptr());
- TEST_CHECK(c.package_name_part_ptr());
- TEST_CHECK_EQUAL(*c.package_name_part_ptr(), PackageNamePart("foo"));
- TEST_CHECK(! c.category_name_part_ptr());
-
- PackageDepSpec d(parse_user_package_dep_spec("~*/*-0", UserPackageDepSpecOptions() + updso_allow_wildcards));
- TEST_CHECK_STRINGIFY_EQUAL(d, "~*/*-0");
- TEST_CHECK(! d.package_ptr());
- TEST_CHECK(! d.package_name_part_ptr());
- TEST_CHECK(! d.category_name_part_ptr());
-
- PackageDepSpec e(parse_user_package_dep_spec(">=foo/*-1.23", UserPackageDepSpecOptions() + updso_allow_wildcards));
- TEST_CHECK_STRINGIFY_EQUAL(e, ">=foo/*-1.23");
- TEST_CHECK(! e.package_ptr());
- TEST_CHECK(! e.package_name_part_ptr());
- TEST_CHECK(e.category_name_part_ptr());
- TEST_CHECK_EQUAL(*e.category_name_part_ptr(), CategoryNamePart("foo"));
-
- PackageDepSpec f(parse_user_package_dep_spec("=*/foo-1*", UserPackageDepSpecOptions() + updso_allow_wildcards));
- TEST_CHECK_STRINGIFY_EQUAL(f, "=*/foo-1*");
- TEST_CHECK(! f.package_ptr());
- TEST_CHECK(f.package_name_part_ptr());
- TEST_CHECK_EQUAL(*f.package_name_part_ptr(), PackageNamePart("foo"));
- TEST_CHECK(! f.category_name_part_ptr());
- }
- } test_package_dep_spec_unspecific;
-
struct DepSpecCloneTest : TestCase
{
DepSpecCloneTest() : TestCase("dep spec clone") { }
diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc
index 7e411eb..8031d33 100644
--- a/paludis/environments/paludis/keywords_conf.cc
+++ b/paludis/environments/paludis/keywords_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
@@ -22,6 +22,7 @@
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/options.hh>
diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc
index 6716d03..f6c3601 100644
--- a/paludis/environments/paludis/licenses_conf.cc
+++ b/paludis/environments/paludis/licenses_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
@@ -22,6 +22,7 @@
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
#include <paludis/package_id.hh>
diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc
index 8a3533f..6fa7f48 100644
--- a/paludis/environments/paludis/package_mask_conf.cc
+++ b/paludis/environments/paludis/package_mask_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
@@ -22,6 +22,7 @@
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
#include <paludis/package_id.hh>
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 61549ce..892bf17 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -35,6 +35,7 @@
#include <paludis/dep_tag.hh>
#include <paludis/package_id.hh>
#include <paludis/mask.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/log.hh>
diff --git a/paludis/environments/paludis/paludis_environment_TEST.cc b/paludis/environments/paludis/paludis_environment_TEST.cc
index 09fad04..ef0f26f 100644
--- a/paludis/environments/paludis/paludis_environment_TEST.cc
+++ b/paludis/environments/paludis/paludis_environment_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 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
@@ -26,6 +26,7 @@
#include <paludis/util/options.hh>
#include <paludis/query.hh>
#include <paludis/package_id.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
#include <cstdlib>
diff --git a/paludis/environments/paludis/use_conf.cc b/paludis/environments/paludis/use_conf.cc
index cc72e83..61bd2e6 100644
--- a/paludis/environments/paludis/use_conf.cc
+++ b/paludis/environments/paludis/use_conf.cc
@@ -23,6 +23,7 @@
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/options.hh>
#include <paludis/package_id.hh>
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 2bbeb80..ccba734 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -43,6 +43,7 @@
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
+#include <paludis/user_dep_spec.hh>
#include <algorithm>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/mutex.hh>
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index afc3c99..02877f6 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.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
@@ -30,6 +30,7 @@
#include <paludis/package_database.hh>
#include <paludis/dep_spec.hh>
#include <paludis/name.hh>
+#include <paludis/user_dep_spec.hh>
using namespace paludis;
using namespace test;
diff --git a/paludis/files.m4 b/paludis/files.m4
index 978e014..bae636f 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -16,7 +16,7 @@ add(`dep_label', `hh', `cc', `fwd')
add(`dep_list', `hh', `cc', `fwd', `sr', `test', `fwd')
add(`dep_list_exceptions', `hh', `cc')
add(`dep_list_options', `hh', `cc', `se')
-add(`dep_spec', `hh', `cc', `se', `test', `fwd')
+add(`dep_spec', `hh', `cc', `test', `fwd')
add(`dep_spec_flattener', `hh', `cc')
add(`dep_tree', `hh', `cc', `fwd')
add(`dep_tag', `hh', `cc', `fwd', `sr')
@@ -59,6 +59,7 @@ add(`repository_maker', `hh', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
add(`set_file', `hh', `cc', `se', `sr', `test', `testscript')
add(`show_suggest_visitor', `hh', `cc')
+add(`slot_requirement', `hh', `fwd', `cc')
add(`stage_builder_task', `hh', `cc')
add(`stage_options', `sr')
add(`stringify_formatter', `hh', `cc', `fwd', `impl', `test')
@@ -68,6 +69,7 @@ add(`tasks_exceptions', `hh', `cc')
add(`uninstall_list', `hh', `cc', `se', `sr', `test')
add(`uninstall_task', `hh', `cc')
add(`unmerger', `hh', `cc')
+add(`user_dep_spec', `hh', `cc', `se', `fwd', `test')
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/fuzzy_finder.cc b/paludis/fuzzy_finder.cc
index dababdd..769c198 100644
--- a/paludis/fuzzy_finder.cc
+++ b/paludis/fuzzy_finder.cc
@@ -28,6 +28,7 @@
#include <paludis/package_id.hh>
#include <paludis/name.hh>
#include <paludis/query.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <list>
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index afaee57..a23142a 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -19,6 +19,7 @@
#include <paludis/install_task.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/action.hh>
#include <paludis/metadata_key.hh>
#include <paludis/util/exception.hh>
@@ -38,6 +39,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/kc.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/destringify.hh>
@@ -461,7 +463,7 @@ InstallTask::_add_package_id(const tr1::shared_ptr<const PackageID> & target)
tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec()
.package(target->name())
.version_requirement(VersionRequirement(vo_equal, target->version()))
- .slot(target->slot())
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(target->slot())))
.repository(target->repository()->name())));
spec->set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
@@ -737,7 +739,7 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
collision_list = _imp->env->package_database()->query(
query::Matches(make_package_dep_spec()
.package(dep->package_id->name())
- .slot(dep->package_id->slot())
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(dep->package_id->slot())))
.repository(dep->destination->name())) &
query::SupportsAction<UninstallAction>(),
qo_order_by_version);
@@ -1209,8 +1211,8 @@ namespace
void visit_leaf(const PackageDepSpec & a)
{
- if (a.slot_ptr())
- task->on_update_world_skip(a, ":slot restrictions");
+ if (a.slot_requirement_ptr())
+ task->on_update_world_skip(a, "slot restrictions");
else if (a.version_requirements_ptr() && ! a.version_requirements_ptr()->empty())
task->on_update_world_skip(a, "version restrictions");
else
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index caad407..0852c0c 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -24,12 +24,44 @@
#include <paludis/version_requirements.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
+#include <paludis/slot_requirement.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/tr1_functional.hh>
#include <algorithm>
using namespace paludis;
+namespace
+{
+ struct SlotRequirementChecker :
+ ConstVisitor<SlotRequirementVisitorTypes>
+ {
+ const SlotName actual;
+ bool result;
+
+ SlotRequirementChecker(const SlotName & a) :
+ actual(a),
+ result(true)
+ {
+ }
+
+ void visit(const SlotExactRequirement & s)
+ {
+ result = (actual == s.slot());
+ }
+
+ void visit(const SlotAnyLockedRequirement &)
+ {
+ result = true;
+ }
+
+ void visit(const SlotAnyUnlockedRequirement &)
+ {
+ result = true;
+ }
+ };
+}
+
bool
paludis::match_package(
const Environment & env,
@@ -79,9 +111,13 @@ paludis::match_package(
if (*spec.repository_ptr() != entry.repository()->name())
return false;
- if (spec.slot_ptr())
- if (*spec.slot_ptr() != entry.slot())
+ if (spec.slot_requirement_ptr())
+ {
+ SlotRequirementChecker v(entry.slot());
+ spec.slot_requirement_ptr()->accept(v);
+ if (! v.result)
return false;
+ }
if (spec.additional_requirements_ptr())
{
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index 9dea70c..5e6693c 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.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
@@ -19,6 +19,7 @@
#include <paludis/package_database.hh>
#include <paludis/query.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
diff --git a/paludis/range_rewriter.cc b/paludis/range_rewriter.cc
index b230aeb..d5adf6c 100644
--- a/paludis/range_rewriter.cc
+++ b/paludis/range_rewriter.cc
@@ -17,12 +17,13 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "range_rewriter.hh"
+#include <paludis/range_rewriter.hh>
#include <paludis/util/sequence.hh>
#include <paludis/version_requirements.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/join.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/dep_spec.hh>
#include <list>
#include <sstream>
@@ -116,9 +117,9 @@ namespace
return version_requirements_mode_v;
}
- virtual tr1::shared_ptr<const SlotName> slot_ptr() const
+ virtual tr1::shared_ptr<const SlotRequirement> slot_requirement_ptr() const
{
- return tr1::shared_ptr<const SlotName>();
+ return tr1::shared_ptr<const SlotRequirement>();
}
virtual tr1::shared_ptr<const RepositoryName> repository_ptr() const
@@ -147,6 +148,16 @@ namespace
std::copy(spec.version_requirements_ptr()->begin(), spec.version_requirements_ptr()->end(),
version_requirements->back_inserter());
}
+
+ tr1::shared_ptr<const PackageDepSpecData> without_additional_requirements() const
+ {
+ return make_shared_ptr(new RangeRewrittenPackageDepSpecData(*this));
+ }
+
+ tr1::shared_ptr<const PackageDepSpecData> without_slot_requirements() const
+ {
+ return make_shared_ptr(new RangeRewrittenPackageDepSpecData(*this));
+ }
};
}
@@ -206,7 +217,7 @@ RangeRewriter::visit_leaf(const PackageDepSpec & a)
if (_imp->invalid)
return;
- if (a.additional_requirements_ptr() || a.slot_ptr() || a.repository_ptr() || a.package_name_part_ptr()
+ if (a.additional_requirements_ptr() || a.slot_requirement_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/range_rewriter_TEST.cc b/paludis/range_rewriter_TEST.cc
index c832e5b..f9c48da 100644
--- a/paludis/range_rewriter_TEST.cc
+++ b/paludis/range_rewriter_TEST.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,6 +19,7 @@
#include <paludis/range_rewriter.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/options.hh>
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 8c8dd42..842918e 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -27,6 +27,7 @@
#include <paludis/set_file.hh>
#include <paludis/action.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
#include <paludis/repositories/cran/cran_installed_repository.hh>
diff --git a/paludis/repositories/cran/package_dep_spec.cc b/paludis/repositories/cran/package_dep_spec.cc
index d02cd79..b193f0a 100644
--- a/paludis/repositories/cran/package_dep_spec.cc
+++ b/paludis/repositories/cran/package_dep_spec.cc
@@ -90,9 +90,9 @@ namespace
return vr_and;
}
- virtual tr1::shared_ptr<const SlotName> slot_ptr() const
+ virtual tr1::shared_ptr<const SlotRequirement> slot_requirement_ptr() const
{
- return tr1::shared_ptr<const SlotName>();
+ return tr1::shared_ptr<const SlotRequirement>();
}
virtual tr1::shared_ptr<const RepositoryName> repository_ptr() const
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 55b919a..af44046 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -72,6 +72,7 @@ paludis_repositories_e_include_HEADERS = \
exndbam_repository.hh \
exndbam_repository-sr.hh \
fetch_visitor.hh \
+ fix_locked_dependencies.hh \
glsa-sr.hh \
glsa.hh \
layout.hh \
@@ -125,6 +126,7 @@ libpaludiserepository_la_SOURCES = \
exndbam_repository.cc \
exheres_layout.cc \
fetch_visitor.cc \
+ fix_locked_dependencies.cc \
glsa.cc \
layout.cc \
make_ebuild_repository.cc \
@@ -302,6 +304,18 @@ source_uri_finder_TEST_LDADD = \
$(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
+fix_locked_dependencies_TEST_SOURCES = fix_locked_dependencies_TEST.cc
+
+fix_locked_dependencies_TEST_LDADD = \
+ libpaludiserepository.la \
+ $(top_builddir)/paludis/repositories/fake/libpaludisfakerepository.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
+ $(top_builddir)/test/libtest.a \
+ $(DYNAMIC_LD_LIBS)
+
EXTRA_DIST = \
aa_visitor_TEST.cc \
dep_lexer_TEST.cc \
@@ -340,6 +354,7 @@ EXTRA_DIST = \
fetch_visitor_TEST.cc \
fetch_visitor_TEST_setup.sh \
fetch_visitor_TEST_cleanup.sh \
+ fix_locked_dependencies_TEST.cc \
manifest2_entry.sr \
manifest2_entry-sr.hh \
manifest2_entry-sr.cc \
@@ -507,7 +522,8 @@ TESTS = \
fetch_visitor_TEST \
source_uri_finder_TEST \
exndbam_repository_TEST \
- vdb_repository_TEST
+ vdb_repository_TEST \
+ fix_locked_dependencies_TEST
check_PROGRAMS = $(TESTS)
diff --git a/paludis/repositories/e/dep_parser.se b/paludis/repositories/e/dep_parser.se
index b315600..81fe339 100644
--- a/paludis/repositories/e/dep_parser.se
+++ b/paludis/repositories/e/dep_parser.se
@@ -8,6 +8,8 @@ make_enum_PackageDepSpecParseOption()
namespace paludis::erepository
key pdspo_allow_slot_deps "Allow :slot deps"
+ key pdspo_allow_slot_star_deps "Allow :* slot deps"
+ key pdspo_allow_slot_equal_deps "Allow := and :=blah slot deps"
key pdspo_allow_repository_deps "Allow ::repo deps"
key pdspo_allow_square_bracket_deps "Allow [use] and [opver] deps"
key pdspo_allow_tilde_greater_deps "Allow ~> deps"
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index 70d11e7..177c068 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -41,6 +41,7 @@
#include <paludis/set_file.hh>
#include <paludis/hook.hh>
#include <paludis/dep_tag.hh>
+#include <paludis/user_dep_spec.hh>
#include <fstream>
using namespace paludis;
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 29b80a1..7313ccb 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -39,6 +39,7 @@
#include <paludis/query.hh>
#include <paludis/action.hh>
#include <paludis/stringify_formatter.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index 2f00f0c..c876ff5 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.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
* Copyright (c) 2006 Danny van Dyk
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -22,6 +22,7 @@
#include <paludis/repositories/e/e_repository_sets.hh>
#include <paludis/repositories/e/glsa.hh>
#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/repositories/e/package_dep_spec.hh>
#include <paludis/environment.hh>
#include <paludis/util/config_file.hh>
@@ -31,6 +32,7 @@
#include <paludis/package_id.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_requirements.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/is_file_with_extension.hh>
@@ -42,6 +44,7 @@
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <algorithm>
#include <list>
@@ -291,7 +294,7 @@ ERepositorySets::security_set(bool insecurity) const
_imp->environment->package_database()->query(
query::Matches(make_package_dep_spec()
.package(glsa_pkg->name())
- .slot((*c)->slot())) &
+ .slot_requirement(make_shared_ptr(new erepository::ESlotExactRequirement((*c)->slot(), false)))) &
query::SupportsAction<InstallAction>() &
query::NotMasked(),
qo_order_by_version));
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 37eb858..3d466b0 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -6,7 +6,8 @@ exported_name = exheres-0
can_be_pbin = true
package_dep_spec_parse_options = allow_slot_deps allow_square_bracket_deps \
- allow_tilde_greater_deps strict_star_operator strict_parsing
+ allow_tilde_greater_deps strict_star_operator strict_parsing \
+ allow_slot_equal_deps allow_slot_star_deps
dependency_spec_tree_parse_options = disallow_any_use uri_supports_arrow
iuse_flag_parse_options = strict_parsing
merger_options =
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index 32bf92f..d4335db 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -6,7 +6,8 @@ exported_name = paludis-1
can_be_pbin = true
package_dep_spec_parse_options = allow_slot_deps allow_square_bracket_deps \
- allow_repository_deps allow_tilde_greater_deps strict_parsing
+ allow_repository_deps allow_tilde_greater_deps strict_parsing \
+ allow_slot_equal_deps allow_slot_star_deps
dependency_spec_tree_parse_options = disallow_any_use uri_supports_arrow
iuse_flag_parse_options = allow_iuse_defaults
merger_options = rewrite_symlinks allow_empty_dirs
diff --git a/paludis/repositories/e/ebuild/binary_functions.bash b/paludis/repositories/e/ebuild/binary_functions.bash
index 3d05d78..f1150ae 100644
--- a/paludis/repositories/e/ebuild/binary_functions.bash
+++ b/paludis/repositories/e/ebuild/binary_functions.bash
@@ -65,7 +65,7 @@ make_binary_ebuild()
local p
for p in ${PALUDIS_BINARY_FROM_ENV_VARIABLES} ; do
set -o noglob
- local k=${!p}
+ local k=$(paludis_rewrite_var BINARY "${p}" "${!p}" )
k=${k//\\/\\\\}
k=${k//\"/\\\"}
# {"} fix vim syntax highlighting
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index c4b106f..1ec7333 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -234,6 +234,7 @@ ebuild_scrub_environment()
unset -f diefunc perform_hook inherit builtin_loadenv builtin_saveenv
unset -f ebuild_safe_source portageq best_version has_version paludis_pipe_command
+ unset -f paludis_rewrite_var
if [[ "${2}" == "--pivot" ]] ; then
unset -f ${PALUDIS_IGNORE_PIVOT_ENV_FUNCTIONS}
diff --git a/paludis/repositories/e/ebuild/pipe_functions.bash b/paludis/repositories/e/ebuild/pipe_functions.bash
index b9dcdee..dc9112c 100755
--- a/paludis/repositories/e/ebuild/pipe_functions.bash
+++ b/paludis/repositories/e/ebuild/pipe_functions.bash
@@ -71,3 +71,11 @@ paludis_pipe_command()
echo "$rest"
}
+paludis_rewrite_var()
+{
+ [[ "${#@}" -ne 3 ]] && die "$0 should take exactly three args"
+ local r=$(paludis_pipe_command REWRITE_VAR "$EAPI" "$1" "$2" "$3" )
+ echo ${r#*;}
+ return ${r%%;*}
+}
+
diff --git a/paludis/repositories/e/ebuild/write_vdb_entry.bash b/paludis/repositories/e/ebuild/write_vdb_entry.bash
index 1a47cc0..0014574 100755
--- a/paludis/repositories/e/ebuild/write_vdb_entry.bash
+++ b/paludis/repositories/e/ebuild/write_vdb_entry.bash
@@ -117,7 +117,7 @@ main()
local v VDB_FORMAT="paludis-2" COUNTER="$(date +%s )"
for v in ${PALUDIS_VDB_FROM_ENV_VARIABLES} ; do
- if ! echo "${!v}" > "${vdbdir}"/${v} ; then
+ if ! paludis_rewrite_var VDB "${v}" "${!v}" > "${vdbdir}"/${v} ; then
echo "!!! vdb write ${v} failed"
exit 1
fi
@@ -125,7 +125,7 @@ main()
for v in ${PALUDIS_VDB_FROM_ENV_UNLESS_EMPTY_VARIABLES} ; do
[[ -z "${!v}" ]] && continue
- if ! echo "${!v}" > "${vdbdir}"/${v} ; then
+ if ! paludis_rewrite_var VDB "${v}" "${!v}" > "${vdbdir}"/${v} ; then
echo "!!! vdb write ${v} failed"
exit 1
fi
diff --git a/paludis/repositories/e/fetch_visitor_TEST.cc b/paludis/repositories/e/fetch_visitor_TEST.cc
index 3f5125b..4aab933 100644
--- a/paludis/repositories/e/fetch_visitor_TEST.cc
+++ b/paludis/repositories/e/fetch_visitor_TEST.cc
@@ -28,6 +28,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/package_database.hh>
#include <paludis/query.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
#include <fstream>
diff --git a/paludis/repositories/e/fix_locked_dependencies.cc b/paludis/repositories/e/fix_locked_dependencies.cc
new file mode 100644
index 0000000..90c03cd
--- /dev/null
+++ b/paludis/repositories/e/fix_locked_dependencies.cc
@@ -0,0 +1,217 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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/fix_locked_dependencies.hh>
+#include <paludis/repositories/e/package_dep_spec.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/query.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
+#include <algorithm>
+#include <list>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace
+{
+ void cannot_add(const tr1::shared_ptr<const DependencySpecTree::ConstItem> &) PALUDIS_ATTRIBUTE((noreturn));
+
+ void cannot_add(const tr1::shared_ptr<const DependencySpecTree::ConstItem> &)
+ {
+ throw InternalError(PALUDIS_HERE, "Got weird tree");
+ }
+
+ struct Fixer :
+ ConstVisitor<DependencySpecTree>
+ {
+ std::list<std::pair<
+ tr1::shared_ptr<DependencySpecTree::ConstItem>,
+ tr1::function<void (const tr1::shared_ptr<DependencySpecTree::ConstItem> &)> > > stack;
+
+ tr1::shared_ptr<const DependencySpecTree::ConstItem> result;
+
+ const Environment * const env;
+ const EAPI & eapi;
+ const tr1::shared_ptr<const PackageID> id;
+
+ Fixer(const Environment * const e, const EAPI & a, const tr1::shared_ptr<const PackageID> & i) :
+ env(e),
+ eapi(a),
+ id(i)
+ {
+ }
+
+ void visit_sequence(const AllDepSpec & s,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
+ {
+ tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > c(
+ new ConstTreeSequence<DependencySpecTree, AllDepSpec>(
+ tr1::static_pointer_cast<AllDepSpec>(s.clone())));
+
+ if (! stack.empty())
+ stack.begin()->second(c);
+ else
+ result = c;
+
+ using namespace tr1::placeholders;
+ stack.push_front(std::make_pair(c, tr1::bind(&ConstTreeSequence<DependencySpecTree, AllDepSpec>::add, c.get(), _1)));
+ std::for_each(cur, end, accept_visitor(*this));
+ stack.pop_front();
+ }
+
+ void visit_sequence(const AnyDepSpec & s,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
+ {
+ tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AnyDepSpec> > c(
+ new ConstTreeSequence<DependencySpecTree, AnyDepSpec>(
+ tr1::static_pointer_cast<AnyDepSpec>(s.clone())));
+
+ if (! stack.empty())
+ stack.begin()->second(c);
+ else
+ result = c;
+
+ using namespace tr1::placeholders;
+ stack.push_front(std::make_pair(c, tr1::bind(&ConstTreeSequence<DependencySpecTree, AnyDepSpec>::add, c.get(), _1)));
+ std::for_each(cur, end, accept_visitor(*this));
+ stack.pop_front();
+ }
+
+ void visit_sequence(const ConditionalDepSpec & s,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
+ {
+ tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, ConditionalDepSpec> > c(
+ new ConstTreeSequence<DependencySpecTree, ConditionalDepSpec>(
+ tr1::static_pointer_cast<ConditionalDepSpec>(s.clone())));
+
+ if (! stack.empty())
+ stack.begin()->second(c);
+ else
+ result = c;
+
+ using namespace tr1::placeholders;
+ stack.push_front(std::make_pair(c, tr1::bind(&ConstTreeSequence<DependencySpecTree, ConditionalDepSpec>::add, c.get(), _1)));
+ std::for_each(cur, end, accept_visitor(*this));
+ stack.pop_front();
+ }
+
+ void visit_leaf(const PackageDepSpec & s)
+ {
+ tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > c;
+
+ do
+ {
+ if (! s.slot_requirement_ptr())
+ break;
+
+ const SlotAnyLockedRequirement * const r(visitor_cast<const SlotAnyLockedRequirement>(*s.slot_requirement_ptr()));
+ if (! r)
+ break;
+
+ tr1::shared_ptr<const PackageIDSequence> matches(env->package_database()->query(
+ query::Matches(s) & query::InstalledAtRoot(FSEntry("/")), qo_order_by_version));
+ if (matches->empty())
+ break;
+
+ PackageDepSpec new_s(partial_parse_e_package_dep_spec(stringify(s), eapi, id).slot_requirement(
+ make_shared_ptr(new ESlotExactRequirement((*matches->last())->slot(), true))));
+
+ c.reset(new TreeLeaf<DependencySpecTree, PackageDepSpec>(tr1::static_pointer_cast<PackageDepSpec>(
+ PackageDepSpec(new_s).clone())));
+ } while (false);
+
+ if (! c)
+ c.reset(new TreeLeaf<DependencySpecTree, PackageDepSpec>(tr1::static_pointer_cast<PackageDepSpec>(s.clone())));
+
+ if (stack.empty())
+ {
+ stack.push_front(std::make_pair(c, &cannot_add));
+ result = c;
+ }
+ else
+ stack.begin()->second(c);
+ }
+
+ void visit_leaf(const NamedSetDepSpec & s)
+ {
+ tr1::shared_ptr<TreeLeaf<DependencySpecTree, NamedSetDepSpec> > c(
+ new TreeLeaf<DependencySpecTree, NamedSetDepSpec>(tr1::static_pointer_cast<NamedSetDepSpec>(s.clone())));
+
+ if (stack.empty())
+ {
+ stack.push_front(std::make_pair(c, &cannot_add));
+ result = c;
+ }
+ else
+ stack.begin()->second(c);
+ }
+
+ void visit_leaf(const BlockDepSpec & s)
+ {
+ tr1::shared_ptr<TreeLeaf<DependencySpecTree, BlockDepSpec> > c(
+ new TreeLeaf<DependencySpecTree, BlockDepSpec>(tr1::static_pointer_cast<BlockDepSpec>(s.clone())));
+
+ if (stack.empty())
+ {
+ stack.push_front(std::make_pair(c, &cannot_add));
+ result = c;
+ }
+ else
+ stack.begin()->second(c);
+ }
+
+ void visit_leaf(const DependencyLabelsDepSpec & s)
+ {
+ tr1::shared_ptr<TreeLeaf<DependencySpecTree, DependencyLabelsDepSpec> > c(
+ new TreeLeaf<DependencySpecTree, DependencyLabelsDepSpec>(tr1::static_pointer_cast<DependencyLabelsDepSpec>(s.clone())));
+
+ if (stack.empty())
+ {
+ stack.push_front(std::make_pair(c, &cannot_add));
+ result = c;
+ }
+ else
+ stack.begin()->second(c);
+ }
+ };
+}
+
+const tr1::shared_ptr<const DependencySpecTree::ConstItem>
+paludis::erepository::fix_locked_dependencies(
+ const Environment * const env,
+ const EAPI & e, const tr1::shared_ptr<const PackageID> & id,
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> & b)
+{
+ Fixer f(env, e, id);
+ b->accept(f);
+ return f.result;
+}
+
diff --git a/paludis/repositories/e/fix_locked_dependencies.hh b/paludis/repositories/e/fix_locked_dependencies.hh
new file mode 100644
index 0000000..f41e147
--- /dev/null
+++ b/paludis/repositories/e/fix_locked_dependencies.hh
@@ -0,0 +1,41 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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_REPOSITORIES_E_FIX_LOCKED_DEPENDENCIES_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_FIX_LOCKED_DEPENDENCIES_HH 1
+
+#include <paludis/repositories/e/eapi-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/tr1_memory.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/dep_tree.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> fix_locked_dependencies(
+ const Environment * const env,
+ const EAPI &, const tr1::shared_ptr<const PackageID> &,
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> &) PALUDIS_VISIBLE;
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/fix_locked_dependencies_TEST.cc b/paludis/repositories/e/fix_locked_dependencies_TEST.cc
new file mode 100644
index 0000000..f25ac3d
--- /dev/null
+++ b/paludis/repositories/e/fix_locked_dependencies_TEST.cc
@@ -0,0 +1,84 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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/fix_locked_dependencies.hh>
+#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/environments/test/test_environment.hh>
+#include <paludis/stringify_formatter.hh>
+#include <paludis/package_database.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace test;
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace test_cases
+{
+ struct FixLockedDependenciesTest : TestCase
+ {
+ FixLockedDependenciesTest() : TestCase("fix locked dependencies") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
+ env.package_database()->add_repository(1, repo);
+ tr1::shared_ptr<const PackageID> id(repo->add_version("cat", "pkg", "1"));
+
+ tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed")));
+ env.package_database()->add_repository(2, installed_repo);
+ installed_repo->add_version("cat", "installed", "1")->set_slot(SlotName("monkey"));
+
+ tr1::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string("paludis-1"));
+
+ tr1::shared_ptr<DependencySpecTree::ConstItem> bb(parse_depend(
+ "|| ( foo/bar ( bar/baz oink/squeak ) ) blah/blah", &env, id, *eapi)),
+ aa(fix_locked_dependencies(&env, *eapi, id, bb));
+
+ StringifyFormatter ff;
+ DepSpecPrettyPrinter
+ a(0, tr1::shared_ptr<const PackageID>(), ff, 0, false),
+ b(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
+ aa->accept(a);
+ bb->accept(b);
+
+ TEST_CHECK_STRINGIFY_EQUAL(a, b);
+
+ tr1::shared_ptr<DependencySpecTree::ConstItem> cc(parse_depend(
+ "foo/bar:= cat/installed:= >=cat/installed-1.2:= <=cat/installed-1.2:=", &env, id, *eapi)),
+ dd(fix_locked_dependencies(&env, *eapi, id, cc));
+
+ DepSpecPrettyPrinter
+ c(0, tr1::shared_ptr<const PackageID>(), ff, 0, false),
+ d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
+ cc->accept(c);
+ dd->accept(d);
+
+ TEST_CHECK_STRINGIFY_EQUAL(c, "foo/bar:= cat/installed:= >=cat/installed-1.2:= <=cat/installed-1.2:=");
+ TEST_CHECK_STRINGIFY_EQUAL(d, "foo/bar:= cat/installed:=monkey >=cat/installed-1.2:= <=cat/installed-1.2:=monkey");
+ }
+ } test_fix_locked_dependencies;
+}
+
diff --git a/paludis/repositories/e/package_dep_spec.cc b/paludis/repositories/e/package_dep_spec.cc
index d994fce..5ef6c86 100644
--- a/paludis/repositories/e/package_dep_spec.cc
+++ b/paludis/repositories/e/package_dep_spec.cc
@@ -23,6 +23,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/log.hh>
#include <paludis/util/kc.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/dep_spec.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
@@ -31,8 +32,9 @@
using namespace paludis;
using namespace paludis::erepository;
-PackageDepSpec
-paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAPI & eapi, const tr1::shared_ptr<const PackageID> & id)
+PartiallyMadePackageDepSpec
+paludis::erepository::partial_parse_e_package_dep_spec(
+ const std::string & ss, const EAPI & eapi, const tr1::shared_ptr<const PackageID> & id)
{
Context context("When parsing package dep spec '" + ss + "' with eapi '" + stringify(eapi[k::name()]) + "':");
@@ -229,15 +231,47 @@ paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAP
std::string::size_type slot_p;
if (std::string::npos != ((slot_p = s.rfind(':'))))
{
- if (! (*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_allow_slot_deps])
+ std::string match(s.substr(slot_p + 1));
+ if (match.empty())
+ throw PackageDepSpecError("Empty slot dependency specified");
+
+ if ("*" == match)
{
- if ((*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_strict_parsing])
- throw PackageDepSpecError("Slot dependencies not safe for use with this EAPI");
- else
- Log::get_instance()->message(ll_warning, lc_context, "Slot dependencies not safe for use with this EAPI");
+ if (! (*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_allow_slot_star_deps])
+ {
+ if ((*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_strict_parsing])
+ throw PackageDepSpecError("Slot '*' dependencies not safe for use with this EAPI");
+ else
+ Log::get_instance()->message(ll_warning, lc_context, "Slot '*' dependencies not safe for use with this EAPI");
+ }
+ result.slot_requirement(make_shared_ptr(new ESlotAnyUnlockedRequirement));
}
+ else if ('=' == match.at(0))
+ {
+ if (! (*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_allow_slot_equal_deps])
+ {
+ if ((*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_strict_parsing])
+ throw PackageDepSpecError("Slot '=' dependencies not safe for use with this EAPI");
+ else
+ Log::get_instance()->message(ll_warning, lc_context, "Slot '=' dependencies not safe for use with this EAPI");
+ }
- result.slot(SlotName(s.substr(slot_p + 1)));
+ if (1 == match.length())
+ result.slot_requirement(make_shared_ptr(new ESlotAnyLockedRequirement));
+ else
+ result.slot_requirement(make_shared_ptr(new ESlotExactRequirement(SlotName(s.substr(slot_p + 2)), true)));
+ }
+ else
+ {
+ if (! (*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_allow_slot_deps])
+ {
+ if ((*eapi[k::supported()])[k::package_dep_spec_parse_options()][pdspo_strict_parsing])
+ throw PackageDepSpecError("Slot dependencies not safe for use with this EAPI");
+ else
+ Log::get_instance()->message(ll_warning, lc_context, "Slot dependencies not safe for use with this EAPI");
+ }
+ result.slot_requirement(make_shared_ptr(new ESlotExactRequirement(SlotName(s.substr(slot_p + 1)), false)));
+ }
s.erase(slot_p);
}
@@ -352,3 +386,39 @@ paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAP
return result;
}
+PackageDepSpec
+paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAPI & eapi, const tr1::shared_ptr<const PackageID> & id)
+{
+ return partial_parse_e_package_dep_spec(ss, eapi, id);
+}
+
+ESlotExactRequirement::ESlotExactRequirement(const SlotName & s, const bool e) :
+ _s(s),
+ _e(e)
+{
+}
+
+const std::string
+ESlotExactRequirement::as_string() const
+{
+ return ":" + std::string(_e ? "=" : "") + stringify(_s);
+}
+
+const SlotName
+ESlotExactRequirement::slot() const
+{
+ return _s;
+}
+
+const std::string
+ESlotAnyUnlockedRequirement::as_string() const
+{
+ return ":*";
+}
+
+const std::string
+ESlotAnyLockedRequirement::as_string() const
+{
+ return ":=";
+}
+
diff --git a/paludis/repositories/e/package_dep_spec.hh b/paludis/repositories/e/package_dep_spec.hh
index 64c5f6e..02f9159 100644
--- a/paludis/repositories/e/package_dep_spec.hh
+++ b/paludis/repositories/e/package_dep_spec.hh
@@ -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
@@ -23,6 +23,8 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/repositories/e/eapi-fwd.hh>
+#include <paludis/slot_requirement.hh>
+#include <paludis/name.hh>
namespace paludis
{
@@ -30,6 +32,37 @@ namespace paludis
{
PackageDepSpec parse_e_package_dep_spec(const std::string &, const EAPI & eapi,
const tr1::shared_ptr<const PackageID> & id) PALUDIS_VISIBLE;
+
+ PartiallyMadePackageDepSpec partial_parse_e_package_dep_spec(const std::string &, const EAPI & eapi,
+ const tr1::shared_ptr<const PackageID> & id) PALUDIS_VISIBLE;
+
+ class ESlotExactRequirement :
+ public SlotExactRequirement
+ {
+ private:
+ const SlotName _s;
+ const bool _e;
+
+ public:
+ ESlotExactRequirement(const SlotName &, const bool equals);
+
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class ESlotAnyUnlockedRequirement :
+ public SlotAnyUnlockedRequirement
+ {
+ public:
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class ESlotAnyLockedRequirement :
+ public SlotAnyLockedRequirement
+ {
+ public:
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
}
}
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index f6a4cba..1445c68 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -20,6 +20,9 @@
#include <paludis/repositories/e/pipe_command_handler.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/package_dep_spec.hh>
+#include <paludis/repositories/e/fix_locked_dependencies.hh>
+#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
#include <paludis/util/log.hh>
#include <paludis/util/join.hh>
#include <paludis/util/exception.hh>
@@ -35,6 +38,7 @@
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/stringify_formatter.hh>
#include <vector>
using namespace paludis;
@@ -215,6 +219,37 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
return "O0;" + stringify(visitor_cast<const MetadataValueKey<FSEntry> >(**key)->value());
}
}
+ else if (tokens[0] == "REWRITE_VAR")
+ {
+ if (tokens.size() < 4)
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Got bad REWRITE_VAR pipe command";
+ return "Ebad REWRITE_VAR command";
+ }
+
+ tr1::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string(tokens[1]));
+ if (! (*eapi)[k::supported()])
+ return "EREWRITE_VAR EAPI " + tokens[1] + " unsupported";
+
+ std::string var(tokens[2]);
+
+ if ((var == (*(*eapi)[k::supported()])[k::ebuild_metadata_variables()].metadata_build_depend) ||
+ (var == (*(*eapi)[k::supported()])[k::ebuild_metadata_variables()].metadata_run_depend) ||
+ (var == (*(*eapi)[k::supported()])[k::ebuild_metadata_variables()].metadata_pdepend) ||
+ (var == (*(*eapi)[k::supported()])[k::ebuild_metadata_variables()].metadata_dependencies))
+ {
+ tr1::shared_ptr<const DependencySpecTree::ConstItem> before(parse_depend(join(tokens.begin() + 4, tokens.end(), " "),
+ environment, package_id, *eapi));
+ tr1::shared_ptr<const DependencySpecTree::ConstItem> after(fix_locked_dependencies(
+ environment, *eapi, package_id, before));
+ StringifyFormatter ff;
+ DepSpecPrettyPrinter p(0, tr1::shared_ptr<const PackageID>(), ff, 0, false);
+ after->accept(p);
+ return "O0;" + stringify(p);
+ }
+
+ return "O0;" + join(tokens.begin() + 4, tokens.end(), " ");
+ }
else if (tokens[0] == "EVER")
{
if (tokens.size() < 3)
diff --git a/paludis/repositories/e/qa/visibility.cc b/paludis/repositories/e/qa/visibility.cc
index 586b283..f5983b4 100644
--- a/paludis/repositories/e/qa/visibility.cc
+++ b/paludis/repositories/e/qa/visibility.cc
@@ -127,8 +127,8 @@ namespace
tr1::bind(&PartiallyMadePackageDepSpec::version_requirement, &pp, _1));
pp.package(*v->second->package_ptr());
- if (orig_p.slot_ptr())
- pp.slot(*orig_p.slot_ptr());
+ if (orig_p.slot_requirement_ptr())
+ pp.slot_requirement(orig_p.slot_requirement_ptr());
if (orig_p.repository_ptr())
pp.repository(*orig_p.repository_ptr());
diff --git a/paludis/repositories/e/qa/visibility_TEST.cc b/paludis/repositories/e/qa/visibility_TEST.cc
index fa4f3c1..d1b4743 100644
--- a/paludis/repositories/e/qa/visibility_TEST.cc
+++ b/paludis/repositories/e/qa/visibility_TEST.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
@@ -28,6 +28,7 @@
#include <paludis/qa.hh>
#include <paludis/query.hh>
#include <paludis/package_database.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 1a61c2e..e5278e2 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -31,6 +31,7 @@
#include <paludis/action.hh>
#include <paludis/util/config_file.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/literal_metadata_key.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/dep_tag.hh>
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 1b963c5..a44624e 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -29,6 +29,7 @@
#include <paludis/util/options.hh>
#include <paludis/query.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/stringify_formatter.hh>
#include <paludis/action.hh>
#include <test/test_framework.hh>
diff --git a/paludis/repositories/unpackaged/dep_parser.cc b/paludis/repositories/unpackaged/dep_parser.cc
index 49a9b72..98b084e 100644
--- a/paludis/repositories/unpackaged/dep_parser.cc
+++ b/paludis/repositories/unpackaged/dep_parser.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
@@ -23,6 +23,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/options.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <list>
using namespace paludis;
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index a7b1e32..0b15a73 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -24,6 +24,7 @@
#include <paludis/query.hh>
#include <paludis/package_id.hh>
#include <paludis/action.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/metadata_key.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/join.hh>
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index f508ded..451fd7f 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -38,6 +38,7 @@
#include <paludis/package_database.hh>
#include <paludis/query.hh>
#include <paludis/literal_metadata_key.hh>
+#include <paludis/user_dep_spec.hh>
using namespace paludis;
using namespace paludis::virtuals;
@@ -60,7 +61,7 @@ namespace paludis
make_package_dep_spec()
.package(v->name())
.version_requirement(VersionRequirement(vo_equal, v->version()))
- .slot(v->slot())
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(v->slot())))
.repository(v->repository()->name()))))
:
new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec(
diff --git a/paludis/repositories/virtuals/virtuals_repository_TEST.cc b/paludis/repositories/virtuals/virtuals_repository_TEST.cc
index 941908d..917d00c 100644
--- a/paludis/repositories/virtuals/virtuals_repository_TEST.cc
+++ b/paludis/repositories/virtuals/virtuals_repository_TEST.cc
@@ -32,6 +32,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/options.hh>
#include <paludis/query.hh>
+#include <paludis/user_dep_spec.hh>
using namespace test;
using namespace paludis;
diff --git a/paludis/set_file_TEST.cc b/paludis/set_file_TEST.cc
index 6ea2af7..137a6ad 100644
--- a/paludis/set_file_TEST.cc
+++ b/paludis/set_file_TEST.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
@@ -23,6 +23,7 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <fstream>
using namespace test;
diff --git a/paludis/slot_requirement-fwd.hh b/paludis/slot_requirement-fwd.hh
new file mode 100644
index 0000000..9f743d9
--- /dev/null
+++ b/paludis/slot_requirement-fwd.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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_SLOT_REQUIREMENT_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_SLOT_REQUIREMENT_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ struct SlotRequirement;
+ struct SlotExactRequirement;
+ struct SlotAnyLockedRequirement;
+ struct SlotAnyUnlockedRequirement;
+ struct SlotRequirementVisitorTypes;
+
+ std::ostream & operator<< (std::ostream &, const SlotRequirement &) PALUDIS_VISIBLE;
+}
+
+#endif
diff --git a/paludis/slot_requirement.cc b/paludis/slot_requirement.cc
new file mode 100644
index 0000000..00c7574
--- /dev/null
+++ b/paludis/slot_requirement.cc
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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/slot_requirement.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <ostream>
+
+using namespace paludis;
+
+template class ConstAcceptInterface<SlotRequirementVisitorTypes>;
+template class ConstAcceptInterfaceVisitsThis<SlotRequirementVisitorTypes, SlotExactRequirement>;
+template class ConstAcceptInterfaceVisitsThis<SlotRequirementVisitorTypes, SlotAnyLockedRequirement>;
+template class ConstAcceptInterfaceVisitsThis<SlotRequirementVisitorTypes, SlotAnyUnlockedRequirement>;
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const SlotRequirement & r)
+{
+ s << r.as_string();
+ return s;
+}
+
diff --git a/paludis/slot_requirement.hh b/paludis/slot_requirement.hh
new file mode 100644
index 0000000..9674ba9
--- /dev/null
+++ b/paludis/slot_requirement.hh
@@ -0,0 +1,68 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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_SLOT_REQUIREMENT_HH
+#define PALUDIS_GUARD_PALUDIS_SLOT_REQUIREMENT_HH 1
+
+#include <paludis/slot_requirement-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/util/visitor.hh>
+
+namespace paludis
+{
+ struct SlotRequirementVisitorTypes :
+ VisitorTypes<
+ SlotRequirementVisitorTypes,
+ SlotRequirement,
+ SlotExactRequirement,
+ SlotAnyLockedRequirement,
+ SlotAnyUnlockedRequirement
+ >
+ {
+ };
+
+ class PALUDIS_VISIBLE SlotRequirement :
+ public virtual ConstAcceptInterface<SlotRequirementVisitorTypes>
+ {
+ public:
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ class PALUDIS_VISIBLE SlotExactRequirement :
+ public SlotRequirement,
+ public ConstAcceptInterfaceVisitsThis<SlotRequirementVisitorTypes, SlotExactRequirement>
+ {
+ public:
+ virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ class PALUDIS_VISIBLE SlotAnyLockedRequirement :
+ public SlotRequirement,
+ public ConstAcceptInterfaceVisitsThis<SlotRequirementVisitorTypes, SlotAnyLockedRequirement>
+ {
+ };
+
+ class PALUDIS_VISIBLE SlotAnyUnlockedRequirement :
+ public SlotRequirement,
+ public ConstAcceptInterfaceVisitsThis<SlotRequirementVisitorTypes, SlotAnyUnlockedRequirement>
+ {
+ };
+}
+
+#endif
diff --git a/paludis/stringify_formatter_TEST.cc b/paludis/stringify_formatter_TEST.cc
index c1e85f3..1b7a5e5 100644
--- a/paludis/stringify_formatter_TEST.cc
+++ b/paludis/stringify_formatter_TEST.cc
@@ -23,6 +23,7 @@
#include <paludis/util/options.hh>
#include <paludis/dep_spec.hh>
#include <paludis/dep_tree.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
#include <paludis/util/clone-impl.hh>
diff --git a/paludis/uninstall_list.cc b/paludis/uninstall_list.cc
index 5539ed0..bb42877 100644
--- a/paludis/uninstall_list.cc
+++ b/paludis/uninstall_list.cc
@@ -24,6 +24,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
#include <paludis/util/set.hh>
#include <paludis/util/set-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
@@ -38,6 +39,7 @@
#include <paludis/query.hh>
#include <paludis/metadata_key.hh>
#include <paludis/dep_tag.hh>
+#include <paludis/slot_requirement.hh>
#include <list>
#include <algorithm>
#include <set>
@@ -276,8 +278,13 @@ namespace
Save<tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c(
&conditions, ConditionTracker(conditions).add_condition(a));
+ bool best_only(false);
+ if (a.slot_requirement_ptr())
+ best_only = visitor_cast<const SlotAnyUnlockedRequirement>(*a.slot_requirement_ptr());
+
tr1::shared_ptr<const PackageIDSequence> m(env->package_database()->query(
- query::Matches(a) & query::InstalledAtRoot(env->root()), qo_order_by_version));
+ query::Matches(a) & query::InstalledAtRoot(env->root()),
+ best_only ? qo_best_version_only : qo_order_by_version));
for (PackageIDSequence::ConstIterator it = m->begin(), it_end = m->end();
it_end != it; ++it)
matches->insert(DepTagEntry(tr1::shared_ptr<const DepTag>(new DependencyDepTag(*it, a, conditions)), 0));
diff --git a/paludis/uninstall_list_TEST.cc b/paludis/uninstall_list_TEST.cc
index 4839416..94f822f 100644
--- a/paludis/uninstall_list_TEST.cc
+++ b/paludis/uninstall_list_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 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
@@ -26,6 +26,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/options.hh>
#include <paludis/package_database.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <string>
@@ -61,6 +62,7 @@ namespace test_cases
tr1::shared_ptr<PackageIDSequence> targets;
std::list<std::string> expected;
bool done_populate;
+ bool unused_target;
/**
* Constructor.
@@ -71,7 +73,8 @@ namespace test_cases
installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed"))),
virtuals_repo(new VirtualsRepository(&env)),
targets(new PackageIDSequence),
- done_populate(false)
+ done_populate(false),
+ unused_target(false)
{
env.package_database()->add_repository(2, installed_repo);
env.package_database()->add_repository(1, virtuals_repo);
@@ -96,6 +99,11 @@ namespace test_cases
RepositoryName("installed")));
}
+ void add_unused_target()
+ {
+ unused_target = true;
+ }
+
/**
* Populate our expected member.
*/
@@ -108,18 +116,21 @@ namespace test_cases
{
TEST_CHECK(true);
UninstallList d(&env, options());
- for (PackageIDSequence::ConstIterator i(targets->begin()),
- i_end(targets->end()) ; i != i_end ; ++i)
- d.add(*i);
+ if (unused_target)
+ d.add_unused();
+ else
+ for (PackageIDSequence::ConstIterator i(targets->begin()),
+ i_end(targets->end()) ; i != i_end ; ++i)
+ d.add(*i);
TEST_CHECK(true);
- unsigned n(0);
+ TestMessageSuffix s("got={ " + join(d.begin(), d.end(), ", ") + " }", false);
+ TestMessageSuffix s2("expected={ " + join(expected.begin(), expected.end(), ", ") + " }", false);
+
std::list<std::string>::const_iterator exp(expected.begin());
UninstallList::ConstIterator got(d.begin());
while (true)
{
- TestMessageSuffix s(stringify(n++), true);
-
TEST_CHECK((exp == expected.end()) == (got == d.end()));
if (got == d.end())
break;
@@ -409,6 +420,70 @@ namespace test_cases
.with_dependencies_as_errors(false);
}
} uninstall_list_with_unused_deps_world_target_test;
+
+ struct UninstallListWithSlotsTest :
+ UninstallListTestCaseBase
+ {
+ UninstallListWithSlotsTest() :
+ UninstallListTestCaseBase("with slots")
+ {
+ tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > world(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+ world->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_user_package_dep_spec("cat/needs-a", UserPackageDepSpecOptions()))))));
+ world->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_user_package_dep_spec("cat/needs-b", UserPackageDepSpecOptions()))))));
+ world->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_user_package_dep_spec("cat/needs-c", UserPackageDepSpecOptions()))))));
+ world->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_user_package_dep_spec("cat/needs-d", UserPackageDepSpecOptions()))))));
+ installed_repo->add_package_set(SetName("world"), world);
+ }
+
+ void populate_targets()
+ {
+ add_unused_target();
+ }
+
+ void populate_repo()
+ {
+ installed_repo->add_version("cat", "needs-a", "1")->run_dependencies_key()->set_from_string("cat/a:1");
+ installed_repo->add_version("cat", "needs-b", "1")->run_dependencies_key()->set_from_string("cat/b:2");
+ installed_repo->add_version("cat", "needs-c", "1")->run_dependencies_key()->set_from_string("cat/c");
+ installed_repo->add_version("cat", "needs-d", "1")->run_dependencies_key()->set_from_string("cat/d:*");
+
+ installed_repo->add_version("cat", "a", "1")->set_slot(SlotName("1"));
+ installed_repo->add_version("cat", "a", "2")->set_slot(SlotName("2"));
+
+ installed_repo->add_version("cat", "b", "1")->set_slot(SlotName("1"));
+ installed_repo->add_version("cat", "b", "2")->set_slot(SlotName("2"));
+
+ installed_repo->add_version("cat", "c", "1")->set_slot(SlotName("1"));
+ installed_repo->add_version("cat", "c", "2")->set_slot(SlotName("2"));
+
+ installed_repo->add_version("cat", "d", "1")->set_slot(SlotName("1"));
+ installed_repo->add_version("cat", "d", "2")->set_slot(SlotName("2"));
+ }
+
+ void populate_expected()
+ {
+ expected.push_back("cat/a-2:2::installed");
+ expected.push_back("cat/b-1:1::installed");
+ expected.push_back("cat/d-1:1::installed");
+ }
+
+ UninstallListOptions options()
+ {
+ return UninstallListOptions::create()
+ .with_unused_dependencies(false)
+ .with_dependencies_included(false)
+ .with_dependencies_as_errors(false);
+ }
+ } uninstall_list_slots_test;
}
diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc
index 1b5dd66..1b84f65 100644
--- a/paludis/uninstall_task.cc
+++ b/paludis/uninstall_task.cc
@@ -17,12 +17,13 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "uninstall_task.hh"
+#include <paludis/uninstall_task.hh>
#include <paludis/environment.hh>
#include <paludis/action.hh>
#include <paludis/uninstall_list.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/tasks_exceptions.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
@@ -436,7 +437,7 @@ namespace
void visit_leaf(const PackageDepSpec & a)
{
- if (! (a.slot_ptr() || (a.version_requirements_ptr() && ! a.version_requirements_ptr()->empty())))
+ if (! (a.slot_requirement_ptr() || (a.version_requirements_ptr() && ! a.version_requirements_ptr()->empty())))
{
for (PackageDatabase::RepositoryConstIterator r(env->package_database()->begin_repositories()),
r_end(env->package_database()->end_repositories()) ;
diff --git a/paludis/user_dep_spec-fwd.hh b/paludis/user_dep_spec-fwd.hh
new file mode 100644
index 0000000..3bfb13e
--- /dev/null
+++ b/paludis/user_dep_spec-fwd.hh
@@ -0,0 +1,52 @@
+/* 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_USER_DEP_SPEC_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_USER_DEP_SPEC_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/options-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+
+#include <paludis/user_dep_spec-se.hh>
+
+ /**
+ * Options for parse_user_package_dep_spec.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ typedef Options<UserPackageDepSpecOption> UserPackageDepSpecOptions;
+
+ /**
+ * Create a PackageDepSpec from user input.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ PackageDepSpec parse_user_package_dep_spec(const std::string &, const UserPackageDepSpecOptions &) PALUDIS_VISIBLE;
+
+ struct UserSlotExactRequirement;
+}
+
+#endif
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
new file mode 100644
index 0000000..83c46a0
--- /dev/null
+++ b/paludis/user_dep_spec.cc
@@ -0,0 +1,286 @@
+/* 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
+ */
+
+#include <paludis/user_dep_spec.hh>
+#include <paludis/environment.hh>
+#include <paludis/version_operator.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/version_requirements.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/log.hh>
+
+using namespace paludis;
+
+#include <paludis/user_dep_spec-se.cc>
+
+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 ? "disabled" : "enabled");
+ }
+
+ 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)
+{
+ Context context("When parsing package dep spec '" + ss + "':");
+
+ if (ss.empty())
+ throw PackageDepSpecError("Got empty dep spec");
+
+ std::string s(ss);
+ PartiallyMadePackageDepSpec result;
+ bool had_bracket_version_requirements(false);
+
+ std::string::size_type use_group_p;
+ while (std::string::npos != ((use_group_p = s.rfind('['))))
+ {
+ if (s.at(s.length() - 1) != ']')
+ throw PackageDepSpecError("Mismatched []");
+
+ std::string flag(s.substr(use_group_p + 1));
+ if (flag.length() < 2)
+ throw PackageDepSpecError("Invalid [] contents");
+
+ flag.erase(flag.length() - 1);
+
+ switch (flag.at(0))
+ {
+ case '<':
+ case '>':
+ case '=':
+ case '~':
+ {
+ char needed_mode(0);
+
+ while (! flag.empty())
+ {
+ Context cc("When parsing [] segment '" + flag + "':");
+
+ std::string op;
+ std::string::size_type opos(0);
+ while (opos < flag.length())
+ if (std::string::npos == std::string("><=~").find(flag.at(opos)))
+ break;
+ else
+ ++opos;
+
+ op = flag.substr(0, opos);
+ flag.erase(0, opos);
+
+ if (op.empty())
+ throw PackageDepSpecError("Missing operator inside []");
+
+ VersionOperator vop(op);
+
+ std::string ver;
+ opos = flag.find_first_of("|&");
+ if (std::string::npos == opos)
+ {
+ ver = flag;
+ flag.clear();
+ }
+ else
+ {
+ if (0 == needed_mode)
+ needed_mode = flag.at(opos);
+ else if (needed_mode != flag.at(opos))
+ throw PackageDepSpecError("Mixed & and | inside []");
+
+ result.version_requirements_mode(flag.at(opos) == '|' ? vr_or : vr_and);
+ ver = flag.substr(0, opos++);
+ flag.erase(0, opos);
+ }
+
+ if (ver.empty())
+ throw PackageDepSpecError("Missing version after operator '" + stringify(vop) + " inside []");
+
+ if ('*' == ver.at(ver.length() - 1))
+ {
+ ver.erase(ver.length() - 1);
+ if (vop == vo_equal)
+ vop = vo_equal_star;
+ else
+ throw PackageDepSpecError("Invalid use of * with operator '" + stringify(vop) + " inside []");
+ }
+
+ VersionSpec vs(ver);
+ result.version_requirement(VersionRequirement(vop, vs));
+ had_bracket_version_requirements = true;
+ }
+ }
+ break;
+
+ default:
+ {
+ tr1::shared_ptr<UserUseRequirement> req(new UserUseRequirement(flag));
+ result.additional_requirement(req);
+ }
+ break;
+ };
+
+ s.erase(use_group_p);
+ }
+
+ std::string::size_type repo_p;
+ if (std::string::npos != ((repo_p = s.rfind("::"))))
+ {
+ result.repository(RepositoryName(s.substr(repo_p + 2)));
+ s.erase(repo_p);
+ }
+
+ std::string::size_type slot_p;
+ if (std::string::npos != ((slot_p = s.rfind(':'))))
+ {
+ result.slot_requirement(make_shared_ptr(new UserSlotExactRequirement(SlotName(s.substr(slot_p + 1)))));
+ s.erase(slot_p);
+ }
+
+ if (std::string::npos != std::string("<>=~").find(s.at(0)))
+ {
+ if (had_bracket_version_requirements)
+ throw PackageDepSpecError("Cannot mix [] and traditional version specifications");
+
+ std::string::size_type p(1);
+ if (s.length() > 1 && std::string::npos != std::string("<>=~").find(s.at(1)))
+ ++p;
+ VersionOperator op(s.substr(0, p));
+ std::string::size_type q(p);
+
+ while (true)
+ {
+ if (p >= s.length())
+ throw PackageDepSpecError("Couldn't parse dep spec '" + ss + "'");
+ q = s.find('-', q + 1);
+ if ((std::string::npos == q) || (++q >= s.length()))
+ throw PackageDepSpecError("Couldn't parse dep spec '" + ss + "'");
+ if ((s.at(q) >= '0' && s.at(q) <= '9') || (0 == s.compare(q, 3, "scm")))
+ break;
+ }
+
+ std::string::size_type new_q(q);
+ while (true)
+ {
+ if (new_q >= s.length())
+ break;
+ new_q = s.find('-', new_q + 1);
+ if ((std::string::npos == new_q) || (++new_q >= s.length()))
+ break;
+ if (s.at(new_q) >= '0' && s.at(new_q) <= '9')
+ q = new_q;
+ }
+
+ std::string t(s.substr(p, q - p - 1));
+ if (t.length() >= 3 && (0 == t.compare(0, 2, "*/")))
+ {
+ if (! options[updso_allow_wildcards])
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
+
+ if (0 != t.compare(t.length() - 2, 2, "/*"))
+ result.package_name_part(PackageNamePart(t.substr(2)));
+ }
+ else if (t.length() >= 3 && (0 == t.compare(t.length() - 2, 2, "/*")))
+ {
+ if (! options[updso_allow_wildcards])
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
+
+ result.category_name_part(CategoryNamePart(t.substr(0, t.length() - 2)));
+ }
+ else
+ result.package(QualifiedPackageName(t));
+
+ if ('*' == s.at(s.length() - 1))
+ {
+ if (op != vo_equal)
+ Log::get_instance()->message(ll_qa, lc_context,
+ "Package dep spec '" + ss + "' uses * "
+ "with operator '" + stringify(op) +
+ "', pretending it uses the equals operator instead");
+ op = vo_equal_star;
+
+ result.version_requirement(VersionRequirement(op, VersionSpec(s.substr(q, s.length() - q - 1))));
+ }
+ else
+ result.version_requirement(VersionRequirement(op, VersionSpec(s.substr(q))));
+ }
+ else
+ {
+ if (s.length() >= 3 && (0 == s.compare(0, 2, "*/")))
+ {
+ if (! options[updso_allow_wildcards])
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
+
+ if (0 != s.compare(s.length() - 2, 2, "/*"))
+ result.package_name_part(PackageNamePart(s.substr(2)));
+ }
+ else if (s.length() >= 3 && (0 == s.compare(s.length() - 2, 2, "/*")))
+ {
+ if (! options[updso_allow_wildcards])
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "'");
+
+ result.category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
+ }
+ else
+ result.package(QualifiedPackageName(s));
+ }
+
+ return result;
+}
+
+UserSlotExactRequirement::UserSlotExactRequirement(const SlotName & s) :
+ _s(s)
+{
+}
+const SlotName
+UserSlotExactRequirement::slot() const
+{
+ return _s;
+}
+
+const std::string
+UserSlotExactRequirement::as_string() const
+{
+ return ":" + stringify(_s);
+}
+
diff --git a/paludis/user_dep_spec.hh b/paludis/user_dep_spec.hh
new file mode 100644
index 0000000..c5bda68
--- /dev/null
+++ b/paludis/user_dep_spec.hh
@@ -0,0 +1,48 @@
+/* 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_USER_DEP_SPEC_HH
+#define PALUDIS_GUARD_PALUDIS_USER_DEP_SPEC_HH 1
+
+#include <paludis/user_dep_spec-fwd.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/slot_requirement.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE UserSlotExactRequirement :
+ public SlotExactRequirement
+ {
+ private:
+ const SlotName _s;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ UserSlotExactRequirement(const SlotName &);
+
+ ///\}
+
+ virtual const SlotName slot() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/dep_spec.se b/paludis/user_dep_spec.se
index da551b5..86847b8 100644
--- a/paludis/dep_spec.se
+++ b/paludis/user_dep_spec.se
@@ -16,3 +16,4 @@ make_enum_UserPackageDepSpecOption()
*/
END
}
+
diff --git a/paludis/user_dep_spec_TEST.cc b/paludis/user_dep_spec_TEST.cc
new file mode 100644
index 0000000..af45312
--- /dev/null
+++ b/paludis/user_dep_spec_TEST.cc
@@ -0,0 +1,201 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ */
+
+#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/util/clone-impl.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/iterator_funcs.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/visitor_cast.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/version_requirements.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace paludis;
+using namespace test;
+
+namespace test_cases
+{
+ struct UserPackageDepSpecTest : TestCase
+ {
+ UserPackageDepSpecTest() : TestCase("user package dep spec") { }
+
+ void run()
+ {
+ PackageDepSpec a(parse_user_package_dep_spec("foo/bar", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(a, "foo/bar");
+ TEST_CHECK_STRINGIFY_EQUAL(*a.package_ptr(), "foo/bar");
+ TEST_CHECK(! a.slot_requirement_ptr());
+ TEST_CHECK(! a.version_requirements_ptr());
+
+ PackageDepSpec b(parse_user_package_dep_spec(">=foo/bar-1.2.3", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(b, ">=foo/bar-1.2.3");
+ TEST_CHECK_STRINGIFY_EQUAL(*b.package_ptr(), "foo/bar");
+ TEST_CHECK(! b.slot_requirement_ptr());
+ TEST_CHECK(b.version_requirements_ptr());
+ TEST_CHECK_EQUAL(std::distance(b.version_requirements_ptr()->begin(),
+ b.version_requirements_ptr()->end()), 1);
+ TEST_CHECK_STRINGIFY_EQUAL(b.version_requirements_ptr()->begin()->version_spec, "1.2.3");
+ TEST_CHECK_EQUAL(b.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
+
+ PackageDepSpec c(parse_user_package_dep_spec("foo/bar:baz", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(c, "foo/bar:baz");
+ TEST_CHECK_STRINGIFY_EQUAL(*c.package_ptr(), "foo/bar");
+ TEST_CHECK(c.slot_requirement_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*c.slot_requirement_ptr(), ":baz");
+ TEST_CHECK(! c.version_requirements_ptr());
+
+ PackageDepSpec d(parse_user_package_dep_spec("=foo/bar-1.2*:1.2.1", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(d, "=foo/bar-1.2*:1.2.1");
+ TEST_CHECK_STRINGIFY_EQUAL(*d.package_ptr(), "foo/bar");
+ TEST_CHECK(d.slot_requirement_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*d.slot_requirement_ptr(), ":1.2.1");
+ TEST_CHECK(d.version_requirements_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(d.version_requirements_ptr()->begin()->version_spec, "1.2");
+ TEST_CHECK_EQUAL(d.version_requirements_ptr()->begin()->version_operator, vo_equal_star);
+
+ PackageDepSpec e(parse_user_package_dep_spec("foo/bar:1.2.1", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(e, "foo/bar:1.2.1");
+ TEST_CHECK_STRINGIFY_EQUAL(*e.package_ptr(), "foo/bar");
+ TEST_CHECK(e.slot_requirement_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*e.slot_requirement_ptr(), ":1.2.1");
+ TEST_CHECK(! e.version_requirements_ptr());
+
+ PackageDepSpec f(parse_user_package_dep_spec("foo/bar:0", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(f, "foo/bar:0");
+ TEST_CHECK_STRINGIFY_EQUAL(*f.package_ptr(), "foo/bar");
+ TEST_CHECK(f.slot_requirement_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(*f.slot_requirement_ptr(), ":0");
+ TEST_CHECK(! f.version_requirements_ptr());
+
+ PackageDepSpec g(parse_user_package_dep_spec("foo/bar-100dpi", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(g, "foo/bar-100dpi");
+ TEST_CHECK_STRINGIFY_EQUAL(*g.package_ptr(), "foo/bar-100dpi");
+
+ PackageDepSpec h(parse_user_package_dep_spec(">=foo/bar-100dpi-1.23", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(h, ">=foo/bar-100dpi-1.23");
+ TEST_CHECK_STRINGIFY_EQUAL(*h.package_ptr(), "foo/bar-100dpi");
+ TEST_CHECK(h.version_requirements_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(h.version_requirements_ptr()->begin()->version_spec, "1.23");
+ TEST_CHECK_EQUAL(h.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
+
+ TEST_CHECK_THROWS(parse_user_package_dep_spec("", UserPackageDepSpecOptions()), PackageDepSpecError);
+ TEST_CHECK_THROWS(parse_user_package_dep_spec("=foo/bar-1.2[=1.3]", UserPackageDepSpecOptions()), PackageDepSpecError);
+
+ PackageDepSpec i(parse_user_package_dep_spec("foo/bar[one][-two]", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(i, "foo/bar[-two][one]");
+ TEST_CHECK_STRINGIFY_EQUAL(*i.package_ptr(), "foo/bar");
+ TEST_CHECK(! i.version_requirements_ptr());
+ TEST_CHECK(! i.repository_ptr());
+ TEST_CHECK(! i.slot_requirement_ptr());
+ 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");
+ TEST_CHECK_STRINGIFY_EQUAL(*j.package_ptr(), "foo/bar");
+ TEST_CHECK(j.version_requirements_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(j.version_requirements_ptr()->begin()->version_spec, "scm-r3");
+ TEST_CHECK_EQUAL(j.version_requirements_ptr()->begin()->version_operator, vo_equal);
+
+ PackageDepSpec k(parse_user_package_dep_spec("=foo/bar-scm", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(k, "=foo/bar-scm");
+ TEST_CHECK_STRINGIFY_EQUAL(*k.package_ptr(), "foo/bar");
+ TEST_CHECK(k.version_requirements_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(k.version_requirements_ptr()->begin()->version_spec, "scm");
+ TEST_CHECK_EQUAL(k.version_requirements_ptr()->begin()->version_operator, vo_equal);
+
+ PackageDepSpec l(parse_user_package_dep_spec("foo/bar[one][-two][>=1.2&<2.0]", UserPackageDepSpecOptions()));
+ TEST_CHECK_STRINGIFY_EQUAL(l, "foo/bar[>=1.2&<2.0][-two][one]");
+ TEST_CHECK_STRINGIFY_EQUAL(*l.package_ptr(), "foo/bar");
+ TEST_CHECK(l.version_requirements_ptr());
+ TEST_CHECK(! l.repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(l.version_requirements_ptr()->begin()->version_spec, "1.2");
+ TEST_CHECK_EQUAL(l.version_requirements_ptr()->begin()->version_operator, vo_greater_equal);
+ 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_requirement_ptr());
+
+ 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]");
+ TEST_CHECK_STRINGIFY_EQUAL(*m.package_ptr(), "foo/bar");
+ TEST_CHECK(m.version_requirements_ptr());
+ TEST_CHECK(! m.repository_ptr());
+ TEST_CHECK_STRINGIFY_EQUAL(m.version_requirements_ptr()->begin()->version_spec, "1.2");
+ TEST_CHECK_EQUAL(m.version_requirements_ptr()->begin()->version_operator, vo_equal);
+ TEST_CHECK_STRINGIFY_EQUAL(next(m.version_requirements_ptr()->begin())->version_spec, "1.3");
+ TEST_CHECK_EQUAL(next(m.version_requirements_ptr()->begin())->version_operator, vo_equal_star);
+ 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_requirement_ptr());
+ }
+ } test_user_package_dep_spec;
+
+ struct UserPackageDepSpecUnspecificTest : TestCase
+ {
+ UserPackageDepSpecUnspecificTest() : TestCase("user package dep spec unspecific") { }
+
+ void run()
+ {
+ PackageDepSpec a(parse_user_package_dep_spec("*/*", UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK_STRINGIFY_EQUAL(a, "*/*");
+ TEST_CHECK(! a.package_ptr());
+ TEST_CHECK(! a.package_name_part_ptr());
+ TEST_CHECK(! a.category_name_part_ptr());
+
+ PackageDepSpec b(parse_user_package_dep_spec("foo/*", UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK_STRINGIFY_EQUAL(b, "foo/*");
+ TEST_CHECK(! b.package_ptr());
+ TEST_CHECK(! b.package_name_part_ptr());
+ TEST_CHECK(b.category_name_part_ptr());
+ TEST_CHECK_EQUAL(*b.category_name_part_ptr(), CategoryNamePart("foo"));
+
+ PackageDepSpec c(parse_user_package_dep_spec("*/foo", UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK_STRINGIFY_EQUAL(c, "*/foo");
+ TEST_CHECK(! c.package_ptr());
+ TEST_CHECK(c.package_name_part_ptr());
+ TEST_CHECK_EQUAL(*c.package_name_part_ptr(), PackageNamePart("foo"));
+ TEST_CHECK(! c.category_name_part_ptr());
+
+ PackageDepSpec d(parse_user_package_dep_spec("~*/*-0", UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK_STRINGIFY_EQUAL(d, "~*/*-0");
+ TEST_CHECK(! d.package_ptr());
+ TEST_CHECK(! d.package_name_part_ptr());
+ TEST_CHECK(! d.category_name_part_ptr());
+
+ PackageDepSpec e(parse_user_package_dep_spec(">=foo/*-1.23", UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK_STRINGIFY_EQUAL(e, ">=foo/*-1.23");
+ TEST_CHECK(! e.package_ptr());
+ TEST_CHECK(! e.package_name_part_ptr());
+ TEST_CHECK(e.category_name_part_ptr());
+ TEST_CHECK_EQUAL(*e.category_name_part_ptr(), CategoryNamePart("foo"));
+
+ PackageDepSpec f(parse_user_package_dep_spec("=*/foo-1*", UserPackageDepSpecOptions() + updso_allow_wildcards));
+ TEST_CHECK_STRINGIFY_EQUAL(f, "=*/foo-1*");
+ TEST_CHECK(! f.package_ptr());
+ TEST_CHECK(f.package_name_part_ptr());
+ TEST_CHECK_EQUAL(*f.package_name_part_ptr(), PackageNamePart("foo"));
+ TEST_CHECK(! f.category_name_part_ptr());
+ }
+ } test_user_package_dep_spec_unspecific;
+}
+
diff --git a/python/additional_tests.cc b/python/additional_tests.cc
index 9bc2859..06e7a1e 100644
--- a/python/additional_tests.cc
+++ b/python/additional_tests.cc
@@ -32,6 +32,7 @@
#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/mask.hh>
#include <paludis/hook.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/options.hh>
#include <paludis/formatter.hh>
#include <paludis/stringify_formatter-impl.hh>
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index f9a605f..c76d598 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -17,13 +17,15 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "dep_spec.hh"
+#include <python/dep_spec.hh>
#include <python/paludis_python.hh>
#include <python/exception.hh>
#include <python/options.hh>
#include <python/nice_names-nn.hh>
#include <paludis/dep_tag.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/version_requirements.hh>
#include <paludis/util/clone-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
@@ -108,7 +110,7 @@ namespace paludis
tr1::shared_ptr<const PackageNamePart> package_name_part_ptr;
tr1::shared_ptr<VersionRequirements> version_requirements;
VersionRequirementsMode version_requirements_mode;
- tr1::shared_ptr<const SlotName> slot;
+ tr1::shared_ptr<const SlotRequirement> slot;
tr1::shared_ptr<const RepositoryName> repository;
tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements;
tr1::shared_ptr<const DepTag> tag;
@@ -120,7 +122,7 @@ namespace paludis
const tr1::shared_ptr<const PackageNamePart> & p,
const tr1::shared_ptr<VersionRequirements> & v,
const VersionRequirementsMode m,
- const tr1::shared_ptr<const SlotName> & s,
+ const tr1::shared_ptr<const SlotRequirement> & s,
const tr1::shared_ptr<const RepositoryName> & r,
const tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> & u,
const tr1::shared_ptr<const DepTag> & t,
@@ -256,7 +258,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
deep_copy(p.package_name_part_ptr()),
make_shared_ptr(new VersionRequirements),
p.version_requirements_mode(),
- deep_copy(p.slot_ptr()),
+ p.slot_requirement_ptr(),
deep_copy(p.repository_ptr()),
p.additional_requirements_ptr(),
p.tag(),
@@ -277,7 +279,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) :
deep_copy(p.package_name_part_ptr()),
make_shared_ptr(new VersionRequirements),
p.version_requirements_mode(),
- deep_copy(p.slot_ptr()),
+ p.slot_requirement_ptr(),
deep_copy(p.repository_ptr()),
p.additional_requirements_ptr(),
p.tag(),
@@ -306,8 +308,8 @@ PythonPackageDepSpec::operator PackageDepSpec() const
p.version_requirements_mode(version_requirements_mode());
- if (slot_ptr())
- p.slot(*slot_ptr());
+ if (slot_requirement_ptr())
+ p.slot_requirement(slot_requirement_ptr());
if (repository_ptr())
p.repository(*repository_ptr());
@@ -385,8 +387,8 @@ PythonPackageDepSpec::set_version_requirements_mode(const VersionRequirementsMod
_imp->version_requirements_mode = m;
}
-tr1::shared_ptr<const SlotName>
-PythonPackageDepSpec::slot_ptr() const
+tr1::shared_ptr<const SlotRequirement>
+PythonPackageDepSpec::slot_requirement_ptr() const
{
return _imp->slot;
}
@@ -1219,10 +1221,12 @@ void expose_dep_spec()
"Version requirements mode."
)
+#if 0
.add_property("slot", &PythonPackageDepSpec::slot_ptr,
"[ro] SlotName\n"
"Slot name (may be None)."
)
+#endif
.add_property("repository", &PythonPackageDepSpec::repository_ptr,
"[ro] RepositoryName\n"
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index 2d279bc..7a5ed70 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -174,7 +174,7 @@ namespace paludis
tr1::shared_ptr<const VersionRequirements> version_requirements_ptr() const;
VersionRequirementsMode version_requirements_mode() const;
void set_version_requirements_mode(const VersionRequirementsMode m);
- tr1::shared_ptr<const SlotName> slot_ptr() const;
+ tr1::shared_ptr<const SlotRequirement> slot_requirement_ptr() const;
tr1::shared_ptr<const RepositoryName> repository_ptr() const;
tr1::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const;
tr1::shared_ptr<const DepTag> tag() const;
diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py
index d4dc53b..2326fa3 100755
--- a/python/dep_spec_TEST.py
+++ b/python/dep_spec_TEST.py
@@ -55,9 +55,9 @@ class TestCase_1_DepSpecs(unittest.TestCase):
self.assertEqual(str(self.bds.blocked_spec), ">=foo/bar-1:100::testrepo")
self.assertEqual(str(self.nds), "system")
- def test_04_slot(self):
- self.get_depspecs()
- self.assertEqual(str(self.pds.slot), "100")
+### def test_04_slot(self):
+### self.get_depspecs()
+### self.assertEqual(str(self.pds.slot), "100")
def test_05_package(self):
self.get_depspecs()
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index d289873..f726514 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -20,6 +20,7 @@
#include <paludis_ruby.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/version_requirements.hh>
#include <paludis/version_operator.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -665,6 +666,7 @@ namespace
return rb_str_new2(stringify(*tr1::static_pointer_cast<const WrappedSpec<T_> >(*ptr)->spec()).c_str());
}
+#if 0
/*
* call-seq:
* slot -> String or Nil
@@ -680,6 +682,7 @@ namespace
return Qnil;
return rb_str_new2(stringify((*tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->slot_ptr())).c_str());
}
+#endif
/*
* call-seq:
@@ -1045,7 +1048,9 @@ namespace
rb_define_method(c_package_dep_spec, "package", RUBY_FUNC_CAST(&package_dep_spec_package), 0);
rb_define_method(c_package_dep_spec, "package_name_part", RUBY_FUNC_CAST(&package_dep_spec_package_name_part), 0);
rb_define_method(c_package_dep_spec, "category_name_part", RUBY_FUNC_CAST(&package_dep_spec_category_name_part), 0);
+#ifdef CIARANM_REMOVED_THIS
rb_define_method(c_package_dep_spec, "slot", RUBY_FUNC_CAST(&package_dep_spec_slot_ptr), 0);
+#endif
rb_define_method(c_package_dep_spec, "repository", RUBY_FUNC_CAST(&package_dep_spec_repository_ptr), 0);
rb_define_method(c_package_dep_spec, "version_requirements", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_ptr), 0);
rb_define_method(c_package_dep_spec, "version_requirements_mode", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_mode), 0);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 9b47b59..5abaaf3 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -86,10 +86,10 @@ module Paludis
assert_equal "*/bar", pdb.text
end
- def test_slot
- assert_equal "100", pda.slot
- assert_nil pdb.slot
- end
+### def test_slot
+### assert_equal "100", pda.slot
+### assert_nil pdb.slot
+### end
def test_package
assert_equal QualifiedPackageName.new("foo/bar"), pda.package
diff --git a/src/clients/adjutrix/downgrade_check.cc b/src/clients/adjutrix/downgrade_check.cc
index 3bcdff7..dc11d2b 100644
--- a/src/clients/adjutrix/downgrade_check.cc
+++ b/src/clients/adjutrix/downgrade_check.cc
@@ -26,7 +26,9 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/iterator_funcs.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/package_id.hh>
+#include <paludis/user_dep_spec.hh>
#include <fstream>
#include <iostream>
#include <vector>
@@ -138,7 +140,7 @@ namespace
{
if (! env.package_database()->query(query::Matches(make_package_dep_spec()
.package(b->first.name)
- .slot(b->first.slot)),
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(b->first.slot)))),
qo_whatever)->empty())
{
results.insert(std::make_pair(b->first, stringify(b->second) + " -> nothing on " + desc));
diff --git a/src/clients/adjutrix/find_reverse_deps.cc b/src/clients/adjutrix/find_reverse_deps.cc
index 5ab5eb1..9277140 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -29,6 +29,7 @@
#include <paludis/util/options.hh>
#include <paludis/query.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/package_id.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
index 2a442b2..baf9723 100644
--- a/src/clients/adjutrix/what_needs_keywording.cc
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -37,6 +37,7 @@
#include <paludis/mask.hh>
#include <paludis/fuzzy_finder.hh>
#include <paludis/query.hh>
+#include <paludis/user_dep_spec.hh>
#include <set>
#include <map>
diff --git a/src/clients/contrarius/stage.cc b/src/clients/contrarius/stage.cc
index 9b34e31..6150f93 100644
--- a/src/clients/contrarius/stage.cc
+++ b/src/clients/contrarius/stage.cc
@@ -25,6 +25,7 @@
#include <paludis/package_database.hh>
#include <paludis/environments/adapted/adapted_environment.hh>
#include <paludis/query.hh>
+#include <paludis/user_dep_spec.hh>
#include <string>
#include <paludis/util/tr1_memory.hh>
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
index 23e1968..63a909e 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
@@ -9,6 +9,7 @@
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_id.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/tr1_functional.hh>
@@ -139,7 +140,7 @@ namespace
query::Matches(pds) &
query::Matches(make_package_dep_spec()
.package(id->name())
- .slot(id->slot())),
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(id->slot())))),
qo_order_by_version));
paludis::tr1::shared_ptr<const PackageIDSequence> av(
@@ -148,7 +149,7 @@ namespace
query::Matches(pds) &
query::Matches(make_package_dep_spec()
.package(id->name())
- .slot(id->slot())) &
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(id->slot())))) &
query::NotMasked(),
qo_order_by_version));
@@ -178,7 +179,7 @@ namespace
query::Matches(pds) &
query::Matches(make_package_dep_spec()
.package(id->name())
- .slot(id->slot())) &
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(id->slot())))) &
query::SupportsAction<InstallAction>() &
query::NotMasked(),
qo_order_by_version));
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index 4b12883..988ae51 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -22,6 +22,7 @@
#include "src/output/colour.hh"
#include "src/output/colour_formatter.hh"
#include <paludis/about.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/visitor_cast.hh>
diff --git a/src/clients/reconcilio/fix_linkage.cc b/src/clients/reconcilio/fix_linkage.cc
index 5bc6f71..894a6db 100644
--- a/src/clients/reconcilio/fix_linkage.cc
+++ b/src/clients/reconcilio/fix_linkage.cc
@@ -31,6 +31,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
#include <paludis/name.hh>
#include <paludis/package_id.hh>
#include <paludis/version_requirements.hh>
@@ -104,11 +105,11 @@ do_fix_linkage(const tr1::shared_ptr<Environment> & env)
targets->push_back(stringify(make_package_dep_spec()
.package((*pkg_it)->name())
.version_requirement(VersionRequirement(vo_equal, (*pkg_it)->version()))
- .slot((*pkg_it)->slot())));
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement((*pkg_it)->slot())))));
else
targets->push_back(stringify(make_package_dep_spec()
.package((*pkg_it)->name())
- .slot((*pkg_it)->slot())));
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement((*pkg_it)->slot())))));
}
tr1::shared_ptr<const PackageID> orphans;
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index fd59cdd..f539238 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -37,6 +37,7 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/kc.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/query.hh>
#include <paludis/action.hh>
#include <paludis/repository.hh>
@@ -46,6 +47,7 @@
#include <paludis/mask.hh>
#include <paludis/hook.hh>
#include <paludis/fuzzy_finder.hh>
+#include <paludis/user_dep_spec.hh>
#include <algorithm>
#include <set>
@@ -360,8 +362,14 @@ ConsoleInstallTask::on_display_merge_list_entry(const DepListEntry & d)
tr1::shared_ptr<const PackageIDSequence> existing_slot_repo(environment()->package_database()->
query(query::Matches(repo ?
- make_package_dep_spec().package(d.package_id->name()).slot(d.package_id->slot()).repository(*repo) :
- make_package_dep_spec().package(d.package_id->name()).slot(d.package_id->slot())),
+ make_package_dep_spec()
+ .package(d.package_id->name())
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(d.package_id->slot())))
+ .repository(*repo) :
+ make_package_dep_spec()
+ .package(d.package_id->name())
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(d.package_id->slot())))
+ ),
qo_order_by_version));
display_merge_list_entry_start(d, m);
@@ -969,7 +977,7 @@ ConsoleInstallTask::display_merge_list_entry_repository(const DepListEntry & d,
environment()->package_database()->query(
query::Matches(make_package_dep_spec()
.package(d.package_id->name())
- .slot(d.package_id->slot())) &
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(d.package_id->slot())))) &
query::InstalledAtRoot(environment()->root()),
qo_best_version_only));
bool changed(normal_entry == m &&
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 551c418..eddd7bc 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.additional_requirements_ptr() ||
+ if (a.version_requirements_ptr() || a.slot_requirement_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.additional_requirements_ptr() ||
+ if (a.version_requirements_ptr() || a.slot_requirement_ptr() || a.additional_requirements_ptr() ||
a.repository_ptr())
{
std::string pad(std::max<long>(1, 30 - stringify(a).length()), ' ');