aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-02 00:45:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-02 00:45:40 +0000
commit1c22d3e80fc3c4cd50e163fc2ae9f0f75de6db1a (patch)
tree306f97b9a1d8e7f5d24e674bb1e1ff623bd52402
parentcfde917750de96cf0c5d660f87e0e8e514b20cc0 (diff)
downloadpaludis-1c22d3e80fc3c4cd50e163fc2ae9f0f75de6db1a.tar.gz
paludis-1c22d3e80fc3c4cd50e163fc2ae9f0f75de6db1a.tar.xz
Abstractify PackageDepSpec, to allow repositories to display deps in their native formats. Fixes: ticket:333
-rw-r--r--doc/api/cplusplus/examples/example_action.cc2
-rw-r--r--doc/api/cplusplus/examples/example_contents.cc2
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec.cc9
-rw-r--r--doc/api/cplusplus/examples/example_environment.cc2
-rw-r--r--doc/api/cplusplus/examples/example_formatter.cc2
-rw-r--r--doc/api/cplusplus/examples/example_mask.cc2
-rw-r--r--doc/api/cplusplus/examples/example_match_package.cc2
-rw-r--r--doc/api/cplusplus/examples/example_metadata_key.cc2
-rw-r--r--doc/api/cplusplus/examples/example_package_id.cc2
-rw-r--r--doc/api/cplusplus/examples/example_query.cc6
-rw-r--r--doc/api/cplusplus/examples/example_stringify_formatter.cc2
-rw-r--r--doc/api/ruby/example_action.rb2
-rw-r--r--doc/api/ruby/example_contents.rb2
-rw-r--r--doc/api/ruby/example_dep_spec.rb7
-rw-r--r--doc/api/ruby/example_environment.rb2
-rw-r--r--doc/api/ruby/example_query.rb6
-rw-r--r--paludis/dep_list.cc44
-rw-r--r--paludis/dep_list_TEST.cc50
-rw-r--r--paludis/dep_list_TEST.hh3
-rw-r--r--paludis/dep_list_TEST_blockers.cc16
-rw-r--r--paludis/dep_spec-fwd.hh32
-rw-r--r--paludis/dep_spec.cc1339
-rw-r--r--paludis/dep_spec.hh195
-rw-r--r--paludis/dep_spec.se17
-rw-r--r--paludis/dep_spec_TEST.cc66
-rw-r--r--paludis/environments/paludis/keywords_conf.cc4
-rw-r--r--paludis/environments/paludis/licenses_conf.cc4
-rw-r--r--paludis/environments/paludis/package_mask_conf.cc4
-rw-r--r--paludis/environments/paludis/paludis_environment.cc7
-rw-r--r--paludis/environments/paludis/paludis_environment_TEST.cc15
-rw-r--r--paludis/environments/paludis/use_conf.cc4
-rw-r--r--paludis/environments/portage/portage_environment.cc5
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc17
-rw-r--r--paludis/find_unused_packages_task.cc11
-rw-r--r--paludis/fuzzy_finder.cc3
-rw-r--r--paludis/install_task.cc33
-rw-r--r--paludis/package_database.cc5
-rw-r--r--paludis/package_database_TEST.cc27
-rw-r--r--paludis/query.cc16
-rw-r--r--paludis/range_rewriter.cc189
-rw-r--r--paludis/range_rewriter.hh16
-rw-r--r--paludis/range_rewriter_TEST.cc7
-rw-r--r--paludis/report_task.cc16
-rw-r--r--paludis/repositories/cran/Makefile.am4
-rw-r--r--paludis/repositories/cran/cran_dep_parser.cc51
-rw-r--r--paludis/repositories/cran/cran_dep_parser_TEST.cc21
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc14
-rw-r--r--paludis/repositories/cran/package_dep_spec.cc180
-rw-r--r--paludis/repositories/cran/package_dep_spec.hh34
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/dep_parser-fwd.hh4
-rw-r--r--paludis/repositories/e/dep_parser.cc46
-rw-r--r--paludis/repositories/e/dep_parser.se23
-rw-r--r--paludis/repositories/e/e_repository.cc15
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc135
-rw-r--r--paludis/repositories/e/e_repository_news.cc5
-rw-r--r--paludis/repositories/e/e_repository_profile.cc21
-rw-r--r--paludis/repositories/e/e_repository_sets.cc42
-rw-r--r--paludis/repositories/e/eapi.cc35
-rw-r--r--paludis/repositories/e/eapi.hh1
-rw-r--r--paludis/repositories/e/eapi.sr6
-rw-r--r--paludis/repositories/e/eapis/0.conf5
-rw-r--r--paludis/repositories/e/eapis/1.conf9
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf5
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf5
-rw-r--r--paludis/repositories/e/fetch_visitor_TEST.cc2
-rw-r--r--paludis/repositories/e/package_dep_spec.cc293
-rw-r--r--paludis/repositories/e/package_dep_spec.hh34
-rw-r--r--paludis/repositories/e/qa/visibility.cc44
-rw-r--r--paludis/repositories/e/qa/visibility_TEST.cc17
-rw-r--r--paludis/repositories/e/vdb_repository.cc15
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc8
-rw-r--r--paludis/repositories/unpackaged/dep_parser.cc3
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc2
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc17
-rw-r--r--paludis/repositories/virtuals/package_id.cc18
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc3
-rw-r--r--paludis/repositories/virtuals/virtuals_repository_TEST.cc18
-rw-r--r--paludis/set_file.cc8
-rw-r--r--paludis/set_file.hh2
-rw-r--r--paludis/set_file.sr2
-rw-r--r--paludis/set_file_TEST.cc9
-rw-r--r--paludis/stringify_formatter_TEST.cc5
-rw-r--r--paludis/uninstall_list_TEST.cc10
-rw-r--r--paludis/uninstall_task.cc23
-rw-r--r--paludis/version_requirements-fwd.hh9
-rw-r--r--paludis/version_requirements.cc8
-rw-r--r--ruby/dep_spec.cc95
-rw-r--r--ruby/dep_spec_TEST.rb32
-rw-r--r--ruby/environment_TEST.rb47
-rw-r--r--ruby/package_database_TEST.rb6
-rw-r--r--ruby/paludis_ruby_TEST.rb12
-rw-r--r--ruby/qualified_package_name_TEST.rb2
-rw-r--r--ruby/query_TEST.rb2
-rw-r--r--ruby/repository_TEST.rb3
-rw-r--r--src/clients/adjutrix/downgrade_check.cc10
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc10
-rw-r--r--src/clients/adjutrix/keywords_graph.cc11
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc7
-rw-r--r--src/clients/contrarius/stage.cc51
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc38
-rw-r--r--src/clients/inquisitio/do_search.cc2
-rw-r--r--src/clients/paludis/applets.cc8
-rw-r--r--src/clients/paludis/do_config.cc8
-rw-r--r--src/clients/paludis/do_contents.cc6
-rw-r--r--src/clients/paludis/info.cc6
-rw-r--r--src/clients/paludis/query.cc6
-rw-r--r--src/clients/reconcilio/fix_linkage.cc20
-rw-r--r--src/output/console_install_task.cc22
109 files changed, 2302 insertions, 1512 deletions
diff --git a/doc/api/cplusplus/examples/example_action.cc b/doc/api/cplusplus/examples/example_action.cc
index e00f42f..f00c58a 100644
--- a/doc/api/cplusplus/examples/example_action.cc
+++ b/doc/api/cplusplus/examples/example_action.cc
@@ -38,7 +38,7 @@ int main(int argc, char * argv[])
/* Fetch package IDs for 'sys-apps/paludis'. */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)),
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))),
qo_order_by_version));
/* For each ID: */
diff --git a/doc/api/cplusplus/examples/example_contents.cc b/doc/api/cplusplus/examples/example_contents.cc
index f728c24..6bfae68 100644
--- a/doc/api/cplusplus/examples/example_contents.cc
+++ b/doc/api/cplusplus/examples/example_contents.cc
@@ -80,7 +80,7 @@ int main(int argc, char * argv[])
/* Fetch package IDs for installed 'sys-apps/paludis'. */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)) &
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))) &
query::SupportsAction<InstalledAction>(),
qo_order_by_version));
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc
index 129c2b3..f21bdb8 100644
--- a/doc/api/cplusplus/examples/example_dep_spec.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec.cc
@@ -48,9 +48,12 @@ int main(int argc, char * argv[])
q_end(CommandLine::get_instance()->end_parameters()) ; q != q_end ; ++q)
{
/* Create a PackageDepSpec from the parameter. For user-inputted
- * data, pds_pm_permissive or pds_pm_unspecific should be used (only
- * the latter allows wildcards). */
- PackageDepSpec spec(*q, pds_pm_unspecific);
+ * data, parse_user_package_dep_spec() should be used. If wildcards
+ * are to be permitted, the updso_allow_wildcards option should be
+ * included. If data about the spec is known at compile time,
+ * make_package_dep_spec() should be used instead. */
+ PackageDepSpec spec(parse_user_package_dep_spec(
+ *q, UserPackageDepSpecOptions() + updso_allow_wildcards));
/* Display information about the PackageDepSpec. */
cout << "Information about '" << spec << "':" << endl;
diff --git a/doc/api/cplusplus/examples/example_environment.cc b/doc/api/cplusplus/examples/example_environment.cc
index 5b09235..4c91afd 100644
--- a/doc/api/cplusplus/examples/example_environment.cc
+++ b/doc/api/cplusplus/examples/example_environment.cc
@@ -66,7 +66,7 @@ int main(int argc, char * argv[])
/* And use flags, for which we need a package IDs: */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)) &
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))) &
query::SupportsAction<InstalledAction>(),
qo_order_by_version));
diff --git a/doc/api/cplusplus/examples/example_formatter.cc b/doc/api/cplusplus/examples/example_formatter.cc
index 51582a8..bc6aafb 100644
--- a/doc/api/cplusplus/examples/example_formatter.cc
+++ b/doc/api/cplusplus/examples/example_formatter.cc
@@ -160,7 +160,7 @@ int main(int argc, char * argv[])
/* Fetch package IDs for installable 'sys-apps/paludis'. */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)) &
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))) &
query::SupportsAction<InstallAction>(),
qo_order_by_version));
diff --git a/doc/api/cplusplus/examples/example_mask.cc b/doc/api/cplusplus/examples/example_mask.cc
index 1b60e77..c8fd2d8 100644
--- a/doc/api/cplusplus/examples/example_mask.cc
+++ b/doc/api/cplusplus/examples/example_mask.cc
@@ -85,7 +85,7 @@ int main(int argc, char * argv[])
/* Fetch package IDs for 'sys-apps/paludis'. */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)),
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))),
qo_order_by_version));
/* For each ID: */
diff --git a/doc/api/cplusplus/examples/example_match_package.cc b/doc/api/cplusplus/examples/example_match_package.cc
index dbe5404..90fdd6d 100644
--- a/doc/api/cplusplus/examples/example_match_package.cc
+++ b/doc/api/cplusplus/examples/example_match_package.cc
@@ -54,7 +54,7 @@ int main(int argc, char * argv[])
i != i_end ; ++i)
{
/* Is it paludis? */
- if (match_package(*env, PackageDepSpec("sys-apps/paludis", pds_pm_permissive), **i))
+ if (match_package(*env, make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis")), **i))
cout << left << setw(50) << (stringify(**i) + ":") << " " << "paludis" << endl;
/* No. Is it in system or world? */
diff --git a/doc/api/cplusplus/examples/example_metadata_key.cc b/doc/api/cplusplus/examples/example_metadata_key.cc
index c4b9662..8de9f39 100644
--- a/doc/api/cplusplus/examples/example_metadata_key.cc
+++ b/doc/api/cplusplus/examples/example_metadata_key.cc
@@ -245,7 +245,7 @@ int main(int argc, char * argv[])
/* Fetch package IDs for 'sys-apps/paludis'. */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)),
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))),
qo_order_by_version));
/* For each ID: */
diff --git a/doc/api/cplusplus/examples/example_package_id.cc b/doc/api/cplusplus/examples/example_package_id.cc
index b684e3a..71b5a94 100644
--- a/doc/api/cplusplus/examples/example_package_id.cc
+++ b/doc/api/cplusplus/examples/example_package_id.cc
@@ -47,7 +47,7 @@ int main(int argc, char * argv[])
/* Fetch package IDs for 'sys-apps/paludis'. */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)),
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))),
qo_order_by_version));
/* For each ID: */
diff --git a/doc/api/cplusplus/examples/example_query.cc b/doc/api/cplusplus/examples/example_query.cc
index 161e8cc..9e96ed7 100644
--- a/doc/api/cplusplus/examples/example_query.cc
+++ b/doc/api/cplusplus/examples/example_query.cc
@@ -60,19 +60,19 @@ int main(int argc, char * argv[])
CommandLine::get_instance()->a_environment.argument()));
/* Make some queries, and display what they give. */
- show_query(env, query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)));
+ show_query(env, query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))));
/* Queries can be combined. The resulting query is optimised internally,
* potentially giving better performance than doing things by hand. */
show_query(env,
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)) &
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))) &
query::SupportsAction<InstalledAction>());
/* Usually query::NotMasked should be combined with
* query::SupportsAction<InstallAction>, since installed packages aren't
* masked. */
show_query(env,
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)) &
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))) &
query::SupportsAction<InstallAction>() &
query::NotMasked());
diff --git a/doc/api/cplusplus/examples/example_stringify_formatter.cc b/doc/api/cplusplus/examples/example_stringify_formatter.cc
index 6f5d3b6..150de4e 100644
--- a/doc/api/cplusplus/examples/example_stringify_formatter.cc
+++ b/doc/api/cplusplus/examples/example_stringify_formatter.cc
@@ -39,7 +39,7 @@ int main(int argc, char * argv[])
/* Fetch package IDs for installable 'sys-apps/paludis'. */
tr1::shared_ptr<const PackageIDSequence> ids(env->package_database()->query(
- query::Matches(PackageDepSpec("sys-apps/paludis", pds_pm_permissive)) &
+ query::Matches(make_package_dep_spec().package(QualifiedPackageName("sys-apps/paludis"))) &
query::SupportsAction<InstallAction>(),
qo_order_by_version));
diff --git a/doc/api/ruby/example_action.rb b/doc/api/ruby/example_action.rb
index 21197b4..ca299c2 100644
--- a/doc/api/ruby/example_action.rb
+++ b/doc/api/ruby/example_action.rb
@@ -18,7 +18,7 @@ env = EnvironmentMaker.instance.make_from_spec(ExampleCommandLine.instance.envir
# Fetch package IDs for 'sys-apps/paludis'
ids = env.package_database.query(
- Query::Matches.new(PackageDepSpec.new("sys-apps/paludis", PackageDepSpecParseMode::Permissive)),
+ Query::Matches.new(Paludis::parse_user_package_dep_spec("sys-apps/paludis", [])),
QueryOrder::OrderByVersion)
# For each ID:
diff --git a/doc/api/ruby/example_contents.rb b/doc/api/ruby/example_contents.rb
index 26f2f9e..7020850 100644
--- a/doc/api/ruby/example_contents.rb
+++ b/doc/api/ruby/example_contents.rb
@@ -18,7 +18,7 @@ env = EnvironmentMaker.instance.make_from_spec(ExampleCommandLine.instance.envir
# Fetch package IDs for installed 'sys-apps/paludis'
ids = env.package_database.query(
- Query::Matches.new(PackageDepSpec.new("sys-apps/paludis", PackageDepSpecParseMode::Permissive)) &
+ Query::Matches.new(Paludis::parse_user_package_dep_spec("sys-apps/paludis", [])) &
Query::SupportsInstalledAction.new,
QueryOrder::OrderByVersion)
diff --git a/doc/api/ruby/example_dep_spec.rb b/doc/api/ruby/example_dep_spec.rb
index 5103b93..29b0e4a 100644
--- a/doc/api/ruby/example_dep_spec.rb
+++ b/doc/api/ruby/example_dep_spec.rb
@@ -17,10 +17,9 @@ env = EnvironmentMaker.instance.make_from_spec(ExampleCommandLine.instance.envir
# For each command line parameter:
ARGV.each do | arg |
- # Create a PackageDepSpec from the parameter. For user-inputted data,
- # PackageDepSpecParseMode::Permissive or PackageDepSpecParseMode::Unspecific should be used
- # (only the latter allows wildcards).
- spec = PackageDepSpec.new(arg, PackageDepSpecParseMode::Unspecific)
+ # Create a PackageDepSpec from the parameter. The second parameter should be either
+ # an empty array or [:allow_wildcards].
+ spec = Paludis::parse_user_package_dep_spec(arg, [:allow_wildcards])
# Display information about the PackageDepSpec.
puts "Information about '#{spec}':"
diff --git a/doc/api/ruby/example_environment.rb b/doc/api/ruby/example_environment.rb
index 6732162..888522e 100644
--- a/doc/api/ruby/example_environment.rb
+++ b/doc/api/ruby/example_environment.rb
@@ -42,7 +42,7 @@ end
# And use flags, for which we need package IDs:
ids = env.package_database.query(
- Query::Matches.new(PackageDepSpec.new('sys-apps/paludis', PackageDepSpecParseMode::Permissive)) &
+ Query::Matches.new(Paludis::parse_user_package_dep_spec('sys-apps/paludis', [])) &
Query::SupportsInstalledAction.new,
QueryOrder::OrderByVersion)
diff --git a/doc/api/ruby/example_query.rb b/doc/api/ruby/example_query.rb
index 00cecbd..3eecc0b 100644
--- a/doc/api/ruby/example_query.rb
+++ b/doc/api/ruby/example_query.rb
@@ -30,18 +30,18 @@ end
env = EnvironmentMaker.instance.make_from_spec(ExampleCommandLine.instance.environment)
# Make some queries, and display what they give.
-show_query(env, Query::Matches.new(PackageDepSpec.new("sys-apps/paludis", PackageDepSpecParseMode::Permissive)))
+show_query(env, Query::Matches.new(Paludis::parse_user_package_dep_spec("sys-apps/paludis", [])))
# Queries can be combined. The resulting query is optimised internally,
# potentially giving better performance than doing things by hand.
show_query(env,
- Query::Matches.new(PackageDepSpec.new("sys-apps/paludis", PackageDepSpecParseMode::Permissive)) &
+ Query::Matches.new(Paludis::parse_user_package_dep_spec("sys-apps/paludis", [])) &
Query::SupportsInstalledAction.new)
# Usually Query::NotMasked should be combined with Query::SupportsInstallAction,
# since installed packages aren't masked.
show_query(env,
- Query::Matches.new(PackageDepSpec.new("sys-apps/paludis", PackageDepSpecParseMode::Permissive)) &
+ Query::Matches.new(Paludis::parse_user_package_dep_spec("sys-apps/paludis", [])) &
Query::SupportsInstallAction.new &
Query::NotMasked.new)
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 3358e6e..1151ff8 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -271,8 +271,7 @@ namespace
{
return ! env.package_database()->query(
query::SupportsAction<InstalledAction>() &
- query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(*u->package_ptr())))),
+ query::Matches(make_package_dep_spec().package(*u->package_ptr())),
qo_whatever)->empty();
}
else
@@ -557,13 +556,9 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
tr1::shared_ptr<const PackageIDSequence> are_we_downgrading(
d->_imp->env->package_database()->query(
query::SupportsAction<InstalledAction>() &
- query::Matches(PackageDepSpec(
- make_shared_ptr(new QualifiedPackageName(best_visible_candidate->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- make_shared_ptr(new SlotName(best_visible_candidate->slot())))),
+ query::Matches(make_package_dep_spec()
+ .package(best_visible_candidate->name())
+ .slot(best_visible_candidate->slot())),
qo_order_by_version));
if (are_we_downgrading->empty())
@@ -652,14 +647,16 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
tr1::bind(&is_viable_any_child, tr1::cref(*d->_imp->env), d->_imp->current_package_id(), _1)))
return;
- RangeRewriter r;
- std::for_each(cur, end, accept_visitor(r));
- if (r.spec())
{
- Context context("When using rewritten range '" + stringify(*r.spec()) + "':");
- TreeLeaf<DependencySpecTree, PackageDepSpec> rr(r.spec());
- d->add_not_top_level(rr, destinations, conditions);
- return;
+ RangeRewriter r;
+ std::for_each(cur, end, accept_visitor(r));
+ tr1::shared_ptr<PackageDepSpec> rewritten_spec(r.spec());
+ if (rewritten_spec)
+ {
+ TreeLeaf<DependencySpecTree, PackageDepSpec> rr(r.spec());
+ d->add_not_top_level(rr, destinations, conditions);
+ return;
+ }
}
Save<tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c(
@@ -761,8 +758,7 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
if (a.blocked_spec()->package_ptr())
{
- PackageDepSpec just_package(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- *a.blocked_spec()->package_ptr())));
+ PackageDepSpec just_package(make_package_dep_spec().package(*a.blocked_spec()->package_ptr()));
already_installed = d->_imp->env->package_database()->query(
query::SupportsAction<InstalledAction>() &
query::Matches(just_package),
@@ -1039,13 +1035,9 @@ DepList::add_package(const tr1::shared_ptr<const PackageID> & p, tr1::shared_ptr
for (DepSpecFlattener<ProvideSpecTree, PackageDepSpec>::ConstIterator i(f.begin()), i_end(f.end()) ; i != i_end ; ++i)
{
- tr1::shared_ptr<VersionRequirements> v(new VersionRequirements);
- v->push_back(VersionRequirement(vo_equal, p->version()));
- tr1::shared_ptr<PackageDepSpec> pp(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName((*i)->text())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- v, vr_and));
+ tr1::shared_ptr<PackageDepSpec> pp(new PackageDepSpec(make_package_dep_spec()
+ .package(*(*i)->package_ptr())
+ .version_requirement(VersionRequirement(vo_equal, p->version()))));
std::pair<MergeListIndex::iterator, MergeListIndex::iterator> z;
if (pp->package_ptr())
@@ -1518,7 +1510,7 @@ DepList::replaced(const PackageID & m) const
std::pair<MergeListIndex::const_iterator, MergeListIndex::const_iterator> p(
_imp->merge_list_index.equal_range(m.name()));
- PackageDepSpec spec(make_shared_ptr(new QualifiedPackageName(m.name())));
+ PackageDepSpec spec(make_package_dep_spec().package(m.name()));
while (p.second != ((p.first = std::find_if(p.first, p.second,
MatchDepListEntryAgainstPackageDepSpec(_imp->env, spec)))))
{
diff --git a/paludis/dep_list_TEST.cc b/paludis/dep_list_TEST.cc
index 71c8ec8..d859caf 100644
--- a/paludis/dep_list_TEST.cc
+++ b/paludis/dep_list_TEST.cc
@@ -974,7 +974,7 @@ namespace test_cases
{
TEST_CHECK(true);
DepList d(&env, DepListOptions());
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
@@ -1001,7 +1001,7 @@ namespace test_cases
{
TEST_CHECK(true);
DepList d(&env, DepListOptions());
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
@@ -1068,7 +1068,7 @@ namespace test_cases
{
TEST_CHECK(true);
DepList d(&env, DepListOptions());
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
@@ -1095,7 +1095,7 @@ namespace test_cases
{
TEST_CHECK(true);
DepList d(&env, DepListOptions());
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
@@ -1416,11 +1416,11 @@ namespace test_cases
repo->add_version("cat", "seven", "1")->build_dependencies_key()->set_from_string("cat/doesnotexist");
DepList d(&env, DepListOptions());
- d.add(PackageDepSpec("cat/one", pds_pm_permissive), env.default_destinations());
+ d.add(PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(join(d.begin(), d.end(), " "),
"cat/four-1:0::repo cat/two-1:0::repo cat/three-1:0::repo cat/one-1:0::repo");
- TEST_CHECK_THROWS(d.add(PackageDepSpec("cat/five", pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec("cat/five", UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK_EQUAL(join(d.begin(), d.end(), " "),
@@ -1454,11 +1454,11 @@ namespace test_cases
repo->add_version("cat", "seven", "1")->post_dependencies_key()->set_from_string("cat/doesnotexist");
DepList d(&env, DepListOptions());
- d.add(PackageDepSpec("cat/one", pds_pm_permissive), env.default_destinations());
+ d.add(PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(join(d.begin(), d.end(), " "),
"cat/four-1:0::repo cat/two-1:0::repo cat/three-1:0::repo cat/one-1:0::repo");
- TEST_CHECK_THROWS(d.add(PackageDepSpec("cat/five", pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec("cat/five", UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK_EQUAL(join(d.begin(), d.end(), " "),
@@ -1488,7 +1488,7 @@ namespace test_cases
installed_repo->add_version("cat", "one", "2");
DepList d(&env, DepListOptions());
- d.add(PackageDepSpec("cat/one", pds_pm_permissive), env.default_destinations());
+ d.add(PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(join(d.begin(), d.end(), " "), "cat/one-1:0::repo");
}
} test_dep_list_forced_downgrade_of_installed;
@@ -1515,7 +1515,7 @@ namespace test_cases
DepList d(&env, DepListOptions());
d.options()->fall_back = dl_fall_back_never;
- TEST_CHECK_THROWS(d.add(PackageDepSpec("cat/one", pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
}
} test_dep_list_fall_back_never;
@@ -1542,8 +1542,8 @@ namespace test_cases
DepList d(&env, DepListOptions());
d.options()->fall_back = dl_fall_back_as_needed;
- d.add(PackageDepSpec("cat/one", pds_pm_permissive), env.default_destinations());
- d.add(PackageDepSpec("cat/two", pds_pm_permissive), env.default_destinations());
+ d.add(PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions())), env.default_destinations());
+ d.add(PackageDepSpec(parse_user_package_dep_spec("cat/two", UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(join(d.begin(), d.end(), " "), "cat/two-2:0::installed_repo cat/one-1:0::repo");
}
} test_dep_list_fall_back_as_needed;
@@ -1571,14 +1571,14 @@ namespace test_cases
DepList d1(&env, DepListOptions());
d1.options()->fall_back = dl_fall_back_as_needed_except_targets;
- d1.add(PackageDepSpec("cat/one", pds_pm_permissive), env.default_destinations());
+ d1.add(PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(join(d1.begin(), d1.end(), " "), "cat/two-2:0::installed_repo cat/one-1:0::repo");
- TEST_CHECK_THROWS(d1.add(PackageDepSpec("cat/three", pds_pm_permissive),
+ TEST_CHECK_THROWS(d1.add(PackageDepSpec(parse_user_package_dep_spec("cat/three", UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
DepList d2(&env, DepListOptions());
d2.options()->fall_back = dl_fall_back_as_needed_except_targets;
- TEST_CHECK_THROWS(d2.add(PackageDepSpec("cat/two", pds_pm_permissive),
+ TEST_CHECK_THROWS(d2.add(PackageDepSpec(parse_user_package_dep_spec("cat/two", UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
DepList d3(&env, DepListOptions());
@@ -1586,18 +1586,18 @@ namespace test_cases
tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > t3(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
t3->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("cat/one", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions()))))));
t3->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("cat/two", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/two", UserPackageDepSpecOptions()))))));
TEST_CHECK_THROWS(d3.add(*t3, env.default_destinations()), DepListError);
DepList d4(&env, DepListOptions());
tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > t4(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
t4->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("cat/one", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions()))))));
t4->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("cat/three", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/three", UserPackageDepSpecOptions()))))));
TEST_CHECK_THROWS(d4.add(*t4, env.default_destinations()), DepListError);
}
} test_dep_list_fall_back_as_needed_not_targets;
@@ -1625,7 +1625,7 @@ namespace test_cases
DepList d1(&env, DepListOptions());
d1.options()->upgrade = dl_upgrade_as_needed;
- d1.add(PackageDepSpec("cat/one", pds_pm_permissive), env.default_destinations());
+ d1.add(PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(join(d1.begin(), d1.end(), " "), "cat/two-0:0::installed_repo cat/one-1:0::repo");
DepList d2(&env, DepListOptions());
@@ -1634,9 +1634,9 @@ namespace test_cases
tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > t2(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
t2->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("cat/one", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions()))))));
t2->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("cat/two", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("cat/two", UserPackageDepSpecOptions()))))));
d2.add(*t2, env.default_destinations());
TEST_CHECK_EQUAL(join(d2.begin(), d2.end(), " "), "cat/two-2:0::repo cat/one-1:0::repo");
}
@@ -1676,7 +1676,7 @@ namespace test_cases
DepList d1(&env, DepListOptions());
d1.options()->reinstall_scm = dl_reinstall_scm_always;
- d1.add(PackageDepSpec("cat/zero", pds_pm_permissive), env.default_destinations());
+ d1.add(PackageDepSpec(parse_user_package_dep_spec("cat/zero", UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(join(d1.begin(), d1.end(), " "), "cat/one-scm:0::repo cat/two-2:0::installed_repo "
"cat/three-live-0:0::repo cat/four-cvs-0:0::repo cat/five-svn-0:0::repo cat/six-darcs-0:0::repo "
"cat/zero-1:0::repo");
@@ -1707,10 +1707,10 @@ namespace test_cases
DepList d1(&env, DepListOptions());
d1.options()->dependency_tags = true;
- PackageDepSpec with_target_tag("cat/one", pds_pm_permissive);
+ PackageDepSpec with_target_tag(parse_user_package_dep_spec("cat/one", UserPackageDepSpecOptions()));
with_target_tag.set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
d1.add(with_target_tag, env.default_destinations());
- PackageDepSpec with_set_tag("cat/two", pds_pm_permissive);
+ PackageDepSpec with_set_tag(parse_user_package_dep_spec("cat/two", UserPackageDepSpecOptions()));
with_set_tag.set_tag(tr1::shared_ptr<const DepTag>(new GeneralSetDepTag(SetName("set"), "test")));
d1.add(with_set_tag, env.default_destinations());
diff --git a/paludis/dep_list_TEST.hh b/paludis/dep_list_TEST.hh
index 2ff9073..5be6686 100644
--- a/paludis/dep_list_TEST.hh
+++ b/paludis/dep_list_TEST.hh
@@ -132,7 +132,8 @@ namespace test_cases
{
DepList d(&env, DepListOptions());
set_options(*d.options());
- d.add(PackageDepSpec(merge_target, pds_pm_unspecific), env.default_destinations());
+ d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions() + updso_allow_wildcards)),
+ env.default_destinations());
TEST_CHECK(true);
TestMessageSuffix s("got={ " + join(d.begin(), d.end(), ", ") + " }", false);
diff --git a/paludis/dep_list_TEST_blockers.cc b/paludis/dep_list_TEST_blockers.cc
index 96bae43..ca6eddb 100644
--- a/paludis/dep_list_TEST_blockers.cc
+++ b/paludis/dep_list_TEST_blockers.cc
@@ -47,12 +47,12 @@ namespace test_cases
TEST_CHECK(true);
DepList d(&env, DepListOptions());
d.options()->blocks = dl_blocks_error;
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions()),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
d.options()->blocks = dl_blocks_accumulate;
- d.add(PackageDepSpec(merge_target, pds_pm_permissive), env.default_destinations());
+ d.add(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions()), env.default_destinations());
TEST_CHECK_EQUAL(std::distance(d.begin(), d.end()), 2);
TEST_CHECK_EQUAL(d.begin()->kind, dlk_block);
TEST_CHECK_STRINGIFY_EQUAL(*d.begin()->package_id, "cat/two-1:0::installed");
@@ -123,12 +123,12 @@ namespace test_cases
TEST_CHECK(true);
DepList d(&env, DepListOptions());
d.options()->blocks = dl_blocks_error;
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
d.options()->blocks = dl_blocks_accumulate;
- d.add(PackageDepSpec(merge_target, pds_pm_permissive), env.default_destinations());
+ d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())), env.default_destinations());
TEST_CHECK_EQUAL(std::distance(d.begin(), d.end()), 4);
TEST_CHECK_EQUAL(d.begin()->kind, dlk_block);
TEST_CHECK_STRINGIFY_EQUAL(*d.begin()->package_id, "virtual/two-1::installed-virtuals (virtual for other/two-1:0::installed)");
@@ -162,7 +162,7 @@ namespace test_cases
TEST_CHECK(true);
DepList d(&env, DepListOptions());
d.options()->blocks = dl_blocks_error;
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
@@ -302,7 +302,7 @@ namespace test_cases
TEST_CHECK(true);
DepList d(&env, DepListOptions());
d.options()->blocks = dl_blocks_error;
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
@@ -331,7 +331,7 @@ namespace test_cases
TEST_CHECK(true);
DepList d(&env, DepListOptions());
d.options()->blocks = dl_blocks_error;
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
@@ -360,7 +360,7 @@ namespace test_cases
TEST_CHECK(true);
DepList d(&env, DepListOptions());
d.options()->blocks = dl_blocks_error;
- TEST_CHECK_THROWS(d.add(PackageDepSpec(merge_target, pds_pm_permissive),
+ TEST_CHECK_THROWS(d.add(PackageDepSpec(parse_user_package_dep_spec(merge_target, UserPackageDepSpecOptions())),
env.default_destinations()), DepListError);
TEST_CHECK(d.begin() == d.end());
}
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index 6b4f593..de70dd3 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -26,6 +26,8 @@
#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/tr1_memory.hh>
/** \file
* Forward declarations for paludis/dep_spec.hh .
@@ -65,9 +67,39 @@ namespace paludis
*/
typedef LabelsDepSpec<DependencyLabelVisitorTypes> DependencyLabelsDepSpec;
+ class PackageDepSpecData;
+ class PartiallyMadePackageDepSpec;
+
#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.
+ *
+ * Note the return type is a PartiallyMadePackageDepSpec, which is implicitly convertible to
+ * a PackageDepSpec.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ PartiallyMadePackageDepSpec make_package_dep_spec() PALUDIS_VISIBLE;
+
+ /**
* A PlainTextDepSpec can be written to an ostream.
*
* \ingroup g_dep_spec
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index f023234..1ed9ce1 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -32,6 +32,9 @@
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <list>
#include <map>
@@ -59,50 +62,6 @@ DepSpec::as_package_dep_spec() const
return 0;
}
-namespace paludis
-{
- template<>
- struct Implementation<PackageDepSpec>
- {
- Mutex mutex;
-
- bool unique;
-
- tr1::shared_ptr<QualifiedPackageName> package_ptr;
- tr1::shared_ptr<CategoryNamePart> category_name_part_ptr;
- tr1::shared_ptr<PackageNamePart> package_name_part_ptr;
- tr1::shared_ptr<VersionRequirements> version_requirements;
- VersionRequirementsMode version_requirements_mode;
- tr1::shared_ptr<SlotName> slot;
- tr1::shared_ptr<RepositoryName> repository;
- tr1::shared_ptr<UseRequirements> use_requirements;
- tr1::shared_ptr<const DepTag> tag;
-
- Implementation(
- tr1::shared_ptr<QualifiedPackageName> q,
- tr1::shared_ptr<CategoryNamePart> c,
- tr1::shared_ptr<PackageNamePart> p,
- tr1::shared_ptr<VersionRequirements> v,
- VersionRequirementsMode m,
- tr1::shared_ptr<SlotName> s,
- tr1::shared_ptr<RepositoryName> r,
- tr1::shared_ptr<UseRequirements> u,
- tr1::shared_ptr<const DepTag> t) :
- unique(false),
- package_ptr(q),
- category_name_part_ptr(c),
- package_name_part_ptr(p),
- version_requirements(v),
- version_requirements_mode(m),
- slot(s),
- repository(r),
- use_requirements(u),
- tag(t)
- {
- }
- };
-}
-
AnyDepSpec::AnyDepSpec()
{
}
@@ -189,422 +148,6 @@ BlockDepSpec::BlockDepSpec(tr1::shared_ptr<const PackageDepSpec> a) :
{
}
-PackageDepSpec::PackageDepSpec(const QualifiedPackageName & our_package) :
- StringDepSpec(stringify(our_package)),
- PrivateImplementationPattern<PackageDepSpec>(new Implementation<PackageDepSpec>(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(our_package)),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(),
- tr1::shared_ptr<UseRequirements>(),
- tr1::shared_ptr<const DepTag>()))
-{
-}
-
-PackageDepSpec::PackageDepSpec(const PackageDepSpec & other) :
- Cloneable<DepSpec>(),
- StringDepSpec(stringify(other)),
- PrivateImplementationPattern<PackageDepSpec>(new Implementation<PackageDepSpec>(
- other._imp->package_ptr,
- other._imp->category_name_part_ptr,
- other._imp->package_name_part_ptr,
- other._imp->version_requirements,
- other._imp->version_requirements_mode,
- other._imp->slot,
- other._imp->repository,
- other._imp->use_requirements,
- other._imp->tag))
-{
-}
-
-PackageDepSpec::PackageDepSpec(const std::string & ss) :
- StringDepSpec(ss),
- PrivateImplementationPattern<PackageDepSpec>(new Implementation<PackageDepSpec>(
- tr1::shared_ptr<QualifiedPackageName>(),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(),
- tr1::shared_ptr<UseRequirements>(),
- tr1::shared_ptr<const DepTag>()))
-{
- _do_parse(ss, pds_pm_permissive);
- _imp->unique = true;
-}
-
-PackageDepSpec::PackageDepSpec(const std::string & ss, const PackageDepSpecParseMode p) :
- StringDepSpec(ss),
- PrivateImplementationPattern<PackageDepSpec>(new Implementation<PackageDepSpec>(
- tr1::shared_ptr<QualifiedPackageName>(),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(),
- tr1::shared_ptr<UseRequirements>(),
- tr1::shared_ptr<const DepTag>()))
-{
- _do_parse(ss, p);
- _imp->unique = true;
-}
-
-PackageDepSpec::PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName> q,
- tr1::shared_ptr<CategoryNamePart> c,
- tr1::shared_ptr<PackageNamePart> p,
- tr1::shared_ptr<VersionRequirements> v,
- VersionRequirementsMode m,
- tr1::shared_ptr<SlotName> s,
- tr1::shared_ptr<RepositoryName> r,
- tr1::shared_ptr<UseRequirements> u,
- tr1::shared_ptr<const DepTag> t) :
- StringDepSpec(""),
- PrivateImplementationPattern<PackageDepSpec>(new Implementation<PackageDepSpec>(
- q, c, p, v, m, s, r, u, t))
-{
- set_text(stringify(*this));
-}
-
-void
-StringDepSpec::set_text(const std::string & t)
-{
- _str = t;
-}
-
-void
-PackageDepSpec::_do_parse(const std::string & ss, const PackageDepSpecParseMode mode)
-{
- Context context("When parsing package dep spec '" + ss + "' with parse mode '" + stringify(mode) + "':");
-
- try
- {
- std::string s(ss);
-
- if (s.empty())
- throw PackageDepSpecError("Got empty dep spec");
-
- std::string::size_type use_group_p;
- while (std::string::npos != ((use_group_p = s.rfind('['))))
- {
- switch (mode)
- {
- case pds_pm_exheres_0:
- case pds_pm_unspecific:
- case pds_pm_permissive:
- case last_pds_pm:
- break;
-
- case pds_pm_eapi_0:
- case pds_pm_eapi_1:
- Log::get_instance()->message(ll_warning, lc_context, "[] dependencies not safe for use with this EAPI");
- break;
-
- case pds_pm_eapi_0_strict:
- case pds_pm_eapi_1_strict:
- throw PackageDepSpecError("[] dependencies not safe for use with this EAPI");
- }
-
- 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 '~':
- {
- _imp->version_requirements.reset(new VersionRequirements);
- 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 []");
-
- _imp->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);
- _imp->version_requirements->push_back(VersionRequirement(vop, vs));
- }
- }
- break;
-
- default:
- {
- UseFlagState state(use_enabled);
- if ('-' == flag.at(0))
- {
- state = use_disabled;
- flag.erase(0, 1);
- if (flag.empty())
- throw PackageDepSpecError("Invalid [] contents");
- }
- UseFlagName name(flag);
- if (! _imp->use_requirements)
- _imp->use_requirements.reset(new UseRequirements);
- if (! _imp->use_requirements->insert(name, state))
- throw PackageDepSpecError("Conflicting [] contents");
- }
- break;
- };
-
- s.erase(use_group_p);
- }
-
- std::string::size_type repo_p;
- if (std::string::npos != ((repo_p = s.rfind("::"))))
- {
- switch (mode)
- {
- case pds_pm_unspecific:
- case pds_pm_permissive:
- case last_pds_pm:
- break;
-
- case pds_pm_eapi_0:
- case pds_pm_eapi_1:
- Log::get_instance()->message(ll_warning, lc_context, "Repository dependencies not safe for use with this EAPI");
- break;
-
- case pds_pm_exheres_0:
- case pds_pm_eapi_0_strict:
- case pds_pm_eapi_1_strict:
- throw PackageDepSpecError("Repository dependencies not allowed with this EAPI");
- }
-
- _imp->repository.reset(new RepositoryName(s.substr(repo_p + 2)));
- s.erase(repo_p);
- }
-
- std::string::size_type slot_p;
- if (std::string::npos != ((slot_p = s.rfind(':'))))
- {
- switch (mode)
- {
- case pds_pm_unspecific:
- case pds_pm_permissive:
- case pds_pm_exheres_0:
- case pds_pm_eapi_1:
- case pds_pm_eapi_1_strict:
- case last_pds_pm:
- break;
-
- case pds_pm_eapi_0:
- Log::get_instance()->message(ll_warning, lc_context, "SLOT dependencies not safe for use with this EAPI");
- break;
-
- case pds_pm_eapi_0_strict:
- throw PackageDepSpecError("SLOT dependencies not safe for use with this EAPI");
- }
-
- _imp->slot.reset(new SlotName(s.substr(slot_p + 1)));
- s.erase(slot_p);
- }
-
- if (std::string::npos != std::string("<>=~").find(s.at(0)))
- {
- if (_imp->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));
-
- if (op == vo_tilde_greater)
- switch (mode)
- {
- case pds_pm_unspecific:
- case pds_pm_permissive:
- case pds_pm_exheres_0:
- case last_pds_pm:
- break;
-
- case pds_pm_eapi_0:
- case pds_pm_eapi_1:
- Log::get_instance()->message(ll_warning, lc_context, "~> dependencies not safe for use with this EAPI");
- break;
-
- case pds_pm_eapi_0_strict:
- case pds_pm_eapi_1_strict:
- throw PackageDepSpecError("~> dependencies not safe for use with this EAPI");
- }
-
- 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 (pds_pm_unspecific != mode)
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with parse mode '"
- + stringify(mode) + "'");
-
- if (0 != t.compare(t.length() - 2, 2, "/*"))
- _imp->package_name_part_ptr.reset(new PackageNamePart(t.substr(2)));
- }
- else if (t.length() >= 3 && (0 == t.compare(t.length() - 2, 2, "/*")))
- {
- if (pds_pm_unspecific != mode)
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with parse mode '"
- + stringify(mode) + "'");
-
- _imp->category_name_part_ptr.reset(new CategoryNamePart(t.substr(0, t.length() - 2)));
- }
- else
- _imp->package_ptr.reset(new QualifiedPackageName(t));
-
- _imp->version_requirements.reset(new VersionRequirements);
-
- if ('*' == s.at(s.length() - 1))
- {
- if (op != vo_equal)
- {
- switch (mode)
- {
- case pds_pm_unspecific:
- case pds_pm_permissive:
- case last_pds_pm:
- case pds_pm_eapi_0:
- case pds_pm_eapi_1:
- Log::get_instance()->message(ll_qa, lc_context,
- "Package dep spec '" + ss + "' uses * "
- "with operator '" + stringify(op) +
- "', pretending it uses the equals operator instead");
- break;
-
- case pds_pm_eapi_0_strict:
- case pds_pm_eapi_1_strict:
- case pds_pm_exheres_0:
- throw PackageDepSpecError(
- "Package dep spec '" + ss + "' uses * "
- "with operator '" + stringify(op) + "'");
- }
- }
- op = vo_equal_star;
-
- _imp->version_requirements->push_back(VersionRequirement(op, VersionSpec(s.substr(q, s.length() - q - 1))));
- }
- else
- _imp->version_requirements->push_back(VersionRequirement(op, VersionSpec(s.substr(q))));
- }
- else
- {
- if (s.length() >= 3 && (0 == s.compare(0, 2, "*/")))
- {
- if (pds_pm_unspecific != mode)
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with parse mode '"
- + stringify(mode) + "'");
-
- if (0 != s.compare(s.length() - 2, 2, "/*"))
- _imp->package_name_part_ptr.reset(new PackageNamePart(s.substr(2)));
- }
- else if (s.length() >= 3 && (0 == s.compare(s.length() - 2, 2, "/*")))
- {
- if (pds_pm_unspecific != mode)
- throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with parse mode '"
- + stringify(mode) + "'");
-
- _imp->category_name_part_ptr.reset(new CategoryNamePart(s.substr(0, s.length() - 2)));
- }
- else
- _imp->package_ptr.reset(new QualifiedPackageName(s));
- }
- }
- catch (Exception &)
- {
- throw;
- }
- catch (const std::exception & e)
- {
- throw InternalError(PALUDIS_HERE, "caught std::exception '"
- + stringify(e.what()) + "'");
- }
-}
-
-PackageDepSpec::~PackageDepSpec()
-{
-}
-
std::ostream &
paludis::operator<< (std::ostream & s, const PlainTextDepSpec & a)
{
@@ -663,115 +206,7 @@ paludis::operator<< (std::ostream & s, const SimpleURIDepSpec & p)
std::ostream &
paludis::operator<< (std::ostream & s, const PackageDepSpec & a)
{
- if (a.version_requirements_ptr())
- {
- if (a.version_requirements_ptr()->begin() == a.version_requirements_ptr()->end())
- {
- }
- else if (next(a.version_requirements_ptr()->begin()) == a.version_requirements_ptr()->end())
- {
- if (a.version_requirements_ptr()->begin()->version_operator == vo_equal_star)
- s << "=";
- else
- s << a.version_requirements_ptr()->begin()->version_operator;
- }
- }
-
- if (a.package_ptr())
- s << *a.package_ptr();
- else
- {
- if (a.category_name_part_ptr())
- s << *a.category_name_part_ptr();
- else
- s << "*";
-
- s << "/";
-
- if (a.package_name_part_ptr())
- s << *a.package_name_part_ptr();
- else
- s << "*";
- }
-
- if (a.version_requirements_ptr())
- {
- if (a.version_requirements_ptr()->begin() == a.version_requirements_ptr()->end())
- {
- }
- else if (next(a.version_requirements_ptr()->begin()) == a.version_requirements_ptr()->end())
- {
- s << "-" << a.version_requirements_ptr()->begin()->version_spec;
- if (a.version_requirements_ptr()->begin()->version_operator == vo_equal_star)
- s << "*";
- }
- }
-
- if (a.slot_ptr())
- s << ":" << *a.slot_ptr();
- if (a.repository_ptr())
- s << "::" << *a.repository_ptr();
-
- if (a.version_requirements_ptr())
- {
- if (a.version_requirements_ptr()->begin() == a.version_requirements_ptr()->end())
- {
- }
- else if (next(a.version_requirements_ptr()->begin()) == a.version_requirements_ptr()->end())
- {
- }
- else
- {
- bool need_op(false);
- s << "[";
- for (VersionRequirements::ConstIterator r(a.version_requirements_ptr()->begin()),
- r_end(a.version_requirements_ptr()->end()) ; r != r_end ; ++r)
- {
- if (need_op)
- {
- do
- {
- switch (a.version_requirements_mode())
- {
- case vr_and:
- s << "&";
- continue;
-
- case vr_or:
- s << "|";
- continue;
-
- case last_vr:
- ;
- }
- throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode");
- } while (false);
- }
-
- if (r->version_operator == vo_equal_star)
- s << "=";
- else
- s << r->version_operator;
-
- s << r->version_spec;
-
- if (r->version_operator == vo_equal_star)
- s << "*";
-
- need_op = true;
- }
- s << "]";
- }
- }
-
- if (a.use_requirements_ptr())
- {
- for (UseRequirements::ConstIterator u(a.use_requirements_ptr()->begin()),
- u_end(a.use_requirements_ptr()->end()) ; u != u_end ; ++u)
- s << "[" << (u->second == use_disabled ? "-" + stringify(u->first) :
- stringify(u->first)) << "]";
- }
-
+ s << a._as_string();
return s;
}
@@ -901,83 +336,231 @@ UseRequirements::state(const UseFlagName & u) const
return i->second;
}
-tr1::shared_ptr<PackageDepSpec>
-PackageDepSpec::without_use_requirements() const
+tr1::shared_ptr<const PackageDepSpec>
+BlockDepSpec::blocked_spec() const
{
- tr1::shared_ptr<PackageDepSpec> result(new PackageDepSpec(*this));
- result->_make_unique();
- result->_imp->use_requirements.reset();
- return result;
+ return _spec;
}
tr1::shared_ptr<DepSpec>
-PackageDepSpec::clone() const
+BlockDepSpec::clone() const
+{
+ return tr1::shared_ptr<DepSpec>(new BlockDepSpec(tr1::static_pointer_cast<PackageDepSpec>(_spec->clone())));
+}
+
+FetchableURIDepSpec::FetchableURIDepSpec(const std::string & s) :
+ StringDepSpec(s)
+{
+}
+
+std::string
+FetchableURIDepSpec::original_url() const
+{
+ std::string::size_type p(text().find(" -> "));
+ if (std::string::npos == p)
+ return text();
+ else
+ return text().substr(0, p);
+}
+
+std::string
+FetchableURIDepSpec::renamed_url_suffix() const
+{
+ std::string::size_type p(text().find(" -> "));
+ if (std::string::npos == p)
+ return "";
+ else
+ return text().substr(p + 4);
+}
+
+std::string
+FetchableURIDepSpec::filename() const
+{
+ std::string rus = renamed_url_suffix();
+ if (! rus.empty())
+ return rus;
+
+ std::string orig = original_url();
+ std::string::size_type p(orig.rfind('/'));
+
+ if (std::string::npos == p)
+ return orig;
+ return orig.substr(p+1);
+}
+
+tr1::shared_ptr<DepSpec>
+FetchableURIDepSpec::clone() const
+{
+ return tr1::shared_ptr<FetchableURIDepSpec>(new FetchableURIDepSpec(text()));
+}
+
+namespace paludis
+{
+#ifndef PALUDIS_NO_DOUBLE_TEMPLATE
+ template <>
+#endif
+ template <typename T_>
+ struct Implementation<LabelsDepSpec<T_ > >
+ {
+ std::list<tr1::shared_ptr<const typename T_::BasicNode> > items;
+ };
+}
+
+template <typename T_>
+LabelsDepSpec<T_>::LabelsDepSpec() :
+ PrivateImplementationPattern<LabelsDepSpec<T_> >(new Implementation<LabelsDepSpec<T_> >)
+{
+}
+
+template <typename T_>
+LabelsDepSpec<T_>::~LabelsDepSpec()
+{
+}
+
+template <typename T_>
+tr1::shared_ptr<DepSpec>
+LabelsDepSpec<T_>::clone() const
+{
+ return tr1::shared_ptr<LabelsDepSpec<T_> >(new LabelsDepSpec<T_>);
+}
+
+template <typename T_>
+typename LabelsDepSpec<T_>::ConstIterator
+LabelsDepSpec<T_>::begin() const
+{
+ return ConstIterator(_imp->items.begin());
+}
+
+template <typename T_>
+typename LabelsDepSpec<T_>::ConstIterator
+LabelsDepSpec<T_>::end() const
+{
+ return ConstIterator(_imp->items.end());
+}
+
+template <typename T_>
+void
+LabelsDepSpec<T_>::add_label(const tr1::shared_ptr<const typename T_::BasicNode> & item)
+{
+ _imp->items.push_back(item);
+}
+
+PackageDepSpecData::~PackageDepSpecData()
+{
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<PackageDepSpec>
+ {
+ const tr1::shared_ptr<const PackageDepSpecData> data;
+ tr1::shared_ptr<const DepTag> tag;
+
+ Implementation(const tr1::shared_ptr<const PackageDepSpecData> & d, const tr1::shared_ptr<const DepTag> & t) :
+ data(d),
+ tag(t)
+ {
+ }
+ };
+}
+
+PackageDepSpec::PackageDepSpec(const tr1::shared_ptr<const PackageDepSpecData> & d) :
+ Cloneable<DepSpec>(),
+ StringDepSpec(d->as_string()),
+ PrivateImplementationPattern<PackageDepSpec>(new Implementation<PackageDepSpec>(d, tr1::shared_ptr<const DepTag>()))
+{
+}
+
+PackageDepSpec::~PackageDepSpec()
+{
+}
+
+PackageDepSpec::PackageDepSpec(const PackageDepSpec & d) :
+ Cloneable<DepSpec>(d),
+ StringDepSpec(d._imp->data->as_string()),
+ PrivateImplementationPattern<PackageDepSpec>(new Implementation<PackageDepSpec>(d._imp->data, d._imp->tag)),
+ CloneUsingThis<DepSpec, PackageDepSpec>(d)
{
- tr1::shared_ptr<PackageDepSpec> result(new PackageDepSpec(*this));
- result->_make_unique();
- result->set_tag(_imp->tag);
- return result;
}
tr1::shared_ptr<const QualifiedPackageName>
PackageDepSpec::package_ptr() const
{
- return _imp->package_ptr;
+ return _imp->data->package_ptr();
}
tr1::shared_ptr<const PackageNamePart>
PackageDepSpec::package_name_part_ptr() const
{
- return _imp->package_name_part_ptr;
+ return _imp->data->package_name_part_ptr();
}
tr1::shared_ptr<const CategoryNamePart>
PackageDepSpec::category_name_part_ptr() const
{
- return _imp->category_name_part_ptr;
+ return _imp->data->category_name_part_ptr();
}
tr1::shared_ptr<const VersionRequirements>
PackageDepSpec::version_requirements_ptr() const
{
- return _imp->version_requirements;
+ return _imp->data->version_requirements_ptr();
}
-tr1::shared_ptr<VersionRequirements>
-PackageDepSpec::version_requirements_ptr()
-{
- _make_unique();
- return _imp->version_requirements;
-}
-
-VersionRequirementsMode
+const VersionRequirementsMode
PackageDepSpec::version_requirements_mode() const
{
- return _imp->version_requirements_mode;
-}
-
-void
-PackageDepSpec::set_version_requirements_mode(const VersionRequirementsMode m)
-{
- _imp->version_requirements_mode = m;
+ return _imp->data->version_requirements_mode();
}
tr1::shared_ptr<const SlotName>
PackageDepSpec::slot_ptr() const
{
- return _imp->slot;
+ return _imp->data->slot_ptr();
}
tr1::shared_ptr<const RepositoryName>
PackageDepSpec::repository_ptr() const
{
- return _imp->repository;
+ return _imp->data->repository_ptr();
}
tr1::shared_ptr<const UseRequirements>
PackageDepSpec::use_requirements_ptr() const
{
- return _imp->use_requirements;
+ return _imp->data->use_requirements_ptr();
+}
+
+tr1::shared_ptr<PackageDepSpec>
+PackageDepSpec::without_use_requirements() const
+{
+ using namespace tr1::placeholders;
+
+ PartiallyMadePackageDepSpec result;
+
+ if (package_ptr())
+ result.package(*package_ptr());
+
+ if (package_name_part_ptr())
+ result.package_name_part(*package_name_part_ptr());
+
+ if (category_name_part_ptr())
+ result.category_name_part(*category_name_part_ptr());
+
+ if (version_requirements_ptr())
+ std::for_each(version_requirements_ptr()->begin(), version_requirements_ptr()->end(),
+ tr1::bind(&PartiallyMadePackageDepSpec::version_requirement, &result, _1));
+
+ result.version_requirements_mode(version_requirements_mode());
+
+ if (slot_ptr())
+ result.slot(*slot_ptr());
+
+ if (repository_ptr())
+ result.repository(*repository_ptr());
+
+ return make_shared_ptr(new PackageDepSpec(result));
}
tr1::shared_ptr<const DepTag>
@@ -992,149 +575,526 @@ PackageDepSpec::set_tag(const tr1::shared_ptr<const DepTag> & s)
_imp->tag = s;
}
-void
-PackageDepSpec::_make_unique()
+std::string
+PackageDepSpec::_as_string() const
+{
+ return _imp->data->as_string();
+}
+
+PackageDepSpec
+paludis::parse_user_package_dep_spec(const std::string & ss, const UserPackageDepSpecOptions & options)
{
- Lock l(_imp->mutex);
+ Context context("When parsing package dep spec '" + ss + "':");
- if (_imp->unique)
- return;
+ if (ss.empty())
+ throw PackageDepSpecError("Got empty dep spec");
- if (_imp->package_ptr && ! _imp->package_ptr.unique())
- _imp->package_ptr.reset(new QualifiedPackageName(*_imp->package_ptr));
+ std::string s(ss);
+ PartiallyMadePackageDepSpec result;
+ bool had_bracket_version_requirements(false);
- if (_imp->category_name_part_ptr && ! _imp->category_name_part_ptr.unique())
- _imp->category_name_part_ptr.reset(new CategoryNamePart(*_imp->category_name_part_ptr));
+ 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 []");
- if (_imp->package_name_part_ptr && ! _imp->package_name_part_ptr.unique())
- _imp->package_name_part_ptr.reset(new PackageNamePart(*_imp->package_name_part_ptr));
+ VersionOperator vop(op);
- if (_imp->version_requirements && ! _imp->version_requirements.unique())
+ 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:
+ {
+ UseFlagState state(use_enabled);
+ if ('-' == flag.at(0))
+ {
+ state = use_disabled;
+ flag.erase(0, 1);
+ if (flag.empty())
+ throw PackageDepSpecError("Invalid [] contents");
+ }
+ UseFlagName name(flag);
+ result.use_requirement(name, state);
+ }
+ 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(':'))))
{
- tr1::shared_ptr<VersionRequirements> v(new VersionRequirements);
- std::copy(_imp->version_requirements->begin(), _imp->version_requirements->end(), v->back_inserter());
- _imp->version_requirements = v;
+ result.slot(SlotName(s.substr(slot_p + 1)));
+ s.erase(slot_p);
}
- if (_imp->slot && ! _imp->slot.unique())
- _imp->slot.reset(new SlotName(*_imp->slot));
+ 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 (_imp->repository && ! _imp->repository.unique())
- _imp->repository.reset(new RepositoryName(*_imp->repository));
+ 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) + "'");
- if (_imp->use_requirements && ! _imp->use_requirements.unique())
- _imp->use_requirements.reset(new UseRequirements(*_imp->use_requirements));
+ result.category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
+ }
+ else
+ result.package(QualifiedPackageName(s));
+ }
- _imp->unique = true;
+ return result;
}
-tr1::shared_ptr<const PackageDepSpec>
-BlockDepSpec::blocked_spec() const
+PartiallyMadePackageDepSpec
+paludis::make_package_dep_spec()
{
- return _spec;
+ return PartiallyMadePackageDepSpec();
}
-tr1::shared_ptr<DepSpec>
-BlockDepSpec::clone() const
+namespace
{
- return tr1::shared_ptr<DepSpec>(new BlockDepSpec(tr1::static_pointer_cast<PackageDepSpec>(_spec->clone())));
+ struct PartiallyMadePackageDepSpecData :
+ PackageDepSpecData
+ {
+ tr1::shared_ptr<QualifiedPackageName> package;
+ tr1::shared_ptr<PackageNamePart> package_name_part;
+ 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<RepositoryName> repository;
+ tr1::shared_ptr<UseRequirements> use_requirements;
+
+ PartiallyMadePackageDepSpecData() :
+ PackageDepSpecData(),
+ version_requirements_mode_v(vr_and)
+ {
+ }
+
+ PartiallyMadePackageDepSpecData(const PartiallyMadePackageDepSpecData & other) :
+ PackageDepSpecData(other),
+ package(other.package),
+ package_name_part(other.package_name_part),
+ category_name_part(other.category_name_part),
+ version_requirements(other.version_requirements),
+ version_requirements_mode_v(other.version_requirements_mode_v),
+ slot(other.slot),
+ repository(other.repository),
+ use_requirements(other.use_requirements)
+ {
+ }
+
+ virtual std::string as_string() const
+ {
+ std::ostringstream s;
+
+ if (version_requirements_ptr())
+ {
+ if (version_requirements_ptr()->begin() == version_requirements_ptr()->end())
+ {
+ }
+ else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end())
+ {
+ if (version_requirements_ptr()->begin()->version_operator == vo_equal_star)
+ s << "=";
+ else
+ s << version_requirements_ptr()->begin()->version_operator;
+ }
+ }
+
+ if (package_ptr())
+ s << *package_ptr();
+ else
+ {
+ if (category_name_part_ptr())
+ s << *category_name_part_ptr();
+ else
+ s << "*";
+
+ s << "/";
+
+ if (package_name_part_ptr())
+ s << *package_name_part_ptr();
+ else
+ s << "*";
+ }
+
+ if (version_requirements_ptr())
+ {
+ if (version_requirements_ptr()->begin() == version_requirements_ptr()->end())
+ {
+ }
+ else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end())
+ {
+ s << "-" << version_requirements_ptr()->begin()->version_spec;
+ if (version_requirements_ptr()->begin()->version_operator == vo_equal_star)
+ s << "*";
+ }
+ }
+
+ if (slot_ptr())
+ s << ":" << *slot_ptr();
+ if (repository_ptr())
+ s << "::" << *repository_ptr();
+
+ if (version_requirements_ptr())
+ {
+ if (version_requirements_ptr()->begin() == version_requirements_ptr()->end())
+ {
+ }
+ else if (next(version_requirements_ptr()->begin()) == version_requirements_ptr()->end())
+ {
+ }
+ else
+ {
+ bool need_op(false);
+ s << "[";
+ for (VersionRequirements::ConstIterator r(version_requirements_ptr()->begin()),
+ r_end(version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ {
+ if (need_op)
+ {
+ do
+ {
+ switch (version_requirements_mode())
+ {
+ case vr_and:
+ s << "&";
+ continue;
+
+ case vr_or:
+ s << "|";
+ continue;
+
+ case last_vr:
+ ;
+ }
+ throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode");
+ } while (false);
+ }
+
+ if (r->version_operator == vo_equal_star)
+ s << "=";
+ else
+ s << r->version_operator;
+
+ s << r->version_spec;
+
+ if (r->version_operator == vo_equal_star)
+ s << "*";
+
+ need_op = true;
+ }
+ s << "]";
+ }
+ }
+
+ if (use_requirements_ptr())
+ {
+ for (UseRequirements::ConstIterator u(use_requirements_ptr()->begin()),
+ u_end(use_requirements_ptr()->end()) ; u != u_end ; ++u)
+ s << "[" << (u->second == use_disabled ? "-" + stringify(u->first) :
+ stringify(u->first)) << "]";
+ }
+
+ return s.str();
+ }
+
+ virtual tr1::shared_ptr<const QualifiedPackageName> package_ptr() const
+ {
+ return package;
+ }
+
+ virtual tr1::shared_ptr<const PackageNamePart> package_name_part_ptr() const
+ {
+ return package_name_part;
+ }
+
+ virtual tr1::shared_ptr<const CategoryNamePart> category_name_part_ptr() const
+ {
+ return category_name_part;
+ }
+
+ virtual tr1::shared_ptr<const VersionRequirements> version_requirements_ptr() const
+ {
+ return version_requirements;
+ }
+
+ virtual const VersionRequirementsMode version_requirements_mode() const
+ {
+ return version_requirements_mode_v;
+ }
+
+ virtual tr1::shared_ptr<const SlotName> slot_ptr() const
+ {
+ return slot;
+ }
+
+ virtual tr1::shared_ptr<const RepositoryName> repository_ptr() const
+ {
+ return repository;
+ }
+
+ virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const
+ {
+ return use_requirements;
+ }
+ };
}
-FetchableURIDepSpec::FetchableURIDepSpec(const std::string & s) :
- StringDepSpec(s)
+namespace paludis
{
+ template <>
+ struct Implementation<PartiallyMadePackageDepSpec>
+ {
+ tr1::shared_ptr<PartiallyMadePackageDepSpecData> data;
+
+ Implementation() :
+ data(new PartiallyMadePackageDepSpecData)
+ {
+ }
+
+ Implementation(const Implementation & other) :
+ data(new PartiallyMadePackageDepSpecData(*other.data))
+ {
+ }
+ };
}
-std::string
-FetchableURIDepSpec::original_url() const
+PartiallyMadePackageDepSpec::PartiallyMadePackageDepSpec() :
+ PrivateImplementationPattern<PartiallyMadePackageDepSpec>(new Implementation<PartiallyMadePackageDepSpec>)
{
- std::string::size_type p(text().find(" -> "));
- if (std::string::npos == p)
- return text();
- else
- return text().substr(0, p);
}
-std::string
-FetchableURIDepSpec::renamed_url_suffix() const
+PartiallyMadePackageDepSpec::PartiallyMadePackageDepSpec(const PartiallyMadePackageDepSpec & other) :
+ PrivateImplementationPattern<PartiallyMadePackageDepSpec>(new Implementation<PartiallyMadePackageDepSpec>(*other._imp.get()))
{
- std::string::size_type p(text().find(" -> "));
- if (std::string::npos == p)
- return "";
- else
- return text().substr(p + 4);
}
-std::string
-FetchableURIDepSpec::filename() const
+PartiallyMadePackageDepSpec::~PartiallyMadePackageDepSpec()
{
- std::string rus = renamed_url_suffix();
- if (! rus.empty())
- return rus;
+}
- std::string orig = original_url();
- std::string::size_type p(orig.rfind('/'));
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::package(const QualifiedPackageName & name)
+{
+ _imp->data->package.reset(new QualifiedPackageName(name));
+ return *this;
+}
- if (std::string::npos == p)
- return orig;
- return orig.substr(p+1);
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::slot(const SlotName & s)
+{
+ _imp->data->slot.reset(new SlotName(s));
+ return *this;
}
-tr1::shared_ptr<DepSpec>
-FetchableURIDepSpec::clone() const
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::repository(const RepositoryName & repo)
{
- return tr1::shared_ptr<FetchableURIDepSpec>(new FetchableURIDepSpec(text()));
+ _imp->data->repository.reset(new RepositoryName(repo));
+ return *this;
}
-namespace paludis
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::package_name_part(const PackageNamePart & part)
{
-#ifndef PALUDIS_NO_DOUBLE_TEMPLATE
- template <>
-#endif
- template <typename T_>
- struct Implementation<LabelsDepSpec<T_ > >
- {
- std::list<tr1::shared_ptr<const typename T_::BasicNode> > items;
- };
+ _imp->data->package_name_part.reset(new PackageNamePart(part));
+ return *this;
}
-template <typename T_>
-LabelsDepSpec<T_>::LabelsDepSpec() :
- PrivateImplementationPattern<LabelsDepSpec<T_> >(new Implementation<LabelsDepSpec<T_> >)
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::category_name_part(const CategoryNamePart & part)
{
+ _imp->data->category_name_part.reset(new CategoryNamePart(part));
+ return *this;
}
-template <typename T_>
-LabelsDepSpec<T_>::~LabelsDepSpec()
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::version_requirement(const VersionRequirement & req)
{
+ if (! _imp->data->version_requirements)
+ _imp->data->version_requirements.reset(new VersionRequirements);
+ _imp->data->version_requirements->push_back(req);
+ return *this;
}
-template <typename T_>
-tr1::shared_ptr<DepSpec>
-LabelsDepSpec<T_>::clone() const
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::version_requirements_mode(const VersionRequirementsMode & mode)
{
- return tr1::shared_ptr<LabelsDepSpec<T_> >(new LabelsDepSpec<T_>);
+ _imp->data->version_requirements_mode_v = mode;
+ return *this;
}
-template <typename T_>
-typename LabelsDepSpec<T_>::ConstIterator
-LabelsDepSpec<T_>::begin() const
+PartiallyMadePackageDepSpec &
+PartiallyMadePackageDepSpec::use_requirement(const UseFlagName & f, const UseFlagState s)
{
- return ConstIterator(_imp->items.begin());
+ if (! _imp->data->use_requirements)
+ _imp->data->use_requirements.reset(new UseRequirements);
+ _imp->data->use_requirements->insert(f, s);
+ return *this;
}
-template <typename T_>
-typename LabelsDepSpec<T_>::ConstIterator
-LabelsDepSpec<T_>::end() const
+PartiallyMadePackageDepSpec::operator const PackageDepSpec() const
{
- return ConstIterator(_imp->items.end());
+ return PackageDepSpec(_imp->data);
}
-template <typename T_>
-void
-LabelsDepSpec<T_>::add_label(const tr1::shared_ptr<const typename T_::BasicNode> & item)
+const PackageDepSpec
+PartiallyMadePackageDepSpec::to_package_dep_spec() const
{
- _imp->items.push_back(item);
+ return operator const PackageDepSpec();
}
template class WrappedForwardIterator<UseRequirements::ConstIteratorTag, const std::pair<const UseFlagName, UseFlagState> >;
@@ -1147,4 +1107,3 @@ template class LabelsDepSpec<DependencyLabelVisitorTypes>;
template class WrappedForwardIterator<LabelsDepSpec<DependencyLabelVisitorTypes>::ConstIteratorTag,
const tr1::shared_ptr<const DependencyLabelVisitorTypes::BasicNode> >;
-
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index 8e5df7f..1cd421a 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -238,8 +238,7 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
/// Insert a new requirement.
- bool insert(const UseFlagName & u, UseFlagState s)
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool insert(const UseFlagName & u, UseFlagState s);
/// What state is desired for a particular use flag?
UseFlagState state(const UseFlagName &) const
@@ -251,53 +250,119 @@ namespace paludis
};
/**
+ * A PartiallyMadePackageDepSpec is returned by make_package_dep_spec()
+ * and is used to incrementally build a PackageDepSpec.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.26
+ */
+ class PALUDIS_VISIBLE PartiallyMadePackageDepSpec :
+ private PrivateImplementationPattern<PartiallyMadePackageDepSpec>
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ PartiallyMadePackageDepSpec();
+ ~PartiallyMadePackageDepSpec();
+ PartiallyMadePackageDepSpec(const PartiallyMadePackageDepSpec &);
+
+ ///\}
+
+ /**
+ * Set our package requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & package(const QualifiedPackageName &);
+
+ /**
+ * Set our slot requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & slot(const SlotName &);
+
+ /**
+ * Set our repository requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & repository(const RepositoryName &);
+
+ /**
+ * Set our package name part requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & package_name_part(const PackageNamePart &);
+
+ /**
+ * Set our category name part requirements, return ourself.
+ */
+ PartiallyMadePackageDepSpec & category_name_part(const CategoryNamePart &);
+
+ /**
+ * Add a version requirement, return ourself.
+ */
+ PartiallyMadePackageDepSpec & version_requirement(const VersionRequirement &);
+
+ /**
+ * Set our version requirements mode, return ourself.
+ */
+ PartiallyMadePackageDepSpec & version_requirements_mode(const VersionRequirementsMode &);
+
+ /**
+ * Add a use requirement, return ourself.
+ */
+ PartiallyMadePackageDepSpec & use_requirement(const UseFlagName &, const UseFlagState);
+
+ /**
+ * Turn ourselves into a PackageDepSpec.
+ */
+ operator const PackageDepSpec() const;
+
+ /**
+ * Explicitly turn ourselves into a PackageDepSpec.
+ */
+ const PackageDepSpec to_package_dep_spec() const;
+ };
+
+ /**
* A PackageDepSpec represents a package name (for example,
* 'app-editors/vim'), possibly with associated version and SLOT
* restrictions.
*
+ * A PackageDepSpec is implemented in terms of PackageDepSpecData. Individual
+ * repositories provide their own way of creating PackageDepSpec::Data that
+ * handle the native syntax for those repositories (e.g. CRAN uses
+ * "Blah (>= 1.23)" whilst E uses ">=cat/blah-1.23").
+ *
+ * To create a PackageDepSpec from user input, use
+ * parse_user_package_dep_spec(), and for programmer input, use
+ * make_package_dep_spec().
+ *
* \ingroup g_dep_spec
* \nosubgrouping
*/
class PALUDIS_VISIBLE PackageDepSpec :
public StringDepSpec,
- private PrivateImplementationPattern<PackageDepSpec>
+ private PrivateImplementationPattern<PackageDepSpec>,
+ public CloneUsingThis<DepSpec, PackageDepSpec>
{
+ friend std::ostream & operator<< (std::ostream &, const PackageDepSpec &);
+
private:
const PackageDepSpec & operator= (const PackageDepSpec &);
-
- void _do_parse(const std::string &, const PackageDepSpecParseMode);
- void _make_unique();
+ std::string _as_string() const;
public:
///\name Basic operations
///\{
/**
- * Constructor, no version or SLOT restrictions.
+ * Constructor.
*
- * \deprecated Use the two arg form.
- */
- PackageDepSpec(const QualifiedPackageName & package) PALUDIS_ATTRIBUTE((deprecated));
-
- /**
- * Constructor, parse restrictions ourself.
+ * Clients will usually use either parse_user_package_dep_spec() or
+ * make_package_dep_spec() rather than calling this method
+ * directly. Repositories will define their own way of creating
+ * a PackageDepSpec.
*
- * \deprecated Use the two arg form.
+ * \since 0.26
*/
- explicit PackageDepSpec(const std::string &) PALUDIS_ATTRIBUTE((deprecated));
-
- PackageDepSpec(const std::string &, const PackageDepSpecParseMode);
-
- explicit PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName> q = tr1::shared_ptr<QualifiedPackageName>(),
- tr1::shared_ptr<CategoryNamePart> c = tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart> p = tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements> v = tr1::shared_ptr<VersionRequirements>(),
- VersionRequirementsMode m = vr_and,
- tr1::shared_ptr<SlotName> s = tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName> r = tr1::shared_ptr<RepositoryName>(),
- tr1::shared_ptr<UseRequirements> u = tr1::shared_ptr<UseRequirements>(),
- tr1::shared_ptr<const DepTag> t = tr1::shared_ptr<const DepTag>());
+ PackageDepSpec(const tr1::shared_ptr<const PackageDepSpecData> &);
PackageDepSpec(const PackageDepSpec &);
@@ -326,19 +391,9 @@ namespace paludis
tr1::shared_ptr<const VersionRequirements> version_requirements_ptr() const;
/**
- * Fetch the version requirements (may be a zero pointer).
- */
- tr1::shared_ptr<VersionRequirements> version_requirements_ptr();
-
- /**
* Fetch the version requirements mode.
*/
- VersionRequirementsMode version_requirements_mode() const;
-
- /**
- * Set the version requirements mode.
- */
- void set_version_requirements_mode(const VersionRequirementsMode m);
+ const VersionRequirementsMode version_requirements_mode() const;
/**
* Fetch the slot name (may be a zero pointer).
@@ -371,8 +426,68 @@ namespace paludis
tr1::shared_ptr<PackageDepSpec> without_use_requirements() const;
virtual const PackageDepSpec * as_package_dep_spec() const;
+ };
- virtual tr1::shared_ptr<DepSpec> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ /**
+ * Data for a PackageDepSpec.
+ *
+ * \since 0.26
+ * \ingroup g_dep_spec
+ */
+ class PALUDIS_VISIBLE PackageDepSpecData
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ virtual ~PackageDepSpecData();
+
+ ///\}
+
+ /**
+ * Fetch ourself as a string.
+ */
+ virtual std::string as_string() const = 0;
+
+ /**
+ * Fetch the package name (may be a zero pointer).
+ */
+ virtual tr1::shared_ptr<const QualifiedPackageName> package_ptr() const = 0;
+
+ /**
+ * Fetch the package name part, if wildcarded, or a zero pointer otherwise.
+ */
+ virtual tr1::shared_ptr<const PackageNamePart> package_name_part_ptr() const = 0;
+
+ /**
+ * Fetch the category name part, if wildcarded, or a zero pointer otherwise.
+ */
+ virtual tr1::shared_ptr<const CategoryNamePart> category_name_part_ptr() const = 0;
+
+ /**
+ * Fetch the version requirements (may be a zero pointer).
+ */
+ virtual tr1::shared_ptr<const VersionRequirements> version_requirements_ptr() const = 0;
+
+ /**
+ * Fetch the version requirements mode.
+ */
+ virtual const VersionRequirementsMode version_requirements_mode() const = 0;
+
+ /**
+ * Fetch the slot name (may be a zero pointer).
+ */
+ virtual tr1::shared_ptr<const SlotName> slot_ptr() const = 0;
+
+ /**
+ * Fetch the repo name (may be a zero pointer).
+ */
+ virtual tr1::shared_ptr<const RepositoryName> repository_ptr() const = 0;
+
+ /**
+ * Fetch the use requirements (may be a zero pointer).
+ */
+ virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const = 0;
};
/**
diff --git a/paludis/dep_spec.se b/paludis/dep_spec.se
index 47c3a7a..dd75fd3 100644
--- a/paludis/dep_spec.se
+++ b/paludis/dep_spec.se
@@ -1,25 +1,18 @@
#!/bin/bash
# vim: set sw=4 sts=4 et ft=sh :
-make_enum_PackageDepSpecParseMode()
+make_enum_UserPackageDepSpecOption()
{
- prefix pds_pm
- want_destringify
+ prefix updso
- key pds_pm_eapi_0 "EAPI 0"
- key pds_pm_eapi_0_strict "EAPI 0, errors for non-permitted things"
- key pds_pm_eapi_1 "EAPI 1"
- key pds_pm_eapi_1_strict "EAPI 1, errors for non-permitted things"
- key pds_pm_exheres_0 "EAPI exheres-0"
- key pds_pm_permissive "Permissive"
- key pds_pm_unspecific "Permissive, and allow unspecific cat/pkg"
+ key updso_allow_wildcards "Allow wildcards for category, package"
doxygen_comment << "END"
/**
- * How to parse a PackageDepSpec string.
+ * Options for parse_user_package_dep_spec
*
- * \see PackageDepSpec
* \ingroup g_dep_spec
+ * \since 0.26
*/
END
}
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index 7355030..daec107 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -22,31 +22,23 @@
#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/version_requirements.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
-/** \file
- * Test cases for dep_spec.hh classes.
- *
- */
-
using namespace paludis;
using namespace test;
namespace test_cases
{
- /**
- * \test Test DepSpec as_ functions.
- *
- */
struct DepSpecAsTest : TestCase
{
DepSpecAsTest() : TestCase("dep spec as") { }
void run()
{
- tr1::shared_ptr<PackageDepSpec> x(new PackageDepSpec("foo/bar", pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> x(new PackageDepSpec(parse_user_package_dep_spec("foo/bar", UserPackageDepSpecOptions())));
TEST_CHECK(0 == x->as_use_dep_spec());
tr1::shared_ptr<UseDepSpec> y(new UseDepSpec(UseFlagName("foo"), x));
@@ -55,23 +47,19 @@ namespace test_cases
}
} test_dep_spec_as;
- /**
- * \test Test PackageDepSpec.
- *
- */
struct PackageDepSpecTest : TestCase
{
PackageDepSpecTest() : TestCase("package dep spec") { }
void run()
{
- PackageDepSpec a("foo/bar", pds_pm_permissive);
+ 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(">=foo/bar-1.2.3", pds_pm_permissive);
+ 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());
@@ -81,14 +69,14 @@ namespace test_cases
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("foo/bar:baz", pds_pm_permissive);
+ 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("=foo/bar-1.2*:1.2.1", pds_pm_permissive);
+ 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());
@@ -97,35 +85,35 @@ namespace test_cases
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("foo/bar:1.2.1", pds_pm_permissive);
+ 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("foo/bar:0", pds_pm_permissive);
+ 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("foo/bar-100dpi", pds_pm_permissive);
+ 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(">=foo/bar-100dpi-1.23", pds_pm_permissive);
+ 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(PackageDepSpec("", pds_pm_permissive), PackageDepSpecError);
- TEST_CHECK_THROWS(PackageDepSpec("=foo/bar-1.2[=1.3]", pds_pm_permissive), PackageDepSpecError);
+ 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("foo/bar[one][-two]", pds_pm_permissive);
+ PackageDepSpec i(parse_user_package_dep_spec("foo/bar[one][-two]", UserPackageDepSpecOptions()));
TEST_CHECK_STRINGIFY_EQUAL(i, "foo/bar[one][-two]");
TEST_CHECK_STRINGIFY_EQUAL(*i.package_ptr(), "foo/bar");
TEST_CHECK(! i.version_requirements_ptr());
@@ -142,21 +130,21 @@ namespace test_cases
TEST_CHECK(i.use_requirements_ptr()->state(UseFlagName("two")) == use_disabled);
TEST_CHECK(i.use_requirements_ptr()->state(UseFlagName("moo")) == use_unspecified);
- PackageDepSpec j("=foo/bar-scm-r3", pds_pm_permissive);
+ 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("=foo/bar-scm", pds_pm_permissive);
+ 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("foo/bar[one][-two][>=1.2&<2.0]", pds_pm_permissive);
+ 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][one][-two]");
TEST_CHECK_STRINGIFY_EQUAL(*l.package_ptr(), "foo/bar");
TEST_CHECK(l.version_requirements_ptr());
@@ -177,7 +165,7 @@ namespace test_cases
TEST_CHECK(l.use_requirements_ptr()->state(UseFlagName("two")) == use_disabled);
TEST_CHECK(l.use_requirements_ptr()->state(UseFlagName("moo")) == use_unspecified);
- PackageDepSpec m("foo/bar[=1.2|=1.3*|~1.4]", pds_pm_permissive);
+ 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());
@@ -219,40 +207,40 @@ namespace test_cases
void run()
{
- PackageDepSpec a("*/*", pds_pm_unspecific);
+ 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("foo/*", pds_pm_unspecific);
+ 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("*/foo", pds_pm_unspecific);
+ 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("~*/*-0", pds_pm_unspecific);
+ 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(">=foo/*-1.23", pds_pm_unspecific);
+ 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("=*/foo-1*", pds_pm_unspecific);
+ 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());
@@ -267,23 +255,17 @@ namespace test_cases
void run()
{
- PackageDepSpec a("cat/pkg:1::repo[=1|>3.2][foo]", pds_pm_permissive);
+ PackageDepSpec a(parse_user_package_dep_spec("cat/pkg:1::repo[=1|>3.2][foo]", UserPackageDepSpecOptions()));
tr1::shared_ptr<PackageDepSpec> b(tr1::static_pointer_cast<PackageDepSpec>(a.clone()));
TEST_CHECK_STRINGIFY_EQUAL(a, *b);
- b->set_version_requirements_mode(vr_and);
- TEST_CHECK(stringify(a) != stringify(*b));
tr1::shared_ptr<PackageDepSpec> c(tr1::static_pointer_cast<PackageDepSpec>(a.clone()));
TEST_CHECK_STRINGIFY_EQUAL(a, *c);
- c->version_requirements_ptr()->push_back(VersionRequirement(vo_tilde, VersionSpec("1.5")));
- TEST_CHECK(stringify(a) != stringify(*c));
BlockDepSpec d(c);
tr1::shared_ptr<BlockDepSpec> e(tr1::static_pointer_cast<BlockDepSpec>(d.clone()));
TEST_CHECK_STRINGIFY_EQUAL(*(d.blocked_spec()), *(e->blocked_spec()));
- c->set_version_requirements_mode(vr_and);
- TEST_CHECK(stringify(*(d.blocked_spec())) != stringify(*(e->blocked_spec())));
}
} test_dep_spec_clone;
}
diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc
index b3c399f..7e411eb 100644
--- a/paludis/environments/paludis/keywords_conf.cc
+++ b/paludis/environments/paludis/keywords_conf.cc
@@ -24,6 +24,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
+#include <paludis/util/options.hh>
#include <paludis/package_id.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
@@ -112,7 +113,8 @@ KeywordsConf::add(const FSEntry & filename)
}
else
{
- tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
+ tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(parse_user_package_dep_spec(
+ tokens.at(0), UserPackageDepSpecOptions() + updso_allow_wildcards)));
if (d->package_ptr())
{
KeywordsList & k(_imp->qualified[*d->package_ptr()][d]);
diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc
index 111a995..6716d03 100644
--- a/paludis/environments/paludis/licenses_conf.cc
+++ b/paludis/environments/paludis/licenses_conf.cc
@@ -25,6 +25,7 @@
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
#include <paludis/package_id.hh>
+#include <paludis/util/options.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
@@ -111,7 +112,8 @@ LicensesConf::add(const FSEntry & filename)
}
else
{
- tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
+ tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(parse_user_package_dep_spec(
+ tokens.at(0), UserPackageDepSpecOptions() + updso_allow_wildcards)));
if (d->package_ptr())
{
LicensesList & k(_imp->qualified[*d->package_ptr()][d]);
diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc
index c53ff45..90bb412 100644
--- a/paludis/environments/paludis/package_mask_conf.cc
+++ b/paludis/environments/paludis/package_mask_conf.cc
@@ -29,6 +29,7 @@
#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/options.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/indirect_iterator-impl.hh>
@@ -74,7 +75,8 @@ PackageMaskConf::add(const FSEntry & filename)
for (LineConfigFile::ConstIterator line(f->begin()), line_end(f->end()) ;
line != line_end ; ++line)
- _imp->masks.push_back(tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(*line, pds_pm_unspecific)));
+ _imp->masks.push_back(tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec(
+ *line, UserPackageDepSpecOptions() + updso_allow_wildcards))));
}
bool
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 22c0ebf..de028db 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -52,6 +52,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/options.hh>
#include <functional>
#include <algorithm>
@@ -340,6 +341,8 @@ PaludisEnvironment::syncers_dirs() const
tr1::shared_ptr<SetSpecTree::ConstItem>
PaludisEnvironment::local_set(const SetName & s) const
{
+ using namespace tr1::placeholders;
+
Context context("When looking for package set '" + stringify(s) + "' in paludis environment:");
Lock l(_imp->sets_mutex);
@@ -356,7 +359,7 @@ PaludisEnvironment::local_set(const SetName & s) const
SetFile f(SetFileParams::create()
.file_name(dir / (stringify(s) + ".bash"))
.type(sft_paludis_bash)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions() + updso_allow_wildcards))
.tag(tag)
.environment(this));
@@ -368,7 +371,7 @@ PaludisEnvironment::local_set(const SetName & s) const
SetFile f(SetFileParams::create()
.file_name(dir / (stringify(s) + ".conf"))
.type(sft_paludis_conf)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions() + updso_allow_wildcards))
.tag(tag)
.environment(this));
diff --git a/paludis/environments/paludis/paludis_environment_TEST.cc b/paludis/environments/paludis/paludis_environment_TEST.cc
index a1b01ab..09fad04 100644
--- a/paludis/environments/paludis/paludis_environment_TEST.cc
+++ b/paludis/environments/paludis/paludis_environment_TEST.cc
@@ -23,6 +23,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/options.hh>
#include <paludis/query.hh>
#include <paludis/package_id.hh>
#include <test/test_runner.hh>
@@ -45,9 +46,9 @@ namespace test_cases
tr1::shared_ptr<Environment> env(new PaludisEnvironment(""));
const tr1::shared_ptr<const PackageID> one(*env->package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
const tr1::shared_ptr<const PackageID> three(*env->package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-two-3", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-two-3", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(env->query_use(UseFlagName("foo"), *one));
TEST_CHECK(! env->query_use(UseFlagName("foofoo"), *one));
@@ -77,7 +78,7 @@ namespace test_cases
tr1::shared_ptr<Environment> env(new PaludisEnvironment(""));
const tr1::shared_ptr<const PackageID> one(*env->package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
tr1::shared_ptr<const UseFlagNameSet> k1(env->known_use_expand_names(UseFlagName("foo_cards"), *one));
TEST_CHECK_EQUAL(join(k1->begin(), k1->end(), " "), "foo_cards_one foo_cards_three foo_cards_two");
}
@@ -95,9 +96,9 @@ namespace test_cases
tr1::shared_ptr<Environment> env(new PaludisEnvironment(""));
const tr1::shared_ptr<const PackageID> one(*env->package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
const tr1::shared_ptr<const PackageID> three(*env->package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-two-3", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-two-3", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(env->query_use(UseFlagName("foo"), *one));
TEST_CHECK(! env->query_use(UseFlagName("foofoo"), *one));
@@ -126,9 +127,9 @@ namespace test_cases
tr1::shared_ptr<Environment> env(new PaludisEnvironment(""));
const tr1::shared_ptr<const PackageID> one(*env->package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
const tr1::shared_ptr<const PackageID> three(*env->package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-two-3", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-two-3", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(env->query_use(UseFlagName("foo"), *one));
TEST_CHECK(! env->query_use(UseFlagName("foofoo"), *one));
diff --git a/paludis/environments/paludis/use_conf.cc b/paludis/environments/paludis/use_conf.cc
index 7d0d1cc..fcbcdc8 100644
--- a/paludis/environments/paludis/use_conf.cc
+++ b/paludis/environments/paludis/use_conf.cc
@@ -24,6 +24,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/util/config_file.hh>
+#include <paludis/util/options.hh>
#include <paludis/package_id.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
@@ -128,7 +129,8 @@ UseConf::add(const FSEntry & filename)
}
else
{
- tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(tokens.at(0), pds_pm_unspecific));
+ tr1::shared_ptr<PackageDepSpec> d(new PackageDepSpec(parse_user_package_dep_spec(
+ tokens.at(0), UserPackageDepSpecOptions() + updso_allow_wildcards)));
if (d->use_requirements_ptr())
{
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 5338e48..dd4c1bb 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -287,7 +287,8 @@ PortageEnvironment::_load_atom_file(const FSEntry & f, I_ i, const std::string &
if (tokens.empty())
continue;
- tr1::shared_ptr<PackageDepSpec> p(new PackageDepSpec(tokens.at(0), pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> p(new PackageDepSpec(parse_user_package_dep_spec(
+ tokens.at(0), UserPackageDepSpecOptions())));
if (1 == tokens.size())
{
if (! def_value.empty())
@@ -325,7 +326,7 @@ PortageEnvironment::_load_lined_file(const FSEntry & f, I_ i)
for (LineConfigFile::ConstIterator line(file.begin()), line_end(file.end()) ;
line != line_end ; ++line)
*i++ = tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
- strip_trailing(strip_leading(*line, " \t"), " \t"), pds_pm_permissive));
+ parse_user_package_dep_spec(strip_trailing(strip_leading(*line, " \t"), " \t"), UserPackageDepSpecOptions())));
}
}
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index b65eb3a..afc3c99 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.cc
@@ -24,6 +24,7 @@
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/options.hh>
#include <paludis/package_id.hh>
#include <paludis/query.hh>
#include <paludis/package_database.hh>
@@ -67,10 +68,10 @@ namespace test_cases
PortageEnvironment env("portage_environment_TEST_dir/query_use");
const tr1::shared_ptr<const PackageID> idx(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-x-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-x-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
const tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(env.query_use(UseFlagName("one"), *idx));
TEST_CHECK(env.query_use(UseFlagName("two"), *idx));
@@ -95,7 +96,7 @@ namespace test_cases
PortageEnvironment env("portage_environment_TEST_dir/known_use_expand_names");
const tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
tr1::shared_ptr<const UseFlagNameSet> k1(env.known_use_expand_names(UseFlagName("foo_cards"), *id1));
TEST_CHECK_EQUAL(join(k1->begin(), k1->end(), " "), "foo_cards_one foo_cards_three");
}
@@ -110,35 +111,35 @@ namespace test_cases
TestPortageEnvironment env("portage_environment_TEST_dir/accept_keywords");
const tr1::shared_ptr<const PackageID> idx(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-x-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-x-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(accept_keyword(env, KeywordName("arch"), *idx));
TEST_CHECK(accept_keyword(env, KeywordName("other_arch"), *idx));
TEST_CHECK(! accept_keyword(env, KeywordName("~arch"), *idx));
const tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(accept_keyword(env, KeywordName("arch"), *id1));
TEST_CHECK(accept_keyword(env, KeywordName("other_arch"), *id1));
TEST_CHECK(accept_keyword(env, KeywordName("~arch"), *id1));
const tr1::shared_ptr<const PackageID> id2(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-two-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-two-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(accept_keyword(env, KeywordName("other_arch"), *id2));
TEST_CHECK(accept_keyword(env, KeywordName("arch"), *id2));
TEST_CHECK(accept_keyword(env, KeywordName("~arch"), *id2));
const tr1::shared_ptr<const PackageID> id3(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-three-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-three-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(! accept_keyword(env, KeywordName("other_arch"), *id3));
TEST_CHECK(! accept_keyword(env, KeywordName("arch"), *id3));
TEST_CHECK(! accept_keyword(env, KeywordName("~arch"), *id3));
const tr1::shared_ptr<const PackageID> id4(*env.package_database()->query(
- query::Matches(PackageDepSpec("=cat-one/pkg-four-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-four-1", UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(accept_keyword(env, KeywordName("fred"), *id4));
}
} test_accept_keywords;
diff --git a/paludis/find_unused_packages_task.cc b/paludis/find_unused_packages_task.cc
index 5f38cd1..d02121b 100644
--- a/paludis/find_unused_packages_task.cc
+++ b/paludis/find_unused_packages_task.cc
@@ -43,14 +43,9 @@ FindUnusedPackagesTask::execute(const QualifiedPackageName & package)
{
tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence);
tr1::shared_ptr<const PackageIDSequence> packages(_env->package_database()->query(
- query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(package)),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(new RepositoryName(_repo->name())))),
+ query::Matches(make_package_dep_spec()
+ .package(package)
+ .repository(_repo->name())),
qo_group_by_slot));
SlotName old_slot("I_am_a_slot");
diff --git a/paludis/fuzzy_finder.cc b/paludis/fuzzy_finder.cc
index 33cc715..442ed79 100644
--- a/paludis/fuzzy_finder.cc
+++ b/paludis/fuzzy_finder.cc
@@ -21,6 +21,7 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/damerau_levenshtein.hh>
+#include <paludis/util/options.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/repository.hh>
@@ -74,7 +75,7 @@ FuzzyCandidatesFinder::FuzzyCandidatesFinder(const Environment & e, const std::s
if (std::string::npos != name.find('/'))
{
- PackageDepSpec pds(name, pds_pm_permissive);
+ PackageDepSpec pds(parse_user_package_dep_spec(name, UserPackageDepSpecOptions()));
if (pds.package_ptr())
{
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index ead64d1..bbc33f4 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -30,6 +30,7 @@
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
+#include <paludis/version_requirements.hh>
#include <paludis/tasks_exceptions.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/tokeniser.hh>
@@ -185,7 +186,7 @@ InstallTask::add_target(const std::string & target)
if (std::string::npos != target.find('/'))
{
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(target, pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(parse_user_package_dep_spec(target, UserPackageDepSpecOptions())));
spec->set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
_imp->targets->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
@@ -197,8 +198,7 @@ InstallTask::add_target(const std::string & target)
QualifiedPackageName q(_imp->env->package_database()->fetch_unique_qualified_package_name(
PackageNamePart(target), query::MaybeSupportsAction<InstallAction>()));
modified_target = stringify(q);
- tr1::shared_ptr<PackageDepSpec> spec(
- new PackageDepSpec(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(q))));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec().package(q)));
spec->set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
_imp->targets->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
@@ -229,14 +229,11 @@ InstallTask::add_exact_package(const tr1::shared_ptr<const PackageID> & target)
if (! _imp->override_target_type)
_imp->dep_list.options()->target_type = dl_target_package;
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(target->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- make_equal_to_version_requirements(target->version()),
- vr_and,
- tr1::shared_ptr<SlotName>(new SlotName(target->slot())),
- tr1::shared_ptr<RepositoryName>(new RepositoryName(target->repository()->name()))));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec()
+ .package(target->name())
+ .version_requirement(VersionRequirement(vo_equal, target->version()))
+ .slot(target->slot())
+ .repository(target->repository()->name())));
spec->set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
_imp->targets->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
@@ -509,14 +506,10 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
if (dep->destination)
collision_list = _imp->env->package_database()->query(
- query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(dep->package_id->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(new SlotName(dep->package_id->slot())),
- tr1::shared_ptr<RepositoryName>(new RepositoryName(dep->destination->name())))) &
+ query::Matches(make_package_dep_spec()
+ .package(dep->package_id->name())
+ .slot(dep->package_id->slot())
+ .repository(dep->destination->name())) &
query::SupportsAction<UninstallAction>(),
qo_order_by_version);
@@ -734,7 +727,7 @@ InstallTask::_main_actions()
t != t_end ; ++t)
all->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(tr1::shared_ptr<PackageDepSpec>(
- new PackageDepSpec(*t, pds_pm_permissive)))));
+ new PackageDepSpec(parse_user_package_dep_spec(*t, UserPackageDepSpecOptions()))))));
world_update_packages(all);
}
else
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index 40f0350..83d3801 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -247,10 +247,7 @@ PackageDatabase::fetch_unique_qualified_package_name(
{
Context context("When disambiguating package name '" + stringify(p) + "':");
- const Query & real_q(q & query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(new PackageNamePart(p)))));
+ const Query & real_q(q & query::Matches(make_package_dep_spec().package_name_part(p)));
// Map matching QualifiedPackageNames with a flag specifying that
// at least one repository containing the package things the
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index 0997844..9dea70c 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.cc
@@ -27,6 +27,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/set.hh>
#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/options.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -120,49 +121,49 @@ namespace test_cases
p.add_repository(10, r2);
TEST_CHECK(true);
- PackageDepSpec d1("r1c1/r1c1p1", pds_pm_permissive);
+ PackageDepSpec d1(parse_user_package_dep_spec("r1c1/r1c1p1", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q1(p.query(
query::Matches(d1), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q1->begin(), q1->end()), 1);
- PackageDepSpec d2("r1c1/r1c1p2", pds_pm_permissive);
+ PackageDepSpec d2(parse_user_package_dep_spec("r1c1/r1c1p2", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q2(p.query(
query::Matches(d2), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q2->begin(), q2->end()), 2);
- PackageDepSpec d3(">=r1c1/r1c1p2-1", pds_pm_permissive);
+ PackageDepSpec d3(parse_user_package_dep_spec(">=r1c1/r1c1p2-1", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q3(p.query(
query::Matches(d3), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q3->begin(), q3->end()), 2);
- PackageDepSpec d4(">=r1c1/r1c1p2-2", pds_pm_permissive);
+ PackageDepSpec d4(parse_user_package_dep_spec(">=r1c1/r1c1p2-2", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q4(p.query(
query::Matches(d4), qo_order_by_version));
TEST_CHECK_EQUAL(join(indirect_iterator(q4->begin()), indirect_iterator(q4->end()), " "),
"r1c1/r1c1p2-2:0::repo1");
TEST_CHECK_EQUAL(std::distance(q4->begin(), q4->end()), 1);
- PackageDepSpec d5(">=r1c1/r1c1p2-3", pds_pm_permissive);
+ PackageDepSpec d5(parse_user_package_dep_spec(">=r1c1/r1c1p2-3", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q5(p.query(
query::Matches(d5), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q5->begin(), q5->end()), 0);
- PackageDepSpec d6("<r1c1/r1c1p2-3", pds_pm_permissive);
+ PackageDepSpec d6(parse_user_package_dep_spec("<r1c1/r1c1p2-3", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q6(p.query(
query::Matches(d6), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q6->begin(), q6->end()), 2);
- PackageDepSpec d7("rac1/rac1pa", pds_pm_permissive);
+ PackageDepSpec d7(parse_user_package_dep_spec("rac1/rac1pa", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q7(p.query(
query::Matches(d7), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q7->begin(), q7->end()), 4);
- PackageDepSpec d8("foo/bar", pds_pm_permissive);
+ PackageDepSpec d8(parse_user_package_dep_spec("foo/bar", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q8(p.query(
query::Matches(d8), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q8->begin(), q8->end()), 0);
- PackageDepSpec d9("r1c1/r1c1p1", pds_pm_permissive);
+ PackageDepSpec d9(parse_user_package_dep_spec("r1c1/r1c1p1", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q9(p.query(
query::Matches(d9) & query::SupportsAction<InstallAction>(), qo_order_by_version));
TEST_CHECK_EQUAL(std::distance(q9->begin(), q9->end()), 1);
@@ -192,7 +193,7 @@ namespace test_cases
p.add_repository(5, r2);
TEST_CHECK(true);
- PackageDepSpec d("cat/pkg", pds_pm_permissive);
+ PackageDepSpec d(parse_user_package_dep_spec("cat/pkg", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q1(p.query(query::Matches(d), qo_order_by_version));
TEST_CHECK_EQUAL(join(indirect_iterator(q1->begin()), indirect_iterator(q1->end()), " "),
@@ -215,7 +216,7 @@ namespace test_cases
p.add_repository(5, r3);
TEST_CHECK(true);
- PackageDepSpec c("cat/*", pds_pm_unspecific);
+ PackageDepSpec c(parse_user_package_dep_spec("cat/*", UserPackageDepSpecOptions() + updso_allow_wildcards));
const tr1::shared_ptr<const PackageIDSequence> q5(p.query(query::Matches(c), qo_order_by_version));
TEST_CHECK_EQUAL(join(indirect_iterator(q5->begin()), indirect_iterator(q5->end()), " "),
@@ -235,12 +236,12 @@ namespace test_cases
TEST_CHECK_EQUAL(join(indirect_iterator(q8->begin()), indirect_iterator(q8->end()), " "),
"cat/other-1:a::repo3 cat/pkg-3:b::repo2 cat/pkg-3:c::repo1 cat/pkg-4:a::repo1");
- PackageDepSpec b("cat/pkg:a", pds_pm_permissive);
+ PackageDepSpec b(parse_user_package_dep_spec("cat/pkg:a", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q9(p.query(query::Matches(b), qo_group_by_slot));
TEST_CHECK_EQUAL(join(indirect_iterator(q9->begin()), indirect_iterator(q9->end()), " "),
"cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-4:a::repo1");
- PackageDepSpec a("cat/pkg[=1|=3]", pds_pm_permissive);
+ PackageDepSpec a(parse_user_package_dep_spec("cat/pkg[=1|=3]", UserPackageDepSpecOptions()));
const tr1::shared_ptr<const PackageIDSequence> q10(p.query(query::Matches(a), qo_group_by_slot));
TEST_CHECK_EQUAL(join(indirect_iterator(q10->begin()), indirect_iterator(q10->end()), " "),
"cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-3:b::repo2 cat/pkg-3:c::repo1");
diff --git a/paludis/query.cc b/paludis/query.cc
index 547d439..c4c0d3f 100644
--- a/paludis/query.cc
+++ b/paludis/query.cc
@@ -208,27 +208,17 @@ query::Matches::Matches(const PackageDepSpec & a) :
}
query::Package::Package(const QualifiedPackageName & a) :
- Query(tr1::shared_ptr<QueryDelegate>(new MatchesDelegate(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(a))))))
+ Query(tr1::shared_ptr<QueryDelegate>(new MatchesDelegate(PackageDepSpec(make_package_dep_spec().package(a)))))
{
}
query::Repository::Repository(const RepositoryName & a) :
- Query(tr1::shared_ptr<QueryDelegate>(new MatchesDelegate(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(new RepositoryName(a))))))
+ Query(tr1::shared_ptr<QueryDelegate>(new MatchesDelegate(make_package_dep_spec().repository(a))))
{
}
query::Category::Category(const CategoryNamePart & a) :
- Query(tr1::shared_ptr<QueryDelegate>(new MatchesDelegate(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(),
- tr1::shared_ptr<CategoryNamePart>(new CategoryNamePart(a))))))
+ Query(tr1::shared_ptr<QueryDelegate>(new MatchesDelegate(make_package_dep_spec().category_name_part(a))))
{
}
diff --git a/paludis/range_rewriter.cc b/paludis/range_rewriter.cc
index 8437134..9f99d93 100644
--- a/paludis/range_rewriter.cc
+++ b/paludis/range_rewriter.cc
@@ -21,12 +21,152 @@
#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/dep_spec.hh>
+#include <list>
+#include <sstream>
+#include <algorithm>
using namespace paludis;
+namespace
+{
+ struct RangeRewrittenPackageDepSpecData :
+ PackageDepSpecData
+ {
+ tr1::shared_ptr<QualifiedPackageName> package;
+ tr1::shared_ptr<VersionRequirements> version_requirements;
+ VersionRequirementsMode version_requirements_mode_v;
+ std::list<std::string> strings;
+
+ virtual std::string as_string() const
+ {
+ std::ostringstream s;
+ s << *package_ptr();
+
+ if (version_requirements_ptr())
+ {
+ bool need_op(false);
+ s << "[";
+ for (VersionRequirements::ConstIterator r(version_requirements_ptr()->begin()),
+ r_end(version_requirements_ptr()->end()) ; r != r_end ; ++r)
+ {
+ if (need_op)
+ {
+ do
+ {
+ switch (version_requirements_mode())
+ {
+ case vr_and:
+ s << "&";
+ continue;
+
+ case vr_or:
+ s << "|";
+ continue;
+
+ case last_vr:
+ ;
+ }
+ throw InternalError(PALUDIS_HERE, "Bad version_requirements_mode");
+ } while (false);
+ }
+
+ if (r->version_operator == vo_equal_star)
+ s << "=";
+ else
+ s << r->version_operator;
+
+ s << r->version_spec;
+
+ if (r->version_operator == vo_equal_star)
+ s << "*";
+
+ need_op = true;
+ }
+ s << "]";
+ }
+
+ return s.str() + " (rewritten from { " + join(strings.begin(), strings.end(), ", ") + " })";
+ }
+
+ virtual tr1::shared_ptr<const QualifiedPackageName> package_ptr() const
+ {
+ return package;
+ }
+
+ virtual tr1::shared_ptr<const PackageNamePart> package_name_part_ptr() const
+ {
+ return tr1::shared_ptr<const PackageNamePart>();
+ }
+
+ virtual tr1::shared_ptr<const CategoryNamePart> category_name_part_ptr() const
+ {
+ return tr1::shared_ptr<const CategoryNamePart>();
+ }
+
+ virtual tr1::shared_ptr<const VersionRequirements> version_requirements_ptr() const
+ {
+ return version_requirements;
+ }
+
+ virtual const VersionRequirementsMode version_requirements_mode() const
+ {
+ return version_requirements_mode_v;
+ }
+
+ virtual tr1::shared_ptr<const SlotName> slot_ptr() const
+ {
+ return tr1::shared_ptr<const SlotName>();
+ }
+
+ virtual tr1::shared_ptr<const RepositoryName> repository_ptr() const
+ {
+ return tr1::shared_ptr<const RepositoryName>();
+ }
+
+ virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const
+ {
+ return tr1::shared_ptr<const UseRequirements>();
+ }
+
+ void add_spec(const PackageDepSpec & spec)
+ {
+ strings.push_back(stringify(spec));
+ std::copy(spec.version_requirements_ptr()->begin(), spec.version_requirements_ptr()->end(),
+ version_requirements->back_inserter());
+ }
+
+ RangeRewrittenPackageDepSpecData(const PackageDepSpec & spec) :
+ package(new QualifiedPackageName(*spec.package_ptr())),
+ version_requirements(new VersionRequirements),
+ version_requirements_mode_v(vr_or)
+ {
+ strings.push_back(stringify(spec));
+ std::copy(spec.version_requirements_ptr()->begin(), spec.version_requirements_ptr()->end(),
+ version_requirements->back_inserter());
+ }
+ };
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<RangeRewriter>
+ {
+ bool invalid;
+ tr1::shared_ptr<RangeRewrittenPackageDepSpecData> spec_data;
+
+ Implementation() :
+ invalid(false)
+ {
+ }
+ };
+}
+
RangeRewriter::RangeRewriter() :
- _invalid(false)
+ PrivateImplementationPattern<RangeRewriter>(new Implementation<RangeRewriter>())
{
}
@@ -40,7 +180,7 @@ RangeRewriter::visit_sequence(const AllDepSpec &,
DependencySpecTree::ConstSequenceIterator end)
{
if (cur != end)
- _invalid = true;
+ _imp->invalid = true;
}
void
@@ -49,7 +189,7 @@ RangeRewriter::visit_sequence(const AnyDepSpec &,
DependencySpecTree::ConstSequenceIterator end)
{
if (cur != end)
- _invalid = true;
+ _imp->invalid = true;
}
void
@@ -57,62 +197,69 @@ RangeRewriter::visit_sequence(const UseDepSpec &,
DependencySpecTree::ConstSequenceIterator,
DependencySpecTree::ConstSequenceIterator)
{
- _invalid = true;
+ _imp->invalid = true;
}
void
RangeRewriter::visit_leaf(const PackageDepSpec & a)
{
- if (_invalid)
+ if (_imp->invalid)
return;
- if (a.use_requirements_ptr() || a.slot_ptr() || a.use_requirements_ptr() || ! a.version_requirements_ptr())
+ if (a.use_requirements_ptr() || a.slot_ptr() || a.repository_ptr() || a.package_name_part_ptr()
+ || a.category_name_part_ptr() || ! a.version_requirements_ptr() || ! a.package_ptr())
{
- _invalid = true;
+ _imp->invalid = true;
return;
}
- if (a.version_requirements_mode() != vr_or && 1 != std::distance(a.version_requirements_ptr()->begin(),
- a.version_requirements_ptr()->end()))
+ if (a.version_requirements_mode() == vr_and &&
+ 1 != std::distance(a.version_requirements_ptr()->begin(), a.version_requirements_ptr()->end()))
{
- _invalid = true;
+ _imp->invalid = true;
return;
}
- if (_spec)
+ if (_imp->spec_data)
{
- if ((! a.package_ptr()) || (! _spec->package_ptr()) || (*a.package_ptr() != *_spec->package_ptr()))
+ if (*_imp->spec_data->package_ptr() != *a.package_ptr())
{
- _invalid = true;
+ _imp->invalid = true;
return;
}
- for (VersionRequirements::ConstIterator v(a.version_requirements_ptr()->begin()),
- v_end(a.version_requirements_ptr()->end()) ; v != v_end ; ++v)
- _spec->version_requirements_ptr()->push_back(*v);
+ _imp->spec_data->add_spec(a);
}
else
{
- _spec.reset(new PackageDepSpec(a));
- _spec->set_version_requirements_mode(vr_or);
+ _imp->spec_data.reset(new RangeRewrittenPackageDepSpecData(a));
}
}
void
RangeRewriter::visit_leaf(const BlockDepSpec &)
{
- _invalid = true;
+ _imp->invalid = true;
}
void
RangeRewriter::visit_leaf(const DependencyLabelsDepSpec &)
{
- _invalid = true;
+ _imp->invalid = true;
}
void
RangeRewriter::visit_leaf(const NamedSetDepSpec &)
{
- _invalid = true;
+ _imp->invalid = true;
+}
+
+tr1::shared_ptr<PackageDepSpec>
+RangeRewriter::spec() const
+{
+ if (_imp->invalid || ! _imp->spec_data)
+ return tr1::shared_ptr<PackageDepSpec>();
+
+ return tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(_imp->spec_data));
}
diff --git a/paludis/range_rewriter.hh b/paludis/range_rewriter.hh
index 2f8a97f..37088c4 100644
--- a/paludis/range_rewriter.hh
+++ b/paludis/range_rewriter.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_RANGE_REWRITER_HH 1
#include <paludis/dep_tree.hh>
+#include <paludis/util/private_implementation_pattern.hh>
/** \file
* Declarations for RangeRewriter, which is used internally by Deplist.
@@ -43,12 +44,9 @@ namespace paludis
* \nosubgrouping
*/
class PALUDIS_VISIBLE RangeRewriter :
- public ConstVisitor<DependencySpecTree>
+ public ConstVisitor<DependencySpecTree>,
+ private PrivateImplementationPattern<RangeRewriter>
{
- private:
- tr1::shared_ptr<PackageDepSpec> _spec;
- bool _invalid;
-
public:
///\name Basic operations
///\{
@@ -62,13 +60,7 @@ namespace paludis
* Our rewritten spec, or a zero pointer if we couldn't do any
* rewriting.
*/
- tr1::shared_ptr<PackageDepSpec> spec() const
- {
- if (_invalid)
- return tr1::shared_ptr<PackageDepSpec>();
-
- return _spec;
- }
+ tr1::shared_ptr<PackageDepSpec> spec() const;
///\name Visit methods
///\{
diff --git a/paludis/range_rewriter_TEST.cc b/paludis/range_rewriter_TEST.cc
index d4584c0..c832e5b 100644
--- a/paludis/range_rewriter_TEST.cc
+++ b/paludis/range_rewriter_TEST.cc
@@ -20,6 +20,7 @@
#include <paludis/range_rewriter.hh>
#include <paludis/dep_spec.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/options.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
@@ -39,9 +40,9 @@ namespace test_cases
void run()
{
tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > a(new TreeLeaf<DependencySpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("=a/b-1", pds_pm_permissive))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("=a/b-1", UserPackageDepSpecOptions())))));
tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > b(new TreeLeaf<DependencySpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("=a/b-2", pds_pm_permissive))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_user_package_dep_spec("=a/b-2", UserPackageDepSpecOptions())))));
RangeRewriter r;
TEST_CHECK(! r.spec());
@@ -50,7 +51,7 @@ namespace test_cases
TEST_CHECK(r.spec());
TEST_CHECK(r.spec());
- TEST_CHECK_STRINGIFY_EQUAL(*r.spec(), "a/b[=1|=2]");
+ TEST_CHECK_STRINGIFY_EQUAL(*r.spec(), "a/b[=1|=2] (rewritten from { =a/b-1, =a/b-2 })");
}
} test_range_rewriter;
}
diff --git a/paludis/report_task.cc b/paludis/report_task.cc
index 69ec926..6fa4c2f 100644
--- a/paludis/report_task.cc
+++ b/paludis/report_task.cc
@@ -29,6 +29,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/package_database.hh>
+#include <paludis/version_requirements.hh>
#include <set>
#include <map>
@@ -194,21 +195,14 @@ ReportTask::execute()
if ((*v)->source_origin_key())
{
- tr1::shared_ptr<QualifiedPackageName> pkg_name(new QualifiedPackageName((*v)->name()));
- tr1::shared_ptr<VersionRequirements> ver_reqs(make_equal_to_version_requirements((*v)->version()));
repo_name.reset(new RepositoryName((*v)->source_origin_key()->value()));
tr1::shared_ptr<const PackageIDSequence> installable(
e->package_database()->query(
- query::Matches(
- PackageDepSpec(
- pkg_name,
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- ver_reqs,
- vr_and,
- tr1::shared_ptr<SlotName>(),
- repo_name)) &
+ query::Matches(make_package_dep_spec()
+ .package((*v)->name())
+ .version_requirement(VersionRequirement(vo_equal, (*v)->version()))
+ .repository(*repo_name)) &
query::SupportsAction<InstallAction>(),
qo_best_version_only));
diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am
index 4aa5404..f51773f 100644
--- a/paludis/repositories/cran/Makefile.am
+++ b/paludis/repositories/cran/Makefile.am
@@ -36,7 +36,8 @@ paludis_repositories_cran_include_HEADERS = \
masks.hh \
keys.hh \
normalise.hh \
- dep_spec_pretty_printer.hh
+ dep_spec_pretty_printer.hh \
+ package_dep_spec.hh
libpaludiscranrepository_la_SOURCES = \
cran_package_id.cc \
@@ -49,6 +50,7 @@ libpaludiscranrepository_la_SOURCES = \
masks.cc \
keys.cc \
dep_spec_pretty_printer.cc \
+ package_dep_spec.cc \
$(paludis_repositories_cran_include_HEADERS)
libpaludiscranrepository_la_LIBADD = \
diff --git a/paludis/repositories/cran/cran_dep_parser.cc b/paludis/repositories/cran/cran_dep_parser.cc
index a37eeba..307d1ca 100644
--- a/paludis/repositories/cran/cran_dep_parser.cc
+++ b/paludis/repositories/cran/cran_dep_parser.cc
@@ -20,6 +20,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
#include <paludis/repositories/cran/normalise.hh>
+#include <paludis/repositories/cran/package_dep_spec.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/stringify.hh>
@@ -39,45 +40,37 @@ cranrepository::parse_depends(const std::string & s)
new ConstTreeSequence<DependencySpecTree, AllDepSpec>(tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
std::list<std::string> specs;
- tokenise<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(s, ",", "", std::back_inserter(specs));
- std::list<std::string>::const_iterator a(specs.begin()), a_end(specs.end());
- for ( ; a != a_end ; ++a)
+ std::string::size_type p(0), s_p(0);
+ while (p < s.length())
{
- Context local_context("When processing token '" + *a + "':");
-
- std::string aa = strip_leading(strip_trailing(*a, ")"), " \t");
-
- std::string name, tmp, version, range;
- std::string::size_type p(aa.find('('));
- if ((std::string::npos != p))
+ if (s[p] == ',')
+ {
+ specs.push_back(s.substr(s_p, p - s_p));
+ s_p = ++p;
+ }
+ else if (s[p] == '(')
{
- name = strip_leading(strip_trailing(aa.substr(0, p), " \t"), " \t");
- tmp = aa.substr(p + 1);
- p = tmp.find(')');
- aa = tmp.substr(0, p);
- version = strip_trailing(strip_leading(aa, " \t(<>=~"), " )\t\n");
- range = strip_trailing(strip_leading(aa.substr(0, aa.find(version)), " \t"), " \t\n");
+ p = s.find(')', p);
+ if (std::string::npos == p)
+ p = s.length();
}
else
- name = strip_leading(strip_trailing(aa, " \t"), " \t");
+ ++p;
+ }
- name = cran_name_to_internal(name);
- version = cran_version_to_internal(version);
+ if (s_p < s.length())
+ specs.push_back(s.substr(s_p));
- if ("R" == name)
- name = "dev-lang/R";
- else
- name = "cran/" + name;
+ std::list<std::string>::const_iterator a(specs.begin()), a_end(specs.end());
+ for ( ; a != a_end ; ++a)
+ {
+ Context local_context("When processing token '" + *a + "':");
- std::string spec_string;
- if (version.empty() || range.empty())
- spec_string = name;
- else
- spec_string = range + name + "-" + version;
tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > spec(
new TreeLeaf<DependencySpecTree, PackageDepSpec>(tr1::shared_ptr<PackageDepSpec>(
- new PackageDepSpec(spec_string, pds_pm_permissive))));
+ new PackageDepSpec(cranrepository::parse_cran_package_dep_spec(
+ strip_leading(strip_trailing(*a, " \r\n\t"), " \r\n\t"))))));
result->add(spec);
}
diff --git a/paludis/repositories/cran/cran_dep_parser_TEST.cc b/paludis/repositories/cran/cran_dep_parser_TEST.cc
index 94fb6da..777ef2a 100644
--- a/paludis/repositories/cran/cran_dep_parser_TEST.cc
+++ b/paludis/repositories/cran/cran_dep_parser_TEST.cc
@@ -40,22 +40,35 @@ namespace test_cases
void run()
{
StringifyFormatter ff;
- cranrepository::DepSpecPrettyPrinter d1(0, ff, 0, false), d2(0, ff, 0, false), d3(0, ff, 0, false);
+ cranrepository::DepSpecPrettyPrinter d1(0, ff, 0, false), d2(0, ff, 0, false), d3(0, ff, 0, false),
+ d4(0, ff, 0, false), d5(0, ff, 0, false), d6(0, ff, 0, false);
// test R dependency
std::string dep1("R (>= 2.0.0)");
cranrepository::parse_depends(dep1)->accept(d1);
- TEST_CHECK_EQUAL(stringify(d1), ">=dev-lang/R-2.0.0");
+ TEST_CHECK_EQUAL(stringify(d1), "R (>= 2.0.0)");
// test varying whitespaces
std::string dep2("testpackage1 \t(<1.9)");
cranrepository::parse_depends(dep2)->accept(d2);
- TEST_CHECK_EQUAL(stringify(d2), "<cran/testpackage1-1.9");
+ TEST_CHECK_EQUAL(stringify(d2), "testpackage1 (< 1.9)");
// test for package-name and version normalisation
std::string dep3("R.matlab (>= 2.3-1)");
cranrepository::parse_depends(dep3)->accept(d3);
- TEST_CHECK_EQUAL(stringify(d3), ">=cran/R-matlab-2.3.1");
+ TEST_CHECK_EQUAL(stringify(d3), "R.matlab (>= 2.3.1)");
+
+ std::string dep4("foo (>= 2, <3)");
+ cranrepository::parse_depends(dep4)->accept(d4);
+ TEST_CHECK_EQUAL(stringify(d4), "foo (>= 2, < 3)");
+
+ std::string dep5("foo (>= 2), bar (<=3)");
+ cranrepository::parse_depends(dep5)->accept(d5);
+ TEST_CHECK_EQUAL(stringify(d5), "foo (>= 2), bar (<= 3)");
+
+ std::string dep6("foo (>= 2, <= 4), bar (<=3)");
+ cranrepository::parse_depends(dep6)->accept(d6);
+ TEST_CHECK_EQUAL(stringify(d6), "foo (>= 2, <= 4), bar (<= 3)");
}
} test_cran_dep_parser;
}
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index cd69c35..8c96361 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -30,6 +30,7 @@
#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
#include <paludis/repositories/cran/cran_installed_repository.hh>
+#include <paludis/repositories/cran/package_dep_spec.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/fs_entry.hh>
@@ -444,7 +445,7 @@ CRANInstalledRepository::package_set(const SetName & s) const
{
tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> > spec(
new TreeLeaf<SetSpecTree, PackageDepSpec>(make_shared_ptr(
- new PackageDepSpec(make_shared_ptr(new QualifiedPackageName(p->first))))));
+ new PackageDepSpec(cranrepository::parse_cran_package_dep_spec(stringify(p->first.package))))));
result->add(spec);
}
@@ -458,10 +459,11 @@ CRANInstalledRepository::package_set(const SetName & s) const
if (_imp->params.world.exists())
{
+ using namespace tr1::placeholders;
SetFile world(SetFileParams::create()
.file_name(_imp->params.world)
.type(sft_simple)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tag)
.environment(_imp->params.environment));
@@ -503,6 +505,8 @@ CRANInstalledRepository::invalidate_masks()
void
CRANInstalledRepository::add_string_to_world(const std::string & n) const
{
+ using namespace tr1::placeholders;
+
Context context("When adding '" + n + "' to world file '" + stringify(_imp->params.world) + "':");
if (! _imp->params.world.exists())
@@ -519,7 +523,7 @@ CRANInstalledRepository::add_string_to_world(const std::string & n) const
SetFile world(SetFileParams::create()
.file_name(_imp->params.world)
.type(sft_simple)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tr1::shared_ptr<DepTag>())
.environment(_imp->params.environment));
world.add(n);
@@ -529,6 +533,8 @@ CRANInstalledRepository::add_string_to_world(const std::string & n) const
void
CRANInstalledRepository::remove_string_from_world(const std::string & n) const
{
+ using namespace tr1::placeholders;
+
Context context("When removing '" + n + "' from world file '" + stringify(_imp->params.world) + "':");
if (_imp->params.world.exists())
@@ -536,7 +542,7 @@ CRANInstalledRepository::remove_string_from_world(const std::string & n) const
SetFile world(SetFileParams::create()
.file_name(_imp->params.world)
.type(sft_simple)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tr1::shared_ptr<DepTag>())
.environment(_imp->params.environment));
diff --git a/paludis/repositories/cran/package_dep_spec.cc b/paludis/repositories/cran/package_dep_spec.cc
new file mode 100644
index 0000000..09b4c3c
--- /dev/null
+++ b/paludis/repositories/cran/package_dep_spec.cc
@@ -0,0 +1,180 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/cran/package_dep_spec.hh>
+#include <paludis/repositories/cran/normalise.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/version_operator.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/version_requirements.hh>
+#include <vector>
+
+using namespace paludis;
+using namespace paludis::cranrepository;
+
+namespace
+{
+ struct CRANPackageDepSpecData :
+ PackageDepSpecData
+ {
+ std::string unnormalised_package_name;
+ tr1::shared_ptr<const QualifiedPackageName> package_v;
+ tr1::shared_ptr<VersionRequirements> version_requirements_v;
+
+ virtual std::string as_string() const
+ {
+ std::string result(unnormalised_package_name);
+
+ if (version_requirements_v && ! version_requirements_v->empty())
+ {
+ result.append(" (");
+ bool first(true);
+ for (VersionRequirements::ConstIterator r(version_requirements_v->begin()),
+ r_end(version_requirements_v->end()) ; r != r_end ; ++r)
+ {
+ if (! first)
+ result.append(", ");
+ first = false;
+ result.append(stringify(r->version_operator));
+ result.append(" ");
+ result.append(stringify(r->version_spec));
+ }
+ result.append(")");
+ }
+
+ return result;
+ }
+
+ virtual tr1::shared_ptr<const QualifiedPackageName> package_ptr() const
+ {
+ return package_v;
+ }
+
+ virtual tr1::shared_ptr<const PackageNamePart> package_name_part_ptr() const
+ {
+ return tr1::shared_ptr<const PackageNamePart>();
+ }
+
+ virtual tr1::shared_ptr<const CategoryNamePart> category_name_part_ptr() const
+ {
+ return tr1::shared_ptr<const CategoryNamePart>();
+ }
+
+ virtual tr1::shared_ptr<const VersionRequirements> version_requirements_ptr() const
+ {
+ return version_requirements_v;
+ }
+
+ virtual const VersionRequirementsMode version_requirements_mode() const
+ {
+ return vr_and;
+ }
+
+ virtual tr1::shared_ptr<const SlotName> slot_ptr() const
+ {
+ return tr1::shared_ptr<const SlotName>();
+ }
+
+ virtual tr1::shared_ptr<const RepositoryName> repository_ptr() const
+ {
+ return tr1::shared_ptr<const RepositoryName>();
+ }
+
+ virtual tr1::shared_ptr<const UseRequirements> use_requirements_ptr() const
+ {
+ return tr1::shared_ptr<const UseRequirements>();
+ }
+
+ CRANPackageDepSpecData & version_requirement(const VersionRequirement & v)
+ {
+ if (! version_requirements_v)
+ version_requirements_v.reset(new VersionRequirements);
+ version_requirements_v->push_back(v);
+ return *this;
+ }
+
+ CRANPackageDepSpecData & package(const std::string & s)
+ {
+ unnormalised_package_name = s;
+ if ("R" == s)
+ package_v.reset(new QualifiedPackageName("dev-lang/R"));
+ else
+ package_v.reset(new QualifiedPackageName(CategoryNamePart("cran") + PackageNamePart(cran_name_to_internal(s))));
+
+ return *this;
+ }
+ };
+}
+
+PackageDepSpec
+paludis::cranrepository::parse_cran_package_dep_spec(const std::string & ss)
+{
+ Context context("When parsing CRAN package dep spec '" + ss + "':");
+
+ tr1::shared_ptr<CRANPackageDepSpecData> data(new CRANPackageDepSpecData);
+ std::string s(ss);
+
+ std::string::size_type p(s.find('('));
+ if (std::string::npos != p)
+ {
+ std::string restrictions(s.substr(p));
+ s.erase(p);
+ s = strip_trailing(s, " \r\n\t");
+
+ if (restrictions.empty() || (')' != restrictions.at(restrictions.length() - 1)))
+ throw PackageDepSpecError("Invalid () part in '" + ss + "'");
+ restrictions = strip_leading(strip_trailing(restrictions.substr(1, restrictions.length() - 2), " \r\n\t"), " \r\n\t");
+
+ std::vector<std::string> tokens;
+ tokenise<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(restrictions, ",", "", std::back_inserter(tokens));
+ if (tokens.empty())
+ throw PackageDepSpecError("Invalid empty () part in '" + ss + "'");
+
+ for (std::vector<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ {
+ std::vector<std::string> subtokens;
+ tokenise_whitespace(*t, std::back_inserter(subtokens));
+ if (subtokens.size() == 1)
+ {
+ std::string::size_type vp(subtokens[0].find_first_not_of("<>="));
+ if (std::string::npos != vp)
+ {
+ subtokens.push_back(subtokens[0].substr(vp));
+ subtokens[0].erase(vp);
+ }
+ }
+
+ if (subtokens.size() != 2)
+ throw PackageDepSpecError("Invalid () entry '" + *t + "' in '" + ss + "'");
+ data->version_requirement(VersionRequirement(
+ VersionOperator(subtokens[0]),
+ VersionSpec(cran_version_to_internal(subtokens[1]))));
+ }
+ }
+
+ data->package(s);
+
+ return PackageDepSpec(data);
+}
+
diff --git a/paludis/repositories/cran/package_dep_spec.hh b/paludis/repositories/cran/package_dep_spec.hh
new file mode 100644
index 0000000..207cf4b
--- /dev/null
+++ b/paludis/repositories/cran/package_dep_spec.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_PACKAGE_DEP_SPEC_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_PACKAGE_DEP_SPEC_HH 1
+
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ namespace cranrepository
+ {
+ PackageDepSpec parse_cran_package_dep_spec(const std::string &) PALUDIS_VISIBLE;
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 0b7c46a..e6baa16 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -79,6 +79,7 @@ paludis_repositories_e_include_HEADERS = \
make_ebuild_repository.hh \
manifest2_entry-sr.hh \
manifest2_reader.hh \
+ package_dep_spec.hh \
source_uri_finder.hh \
traditional_layout.hh \
use_desc.hh \
@@ -125,6 +126,7 @@ libpaludiserepository_la_SOURCES = \
make_ebin_repository.cc \
make_ebuild_repository.cc \
manifest2_reader.cc \
+ package_dep_spec.cc \
registration.cc \
source_uri_finder.cc \
traditional_layout.cc \
diff --git a/paludis/repositories/e/dep_parser-fwd.hh b/paludis/repositories/e/dep_parser-fwd.hh
index 52c5df2..c4bf91b 100644
--- a/paludis/repositories/e/dep_parser-fwd.hh
+++ b/paludis/repositories/e/dep_parser-fwd.hh
@@ -22,6 +22,7 @@
#include <iosfwd>
#include <paludis/util/attributes.hh>
+#include <paludis/util/options-fwd.hh>
namespace paludis
{
@@ -32,6 +33,9 @@ namespace paludis
#include <paludis/repositories/e/dep_parser-se.hh>
+ typedef Options<PackageDepSpecParseOption> PackageDepSpecParseOptions;
+ typedef Options<DependencySpecTreeParseOption> DependencySpecTreeParseOptions;
+
}
}
diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc
index cd52635..cefbdae 100644
--- a/paludis/repositories/e/dep_parser.cc
+++ b/paludis/repositories/e/dep_parser.cc
@@ -21,6 +21,7 @@
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/dep_lexer.hh>
#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/repositories/e/package_dep_spec.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/tokeniser.hh>
@@ -76,10 +77,10 @@ namespace
struct ParsePackageDepSpec
{
- PackageDepSpecParseMode _parse_mode;
+ const EAPI & _eapi;
- ParsePackageDepSpec(PackageDepSpecParseMode m) :
- _parse_mode(m)
+ ParsePackageDepSpec(const EAPI & e) :
+ _eapi(e)
{
}
@@ -88,7 +89,7 @@ namespace
add(const std::string & s, tr1::function<void (tr1::shared_ptr<ConstAcceptInterface<H_> >)> & p) const
{
p(tr1::shared_ptr<TreeLeaf<H_, PackageDepSpec> >(new TreeLeaf<H_, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(s, _parse_mode)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(parse_e_package_dep_spec(s, _eapi))))));
}
template <typename H_>
@@ -101,10 +102,10 @@ namespace
struct ParsePackageOrBlockDepSpec
{
- PackageDepSpecParseMode _parse_mode;
+ const EAPI & _eapi;
- ParsePackageOrBlockDepSpec(PackageDepSpecParseMode m) :
- _parse_mode(m)
+ ParsePackageOrBlockDepSpec(const EAPI & e) :
+ _eapi(e)
{
}
@@ -114,11 +115,13 @@ namespace
{
if (s.empty() || '!' != s.at(0))
p(tr1::shared_ptr<TreeLeaf<H_, PackageDepSpec> >(new TreeLeaf<H_, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(s, _parse_mode)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_e_package_dep_spec(s, _eapi))))));
else
p(tr1::shared_ptr<TreeLeaf<H_, BlockDepSpec> >(new TreeLeaf<H_, BlockDepSpec>(
tr1::shared_ptr<BlockDepSpec>(new BlockDepSpec(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(s.substr(1), _parse_mode)))))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_e_package_dep_spec(s.substr(1), _eapi))))))));
}
template <typename H_>
@@ -310,24 +313,6 @@ namespace
throw DepStringParseError(s, "Dependency labels not allowed in this EAPI");
}
};
-
- bool disallow_any_use(const DependencySpecTreeParseMode tree_mode)
- {
- switch (tree_mode)
- {
- case dst_pm_eapi_0:
- return false;
-
- case dst_pm_paludis_1:
- case dst_pm_exheres_0:
- return true;
-
- case last_dst_pm:
- ;
- }
-
- throw InternalError(PALUDIS_HERE, "bad _tree_mode");
- }
}
namespace
@@ -683,8 +668,8 @@ paludis::erepository::parse_depend(const std::string & s, const EAPI & e)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' dependencies");
return parse<DependencySpecTree, ParsePackageOrBlockDepSpec, true, true, LabelsAreDependency>(s,
- disallow_any_use(e.supported->dependency_spec_tree_parse_mode),
- ParsePackageOrBlockDepSpec(e.supported->package_dep_spec_parse_mode), e);
+ e.supported->dependency_spec_tree_parse_options[dstpo_disallow_any_use],
+ ParsePackageOrBlockDepSpec(e), e);
}
tr1::shared_ptr<ProvideSpecTree::ConstItem>
@@ -695,8 +680,7 @@ paludis::erepository::parse_provide(const std::string & s, const EAPI & e)
if (! e.supported)
throw DepStringParseError(s, "Don't know how to parse EAPI '" + e.name + "' provides");
- return parse<ProvideSpecTree, ParsePackageDepSpec, false, true, void>(s, false,
- ParsePackageDepSpec(pds_pm_eapi_0), e);
+ return parse<ProvideSpecTree, ParsePackageDepSpec, false, true, void>(s, false, ParsePackageDepSpec(e), e);
}
tr1::shared_ptr<RestrictSpecTree::ConstItem>
diff --git a/paludis/repositories/e/dep_parser.se b/paludis/repositories/e/dep_parser.se
index df9c782..bc5a5f6 100644
--- a/paludis/repositories/e/dep_parser.se
+++ b/paludis/repositories/e/dep_parser.se
@@ -21,3 +21,26 @@ make_enum_DependencySpecTreeParseMode()
END
}
+make_enum_PackageDepSpecParseOption()
+{
+ prefix pdspo
+ want_destringify
+ namespace paludis::erepository
+
+ key pdspo_allow_slot_deps "Allow :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"
+ key pdspo_strict_star_operator "* with an operator other than = is an error"
+ key pdspo_strict_parsing "Error rather than warn for violations"
+}
+
+make_enum_DependencySpecTreeParseOption()
+{
+ prefix dstpo
+ want_destringify
+ namespace paludis::erepository
+
+ key dstpo_disallow_any_use "Disallow || ( use? ( ... ) )"
+}
+
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 604ce65..9eb415d 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -29,6 +29,7 @@
#include <paludis/repositories/e/e_repository_sets.hh>
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/repositories/e/e_repository_entries.hh>
+#include <paludis/repositories/e/package_dep_spec.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/use_desc.hh>
#include <paludis/repositories/e/layout.hh>
@@ -116,6 +117,7 @@ namespace
const Environment * const _env;
const FSEntry _f;
+ const std::string & _p;
protected:
virtual void need_keys_added() const
@@ -141,7 +143,8 @@ namespace
tr1::shared_ptr<MetadataKey> key;
tr1::shared_ptr<const PackageIDSequence> q(
_env->package_database()->query(
- query::Matches(PackageDepSpec(*i, pds_pm_eapi_0)) &
+ query::Matches(erepository::parse_e_package_dep_spec(*i,
+ *erepository::EAPIData::get_instance()->eapi_from_string(_p))) &
query::InstalledAtRoot(_env->root()),
qo_order_by_version));
if (q->empty())
@@ -161,11 +164,12 @@ namespace
}
public:
- PkgInfoSectionKey(const Environment * const e, const FSEntry & f) :
+ PkgInfoSectionKey(const Environment * const e, const FSEntry & f, const std::string & p) :
MetadataSectionKey("info_pkgs", "Package information", mkt_normal),
_added(false),
_env(e),
- _f(f)
+ _f(f),
+ _p(p)
{
}
@@ -323,7 +327,7 @@ namespace paludis
"use_manifest", "use_manifest", mkt_normal, stringify(params.use_manifest))),
info_pkgs_key((layout->info_packages_file(params.location / "profiles")).exists() ?
tr1::shared_ptr<MetadataSectionKey>(new PkgInfoSectionKey(
- params.environment, layout->info_packages_file(params.location / "profiles"))) :
+ params.environment, layout->info_packages_file(params.location / "profiles"), params.profile_eapi)) :
tr1::shared_ptr<MetadataSectionKey>())
{
}
@@ -551,7 +555,8 @@ ERepository::repository_masked(const PackageID & id) const
{
try
{
- tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(line->first, pds_pm_eapi_0));
+ tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(erepository::parse_e_package_dep_spec(
+ line->first, *erepository::EAPIData::get_instance()->eapi_from_string(_imp->params.profile_eapi))));
if (a->package_ptr())
_imp->repo_mask[*a->package_ptr()].push_back(std::make_pair(a, line->second));
else
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 13ee7f1..1ef4956 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -389,11 +389,11 @@ namespace test_cases
indirect_iterator(versions->begin()), indirect_iterator(versions->end()),
tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), VersionSpec("1"))));
TEST_CHECK(indirect_iterator(versions->end()) != std::find_if(
- indirect_iterator(versions->begin()), indirect_iterator(versions->end()),
- tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), VersionSpec("1.1-r1"))));
+ indirect_iterator(versions->begin()), indirect_iterator(versions->end()),
+ tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), VersionSpec("1.1-r1"))));
TEST_CHECK(indirect_iterator(versions->end()) == std::find_if(
- indirect_iterator(versions->begin()), indirect_iterator(versions->end()),
- tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), VersionSpec("2"))));
+ indirect_iterator(versions->begin()), indirect_iterator(versions->end()),
+ tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), VersionSpec("2"))));
versions = repo->package_ids(QualifiedPackageName("cat-one/pkg-neither"));
TEST_CHECK(versions->empty());
@@ -474,7 +474,8 @@ namespace test_cases
{
TestMessageSuffix pass_suffix(stringify(pass), true);
tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/pkg-one-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(id->short_description_key());
TEST_CHECK_EQUAL(id->short_description_key()->value(), "the-description");
@@ -517,7 +518,8 @@ namespace test_cases
TestMessageSuffix pass_suffix("pass=" + stringify(pass), true);
tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/pkg-one-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(id1->end_metadata() != id1->find_metadata("EAPI"));
TEST_CHECK(id1->short_description_key());
@@ -533,7 +535,8 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(pr, "foo/bar");
tr1::shared_ptr<const PackageID> id2(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/pkg-one-2", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-2",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(id2->end_metadata() != id2->find_metadata("EAPI"));
TEST_CHECK(id2->short_description_key());
@@ -582,7 +585,8 @@ namespace test_cases
TestMessageSuffix pass_suffix("pass=" + stringify(pass), true);
tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/stale-pkg-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/stale-pkg-1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(id1->end_metadata() != id1->find_metadata("EAPI"));
TEST_CHECK(id1->short_description_key());
@@ -594,7 +598,8 @@ namespace test_cases
TestMessageSuffix pass_suffix("pass=" + stringify(pass), true);
tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/stale-pkg-2", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/stale-pkg-2",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(id1->end_metadata() != id1->find_metadata("EAPI"));
TEST_CHECK(id1->short_description_key());
@@ -639,7 +644,8 @@ namespace test_cases
TestMessageSuffix pass_suffix(stringify(pass), true);
tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/pkg-two-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-two-1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(id1->end_metadata() != id1->find_metadata("EAPI"));
TEST_CHECK_EQUAL(tr1::static_pointer_cast<const erepository::ERepositoryID>(id1)->eapi()->name, "UNKNOWN");
@@ -672,12 +678,12 @@ namespace test_cases
{
TestMessageSuffix pass_suffix(stringify(pass), true);
- tr1::shared_ptr<const PackageID> p1(*env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat-one/pkg-one-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
- tr1::shared_ptr<const PackageID> p2(*env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat-two/pkg-two-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
- tr1::shared_ptr<const PackageID> p4(*env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat-one/pkg-one-2", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ tr1::shared_ptr<const PackageID> p1(*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
+ tr1::shared_ptr<const PackageID> p2(*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-two/pkg-two-1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
+ tr1::shared_ptr<const PackageID> p4(*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-2",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin());
TEST_CHECK(repo->query_use(UseFlagName("flag1"), *p1) == use_enabled);
TEST_CHECK(repo->query_use(UseFlagName("flag2"), *p1) == use_disabled);
@@ -720,12 +726,15 @@ namespace test_cases
{
TestMessageSuffix pass_suffix(stringify(pass), true);
- TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec("=cat/masked-0", pds_pm_unspecific)),
- qo_require_exactly_one)->begin())->masked());
- TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec("=cat/was_masked-0", pds_pm_unspecific)),
- qo_require_exactly_one)->begin())->masked());
- TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec("=cat/not_masked-0", pds_pm_unspecific)),
- qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat/masked-0",
+ UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat/was_masked-0",
+ UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat/not_masked-0",
+ UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin())->masked());
}
}
} test_e_repository_query_profile_masks;
@@ -750,14 +759,17 @@ namespace test_cases
tr1::shared_ptr<ERepository> repo(make_ebuild_repository(&env, keys));
env.package_database()->add_repository(1, repo);
- TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec("=cat/was_masked-0", pds_pm_unspecific)),
- qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat/was_masked-0",
+ UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin())->masked());
repo->set_profile(repo->find_profile(repo->params().location / "profiles/profile/subprofile"));
- TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec("=cat/was_masked-0", pds_pm_unspecific)),
- qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat/was_masked-0",
+ UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin())->masked());
repo->set_profile(repo->find_profile(repo->params().location / "profiles/profile"));
- TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec("=cat/was_masked-0", pds_pm_unspecific)),
- qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat/was_masked-0",
+ UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin())->masked());
}
} test_e_repository_invalidate_masks;
@@ -786,7 +798,7 @@ namespace test_cases
tr1::shared_ptr<const RepositoryVirtualsInterface::VirtualsSequence> seq(repo->virtual_packages());
for (RepositoryVirtualsInterface::VirtualsSequence::ConstIterator it(seq->begin()),
- it_end(seq->end()); it_end != it; ++it, ++count)
+ it_end(seq->end()); it_end != it; ++it, ++count)
if ("virtual/one" == stringify(it->virtual_name))
{
has_one = true;
@@ -810,7 +822,7 @@ namespace test_cases
seq = repo->virtual_packages();
for (RepositoryVirtualsInterface::VirtualsSequence::ConstIterator it(seq->begin()),
- it_end(seq->end()); it_end != it; ++it, ++count)
+ it_end(seq->end()); it_end != it; ++it, ++count)
if ("virtual/one" == stringify(it->virtual_name))
{
has_one = true;
@@ -904,7 +916,8 @@ namespace test_cases
{
TestMessageSuffix suffix("no files", true);
const tr1::shared_ptr<const PackageID> no_files_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/no-files", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/no-files",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(no_files_id);
TEST_CHECK(no_files_id->short_description_key());
TEST_CHECK_EQUAL(no_files_id->short_description_key()->value(), "The Description");
@@ -914,7 +927,8 @@ namespace test_cases
{
TestMessageSuffix suffix("fetched files", true);
const tr1::shared_ptr<const PackageID> fetched_files_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/fetched-files", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/fetched-files",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(fetched_files_id);
TEST_CHECK((FSEntry("e_repository_TEST_dir") / "distdir" / "already-fetched.txt").is_regular_file());
fetched_files_id->perform_action(action);
@@ -925,7 +939,8 @@ namespace test_cases
TestMessageSuffix suffix("fetchable files", true);
TEST_CHECK(! (FSEntry("e_repository_TEST_dir") / "distdir" / "fetchable-1.txt").is_regular_file());
const tr1::shared_ptr<const PackageID> fetchable_files_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/fetchable-files", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/fetchable-files",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(fetchable_files_id);
fetchable_files_id->perform_action(action);
TEST_CHECK((FSEntry("e_repository_TEST_dir") / "distdir" / "fetchable-1.txt").is_regular_file());
@@ -935,7 +950,8 @@ namespace test_cases
TestMessageSuffix suffix("arrow files", true);
TEST_CHECK(! (FSEntry("e_repository_TEST_dir") / "distdir" / "arrowed.txt").is_regular_file());
const tr1::shared_ptr<const PackageID> arrow_files_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/arrow-files", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/arrow-files",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(arrow_files_id);
arrow_files_id->perform_action(action);
TEST_CHECK((FSEntry("e_repository_TEST_dir") / "distdir" / "arrowed.txt").is_regular_file());
@@ -944,28 +960,32 @@ namespace test_cases
{
TestMessageSuffix suffix("unfetchable files", true);
const tr1::shared_ptr<const PackageID> unfetchable_files_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/unfetchable-files", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/unfetchable-files",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(unfetchable_files_id);
TEST_CHECK_THROWS(unfetchable_files_id->perform_action(action), FetchActionError);
}
{
const tr1::shared_ptr<const PackageID> no_files_restricted_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/no-files-restricted", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/no-files-restricted",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(no_files_restricted_id);
no_files_restricted_id->perform_action(action);
}
{
const tr1::shared_ptr<const PackageID> fetched_files_restricted_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/fetched-files-restricted", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/fetched-files-restricted",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(fetched_files_restricted_id);
fetched_files_restricted_id->perform_action(action);
}
{
const tr1::shared_ptr<const PackageID> fetchable_files_restricted_id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/fetchable-files-restricted", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/fetchable-files-restricted",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(fetchable_files_restricted_id);
TEST_CHECK_THROWS(fetchable_files_restricted_id->perform_action(action), FetchActionError);
}
@@ -1000,7 +1020,8 @@ namespace test_cases
);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("category/package", pds_pm_unspecific)), qo_order_by_version)->last());
+ PackageDepSpec(parse_user_package_dep_spec("category/package",
+ UserPackageDepSpecOptions()))), qo_order_by_version)->last());
TEST_CHECK(id);
id->perform_action(action);
}
@@ -1045,7 +1066,8 @@ namespace test_cases
{
TestMessageSuffix suffix("in-ebuild die", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/in-ebuild-die", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/in-ebuild-die",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
@@ -1053,7 +1075,8 @@ namespace test_cases
{
TestMessageSuffix suffix("in-subshell die", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/in-subshell-die", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/in-subshell-die",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
@@ -1061,7 +1084,8 @@ namespace test_cases
{
TestMessageSuffix suffix("success", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/success", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/success",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
id->perform_action(action);
}
@@ -1069,7 +1093,8 @@ namespace test_cases
{
TestMessageSuffix suffix("unpack die", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/unpack-die", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/unpack-die",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
@@ -1077,7 +1102,8 @@ namespace test_cases
{
TestMessageSuffix suffix("emake fail", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/emake-fail", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/emake-fail",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
id->perform_action(action);
}
@@ -1085,7 +1111,8 @@ namespace test_cases
{
TestMessageSuffix suffix("econf source 0", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat/econf-source-0", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("=cat/econf-source-0",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_EQUAL(visitor_cast<const MetadataStringKey>(**id->find_metadata("EAPI"))->value(), "0");
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
@@ -1132,7 +1159,8 @@ namespace test_cases
{
TestMessageSuffix suffix("econf source 1", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat/econf-source-1", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("=cat/econf-source-1",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_EQUAL(visitor_cast<const MetadataStringKey>(**id->find_metadata("EAPI"))->value(), "1");
id->perform_action(action);
@@ -1179,7 +1207,8 @@ namespace test_cases
{
TestMessageSuffix suffix("in-ebuild die", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/in-ebuild-die", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/in-ebuild-die",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
@@ -1187,7 +1216,8 @@ namespace test_cases
{
TestMessageSuffix suffix("in-subshell die", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/in-subshell-die", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/in-subshell-die",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
@@ -1195,7 +1225,8 @@ namespace test_cases
{
TestMessageSuffix suffix("success", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/success", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/success",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
id->perform_action(action);
}
@@ -1203,7 +1234,8 @@ namespace test_cases
{
TestMessageSuffix suffix("unpack die", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/unpack-die", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/unpack-die",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
@@ -1211,7 +1243,8 @@ namespace test_cases
{
TestMessageSuffix suffix("emake fail", true);
const tr1::shared_ptr<const PackageID> id(*env.package_database()->query(query::Matches(
- PackageDepSpec("cat/emake-fail", pds_pm_unspecific)), qo_require_exactly_one)->last());
+ PackageDepSpec(parse_user_package_dep_spec("cat/emake-fail",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->last());
TEST_CHECK(id);
TEST_CHECK_THROWS(id->perform_action(action), InstallActionError);
}
diff --git a/paludis/repositories/e/e_repository_news.cc b/paludis/repositories/e/e_repository_news.cc
index 45dbb38..9ebd737 100644
--- a/paludis/repositories/e/e_repository_news.cc
+++ b/paludis/repositories/e/e_repository_news.cc
@@ -19,6 +19,8 @@
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/e_repository_news.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/package_dep_spec.hh>
#include <paludis/util/config_file.hh>
#include <paludis/environment.hh>
@@ -134,7 +136,8 @@ ERepositoryNews::update_news() const
for (NewsFile::DisplayIfInstalledConstIterator i(news.begin_display_if_installed()),
i_end(news.end_display_if_installed()) ; i != i_end ; ++i)
if (! _imp->environment->package_database()->query(
- query::Matches(PackageDepSpec(*i, pds_pm_permissive)) &
+ query::Matches(PackageDepSpec(erepository::parse_e_package_dep_spec(*i,
+ *erepository::EAPIData::get_instance()->eapi_from_string(_imp->e_repository->params().profile_eapi)))) &
query::SupportsAction<InstalledAction>(),
qo_whatever)->empty())
local_show = true;
diff --git a/paludis/repositories/e/e_repository_profile.cc b/paludis/repositories/e/e_repository_profile.cc
index b62179f..4aba3f4 100644
--- a/paludis/repositories/e/e_repository_profile.cc
+++ b/paludis/repositories/e/e_repository_profile.cc
@@ -22,6 +22,7 @@
#include <paludis/repositories/e/e_repository_mask_file.hh>
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/repositories/e/package_dep_spec.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/util/log.hh>
@@ -120,7 +121,6 @@ namespace paludis
bool is_incremental(const std::string & s) const;
-
public:
///\name General variables
///\{
@@ -441,7 +441,10 @@ Implementation<ERepositoryProfile>::make_vars_from_file_vars()
continue;
Context context_spec("When parsing '" + *i + "':");
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(i->substr(1), pds_pm_eapi_0));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(
+ erepository::parse_e_package_dep_spec(i->substr(1), *erepository::EAPIData::get_instance()->eapi_from_string(
+ repository->params().profile_eapi))));
+
spec->set_tag(system_tag);
system_packages->add(tr1::shared_ptr<SetSpecTree::ConstItem>(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
}
@@ -466,8 +469,9 @@ Implementation<ERepositoryProfile>::make_vars_from_file_vars()
QualifiedPackageName v(tokens[0]);
virtuals.erase(v);
- virtuals.insert(std::make_pair(v, tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(tokens[1],
- pds_pm_eapi_0))));
+ virtuals.insert(std::make_pair(v, tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ erepository::parse_e_package_dep_spec(tokens[1], *erepository::EAPIData::get_instance()->eapi_from_string(
+ repository->params().profile_eapi))))));
}
}
catch (const Exception & e)
@@ -484,7 +488,10 @@ Implementation<ERepositoryProfile>::make_vars_from_file_vars()
try
{
- tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(line->first, pds_pm_eapi_0));
+ tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(
+ erepository::parse_e_package_dep_spec(line->first, *erepository::EAPIData::get_instance()->eapi_from_string(
+ repository->params().profile_eapi))));
+
if (a->package_ptr())
package_mask[*a->package_ptr()].push_back(std::make_pair(a, line->second));
else
@@ -555,7 +562,9 @@ Implementation<ERepositoryProfile>::load_spec_use_file(const FSEntry & file, Pac
try
{
- tr1::shared_ptr<const PackageDepSpec> spec(new PackageDepSpec(*tokens.begin(), pds_pm_eapi_0));
+ tr1::shared_ptr<const PackageDepSpec> spec(new PackageDepSpec(
+ erepository::parse_e_package_dep_spec(*tokens.begin(), *erepository::EAPIData::get_instance()->eapi_from_string(
+ repository->params().profile_eapi))));
PackageFlagStatusMapList::iterator n(m.insert(m.end(), std::make_pair(spec, FlagStatusMap())));
for (std::list<std::string>::const_iterator t(next(tokens.begin())), t_end(tokens.end()) ;
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index 4a7f5ac..bf09393 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.cc
@@ -85,10 +85,11 @@ ERepositorySets::~ERepositorySets()
{
}
-
tr1::shared_ptr<SetSpecTree::ConstItem>
ERepositorySets::package_set(const SetName & s) const
{
+ using namespace tr1::placeholders;
+
if ("system" == s.data())
throw InternalError(PALUDIS_HERE, "system set should've been handled by ERepository");
else if ("security" == s.data())
@@ -106,10 +107,9 @@ ERepositorySets::package_set(const SetName & s) const
.file_name(ff)
.environment(_imp->environment)
.type(sft_paludis_conf)
- .parse_mode(pds_pm_eapi_0)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tag));
-
return f.contents();
}
else
@@ -269,15 +269,11 @@ ERepositorySets::security_set(bool insecurity) const
if (insecurity)
{
- tr1::shared_ptr<VersionRequirements> v(new VersionRequirements);
- v->push_back(VersionRequirement(vo_equal, (*c)->version()));
tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName((*c)->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- v, vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(new RepositoryName((*c)->repository()->name()))));
+ make_package_dep_spec()
+ .package((*c)->name())
+ .version_requirement(VersionRequirement(vo_equal, (*c)->version()))
+ .repository((*c)->repository()->name())));
spec->set_tag(glsa_tags.find(glsa->id())->second);
security_packages->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
@@ -292,14 +288,9 @@ ERepositorySets::security_set(bool insecurity) const
bool ok(false);
tr1::shared_ptr<const PackageIDSequence> available(
_imp->environment->package_database()->query(
- query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- glsa_pkg->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(new SlotName((*c)->slot())))) &
+ query::Matches(make_package_dep_spec()
+ .package(glsa_pkg->name())
+ .slot((*c)->slot())) &
query::SupportsAction<InstallAction>() &
query::NotMasked(),
qo_order_by_version));
@@ -313,15 +304,10 @@ ERepositorySets::security_set(bool insecurity) const
continue;
}
- tr1::shared_ptr<VersionRequirements> v(new VersionRequirements);
- v->push_back(VersionRequirement(vo_equal, (*r)->version()));
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName((*r)->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- v, vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(new RepositoryName((*r)->repository()->name()))));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec()
+ .package((*r)->name())
+ .version_requirement(VersionRequirement(vo_equal, (*r)->version()))
+ .repository((*r)->repository()->name())));
spec->set_tag(glsa_tags.find(glsa->id())->second);
security_packages->add(tr1::shared_ptr<SetSpecTree::ConstItem>(
new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index b2a933f..cff9a56 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -37,6 +37,7 @@
#include <map>
#include <vector>
+#include <list>
using namespace paludis;
using namespace paludis::erepository;
@@ -66,22 +67,32 @@ namespace paludis
KeyValueConfigFile k(*d, KeyValueConfigFileOptions());
+ PackageDepSpecParseOptions package_dep_spec_parse_options;
+ {
+ std::list<std::string> package_dep_spec_parse_options_tokens;
+ tokenise_whitespace(k.get("package_dep_spec_parse_options"), std::back_inserter(package_dep_spec_parse_options_tokens));
+ for (std::list<std::string>::const_iterator t(package_dep_spec_parse_options_tokens.begin()),
+ t_end(package_dep_spec_parse_options_tokens.end()) ;
+ t != t_end ; ++t)
+ package_dep_spec_parse_options += destringify<PackageDepSpecParseOption>(*t);
+ }
+
+ DependencySpecTreeParseOptions dependency_spec_tree_parse_options;
+ {
+ std::list<std::string> dependency_spec_tree_parse_options_tokens;
+ tokenise_whitespace(k.get("dependency_spec_tree_parse_options"), std::back_inserter(dependency_spec_tree_parse_options_tokens));
+ for (std::list<std::string>::const_iterator t(dependency_spec_tree_parse_options_tokens.begin()),
+ t_end(dependency_spec_tree_parse_options_tokens.end()) ;
+ t != t_end ; ++t)
+ dependency_spec_tree_parse_options += destringify<DependencySpecTreeParseOption>(*t);
+ }
+
tr1::shared_ptr<EAPI> eapi(new EAPI(strip_trailing_string(d->basename(), ".conf"), make_shared_ptr(new SupportedEAPI(
SupportedEAPI::create()
- .package_dep_spec_parse_mode(destringify<PackageDepSpecParseMode>(
- k.get("package_dep_spec_parse_mode")))
- .strict_package_dep_spec_parse_mode(destringify<PackageDepSpecParseMode>(
- k.get("strict_package_dep_spec_parse_mode").empty() ?
- k.get("package_dep_spec_parse_mode") :
- k.get("strict_package_dep_spec_parse_mode")))
- .dependency_spec_tree_parse_mode(destringify<DependencySpecTreeParseMode>(
- k.get("dependency_spec_tree_parse_mode")))
+ .package_dep_spec_parse_options(package_dep_spec_parse_options)
+ .dependency_spec_tree_parse_options(dependency_spec_tree_parse_options)
.iuse_flag_parse_mode(destringify<IUseFlagParseMode>(
k.get("iuse_flag_parse_mode")))
- .strict_iuse_flag_parse_mode(destringify<IUseFlagParseMode>(
- k.get("strict_iuse_flag_parse_mode").empty() ?
- k.get("iuse_flag_parse_mode") :
- k.get("strict_iuse_flag_parse_mode")))
.breaks_portage(destringify<bool>(k.get("breaks_portage")))
.uri_supports_arrow(destringify<bool>(k.get("uri_supports_arrow")))
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index 2772b56..d07a2bb 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -27,6 +27,7 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/tr1_memory.hh>
+#include <paludis/util/options.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec-fwd.hh>
diff --git a/paludis/repositories/e/eapi.sr b/paludis/repositories/e/eapi.sr
index ea9c948..4165ff0 100644
--- a/paludis/repositories/e/eapi.sr
+++ b/paludis/repositories/e/eapi.sr
@@ -153,11 +153,9 @@ make_class_SupportedEAPI()
visible
allow_named_args cc
- key package_dep_spec_parse_mode PackageDepSpecParseMode
- key strict_package_dep_spec_parse_mode PackageDepSpecParseMode
- key dependency_spec_tree_parse_mode "erepository::DependencySpecTreeParseMode"
+ key package_dep_spec_parse_options "erepository::PackageDepSpecParseOptions"
+ key dependency_spec_tree_parse_options "erepository::DependencySpecTreeParseOptions"
key iuse_flag_parse_mode IUseFlagParseMode
- key strict_iuse_flag_parse_mode IUseFlagParseMode
key uri_supports_arrow bool
key breaks_portage bool
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index 7884009..571f457 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -1,9 +1,8 @@
# Configuration for EAPI 0
# EAPI 0 is the default EAPI used by Gentoo. It is specified in PMS.
-package_dep_spec_parse_mode = eapi_0
-strict_package_dep_spec_parse_mode = eapi_0_strict
-dependency_spec_tree_parse_mode = eapi_0
+package_dep_spec_parse_options =
+dependency_spec_tree_parse_options =
iuse_flag_parse_mode = eapi_0
strict_iuse_flag_parse_mode = eapi_0_strict
breaks_portage = false
diff --git a/paludis/repositories/e/eapis/1.conf b/paludis/repositories/e/eapis/1.conf
index f7c12e4..ed6ab9c 100644
--- a/paludis/repositories/e/eapis/1.conf
+++ b/paludis/repositories/e/eapis/1.conf
@@ -1,9 +1,8 @@
-# Configuration for EAPI 0
-# EAPI 0 is the default EAPI used by Gentoo. It is specified in PMS.
+# Configuration for EAPI 1
+# EAPI 1 is specified in PMS.
-package_dep_spec_parse_mode = eapi_1
-strict_package_dep_spec_parse_mode = eapi_1_strict
-dependency_spec_tree_parse_mode = eapi_0
+package_dep_spec_parse_options = allow_slot_deps
+dependency_spec_tree_parse_options =
iuse_flag_parse_mode = eapi_1
strict_iuse_flag_parse_mode = eapi_1_strict
breaks_portage = false
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 313c6cc..32abdf9 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -2,8 +2,9 @@
# This is an experimental EAPI for exheres. It is not stable. When a stable
# version is available, it will be snapshotted as exheres-1.
-package_dep_spec_parse_mode = exheres_0
-dependency_spec_tree_parse_mode = exheres_0
+package_dep_spec_parse_options = allow_slot_deps allow_square_bracket_deps \
+ allow_tilde_greater_deps strict_star_operator strict_parsing
+dependency_spec_tree_parse_options = disallow_any_use
iuse_flag_parse_mode = exheres_0
breaks_portage = true
want_portage_emulation_vars = false
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index 6c433bc..9d70c64 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -2,8 +2,9 @@
# This is an internal EAPI supporting most Paludis extra features. It is not
# particularly stable or ideal for third party use.
-package_dep_spec_parse_mode = permissive
-dependency_spec_tree_parse_mode = paludis_1
+package_dep_spec_parse_options = allow_slot_deps allow_square_bracket_deps \
+ allow_repository_deps allow_tilde_greater_deps strict_parsing
+dependency_spec_tree_parse_options = disallow_any_use
iuse_flag_parse_mode = permissive
breaks_portage = true
has_pkg_pretend = true
diff --git a/paludis/repositories/e/fetch_visitor_TEST.cc b/paludis/repositories/e/fetch_visitor_TEST.cc
index 488fb40..11bbf72 100644
--- a/paludis/repositories/e/fetch_visitor_TEST.cc
+++ b/paludis/repositories/e/fetch_visitor_TEST.cc
@@ -53,7 +53,7 @@ namespace test_cases
TEST_CHECK(! FSEntry("fetch_visitor_TEST_dir/out/input1").exists());
const tr1::shared_ptr<const EAPI> eapi(EAPIData::get_instance()->eapi_from_string("exheres-0"));
- FetchVisitor v(&env, *env.package_database()->query(query::Matches(PackageDepSpec("=cat/pkg-1", pds_pm_permissive)),
+ FetchVisitor v(&env, *env.package_database()->query(query::Matches(parse_user_package_dep_spec("=cat/pkg-1", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin(),
*eapi, FSEntry("fetch_visitor_TEST_dir/out"),
false, false, "test", make_shared_ptr(new URIListedThenMirrorsLabel("listed-then-mirrors")), false);
diff --git a/paludis/repositories/e/package_dep_spec.cc b/paludis/repositories/e/package_dep_spec.cc
new file mode 100644
index 0000000..662ef6a
--- /dev/null
+++ b/paludis/repositories/e/package_dep_spec.cc
@@ -0,0 +1,293 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/package_dep_spec.hh>
+#include <paludis/repositories/e/eapi.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/version_operator.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/version_requirements.hh>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+PackageDepSpec
+paludis::erepository::parse_e_package_dep_spec(const std::string & ss, const EAPI & eapi)
+{
+ Context context("When parsing package dep spec '" + ss + "' with eapi '" + stringify(eapi.name) + "':");
+
+ if (ss.empty())
+ throw PackageDepSpecError("Got empty dep spec");
+
+ if (! eapi.supported)
+ throw PackageDepSpecError("Don't know how to parse dep specs using EAPI '" + eapi.name + "'");
+
+ PartiallyMadePackageDepSpec result;
+ std::string s(ss);
+ bool had_bracket_version_requirements(false);
+
+ std::string::size_type use_group_p;
+ while (std::string::npos != ((use_group_p = s.rfind('['))))
+ {
+ if (! eapi.supported->package_dep_spec_parse_options[pdspo_allow_square_bracket_deps])
+ {
+ if (eapi.supported->package_dep_spec_parse_options[pdspo_strict_parsing])
+ throw PackageDepSpecError("[] dependencies not safe for use with this EAPI");
+ else
+ Log::get_instance()->message(ll_warning, lc_context, "[] dependencies not safe for use with this EAPI");
+ }
+
+ 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:
+ {
+ UseFlagState state(use_enabled);
+ if ('-' == flag.at(0))
+ {
+ state = use_disabled;
+ flag.erase(0, 1);
+ if (flag.empty())
+ throw PackageDepSpecError("Invalid [] contents");
+ }
+ UseFlagName name(flag);
+ result.use_requirement(name, state);
+ }
+ break;
+ };
+
+ s.erase(use_group_p);
+ }
+
+ std::string::size_type repo_p;
+ if (std::string::npos != ((repo_p = s.rfind("::"))))
+ {
+ if (! eapi.supported->package_dep_spec_parse_options[pdspo_allow_repository_deps])
+ {
+ if (eapi.supported->package_dep_spec_parse_options[pdspo_strict_parsing])
+ throw PackageDepSpecError("Repository dependencies not safe for use with this EAPI");
+ else
+ Log::get_instance()->message(ll_warning, lc_context, "Repository dependencies not safe for use with this EAPI");
+ }
+
+ 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(':'))))
+ {
+ if (! eapi.supported->package_dep_spec_parse_options[pdspo_allow_slot_deps])
+ {
+ if (eapi.supported->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)));
+ 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));
+
+ if (op == vo_tilde_greater)
+ if (! eapi.supported->package_dep_spec_parse_options[pdspo_allow_tilde_greater_deps])
+ {
+ if (eapi.supported->package_dep_spec_parse_options[pdspo_strict_parsing])
+ throw PackageDepSpecError("~> dependencies not safe for use with this EAPI");
+ else
+ Log::get_instance()->message(ll_warning, lc_context, "~> dependencies not safe for use with this EAPI");
+ }
+
+ 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, "*/")))
+ {
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with eapi '"
+ + stringify(eapi.name) + "'");
+
+ 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, "/*")))
+ {
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with eapi '"
+ + stringify(eapi.name) + "'");
+
+ 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)
+ {
+ if (! eapi.supported->package_dep_spec_parse_options[pdspo_strict_star_operator])
+ {
+ if (eapi.supported->package_dep_spec_parse_options[pdspo_strict_parsing])
+ throw PackageDepSpecError(
+ "Package dep spec '" + ss + "' uses * "
+ "with operator '" + stringify(op) + "'");
+ else
+ 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, "*/")))
+ {
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with parse eapi '"
+ + stringify(eapi.name) + "'");
+
+ 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, "/*")))
+ {
+ throw PackageDepSpecError("Wildcard '*' not allowed in '" + stringify(ss) + "' with EAPI '"
+ + stringify(eapi.name) + "'");
+
+ result.category_name_part(CategoryNamePart(s.substr(0, s.length() - 2)));
+ }
+ else
+ result.package(QualifiedPackageName(s));
+ }
+
+ return result;
+}
+
diff --git a/paludis/repositories/e/package_dep_spec.hh b/paludis/repositories/e/package_dep_spec.hh
new file mode 100644
index 0000000..9fdf600
--- /dev/null
+++ b/paludis/repositories/e/package_dep_spec.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PACKAGE_DEP_SPEC_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PACKAGE_DEP_SPEC_HH 1
+
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/repositories/e/eapi-fwd.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ PackageDepSpec parse_e_package_dep_spec(const std::string &, const EAPI & eapi) PALUDIS_VISIBLE;
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/qa/visibility.cc b/paludis/repositories/e/qa/visibility.cc
index 0df42ad..5d18fa8 100644
--- a/paludis/repositories/e/qa/visibility.cc
+++ b/paludis/repositories/e/qa/visibility.cc
@@ -101,6 +101,8 @@ namespace
void visit_leaf(const PackageDepSpec & orig_p)
{
+ using namespace tr1::placeholders;
+
success = false;
viable = true;
@@ -113,35 +115,23 @@ namespace
ERepositoryProfile::VirtualsConstIterator v(profile->profile->find_virtual(*p->package_ptr()));
if (profile->profile->end_virtuals() != v)
{
- tr1::shared_ptr<VersionRequirements> reqs;
+ PartiallyMadePackageDepSpec pp;
+
if (v->second->version_requirements_ptr())
- {
- reqs.reset(new VersionRequirements);
- std::copy(v->second->version_requirements_ptr()->begin(), v->second->version_requirements_ptr()->end(),
- reqs->back_inserter());
- }
+ std::for_each(v->second->version_requirements_ptr()->begin(), v->second->version_requirements_ptr()->end(),
+ tr1::bind(&PartiallyMadePackageDepSpec::version_requirement, &pp, _1));
if (orig_p.version_requirements_ptr())
- {
- if (! reqs)
- reqs.reset(new VersionRequirements);
- std::copy(orig_p.version_requirements_ptr()->begin(), orig_p.version_requirements_ptr()->end(),
- reqs->back_inserter());
- }
- local_p.reset(new PackageDepSpec(
- make_shared_ptr(new QualifiedPackageName(*v->second->package_ptr())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- reqs,
- vr_and,
- orig_p.slot_ptr() ?
- make_shared_ptr(new SlotName(*orig_p.slot_ptr())) :
- tr1::shared_ptr<SlotName>(),
- orig_p.repository_ptr() ?
- make_shared_ptr(new RepositoryName(*orig_p.repository_ptr())) :
- tr1::shared_ptr<RepositoryName>(),
- tr1::shared_ptr<UseRequirements>(),
- orig_p.tag()
- ));
+ std::for_each(orig_p.version_requirements_ptr()->begin(), orig_p.version_requirements_ptr()->end(),
+ 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.repository_ptr())
+ pp.repository(*orig_p.repository_ptr());
+
+ local_p.reset(new PackageDepSpec(pp));
+ local_p->set_tag(orig_p.tag());
p = local_p.get();
}
}
diff --git a/paludis/repositories/e/qa/visibility_TEST.cc b/paludis/repositories/e/qa/visibility_TEST.cc
index e2d8f7f..fa4f3c1 100644
--- a/paludis/repositories/e/qa/visibility_TEST.cc
+++ b/paludis/repositories/e/qa/visibility_TEST.cc
@@ -24,6 +24,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/options.hh>
#include <paludis/qa.hh>
#include <paludis/query.hh>
#include <paludis/package_database.hh>
@@ -79,32 +80,32 @@ namespace test_cases
env.package_database()->add_repository(1, repo);
{
- tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat-one/visible-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ tr1::shared_ptr<const PackageID> id1(*env.package_database()->query(query::Matches(parse_user_package_dep_spec(
+ "=cat-one/visible-1", UserPackageDepSpecOptions())), qo_require_exactly_one)->begin());
TestReporter r1;
TEST_CHECK(visibility_check(FSEntry("/var/empty"), r1, &env, repo, id1, "visibility"));
TEST_CHECK_EQUAL(r1.count, 0u);
}
{
- tr1::shared_ptr<const PackageID> id2(*env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat-one/visible-2", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ tr1::shared_ptr<const PackageID> id2(*env.package_database()->query(query::Matches(parse_user_package_dep_spec(
+ "=cat-one/visible-2", UserPackageDepSpecOptions())), qo_require_exactly_one)->begin());
TestReporter r2;
TEST_CHECK(visibility_check(FSEntry("/var/empty"), r2, &env, repo, id2, "visibility"));
TEST_CHECK_EQUAL(r2.count, 0u);
}
{
- tr1::shared_ptr<const PackageID> id3(*env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat-one/masked-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ tr1::shared_ptr<const PackageID> id3(*env.package_database()->query(query::Matches(parse_user_package_dep_spec(
+ "=cat-one/masked-1", UserPackageDepSpecOptions())), qo_require_exactly_one)->begin());
TestReporter r3;
TEST_CHECK(visibility_check(FSEntry("/var/empty"), r3, &env, repo, id3, "visibility"));
TEST_CHECK_EQUAL(r3.count, 0u);
}
{
- tr1::shared_ptr<const PackageID> id4(*env.package_database()->query(query::Matches(PackageDepSpec(
- "=cat-one/needs-masked-1", pds_pm_unspecific)), qo_require_exactly_one)->begin());
+ tr1::shared_ptr<const PackageID> id4(*env.package_database()->query(query::Matches(parse_user_package_dep_spec(
+ "=cat-one/needs-masked-1", UserPackageDepSpecOptions())), qo_require_exactly_one)->begin());
TestReporter r4;
TEST_CHECK(visibility_check(FSEntry("/var/empty"), r4, &env, repo, id4, "visibility"));
TestMessageSuffix s4(r4.messages);
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 913b6cf..eeda341 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -618,8 +618,7 @@ VDBRepository::package_set(const SetName & s) const
for (QualifiedPackageNameSet::ConstIterator e(i->second->begin()), e_end(i->second->end()) ;
e != e_end ; ++e)
{
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(*e))));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec().package(*e)));
spec->set_tag(tag);
result->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
}
@@ -635,7 +634,7 @@ VDBRepository::package_set(const SetName & s) const
SetFile world(SetFileParams::create()
.file_name(_imp->params.world)
.type(sft_simple)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tag)
.environment(_imp->params.environment));
return world.contents();
@@ -679,6 +678,8 @@ VDBRepository::invalidate_masks()
void
VDBRepository::add_string_to_world(const std::string & n) const
{
+ using namespace tr1::placeholders;
+
Lock l(*_imp->big_nasty_mutex);
Context context("When adding '" + n + "' to world file '" + stringify(_imp->params.world) + "':");
@@ -697,7 +698,7 @@ VDBRepository::add_string_to_world(const std::string & n) const
SetFile world(SetFileParams::create()
.file_name(_imp->params.world)
.type(sft_simple)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tr1::shared_ptr<DepTag>())
.environment(_imp->params.environment));
world.add(n);
@@ -707,6 +708,8 @@ VDBRepository::add_string_to_world(const std::string & n) const
void
VDBRepository::remove_string_from_world(const std::string & n) const
{
+ using namespace tr1::placeholders;
+
Lock l(*_imp->big_nasty_mutex);
Context context("When removing '" + n + "' from world file '" + stringify(_imp->params.world) + "':");
@@ -716,7 +719,7 @@ VDBRepository::remove_string_from_world(const std::string & n) const
SetFile world(SetFileParams::create()
.file_name(_imp->params.world)
.type(sft_simple)
- .parse_mode(pds_pm_unspecific)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tr1::shared_ptr<DepTag>())
.environment(_imp->params.environment));
@@ -1218,7 +1221,7 @@ VDBRepository::need_package_ids(const CategoryNamePart & c) const
if (std::string::npos == s.rfind('-'))
continue;
- PackageDepSpec p("=" + stringify(c) + "/" + s, pds_pm_permissive);
+ PackageDepSpec p(parse_user_package_dep_spec("=" + stringify(c) + "/" + s, UserPackageDepSpecOptions()));
q->insert(*p.package_ptr());
IDMap::iterator i(_imp->ids.find(*p.package_ptr()));
if (_imp->ids.end() == i)
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 2564f71..7a7adf6 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -23,7 +23,9 @@
#include <paludis/metadata_key.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/options.hh>
#include <paludis/query.hh>
+#include <paludis/dep_spec.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <fstream>
@@ -107,7 +109,8 @@ namespace test_cases
env.package_database()->add_repository(1, repo);
tr1::shared_ptr<const PackageID> e1(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin());
TEST_CHECK(repo->use_interface->query_use(UseFlagName("flag1"), *e1) == use_enabled);
TEST_CHECK(repo->use_interface->query_use(UseFlagName("flag2"), *e1) == use_enabled);
@@ -315,7 +318,8 @@ namespace test_cases
env.package_database()->add_repository(1, repo);
tr1::shared_ptr<const PackageID> e1(*env.package_database()->query(query::Matches(
- PackageDepSpec("=cat-one/pkg-one-1", pds_pm_permissive)), qo_require_exactly_one)->begin());
+ PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-one-1", UserPackageDepSpecOptions()))),
+ qo_require_exactly_one)->begin());
ContentsGatherer gatherer;
std::for_each(indirect_iterator(e1->contents_key()->value()->begin()),
indirect_iterator(e1->contents_key()->value()->end()),
diff --git a/paludis/repositories/unpackaged/dep_parser.cc b/paludis/repositories/unpackaged/dep_parser.cc
index fda6576..49a9b72 100644
--- a/paludis/repositories/unpackaged/dep_parser.cc
+++ b/paludis/repositories/unpackaged/dep_parser.cc
@@ -21,6 +21,7 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/exception.hh>
+#include <paludis/util/options.hh>
#include <paludis/dep_spec.hh>
#include <list>
@@ -49,7 +50,7 @@ DepParser::parse(const std::string & s)
tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > spec(
new TreeLeaf<DependencySpecTree, PackageDepSpec>(tr1::shared_ptr<PackageDepSpec>(
- new PackageDepSpec(a, pds_pm_permissive))));
+ new PackageDepSpec(parse_user_package_dep_spec(a, UserPackageDepSpecOptions())))));
result->add(spec);
}
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index c8ff42e..afb68e1 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -388,7 +388,7 @@ InstalledUnpackagedRepository::package_set(const SetName & s) const
for (QualifiedPackageNameSet::ConstIterator e(pkgs->begin()), e_end(pkgs->end()) ;
e != e_end ; ++e)
{
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_shared_ptr(new QualifiedPackageName(*e))));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec().package(QualifiedPackageName(*e))));
spec->set_tag(tag);
result->add(make_shared_ptr(new TreeLeaf<SetSpecTree, PackageDepSpec>(spec)));
}
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index 94166b8..edee079 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -28,6 +28,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/join.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/options.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <algorithm>
@@ -117,7 +118,7 @@ namespace test_cases
env.package_database()->add_repository(1, repo);
const tr1::shared_ptr<const PackageID> id1(
- *env.package_database()->query(query::Matches(PackageDepSpec("cat-one/foo:0", pds_pm_unspecific)),
+ *env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat-one/foo:0", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin());
TEST_CHECK_EQUAL(id1->version(), VersionSpec("1"));
@@ -135,7 +136,7 @@ namespace test_cases
TEST_CHECK_EQUAL(d1.s.str(), "dir</fnord>");
const tr1::shared_ptr<const PackageID> id2(
- *env.package_database()->query(query::Matches(PackageDepSpec("cat-one/foo:1", pds_pm_unspecific)),
+ *env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat-one/foo:1", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin());
TEST_CHECK_EQUAL(id2->version(), VersionSpec("2"));
@@ -171,13 +172,13 @@ namespace test_cases
env.package_database()->add_repository(1, repo);
const tr1::shared_ptr<const PackageID> id1(
- *env.package_database()->query(query::Matches(PackageDepSpec("cat-one/foo:0", pds_pm_unspecific)),
+ *env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat-one/foo:0", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin());
TEST_CHECK(! id1->masked());
const tr1::shared_ptr<const PackageID> id2(
- *env.package_database()->query(query::Matches(PackageDepSpec("cat-one/foo:1", pds_pm_unspecific)),
+ *env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat-one/foo:1", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin());
TEST_CHECK(! id2->masked());
@@ -208,7 +209,7 @@ namespace test_cases
TEST_CHECK(repo->some_ids_might_support_action(SupportsActionTest<InstalledAction>()));
const tr1::shared_ptr<const PackageID> id1(
- *env.package_database()->query(query::Matches(PackageDepSpec("cat-one/foo:1", pds_pm_unspecific)),
+ *env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat-one/foo:1", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin());
TEST_CHECK(! id1->supports_action(SupportsActionTest<InstallAction>()));
@@ -301,7 +302,7 @@ namespace test_cases
TEST_CHECK(FSEntry("installed_repository_TEST_dir/repo3/indices/packages/foo/cat-one").is_symbolic_link());
const tr1::shared_ptr<const PackageID> id(
- *env.package_database()->query(query::Matches(PackageDepSpec("cat-one/foo:fred", pds_pm_unspecific)),
+ *env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat-one/foo:fred", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin());
UninstallAction action(UninstallActionOptions::create()
@@ -543,7 +544,7 @@ namespace test_cases
UninstallAction action(UninstallActionOptions::create()
.no_config_protect(false));
- (*env.package_database()->query(query::Matches(PackageDepSpec("cat/pkg4a", pds_pm_unspecific)),
+ (*env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat/pkg4a", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin())->perform_action(action);
TEST_CHECK(FSEntry("installed_repository_TEST_dir/root4/dir").is_directory());
@@ -583,7 +584,7 @@ namespace test_cases
UninstallAction action(UninstallActionOptions::create()
.no_config_protect(false));
- (*env.package_database()->query(query::Matches(PackageDepSpec("cat/pkg4b", pds_pm_unspecific)),
+ (*env.package_database()->query(query::Matches(parse_user_package_dep_spec("cat/pkg4b", UserPackageDepSpecOptions())),
qo_require_exactly_one)->begin())->perform_action(action);
TEST_CHECK(! FSEntry("installed_repository_TEST_dir/root4/dir").is_directory());
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index 52aae67..dcfca2b 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -54,19 +54,17 @@ namespace paludis
env(e),
value(exact ?
new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec(
- make_shared_ptr(new QualifiedPackageName(v->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- make_equal_to_version_requirements(v->version()),
- vr_and,
- make_shared_ptr(new SlotName(v->slot())),
- make_shared_ptr(new RepositoryName(v->repository()->name()))
- )))
+ make_package_dep_spec()
+ .package(v->name())
+ .version_requirement(VersionRequirement(vo_equal, v->version()))
+ .slot(v->slot())
+ .repository(v->repository()->name()))))
:
new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec(
- make_shared_ptr(new QualifiedPackageName(v->name()))
+ make_package_dep_spec()
+ .package(v->name())
)))
- )
+ )
{
}
};
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 6ac8efa..e137fb5 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -163,8 +163,7 @@ VirtualsRepository::need_names() const
for (RepositoryProvidesInterface::ProvidesSequence::ConstIterator p(provides->begin()),
p_end(provides->end()) ; p != p_end ; ++p)
_imp->names.push_back(std::make_pair(p->virtual_name, tr1::shared_ptr<const PackageDepSpec>(
- new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(p->provided_by->name()))))));
+ new PackageDepSpec(make_package_dep_spec().package(p->provided_by->name())))));
}
std::sort(_imp->names.begin(), _imp->names.end(), NamesSortComparator());
diff --git a/paludis/repositories/virtuals/virtuals_repository_TEST.cc b/paludis/repositories/virtuals/virtuals_repository_TEST.cc
index d26f220..3315616 100644
--- a/paludis/repositories/virtuals/virtuals_repository_TEST.cc
+++ b/paludis/repositories/virtuals/virtuals_repository_TEST.cc
@@ -30,6 +30,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/options.hh>
#include <paludis/query.hh>
using namespace test;
@@ -56,7 +57,8 @@ namespace test_cases
repo->add_version("cat", "pkg", "1")->provide_key()->set_from_string("virtual/pkg");
repo->add_version("cat", "pkg", "2")->provide_key()->set_from_string("virtual/pkg");
- repo->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(new PackageDepSpec(">=cat/pkg-2", pds_pm_permissive)));
+ repo->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(new PackageDepSpec(
+ parse_user_package_dep_spec(">=cat/pkg-2", UserPackageDepSpecOptions()))));
TEST_CHECK(repo->virtual_packages());
TEST_CHECK_EQUAL(std::distance(repo->virtual_packages()->begin(), repo->virtual_packages()->end()), 1);
@@ -89,11 +91,15 @@ namespace test_cases
repo1->add_version("cat", "pkg", "1")->provide_key()->set_from_string("virtual/pkg");
repo1->add_version("cat", "pkg", "2")->provide_key()->set_from_string("virtual/pkg");
- repo1->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(new PackageDepSpec(">=cat/pkg-2", pds_pm_permissive)));
- repo1->add_virtual_package(QualifiedPackageName("virtual/foo"), make_shared_ptr(new PackageDepSpec(">=cat/pkg-2", pds_pm_permissive)));
-
- repo2->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(new PackageDepSpec(">=cat/pkg-2", pds_pm_permissive)));
- repo2->add_virtual_package(QualifiedPackageName("virtual/foo"), make_shared_ptr(new PackageDepSpec("<=cat/pkg-1", pds_pm_permissive)));
+ repo1->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(
+ new PackageDepSpec(parse_user_package_dep_spec(">=cat/pkg-2", UserPackageDepSpecOptions()))));
+ repo1->add_virtual_package(QualifiedPackageName("virtual/foo"), make_shared_ptr(
+ new PackageDepSpec(parse_user_package_dep_spec(">=cat/pkg-2", UserPackageDepSpecOptions()))));
+
+ repo2->add_virtual_package(QualifiedPackageName("virtual/pkg"), make_shared_ptr(new PackageDepSpec(
+ parse_user_package_dep_spec(">=cat/pkg-2", UserPackageDepSpecOptions()))));
+ repo2->add_virtual_package(QualifiedPackageName("virtual/foo"), make_shared_ptr(new PackageDepSpec(
+ parse_user_package_dep_spec("<=cat/pkg-1", UserPackageDepSpecOptions()))));
TEST_CHECK(virtuals->has_category_named(CategoryNamePart("virtual")));
TEST_CHECK(virtuals->has_package_named(QualifiedPackageName("virtual/pkg")));
diff --git a/paludis/set_file.cc b/paludis/set_file.cc
index 476aaaa..b9a7edb 100644
--- a/paludis/set_file.cc
+++ b/paludis/set_file.cc
@@ -186,7 +186,7 @@ namespace
Log::get_instance()->message(ll_warning, lc_context, "Line '" + stringify(line) +
"' should start with '?' or '*', assuming '*'");
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(tokens.at(0), params.parse_mode));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser(tokens.at(0))));
if (params.tag)
spec->set_tag(params.tag);
result->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
@@ -194,7 +194,7 @@ namespace
}
else if ("*" == tokens.at(0))
{
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(tokens.at(1), params.parse_mode));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser(tokens.at(1))));
if (params.tag)
spec->set_tag(params.tag);
result->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
@@ -202,7 +202,7 @@ namespace
}
else if ("?" == tokens.at(0))
{
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(tokens.at(1), params.parse_mode));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(params.parser(tokens.at(1))));
if (params.tag)
spec->set_tag(params.tag);
@@ -279,7 +279,7 @@ SimpleHandler::_create_contents() const
}
else
{
- tr1::shared_ptr<PackageDepSpec> p(new PackageDepSpec(stringify(*i), _p.parse_mode));
+ tr1::shared_ptr<PackageDepSpec> p(new PackageDepSpec(_p.parser(stringify(*i))));
if (_p.tag)
p->set_tag(_p.tag);
_contents->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(
diff --git a/paludis/set_file.hh b/paludis/set_file.hh
index 1126db3..08c2ae9 100644
--- a/paludis/set_file.hh
+++ b/paludis/set_file.hh
@@ -24,6 +24,8 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/tr1_functional.hh>
#include <paludis/name.hh>
#include <paludis/dep_tree.hh>
#include <paludis/dep_spec-fwd.hh>
diff --git a/paludis/set_file.sr b/paludis/set_file.sr
index 9c975a7..1318452 100644
--- a/paludis/set_file.sr
+++ b/paludis/set_file.sr
@@ -4,7 +4,7 @@ make_class_SetFileParams()
key file_name FSEntry
key type SetFileType
- key parse_mode PackageDepSpecParseMode
+ key parser "tr1::function<PackageDepSpec (const std::string &)>"
key tag "tr1::shared_ptr<const DepTag>"
key environment "const Environment *"
diff --git a/paludis/set_file_TEST.cc b/paludis/set_file_TEST.cc
index c03f54c..6ea2af7 100644
--- a/paludis/set_file_TEST.cc
+++ b/paludis/set_file_TEST.cc
@@ -22,6 +22,7 @@
#include <test/test_framework.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/dep_spec.hh>
#include <fstream>
using namespace test;
@@ -66,10 +67,12 @@ namespace test_cases
void run()
{
+ using namespace tr1::placeholders;
+
SetFile f(SetFileParams::create()
.file_name(FSEntry("set_file_TEST_dir/simple1"))
.type(sft_simple)
- .parse_mode(pds_pm_eapi_0)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tr1::shared_ptr<DepTag>())
.environment(0));
@@ -127,10 +130,12 @@ namespace test_cases
void run()
{
+ using namespace tr1::placeholders;
+
SetFile f(SetFileParams::create()
.file_name(FSEntry("set_file_TEST_dir/paludisconf1"))
.type(sft_paludis_conf)
- .parse_mode(pds_pm_eapi_0)
+ .parser(tr1::bind(&parse_user_package_dep_spec, _1, UserPackageDepSpecOptions()))
.tag(tr1::shared_ptr<DepTag>())
.environment(0));
diff --git a/paludis/stringify_formatter_TEST.cc b/paludis/stringify_formatter_TEST.cc
index c8827b7..e975ff5 100644
--- a/paludis/stringify_formatter_TEST.cc
+++ b/paludis/stringify_formatter_TEST.cc
@@ -20,6 +20,7 @@
#include <paludis/stringify_formatter.hh>
#include <paludis/stringify_formatter-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/options.hh>
#include <paludis/dep_spec.hh>
#include <paludis/dep_tree.hh>
#include <test/test_runner.hh>
@@ -109,10 +110,10 @@ namespace test_cases
{
PartialFormatter f;
StringifyFormatter ff(f);
- BlockDepSpec b(make_shared_ptr(new PackageDepSpec("cat/pkg", pds_pm_permissive)));
+ BlockDepSpec b(make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec("cat/pkg", UserPackageDepSpecOptions()))));
UseDepSpec u(UseFlagName("foo"), true);
std::string s(format_three(
- PackageDepSpec("cat/pkg", pds_pm_permissive),
+ parse_user_package_dep_spec("cat/pkg", UserPackageDepSpecOptions()),
b, u,
ff));
TEST_CHECK_EQUAL(s, "<cat/pkg> !cat/pkg !foo?");
diff --git a/paludis/uninstall_list_TEST.cc b/paludis/uninstall_list_TEST.cc
index 5d1c913..4839416 100644
--- a/paludis/uninstall_list_TEST.cc
+++ b/paludis/uninstall_list_TEST.cc
@@ -24,6 +24,7 @@
#include <paludis/repositories/virtuals/virtuals_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/options.hh>
#include <paludis/package_database.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -333,7 +334,8 @@ namespace test_cases
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("foo/moo", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_user_package_dep_spec("foo/moo", UserPackageDepSpecOptions()))))));
installed_repo->add_package_set(SetName("world"), world);
}
@@ -373,9 +375,11 @@ namespace test_cases
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("foo/moo", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_user_package_dep_spec("foo/moo", UserPackageDepSpecOptions()))))));
world->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec("foo/bar", pds_pm_permissive)))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
+ parse_user_package_dep_spec("foo/bar", UserPackageDepSpecOptions()))))));
installed_repo->add_package_set(SetName("world"), world);
}
diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc
index 8e7037a..8dec4b5 100644
--- a/paludis/uninstall_task.cc
+++ b/paludis/uninstall_task.cc
@@ -30,6 +30,7 @@
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/options.hh>
#include <paludis/query.hh>
#include <paludis/package_database.hh>
#include <paludis/hook.hh>
@@ -160,7 +161,7 @@ UninstallTask::add_target(const std::string & target)
throw HadBothPackageAndSetTargets();
_imp->had_package_targets = true;
- tr1::shared_ptr<PackageDepSpec> pds(new PackageDepSpec(target, pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> pds(new PackageDepSpec(parse_user_package_dep_spec(target, UserPackageDepSpecOptions())));
pds->set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
_imp->targets.push_back(pds);
}
@@ -187,10 +188,9 @@ UninstallTask::add_target(const std::string & target)
throw HadBothPackageAndSetTargets();
_imp->had_package_targets = false;
- tr1::shared_ptr<PackageDepSpec> pds(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- _imp->env->package_database()->fetch_unique_qualified_package_name(
- PackageNamePart(target), query::MaybeSupportsAction<UninstallAction>())))));
+ tr1::shared_ptr<PackageDepSpec> pds(new PackageDepSpec(make_package_dep_spec()
+ .package(_imp->env->package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(target), query::MaybeSupportsAction<UninstallAction>()))));
pds->set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
_imp->targets.push_back(pds);
}
@@ -201,10 +201,9 @@ UninstallTask::add_target(const std::string & target)
throw HadBothPackageAndSetTargets();
_imp->had_package_targets = false;
- tr1::shared_ptr<PackageDepSpec> pds(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- _imp->env->package_database()->fetch_unique_qualified_package_name(
- PackageNamePart(target), query::MaybeSupportsAction<UninstallAction>())))));
+ tr1::shared_ptr<PackageDepSpec> pds(new PackageDepSpec(make_package_dep_spec()
+ .package(_imp->env->package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(target), query::MaybeSupportsAction<UninstallAction>()))));
pds->set_tag(tr1::shared_ptr<const DepTag>(new TargetDepTag));
_imp->targets.push_back(pds);
}
@@ -314,8 +313,7 @@ UninstallTask::execute()
{
bool remove(true);
tr1::shared_ptr<const PackageIDSequence> installed(
- _imp->env->package_database()->query(query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(i->first)))) &
+ _imp->env->package_database()->query(query::Matches(make_package_dep_spec().package(i->first)) &
query::SupportsAction<InstalledAction>(),
qo_whatever));
for (PackageIDSequence::ConstIterator r(installed->begin()), r_end(installed->end()) ;
@@ -325,8 +323,7 @@ UninstallTask::execute()
if (remove)
all->add(tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> >(new TreeLeaf<SetSpecTree, PackageDepSpec>(
- tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(i->first)))))));
+ tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(make_package_dep_spec().package(i->first))))));
}
world_remove_packages(all);
diff --git a/paludis/version_requirements-fwd.hh b/paludis/version_requirements-fwd.hh
index f4f5efd..4e06770 100644
--- a/paludis/version_requirements-fwd.hh
+++ b/paludis/version_requirements-fwd.hh
@@ -46,15 +46,6 @@ namespace paludis
typedef Sequence<VersionRequirement> VersionRequirements;
/**
- * Convenience function: make VersionRequirements with an equals match on a
- * single entry.
- *
- * \see VersionRequirements
- * \ingroup g_dep_spec
- */
- tr1::shared_ptr<VersionRequirements> make_equal_to_version_requirements(const VersionSpec &) PALUDIS_VISIBLE;
-
- /**
* Whether our version requirements are an 'and' or an 'or' set.
*
* \see PackageDepSpec
diff --git a/paludis/version_requirements.cc b/paludis/version_requirements.cc
index 33c873f..25fe492 100644
--- a/paludis/version_requirements.cc
+++ b/paludis/version_requirements.cc
@@ -32,14 +32,6 @@ template class Sequence<VersionRequirement>;
template class WrappedForwardIterator<Sequence<VersionRequirement>::ConstIteratorTag, const VersionRequirement>;
template class WrappedOutputIterator<Sequence<VersionRequirement>::InserterTag, VersionRequirement>;
-tr1::shared_ptr<VersionRequirements>
-paludis::make_equal_to_version_requirements(const VersionSpec & v)
-{
- tr1::shared_ptr<VersionRequirements> result(new VersionRequirements);
- result->push_back(VersionRequirement(vo_equal, v));
- return result;
-}
-
std::ostream &
paludis::operator<< (std::ostream & o, const VersionRequirementsMode & s)
{
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 5825e4a..3be0b97 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -26,6 +26,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/options.hh>
#include <list>
#include <ruby.h>
@@ -54,7 +55,6 @@ namespace
static VALUE c_use_dep_spec;
static VALUE c_version_requirements_mode;
- static VALUE c_package_dep_spec_parse_mode;
struct WrappedSpecBase;
template <typename> struct WrappedSpec;
@@ -330,34 +330,6 @@ namespace
}
};
- VALUE
- package_dep_spec_new(int argc, VALUE *argv, VALUE self)
- {
- tr1::shared_ptr<const WrappedSpecBase> * ptr(0);
- try
- {
- PackageDepSpecParseMode p;
- if (1 == argc)
- {
- rb_warn("Calling PackageDepSpec.new with one argument has been deprecated");
- p = pds_pm_permissive;
- }
- else
- p = static_cast<PackageDepSpecParseMode>(NUM2INT(argv[1]));
-
- ptr = new tr1::shared_ptr<const WrappedSpecBase>(new WrappedSpec<PackageDepSpec>(
- make_shared_ptr(new PackageDepSpec(StringValuePtr(argv[0]), p))));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
/*
* call-seq:
* flag -> String
@@ -643,6 +615,48 @@ namespace
return rb_str_new2(stringify(tr1::static_pointer_cast<const WrappedSpec<NamedSetDepSpec> >(*ptr)->spec()->text()).c_str());
}
+ /*
+ * Document-method: parse_user_package_dep_spec
+ *
+ * call-seq:
+ * parse_user_package_dep_spec(String, Array) -> PackageDepSpec
+ *
+ * Return a PackageDepSpec parsed from user input. The second parameter is either an empty
+ * array, or [ :allow_wildcards ] to allow wildcards.
+ *
+ */
+ VALUE paludis_parse_user_dep_spec(VALUE, VALUE str, VALUE opts)
+ {
+ tr1::shared_ptr<const WrappedSpecBase> * ptr(0);
+
+ try
+ {
+ std::string s(StringValuePtr(str));
+
+ Check_Type(opts, T_ARRAY);
+ UserPackageDepSpecOptions o;
+ for (unsigned i(0) ; i < RARRAY(opts)->len ; ++i)
+ {
+ VALUE entry(rb_ary_entry(opts, i));
+ Check_Type(entry, T_SYMBOL);
+ if (SYM2ID(entry) == rb_intern("allow_wildcards"))
+ o += updso_allow_wildcards;
+ else
+ rb_raise(rb_eArgError, "Unknown parse_user_package_dep_spec option '%s'", rb_obj_as_string(entry));
+ }
+
+ ptr = new tr1::shared_ptr<const WrappedSpecBase>(new WrappedSpec<PackageDepSpec>(
+ make_shared_ptr(new PackageDepSpec(parse_user_package_dep_spec(s, o)))));
+ return Data_Wrap_Struct(c_package_dep_spec, 0, &Common<tr1::shared_ptr<const WrappedSpecBase> >::free, ptr);
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+
+ }
+
void do_register_dep_spec()
{
/*
@@ -749,11 +763,10 @@ namespace
* Document-class: Paludis::PackageDepSpec
*
* A PackageDepSpec represents a package name (for example, 'app-editors/vim'),
- * possibly with associated version and SLOT restrictions.
+ * possibly with associated version and SLOT restrictions. To create a PackageDepSpec,
+ * use Paludis::parse_user_package_dep_spec or Paludis::make_package_dep_spec.
*/
c_package_dep_spec = rb_define_class_under(paludis_module(), "PackageDepSpec", c_string_dep_spec);
- rb_define_singleton_method(c_package_dep_spec, "new", RUBY_FUNC_CAST(&package_dep_spec_new), -1);
- rb_define_method(c_package_dep_spec, "initialize", RUBY_FUNC_CAST(&package_dep_spec_init), -1);
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);
@@ -826,18 +839,7 @@ namespace
// cc_enum_special<paludis/version_requirements.hh, VersionRequirementsMode, c_version_requirements_mode>
- /*
- * Document-module: Paludis::PackageDepSpecParseMode
- *
- * How to parse a PackageDepSpec string.
- *
- */
- c_package_dep_spec_parse_mode = rb_define_module_under(paludis_module(), "PackageDepSpecParseMode");
- for (PackageDepSpecParseMode l(static_cast<PackageDepSpecParseMode>(0)), l_end(last_pds_pm) ; l != l_end ;
- l = static_cast<PackageDepSpecParseMode>(static_cast<int>(l) + 1))
- rb_define_const(c_package_dep_spec_parse_mode, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
-
- // cc_enum_special<paludis/dep_spec-se.hh, PackageDepSpecParseMode, c_package_dep_spec_parse_mode>
+ rb_define_module_function(paludis_module(), "parse_user_package_dep_spec", RUBY_FUNC_CAST(&paludis_parse_user_dep_spec), 2);
}
}
@@ -850,11 +852,6 @@ paludis::ruby::value_to_package_dep_spec(VALUE v)
Data_Get_Struct(v, tr1::shared_ptr<const WrappedSpecBase>, v_ptr);
return tr1::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*v_ptr)->spec();
}
- if (T_STRING == TYPE(v))
- {
- rb_warn("Calling PackageDepSpec.new with one argument has been deprecated");
- return tr1::shared_ptr<const PackageDepSpec>(new PackageDepSpec(StringValuePtr(v), pds_pm_permissive));
- }
else
{
rb_raise(rb_eTypeError, "Can't convert %s into PackageDepSpec", rb_obj_classname(v));
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index fb9cc79..e7a650e 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -41,11 +41,11 @@ module Paludis
class TestCase_PackageDepSpec < Test::Unit::TestCase
def pda
- PackageDepSpec.new('>=foo/bar-1:100::testrepo[a][-b]', PackageDepSpecParseMode::Permissive)
+ Paludis::parse_user_package_dep_spec('>=foo/bar-1:100::testrepo[a][-b]', [])
end
def pdb
- PackageDepSpec.new('*/bar', PackageDepSpecParseMode::Unspecific)
+ Paludis::parse_user_package_dep_spec('*/bar', [:allow_wildcards])
end
def test_create
@@ -54,11 +54,23 @@ module Paludis
end
def test_create_error
- assert_raise TypeError do
- v = PackageDepSpec.new(0, PackageDepSpecParseMode::Permissive)
+ assert_raise NoMethodError do
+ v = PackageDepSpec.new("foo")
end
assert_raise PackageDepSpecError do
- v = PackageDepSpec.new("=sys-apps/foo", PackageDepSpecParseMode::Permissive)
+ Paludis::parse_user_package_dep_spec("=sys-apps/foo", [])
+ end
+ assert_raise TypeError do
+ Paludis::parse_user_package_dep_spec("sys-apps/foo", {})
+ end
+ assert_raise TypeError do
+ Paludis::parse_user_package_dep_spec("sys-apps/foo", ["foo"])
+ end
+ assert_raise ArgumentError do
+ Paludis::parse_user_package_dep_spec("sys-apps/foo", [:unknown])
+ end
+ assert_raise ArgumentError do
+ Paludis::parse_user_package_dep_spec("sys-apps/foo")
end
end
@@ -149,7 +161,7 @@ module Paludis
class TestCase_BlockDepSpec < Test::Unit::TestCase
def test_create
- v = BlockDepSpec.new(PackageDepSpec.new(">=foo/bar-1", PackageDepSpecParseMode::Permissive))
+ v = BlockDepSpec.new(Paludis::parse_user_package_dep_spec(">=foo/bar-1", []))
end
def test_create_error
@@ -157,17 +169,13 @@ module Paludis
v = BlockDepSpec.new(0)
end
- assert_raise PackageDepSpecError do
- v = BlockDepSpec.new(PackageDepSpec.new("=foo/bar", PackageDepSpecParseMode::Permissive))
- end
-
- assert_raise TypeError do
+ assert_raise TypeError do
v = BlockDepSpec.new(PlainTextDepSpec.new('foo-bar/baz'))
end
end
def test_blocked_spec
- assert_equal "foo/baz", BlockDepSpec.new(PackageDepSpec.new("foo/baz", PackageDepSpecParseMode::Permissive)).blocked_spec.to_s
+ assert_equal "foo/baz", BlockDepSpec.new(Paludis::parse_user_package_dep_spec("foo/baz", [])).blocked_spec.to_s
end
end
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index 8976d92..37bdf36 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -79,8 +79,9 @@ module Paludis
end
def test_query_use
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo',
- PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ pid = env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])),
+ QueryOrder::RequireExactlyOne).first
assert env.query_use("enabled", pid)
assert ! env.query_use("not_enabled", pid)
@@ -103,14 +104,17 @@ module Paludis
end
def pid
- env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])),
+ QueryOrder::RequireExactlyOne).first
end
def test_accept_license
assert env.accept_license('GPL-2', pid)
assert !env.accept_license('Failure', pid)
- pid2 = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/baz-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ pid2 = env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/baz-1.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
assert env.accept_license('GPL-2', pid2)
assert env.accept_license('Failure', pid2)
end
@@ -128,7 +132,8 @@ module Paludis
end
def pid
- env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
end
def test_accept_keywords
@@ -156,7 +161,8 @@ module Paludis
end
def test_query_use
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ pid = env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
assert ! env.query_use("foo", pid)
end
@@ -194,29 +200,27 @@ module Paludis
end
def test_adapt_use
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ pid = env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
assert env.query_use("enabled", pid)
assert ! env.query_use("not_enabled", pid)
assert env.query_use("sometimes_enabled", pid)
- env.adapt_use(PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive), 'enabled', false);
+ env.adapt_use(Paludis::parse_user_package_dep_spec('foo/bar', []), 'enabled', false);
assert ! env.query_use('enabled', pid);
- env.adapt_use(PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive), 'not_enabled', true);
+ env.adapt_use(Paludis::parse_user_package_dep_spec('foo/bar', []), 'not_enabled', true);
assert env.query_use("not_enabled", pid)
- env.adapt_use(PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive), 'sometimes_enabled', false);
+ env.adapt_use(Paludis::parse_user_package_dep_spec('foo/bar', []), 'sometimes_enabled', false);
assert ! env.query_use("sometimes_enabled", pid)
end
def test_adapt_use_bad
assert_raise TypeError do
- env.adapt_use(PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive), 'not_enabled', 'lemon');
+ env.adapt_use(Paludis::parse_user_package_dep_spec('foo/bar', []), 'not_enabled', 'lemon');
end
assert_raise TypeError do
- env.adapt_use(PackageDepSpec.new(123, PackageDepSpecParseMode::Permissive), 'not_enabled', false);
- end
- assert_raise TypeError do
- env.adapt_use(PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive), 7, false);
+ env.adapt_use(Paludis::parse_user_package_dep_spec('foo/bar', []), 7, false);
end
end
end
@@ -227,11 +231,12 @@ module Paludis
end
def test_clear_adaptions
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ pid = env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
assert env.query_use("enabled", pid)
- env.adapt_use(PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive), 'enabled', false);
+ env.adapt_use(Paludis::parse_user_package_dep_spec('foo/bar', []), 'enabled', false);
assert ! env.query_use('enabled', pid);
env.clear_adaptions;
@@ -367,10 +372,10 @@ module Paludis
def test_set_accept_unstable
assert_respond_to env, :accept_unstable=
- assert_nothing_raised do
- env.accept_unstable=true
- env.accept_unstable=false
- end
+ assert_nothing_raised do
+ env.accept_unstable=true
+ env.accept_unstable=false
+ end
end
end
end
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
index b332a60..0840a16 100644
--- a/ruby/package_database_TEST.rb
+++ b/ruby/package_database_TEST.rb
@@ -97,11 +97,11 @@ module Paludis
end
def pda
- PackageDepSpec.new('=foo/bar-1.0', PackageDepSpecParseMode::Permissive)
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0', [])
end
def pda2
- PackageDepSpec.new('foo/bar', PackageDepSpecParseMode::Permissive)
+ Paludis::parse_user_package_dep_spec('foo/bar', [])
end
def test_arg_count
@@ -177,7 +177,7 @@ module Paludis
assert_equal pid.repository_name, pid2.repository_name
- a = db.query(Query::Matches.new(PackageDepSpec.new('>=foo/bar-27',PackageDepSpecParseMode::Permissive)),
+ a = db.query(Query::Matches.new(Paludis::parse_user_package_dep_spec('>=foo/bar-27', [])),
QueryOrder::Whatever)
assert a.empty?
diff --git a/ruby/paludis_ruby_TEST.rb b/ruby/paludis_ruby_TEST.rb
index 892c812..bc3f403 100644
--- a/ruby/paludis_ruby_TEST.rb
+++ b/ruby/paludis_ruby_TEST.rb
@@ -38,9 +38,10 @@ module Paludis
def test_match
env = EnvironmentMaker.instance.make_from_spec("")
- spec_good = PackageDepSpec.new('>=foo/bar-1', PackageDepSpecParseMode::Permissive)
- spec_bad = PackageDepSpec.new('>=foo/bar-2', PackageDepSpecParseMode::Permissive)
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ spec_good = Paludis::parse_user_package_dep_spec('>=foo/bar-1', [])
+ spec_bad = Paludis::parse_user_package_dep_spec('>=foo/bar-2', [])
+ pid = env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
assert Paludis::match_package(env, spec_good, pid)
assert !Paludis::match_package(env, spec_bad, pid)
@@ -49,8 +50,9 @@ module Paludis
def test_type_errors
env = EnvironmentMaker.instance.make_from_spec("")
- spec = PackageDepSpec.new('>=foo/bar-1', PackageDepSpecParseMode::Permissive)
- pid = env.package_database.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-1.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ spec = Paludis::parse_user_package_dep_spec('>=foo/bar-1', [])
+ pid = env.package_database.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
assert_raise TypeError do
Paludis::match_package(spec,spec,pid)
diff --git a/ruby/qualified_package_name_TEST.rb b/ruby/qualified_package_name_TEST.rb
index c4c8da6..aec32f6 100644
--- a/ruby/qualified_package_name_TEST.rb
+++ b/ruby/qualified_package_name_TEST.rb
@@ -95,7 +95,7 @@ module Paludis
def test_to_value_type_error
assert_raise TypeError do
- QualifiedPackageName.new('foo-bar/baz') <=> PackageDepSpec.new('foo-bar/baz', PackageDepSpecParseMode::Permissive)
+ QualifiedPackageName.new('foo-bar/baz') <=> Paludis::parse_user_package_dep_spec('foo-bar/baz', [])
end
end
end
diff --git a/ruby/query_TEST.rb b/ruby/query_TEST.rb
index 2f78dc9..b4f516b 100644
--- a/ruby/query_TEST.rb
+++ b/ruby/query_TEST.rb
@@ -55,7 +55,7 @@ module Paludis
class TestCase_Matches < Test::Unit::TestCase
def get_query
- Query::Matches.new(PackageDepSpec.new('>=foo-bar/baz-1', PackageDepSpecParseMode::Permissive))
+ Query::Matches.new(Paludis::parse_user_package_dep_spec('>=foo-bar/baz-1', []))
end
def test_create
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index a036f1d..29012ca 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -58,7 +58,8 @@ module Paludis
end
def p
- db.query(Query::Matches.new(PackageDepSpec.new('=foo/bar-2.0::testrepo', PackageDepSpecParseMode::Permissive)), QueryOrder::RequireExactlyOne).first
+ db.query(Query::Matches.new(
+ Paludis::parse_user_package_dep_spec('=foo/bar-2.0::testrepo', [])), QueryOrder::RequireExactlyOne).first
end
def installed_pid
diff --git a/src/clients/adjutrix/downgrade_check.cc b/src/clients/adjutrix/downgrade_check.cc
index 56a3540..2e60580 100644
--- a/src/clients/adjutrix/downgrade_check.cc
+++ b/src/clients/adjutrix/downgrade_check.cc
@@ -136,13 +136,9 @@ namespace
std::map<QPNS, VersionSpec>::const_iterator a(after.find(b->first));
if (after.end() == a)
{
- if (! env.package_database()->query(query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(b->first.name)),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(new SlotName(b->first.slot)))),
+ if (! env.package_database()->query(query::Matches(make_package_dep_spec()
+ .package(b->first.name)
+ .slot(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 afa0589..91b53ee 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -26,6 +26,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/options.hh>
#include <paludis/query.hh>
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
@@ -259,13 +260,12 @@ int do_find_reverse_deps(NoConfigEnvironment & env)
{
if (std::string::npos == CommandLine::get_instance()->begin_parameters()->find('/'))
{
- spec.reset(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- env.package_database()->fetch_unique_qualified_package_name(
- PackageNamePart(*CommandLine::get_instance()->begin_parameters()))))));
+ spec.reset(new PackageDepSpec(make_package_dep_spec().package(env.package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(*CommandLine::get_instance()->begin_parameters())))));
}
else
- spec.reset(new PackageDepSpec(*CommandLine::get_instance()->begin_parameters(), pds_pm_permissive));
+ spec.reset(new PackageDepSpec(parse_user_package_dep_spec(*CommandLine::get_instance()->begin_parameters(),
+ UserPackageDepSpecOptions())));
}
catch (const AmbiguousPackageNameError & e)
{
diff --git a/src/clients/adjutrix/keywords_graph.cc b/src/clients/adjutrix/keywords_graph.cc
index ac4cdc4..466f6f7 100644
--- a/src/clients/adjutrix/keywords_graph.cc
+++ b/src/clients/adjutrix/keywords_graph.cc
@@ -71,14 +71,9 @@ namespace
FindUnusedPackagesTask task(&e, &repo);
tr1::shared_ptr<const PackageIDSequence> packages(e.package_database()->query(
- query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(package)),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(),
- tr1::shared_ptr<RepositoryName>(new RepositoryName(repo.name())))),
+ query::Matches(make_package_dep_spec()
+ .package(package)
+ .repository(repo.name())),
qo_group_by_slot));
tr1::shared_ptr<const PackageIDSequence> unused(task.execute(package));
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
index e00f00a..0fe4e4f 100644
--- a/src/clients/adjutrix/what_needs_keywording.cc
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -88,12 +88,11 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
try
{
if (std::string::npos == p->find('/'))
- d.add(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- env.package_database()->fetch_unique_qualified_package_name(PackageNamePart(*p))))),
+ d.add(make_package_dep_spec().package(env.package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(*CommandLine::get_instance()->begin_parameters()))),
env.default_destinations());
else
- d.add(PackageDepSpec(*p, pds_pm_permissive), env.default_destinations());
+ d.add(parse_user_package_dep_spec(*p, UserPackageDepSpecOptions()), env.default_destinations());
}
catch (const NoSuchPackageError & e)
{
diff --git a/src/clients/contrarius/stage.cc b/src/clients/contrarius/stage.cc
index 5467ea9..9b34e31 100644
--- a/src/clients/contrarius/stage.cc
+++ b/src/clients/contrarius/stage.cc
@@ -21,6 +21,7 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/config_file.hh>
+#include <paludis/util/options.hh>
#include <paludis/package_database.hh>
#include <paludis/environments/adapted/adapted_environment.hh>
#include <paludis/query.hh>
@@ -50,8 +51,8 @@ AuxiliaryStage::is_rebuild() const
for (std::list<std::string>::const_iterator p(packages.begin()), p_end(packages.end()) ;
p != p_end ; ++p)
if ( _env->package_database()->query(
- query::Matches(PackageDepSpec(*p, pds_pm_permissive)) &
- query::InstalledAtRoot(_env->root()),
+ query::Matches(parse_user_package_dep_spec(*p, UserPackageDepSpecOptions())) &
+ query::InstalledAtRoot(_env->root()),
qo_whatever)->empty())
return false;
@@ -63,8 +64,8 @@ BinutilsStage::build(const StageOptions &) const
{
Context context("When building BinutilsStage:");
- tr1::shared_ptr<PackageDepSpec> binutils(new PackageDepSpec(TargetConfig::get_instance()->binutils(),
- pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> binutils(new PackageDepSpec(
+ parse_user_package_dep_spec(TargetConfig::get_instance()->binutils(), UserPackageDepSpecOptions())));
_env->clear_adaptions();
@@ -75,7 +76,7 @@ bool
BinutilsStage::is_rebuild() const
{
return (! _env->package_database()->query(
- query::Matches(PackageDepSpec(TargetConfig::get_instance()->binutils(), pds_pm_permissive)) &
+ query::Matches(parse_user_package_dep_spec(TargetConfig::get_instance()->binutils(), UserPackageDepSpecOptions())) &
query::InstalledAtRoot(_env->root()),
qo_whatever)->empty());
}
@@ -85,8 +86,8 @@ KernelHeadersStage::build(const StageOptions &) const
{
Context context("When building KernelHeadersStage:");
- tr1::shared_ptr<PackageDepSpec> headers(new PackageDepSpec(TargetConfig::get_instance()->headers(),
- pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> headers(new PackageDepSpec(
+ parse_user_package_dep_spec(TargetConfig::get_instance()->headers(), UserPackageDepSpecOptions())));
_env->clear_adaptions();
@@ -99,8 +100,8 @@ bool
KernelHeadersStage::is_rebuild() const
{
return (! _env->package_database()->query(
- query::Matches(PackageDepSpec(TargetConfig::get_instance()->headers(), pds_pm_permissive)) &
- query::InstalledAtRoot(_env->root()),
+ query::Matches(parse_user_package_dep_spec(TargetConfig::get_instance()->headers(), UserPackageDepSpecOptions())) &
+ query::InstalledAtRoot(_env->root()),
qo_whatever)->empty());
}
@@ -109,8 +110,8 @@ MinimalStage::build(const StageOptions &) const
{
Context context("When executing MinimalStage:");
- tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(TargetConfig::get_instance()->gcc(),
- pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(parse_user_package_dep_spec(TargetConfig::get_instance()->gcc(),
+ UserPackageDepSpecOptions())));
_env->clear_adaptions();
@@ -131,9 +132,9 @@ bool
MinimalStage::is_rebuild() const
{
return (! _env->package_database()->query(
- query::Matches(PackageDepSpec(TargetConfig::get_instance()->gcc(), pds_pm_permissive)) &
- query::InstalledAtRoot(_env->root()),
- qo_whatever)->empty());
+ query::Matches(parse_user_package_dep_spec(TargetConfig::get_instance()->gcc(), UserPackageDepSpecOptions())) &
+ query::InstalledAtRoot(_env->root()),
+ qo_whatever)->empty());
}
int
@@ -141,8 +142,8 @@ LibCHeadersStage::build(const StageOptions &) const
{
Context context("When building LIbCHeaderStage:");
- tr1::shared_ptr<PackageDepSpec> libc(new PackageDepSpec(TargetConfig::get_instance()->libc(),
- pds_pm_unspecific));
+ tr1::shared_ptr<PackageDepSpec> libc(new PackageDepSpec(parse_user_package_dep_spec(TargetConfig::get_instance()->libc(),
+ UserPackageDepSpecOptions())));
_env->clear_adaptions();
@@ -155,7 +156,7 @@ bool
LibCHeadersStage::is_rebuild() const
{
return (! tr1::shared_ptr<const PackageIDSequence>(_env->package_database()->query(
- query::Matches(PackageDepSpec(TargetConfig::get_instance()->libc(), pds_pm_unspecific)) &
+ query::Matches(parse_user_package_dep_spec(TargetConfig::get_instance()->libc(), UserPackageDepSpecOptions())) &
query::InstalledAtRoot(_env->root()),
qo_whatever))->empty());
}
@@ -165,8 +166,8 @@ LibCStage::build(const StageOptions &) const
{
Context context("When building LibCStage:");
- tr1::shared_ptr<PackageDepSpec> libc(new PackageDepSpec(TargetConfig::get_instance()->libc(),
- pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> libc(new PackageDepSpec(parse_user_package_dep_spec(TargetConfig::get_instance()->libc(),
+ UserPackageDepSpecOptions())));
_env->clear_adaptions();
@@ -177,8 +178,8 @@ bool
LibCStage::is_rebuild() const
{
tr1::shared_ptr<const PackageIDSequence> c(_env->package_database()->query(
- query::Matches(PackageDepSpec(TargetConfig::get_instance()->libc(), pds_pm_permissive)) &
- query::InstalledAtRoot(_env->root()),
+ query::Matches(parse_user_package_dep_spec(TargetConfig::get_instance()->libc(), UserPackageDepSpecOptions())) &
+ query::InstalledAtRoot(_env->root()),
qo_whatever));
if (c->empty())
@@ -192,8 +193,8 @@ FullStage::build(const StageOptions &) const
{
Context context("When building FullStage:");
- tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(TargetConfig::get_instance()->gcc(),
- pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> gcc(new PackageDepSpec(parse_user_package_dep_spec(TargetConfig::get_instance()->gcc(),
+ UserPackageDepSpecOptions())));
_env->clear_adaptions();
@@ -211,8 +212,8 @@ bool
FullStage::is_rebuild() const
{
tr1::shared_ptr<const PackageIDSequence> c(_env->package_database()->query(
- query::Matches(PackageDepSpec(TargetConfig::get_instance()->gcc(), pds_pm_permissive)) &
- query::InstalledAtRoot(_env->root()),
+ query::Matches(parse_user_package_dep_spec(TargetConfig::get_instance()->gcc(), UserPackageDepSpecOptions())) &
+ query::InstalledAtRoot(_env->root()),
qo_whatever));
if (c->empty())
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
index 7364185..23e1968 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
@@ -15,6 +15,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/iterator_funcs.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/options.hh>
#include <list>
#include <algorithm>
#include <set>
@@ -136,26 +137,18 @@ namespace
environment->package_database()->query(
query::InstalledAtRoot(environment->root()) &
query::Matches(pds) &
- query::Matches(PackageDepSpec(
- paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(id->name())),
- paludis::tr1::shared_ptr<CategoryNamePart>(),
- paludis::tr1::shared_ptr<PackageNamePart>(),
- paludis::tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- paludis::tr1::shared_ptr<SlotName>(new SlotName(id->slot())))),
+ query::Matches(make_package_dep_spec()
+ .package(id->name())
+ .slot(id->slot())),
qo_order_by_version));
paludis::tr1::shared_ptr<const PackageIDSequence> av(
environment->package_database()->query(
query::SupportsAction<InstallAction>() &
query::Matches(pds) &
- query::Matches(PackageDepSpec(
- paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(id->name())),
- paludis::tr1::shared_ptr<CategoryNamePart>(),
- paludis::tr1::shared_ptr<PackageNamePart>(),
- paludis::tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- paludis::tr1::shared_ptr<SlotName>(new SlotName(id->slot())))) &
+ query::Matches(make_package_dep_spec()
+ .package(id->name())
+ .slot(id->slot())) &
query::NotMasked(),
qo_order_by_version));
@@ -183,13 +176,9 @@ namespace
paludis::tr1::shared_ptr<const PackageIDSequence> av(
environment->package_database()->query(
query::Matches(pds) &
- query::Matches(PackageDepSpec(
- paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(id->name())),
- paludis::tr1::shared_ptr<CategoryNamePart>(),
- paludis::tr1::shared_ptr<PackageNamePart>(),
- paludis::tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- paludis::tr1::shared_ptr<SlotName>(new SlotName(id->slot())))) &
+ query::Matches(make_package_dep_spec()
+ .package(id->name())
+ .slot(id->slot())) &
query::SupportsAction<InstallAction>() &
query::NotMasked(),
qo_order_by_version));
@@ -238,15 +227,14 @@ PackagesListModel::populate_in_paludis_thread()
if (old_qpn != (*p)->name())
{
data->items.push_front(PopulateItem(stringify((*p)->name().package)));
- data->items.begin()->children.push_front(make_item(
- PackageDepSpec(make_shared_ptr(new QualifiedPackageName((*p)->name()))),
+ data->items.begin()->children.push_front(make_item(make_package_dep_spec().package((*p)->name()),
*p, _imp->main_window->environment()));
data->items.begin()->qpn = data->items.begin()->children.begin()->qpn;
old_qpn = (*p)->name();
}
else
data->items.begin()->children.push_front(make_item(
- PackageDepSpec(make_shared_ptr(new QualifiedPackageName((*p)->name()))),
+ PackageDepSpec(make_package_dep_spec().package((*p)->name())),
*p, _imp->main_window->environment()));
}
}
@@ -263,7 +251,7 @@ PackagesListModel::populate_in_paludis_thread()
{
std::list<PopulateItem>::iterator atom_iter(data->items.insert(data->items.end(), PopulateItem(*i)));
atom_iter->merge_if_one_child = false;
- PackageDepSpec ds(*i, pds_pm_unspecific);
+ PackageDepSpec ds(parse_user_package_dep_spec(*i, UserPackageDepSpecOptions() + updso_allow_wildcards));
if (ds.package_ptr())
{
paludis::tr1::shared_ptr<const PackageIDSequence> c(
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index aac97c7..cd502f1 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -287,7 +287,7 @@ do_search(const Environment & env)
i(ids.begin()), i_end(ids.end()) ; i != i_end ; ++i)
if (i->second)
{
- task.show(PackageDepSpec(make_shared_ptr(new QualifiedPackageName(i->first))), i->second);
+ task.show(make_package_dep_spec().package(i->first), i->second);
any = true;
}
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 43dcadb..5c32a1a 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -171,7 +171,7 @@ int do_has_version(tr1::shared_ptr<Environment> env)
Context context("When performing has-version action from command line:");
std::string query(*CommandLine::get_instance()->begin_parameters());
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(query, pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(parse_user_package_dep_spec(query, UserPackageDepSpecOptions())));
tr1::shared_ptr<const PackageIDSequence> entries(env->package_database()->query(
query::Matches(*spec) & query::InstalledAtRoot(env->root()), qo_whatever));
@@ -188,7 +188,7 @@ int do_best_version(tr1::shared_ptr<Environment> env)
Context context("When performing best-version action from command line:");
std::string query(*CommandLine::get_instance()->begin_parameters());
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(query, pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(parse_user_package_dep_spec(query, UserPackageDepSpecOptions())));
tr1::shared_ptr<const PackageIDSequence> entries(env->package_database()->query(
query::Matches(*spec) & query::InstalledAtRoot(env->root()), qo_order_by_version));
@@ -228,7 +228,7 @@ int do_match(tr1::shared_ptr<Environment> env)
Context context("When performing match action from command line:");
std::string query(*CommandLine::get_instance()->begin_parameters());
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(query, pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(parse_user_package_dep_spec(query, UserPackageDepSpecOptions())));
tr1::shared_ptr<const PackageIDSequence> entries(env->package_database()->query(
query::Matches(*spec) & query::InstalledAtRoot(env->root()), qo_order_by_version));
@@ -271,7 +271,7 @@ int do_environment_variable(tr1::shared_ptr<Environment> env)
std::string spec_str(*CommandLine::get_instance()->begin_parameters());
std::string var_str(* next(CommandLine::get_instance()->begin_parameters()));
- tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(spec_str, pds_pm_permissive));
+ tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(parse_user_package_dep_spec(spec_str, UserPackageDepSpecOptions())));
tr1::shared_ptr<const PackageIDSequence> entries(env->package_database()->query(
query::Matches(*spec) & query::InstalledAtRoot(env->root()), qo_order_by_version));
diff --git a/src/clients/paludis/do_config.cc b/src/clients/paludis/do_config.cc
index caa92a1..c6eff75 100644
--- a/src/clients/paludis/do_config.cc
+++ b/src/clients/paludis/do_config.cc
@@ -73,10 +73,10 @@ namespace
/* we might have a dep spec, but we might just have a simple package name
* without a category. either should work. */
tr1::shared_ptr<PackageDepSpec> spec(std::string::npos == target.find('/') ?
- new PackageDepSpec(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- env->package_database()->fetch_unique_qualified_package_name(
- PackageNamePart(target), query::InstalledAtRoot(env->root()))))) :
- new PackageDepSpec(target, pds_pm_permissive));
+ new PackageDepSpec(make_package_dep_spec().package(
+ env->package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(target), query::InstalledAtRoot(env->root())))) :
+ new PackageDepSpec(parse_user_package_dep_spec(target, UserPackageDepSpecOptions())));
tr1::shared_ptr<const PackageIDSequence>
entries(env->package_database()->query(query::Matches(*spec) & query::InstalledAtRoot(env->root()), qo_order_by_version));
diff --git a/src/clients/paludis/do_contents.cc b/src/clients/paludis/do_contents.cc
index e8e7350..a49fd6a 100644
--- a/src/clients/paludis/do_contents.cc
+++ b/src/clients/paludis/do_contents.cc
@@ -97,9 +97,9 @@ do_one_contents(
/* we might have a dep spec, but we might just have a simple package name
* without a category. either should work. */
tr1::shared_ptr<PackageDepSpec> spec(std::string::npos == q.find('/') ?
- new PackageDepSpec(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(q))))) :
- new PackageDepSpec(q, pds_pm_permissive));
+ new PackageDepSpec(make_package_dep_spec().package(
+ env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(q)))) :
+ new PackageDepSpec(parse_user_package_dep_spec(q, UserPackageDepSpecOptions())));
tr1::shared_ptr<const PackageIDSequence>
entries(env->package_database()->query(query::Matches(*spec) & query::InstalledAtRoot(
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index d9fb0de..3ae98fb 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -194,10 +194,10 @@ int do_one_info(
tr1::shared_ptr<PackageDepSpec> spec;
if (std::string::npos != q.find('/'))
- spec.reset(new PackageDepSpec(q, pds_pm_permissive));
+ spec.reset(new PackageDepSpec(parse_user_package_dep_spec(q, UserPackageDepSpecOptions())));
else
- spec.reset(new PackageDepSpec(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(q))))));
+ spec.reset(new PackageDepSpec(make_package_dep_spec().package(
+ env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(q)))));
tr1::shared_ptr<const PackageIDSequence>
entries(env->package_database()->query(query::Matches(*spec), qo_order_by_version)),
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index 980a48d..3448062 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -141,11 +141,11 @@ void do_one_query(
{
}
if (0 == set)
- spec.reset(new PackageDepSpec(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(q))))));
+ spec.reset(new PackageDepSpec(make_package_dep_spec().package(
+ env->package_database()->fetch_unique_qualified_package_name(PackageNamePart(q)))));
}
else
- spec.reset(new PackageDepSpec(q, pds_pm_permissive));
+ spec.reset(new PackageDepSpec(parse_user_package_dep_spec(q, UserPackageDepSpecOptions())));
if (spec)
do_one_package_query(env, masks_to_explain, spec);
diff --git a/src/clients/reconcilio/fix_linkage.cc b/src/clients/reconcilio/fix_linkage.cc
index c973baf..5bc6f71 100644
--- a/src/clients/reconcilio/fix_linkage.cc
+++ b/src/clients/reconcilio/fix_linkage.cc
@@ -100,17 +100,15 @@ do_fix_linkage(const tr1::shared_ptr<Environment> & env)
std::cout << std::endl;
}
- targets->push_back(
- stringify(
- PackageDepSpec(
- make_shared_ptr(new QualifiedPackageName((*pkg_it)->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- CommandLine::get_instance()->a_exact.specified()
- ? make_equal_to_version_requirements((*pkg_it)->version())
- : tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- make_shared_ptr(new SlotName((*pkg_it)->slot())))));
+ if (CommandLine::get_instance()->a_exact.specified())
+ targets->push_back(stringify(make_package_dep_spec()
+ .package((*pkg_it)->name())
+ .version_requirement(VersionRequirement(vo_equal, (*pkg_it)->version()))
+ .slot((*pkg_it)->slot())));
+ else
+ targets->push_back(stringify(make_package_dep_spec()
+ .package((*pkg_it)->name())
+ .slot((*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 bd19fcf..03100bb 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -343,25 +343,15 @@ ConsoleInstallTask::on_display_merge_list_entry(const DepListEntry & d)
repo.reset(new RepositoryName(d.destination->name()));
tr1::shared_ptr<const PackageIDSequence> existing_repo(environment()->package_database()->
- query(query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(d.package_id->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(),
- repo)),
+ query(query::Matches(repo ?
+ make_package_dep_spec().package(d.package_id->name()).repository(*repo) :
+ make_package_dep_spec().package(d.package_id->name())),
qo_order_by_version));
tr1::shared_ptr<const PackageIDSequence> existing_slot_repo(environment()->package_database()->
- query(query::Matches(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(d.package_id->name())),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(new SlotName(d.package_id->slot())),
- repo)),
+ 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())),
qo_order_by_version));
display_merge_list_entry_start(d, m);