aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-27 19:21:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-27 19:21:52 +0000
commit7e0e5a87926b77173ab057059394c463deac7b69 (patch)
treeff9cc1da484e72be33f9a8945cc13f61115a42e8
parent1e5290d4a82c9c83314a6c81aaad7324e12b5321 (diff)
downloadpaludis-7e0e5a87926b77173ab057059394c463deac7b69.tar.gz
paludis-7e0e5a87926b77173ab057059394c463deac7b69.tar.xz
r3606@snowflake: ciaranm | 2007-06-27 20:17:54 +0100
Switch to Package IDs. Known to be broken: CRAN, Gems, QA / qualudis, gtkpaludis, contrarius, Ruby, Python, paludis --query / inquisitio output
-rw-r--r--doc/examples/pwp_basic_cplusplus_app.cc4
-rw-r--r--paludis/dep_list/Makefile.am10
-rw-r--r--paludis/dep_list/dep_list-fwd.hh7
-rw-r--r--paludis/dep_list/dep_list.cc471
-rw-r--r--paludis/dep_list/dep_list.hh20
-rw-r--r--paludis/dep_list/dep_list.sr3
-rw-r--r--paludis/dep_list/dep_list_TEST.cc252
-rw-r--r--paludis/dep_list/dep_list_TEST.hh3
-rw-r--r--paludis/dep_list/dep_list_TEST_blockers.cc121
-rw-r--r--paludis/dep_list/exceptions.cc2
-rw-r--r--paludis/dep_list/exceptions.hh2
-rw-r--r--paludis/dep_list/query_visitor.cc22
-rw-r--r--paludis/dep_list/query_visitor.hh4
-rw-r--r--paludis/dep_list/show_suggest_visitor.cc19
-rw-r--r--paludis/dep_list/show_suggest_visitor.hh2
-rw-r--r--paludis/dep_list/uninstall_list.cc207
-rw-r--r--paludis/dep_list/uninstall_list.hh21
-rw-r--r--paludis/dep_list/uninstall_list.sr2
-rw-r--r--paludis/dep_list/uninstall_list_TEST.cc64
-rw-r--r--paludis/dep_spec_TEST.cc2
-rw-r--r--paludis/dep_spec_flattener.cc7
-rw-r--r--paludis/dep_spec_flattener.hh8
-rw-r--r--paludis/dep_tag.cc104
-rw-r--r--paludis/dep_tag.hh34
-rw-r--r--paludis/environment-fwd.hh1
-rw-r--r--paludis/environment.cc1
-rw-r--r--paludis/environment.hh21
-rw-r--r--paludis/environment_implementation.cc94
-rw-r--r--paludis/environment_implementation.hh34
-rw-r--r--paludis/environment_implementation_TEST.cc57
-rw-r--r--paludis/environments/adapted/adapted_environment.cc12
-rw-r--r--paludis/environments/adapted/adapted_environment.hh10
-rw-r--r--paludis/environments/no_config/no_config_environment.cc2
-rw-r--r--paludis/environments/no_config/no_config_environment.hh3
-rw-r--r--paludis/environments/paludis/keywords_conf.cc7
-rw-r--r--paludis/environments/paludis/keywords_conf.hh8
-rw-r--r--paludis/environments/paludis/licenses_conf.cc7
-rw-r--r--paludis/environments/paludis/licenses_conf.hh8
-rw-r--r--paludis/environments/paludis/mirrors_conf.cc1
-rw-r--r--paludis/environments/paludis/mirrors_conf.hh1
-rw-r--r--paludis/environments/paludis/package_mask_conf.cc7
-rw-r--r--paludis/environments/paludis/package_mask_conf.hh8
-rw-r--r--paludis/environments/paludis/paludis_environment.cc28
-rw-r--r--paludis/environments/paludis/paludis_environment.hh16
-rw-r--r--paludis/environments/paludis/paludis_environment_TEST.cc10
-rw-r--r--paludis/environments/paludis/use_conf.cc16
-rw-r--r--paludis/environments/paludis/use_conf.hh10
-rw-r--r--paludis/environments/portage/portage_environment.cc26
-rw-r--r--paludis/environments/portage/portage_environment.hh13
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc10
-rw-r--r--paludis/environments/test/test_environment.cc20
-rw-r--r--paludis/environments/test/test_environment.hh12
-rw-r--r--paludis/files.m48
-rw-r--r--paludis/hashed_containers.cc25
-rw-r--r--paludis/hashed_containers.hh86
-rw-r--r--paludis/hashed_containers_TEST.cc1
-rw-r--r--paludis/hook-fwd.hh36
-rw-r--r--paludis/hook.cc52
-rw-r--r--paludis/hook.hh15
-rw-r--r--paludis/hooker_TEST.cc1
-rw-r--r--paludis/mask_reasons.se1
-rw-r--r--paludis/match_package.cc78
-rw-r--r--paludis/match_package.hh9
-rw-r--r--paludis/merger/merger_TEST.cc1
-rw-r--r--paludis/metadata_key-fwd.hh34
-rw-r--r--paludis/metadata_key.cc95
-rw-r--r--paludis/metadata_key.hh120
-rw-r--r--paludis/metadata_key_raw_printer-fwd.hh33
-rw-r--r--paludis/metadata_key_raw_printer.cc (renamed from paludis/repositories/virtuals/vr_entry.cc)6
-rw-r--r--paludis/metadata_key_raw_printer.hh54
-rw-r--r--paludis/name.sr2
-rw-r--r--paludis/package_database.cc156
-rw-r--r--paludis/package_database.hh32
-rw-r--r--paludis/package_database.se1
-rw-r--r--paludis/package_database_TEST.cc91
-rw-r--r--paludis/package_database_entry.hh64
-rw-r--r--paludis/package_database_entry.sr25
-rw-r--r--paludis/package_id-fwd.hh41
-rw-r--r--paludis/package_id.cc133
-rw-r--r--paludis/package_id.hh135
-rw-r--r--paludis/package_id.se22
-rw-r--r--paludis/qa/create_metadata_check.cc1
-rw-r--r--paludis/query.cc127
-rw-r--r--paludis/query.hh27
-rw-r--r--paludis/repositories/cran/Makefile.am6
-rw-r--r--paludis/repositories/cran/cran_dep_parser.cc6
-rw-r--r--paludis/repositories/cran/cran_description.hh135
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc283
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh87
-rw-r--r--paludis/repositories/cran/cran_package_id.cc (renamed from paludis/repositories/cran/cran_description.cc)43
-rw-r--r--paludis/repositories/cran/cran_package_id.hh44
-rw-r--r--paludis/repositories/cran/cran_repository.cc470
-rw-r--r--paludis/repositories/cran/cran_repository.hh47
-rw-r--r--paludis/repositories/cran/cran_repository_TEST.cc2
-rw-r--r--paludis/repositories/cran/cran_version_metadata.cc51
-rw-r--r--paludis/repositories/cran/cran_version_metadata.hh56
-rw-r--r--paludis/repositories/fake/Makefile.am47
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc51
-rw-r--r--paludis/repositories/fake/fake_installed_repository.hh33
-rw-r--r--paludis/repositories/fake/fake_installed_repository_TEST.cc41
-rw-r--r--paludis/repositories/fake/fake_package_id.cc474
-rw-r--r--paludis/repositories/fake/fake_package_id.hh157
-rw-r--r--paludis/repositories/fake/fake_repository.cc61
-rw-r--r--paludis/repositories/fake/fake_repository.hh17
-rw-r--r--paludis/repositories/fake/fake_repository_TEST.cc (renamed from paludis/package_database_entry.cc)39
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc125
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh149
-rw-r--r--paludis/repositories/gems/Makefile.am2
-rw-r--r--paludis/repositories/gems/gem_specification.cc325
-rw-r--r--paludis/repositories/gems/gem_specification.hh57
-rw-r--r--paludis/repositories/gems/gem_specification_TEST.cc82
-rw-r--r--paludis/repositories/gems/gem_specifications.cc25
-rw-r--r--paludis/repositories/gems/gem_specifications.hh3
-rw-r--r--paludis/repositories/gems/gems_repository.cc87
-rw-r--r--paludis/repositories/gems/gems_repository.hh36
-rw-r--r--paludis/repositories/gems/gems_repository_TEST.cc1
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc123
-rw-r--r--paludis/repositories/gems/installed_gems_repository.hh55
-rw-r--r--paludis/repositories/gems/installed_gems_repository_TEST.cc1
-rwxr-xr-xpaludis/repositories/gems/installed_gems_repository_TEST_setup.sh4
-rw-r--r--paludis/repositories/gems/metadata.cc87
-rw-r--r--paludis/repositories/gems/metadata.hh88
-rw-r--r--paludis/repositories/gems/params.sr3
-rw-r--r--paludis/repositories/gems/registration.cc13
-rw-r--r--paludis/repositories/gentoo/Makefile.am12
-rw-r--r--paludis/repositories/gentoo/e_key.cc430
-rw-r--r--paludis/repositories/gentoo/e_key.hh192
-rw-r--r--paludis/repositories/gentoo/ebin.cc60
-rw-r--r--paludis/repositories/gentoo/ebin.hh30
-rw-r--r--paludis/repositories/gentoo/ebin.sr2
-rw-r--r--paludis/repositories/gentoo/ebin_entries.cc92
-rw-r--r--paludis/repositories/gentoo/ebin_entries.hh27
-rw-r--r--paludis/repositories/gentoo/ebuild.cc274
-rw-r--r--paludis/repositories/gentoo/ebuild.hh678
-rw-r--r--paludis/repositories/gentoo/ebuild.sr5
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc318
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.hh29
-rw-r--r--paludis/repositories/gentoo/ebuild_flat_metadata_cache.cc128
-rw-r--r--paludis/repositories/gentoo/ebuild_flat_metadata_cache.hh61
-rw-r--r--paludis/repositories/gentoo/ebuild_id.cc527
-rw-r--r--paludis/repositories/gentoo/ebuild_id.hh109
-rw-r--r--paludis/repositories/gentoo/exheres_layout.cc123
-rw-r--r--paludis/repositories/gentoo/exheres_layout.hh18
-rw-r--r--paludis/repositories/gentoo/layout.cc5
-rw-r--r--paludis/repositories/gentoo/layout.hh17
-rw-r--r--paludis/repositories/gentoo/make_ebuild_repository.cc2
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc174
-rw-r--r--paludis/repositories/gentoo/portage_repository.hh137
-rw-r--r--paludis/repositories/gentoo/portage_repository_TEST.cc229
-rwxr-xr-xpaludis/repositories/gentoo/portage_repository_TEST_setup.sh11
-rw-r--r--paludis/repositories/gentoo/portage_repository_entries.cc2
-rw-r--r--paludis/repositories/gentoo/portage_repository_entries.hh24
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile.cc26
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile.hh17
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets.cc44
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets.hh4
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets_TEST.cc10
-rw-r--r--paludis/repositories/gentoo/portage_virtual_version_metadata.cc53
-rw-r--r--paludis/repositories/gentoo/portage_virtual_version_metadata.hh55
-rw-r--r--paludis/repositories/gentoo/traditional_layout.cc109
-rw-r--r--paludis/repositories/gentoo/traditional_layout.hh19
-rw-r--r--paludis/repositories/gentoo/use_desc.cc6
-rw-r--r--paludis/repositories/gentoo/use_desc.hh6
-rw-r--r--paludis/repositories/gentoo/vdb_id.cc415
-rw-r--r--paludis/repositories/gentoo/vdb_id.hh86
-rw-r--r--paludis/repositories/gentoo/vdb_merger.cc49
-rw-r--r--paludis/repositories/gentoo/vdb_merger.hh2
-rw-r--r--paludis/repositories/gentoo/vdb_merger.sr2
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc1139
-rw-r--r--paludis/repositories/gentoo/vdb_repository.hh204
-rw-r--r--paludis/repositories/gentoo/vdb_unmerger.cc59
-rw-r--r--paludis/repositories/gentoo/vdb_unmerger.sr4
-rw-r--r--paludis/repositories/gentoo/vdb_unmerger_TEST.cc11
-rw-r--r--paludis/repositories/gentoo/vdb_version_metadata.cc79
-rw-r--r--paludis/repositories/gentoo/vdb_version_metadata.hh88
-rw-r--r--paludis/repositories/virtuals/Makefile.am54
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc180
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.hh40
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository_TEST.cc41
-rw-r--r--paludis/repositories/virtuals/package_id.cc327
-rw-r--r--paludis/repositories/virtuals/package_id.hh115
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc196
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.hh51
-rw-r--r--paludis/repositories/virtuals/virtuals_repository_TEST.cc72
-rw-r--r--paludis/repositories/virtuals/vr_entry.hh160
-rw-r--r--paludis/repositories/virtuals/vr_entry.sr25
-rw-r--r--paludis/repository-fwd.hh5
-rw-r--r--paludis/repository.cc216
-rw-r--r--paludis/repository.hh317
-rw-r--r--paludis/repository.sr8
-rw-r--r--paludis/repository_info-fwd.hh (renamed from src/clients/adjutrix/display_profiles_use.hh)14
-rw-r--r--paludis/repository_info.cc142
-rw-r--r--paludis/repository_info.hh112
-rw-r--r--paludis/tasks/find_unused_packages_task.cc21
-rw-r--r--paludis/tasks/find_unused_packages_task.hh10
-rw-r--r--paludis/tasks/install_task.cc58
-rw-r--r--paludis/tasks/install_task.hh10
-rw-r--r--paludis/tasks/report_task.cc57
-rw-r--r--paludis/tasks/report_task.hh18
-rw-r--r--paludis/tasks/uninstall_task.cc30
-rw-r--r--paludis/tasks/uninstall_task.hh8
-rw-r--r--paludis/util/collection.hh15
-rw-r--r--paludis/util/collection_concrete.hh17
-rw-r--r--paludis/util/tr1_functional.hh8
-rw-r--r--paludis/util/tr1_memory.hh4
-rw-r--r--paludis/util/tr1_type_traits.hh4
-rw-r--r--paludis/util/visitor-fwd.hh8
-rw-r--r--paludis/util/visitor.hh66
-rw-r--r--paludis/version_metadata.cc193
-rw-r--r--paludis/version_metadata.hh115
-rw-r--r--paludis/version_metadata.sr259
-rw-r--r--paludis/version_requirements-fwd.hh11
-rw-r--r--paludis/version_requirements.cc12
-rw-r--r--paludis/version_spec-fwd.hh8
-rw-r--r--src/clients/adjutrix/Makefile.am1
-rw-r--r--src/clients/adjutrix/adjutrix.cc12
-rw-r--r--src/clients/adjutrix/command_line.cc2
-rw-r--r--src/clients/adjutrix/command_line.hh1
-rw-r--r--src/clients/adjutrix/display_default_system_resolution.cc2
-rw-r--r--src/clients/adjutrix/display_profiles_use.cc184
-rw-r--r--src/clients/adjutrix/downgrade_check.cc15
-rw-r--r--src/clients/adjutrix/find_dropped_keywords.cc29
-rw-r--r--src/clients/adjutrix/find_insecure_packages.cc20
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc50
-rw-r--r--src/clients/adjutrix/find_stable_candidates.cc30
-rw-r--r--src/clients/adjutrix/find_unused_packages.cc6
-rw-r--r--src/clients/adjutrix/keywords_graph.cc53
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc15
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc2
-rw-r--r--src/clients/inquisitio/description_extractor.cc9
-rw-r--r--src/clients/inquisitio/description_extractor.hh2
-rw-r--r--src/clients/inquisitio/do_search.cc14
-rw-r--r--src/clients/inquisitio/extractor.hh6
-rw-r--r--src/clients/inquisitio/name_extractor.cc6
-rw-r--r--src/clients/inquisitio/name_extractor.hh2
-rw-r--r--src/clients/paludis/applets.cc38
-rw-r--r--src/clients/paludis/do_config.cc22
-rw-r--r--src/clients/paludis/do_contents.cc17
-rw-r--r--src/clients/paludis/install.cc45
-rwxr-xr-xsrc/clients/paludis/install_TEST10
-rw-r--r--src/clients/paludis/list.cc1
-rw-r--r--src/clients/paludis/owner.cc11
-rw-r--r--src/clients/paludis/query.cc2
-rw-r--r--src/clients/paludis/report.cc37
-rw-r--r--src/clients/paludis/uninstall.cc8
-rw-r--r--src/output/console_install_task.cc147
-rw-r--r--src/output/console_install_task.hh29
-rw-r--r--src/output/console_install_task.sr2
-rw-r--r--src/output/console_query_task.cc168
-rw-r--r--src/output/console_query_task.hh15
-rw-r--r--src/output/console_task.cc2
-rw-r--r--src/output/licence.cc8
-rw-r--r--src/output/licence.hh8
-rw-r--r--src/output/use_flag_pretty_printer.cc28
-rw-r--r--src/output/use_flag_pretty_printer.hh8
255 files changed, 9262 insertions, 7777 deletions
diff --git a/doc/examples/pwp_basic_cplusplus_app.cc b/doc/examples/pwp_basic_cplusplus_app.cc
index 72095cf..4a327ae 100644
--- a/doc/examples/pwp_basic_cplusplus_app.cc
+++ b/doc/examples/pwp_basic_cplusplus_app.cc
@@ -17,7 +17,7 @@ int main(int, char *[])
paludis::tr1::shared_ptr<paludis::Environment> env(
paludis::EnvironmentMaker::get_instance()->make_from_spec(""));
- paludis::tr1::shared_ptr<const paludis::PackageDatabaseEntryCollection> packages(
+ paludis::tr1::shared_ptr<const paludis::PackageIDSequence> packages(
env->package_database()->query(
paludis::query::Matches(paludis::PackageDepSpec("app-editors/vim", paludis::pds_pm_eapi_0_strict)) &
paludis::query::InstalledAtRoot(env->root()), paludis::qo_order_by_version));
@@ -25,7 +25,7 @@ int main(int, char *[])
if (packages->empty())
cout << "Vim is not installed" << endl;
else
- cout << "Vim " << packages->last()->version << " is installed" << endl;
+ cout << "Vim " << (*packages->last())->canonical_form(paludis::idcf_version) << " is installed" << endl;
}
catch (const paludis::Exception & e)
{
diff --git a/paludis/dep_list/Makefile.am b/paludis/dep_list/Makefile.am
index 959e380..3049e7c 100644
--- a/paludis/dep_list/Makefile.am
+++ b/paludis/dep_list/Makefile.am
@@ -63,14 +63,18 @@ TESTS = \
range_rewriter_TEST
TESTS_ENVIRONMENT = env \
- PALUDIS_EBUILD_DIR="$(top_srcdir)/ebuild/" \
- PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_EBUILD_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_srcdir)/paludis/repositories/gentoo/ebuild/`" \
PALUDIS_EAPIS_DIR="$(top_srcdir)/paludis/eapis/" \
PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \
- PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ PALUDIS_SKIP_CONFIG="yes" \
TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
+ $(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/gentoo/`:` \
+ $(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/gentoo/.libs/`" \
bash $(top_srcdir)/test/run_test.sh
+
check_PROGRAMS = $(TESTS)
dep_list_TEST_SOURCES = dep_list_TEST.cc
diff --git a/paludis/dep_list/dep_list-fwd.hh b/paludis/dep_list/dep_list-fwd.hh
index 65005ac..7647ce9 100644
--- a/paludis/dep_list/dep_list-fwd.hh
+++ b/paludis/dep_list/dep_list-fwd.hh
@@ -20,11 +20,11 @@
#ifndef PALUDIS_GUARD_PALUDIS_DEP_LIST_FWD_HH
#define PALUDIS_GUARD_PALUDIS_DEP_LIST_FWD_HH 1
-#include <iosfwd>
-#include <paludis/util/attributes.hh>
#include <paludis/util/tr1_memory.hh>
#include <paludis/repository-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
namespace paludis
{
@@ -32,9 +32,8 @@ namespace paludis
class DepListEntryDestination;
class DepListEntry;
class DepList;
- class PackageDatabaseEntry;
- bool is_viable_any_child(const Environment & env, const PackageDatabaseEntry * const pde,
+ bool is_viable_any_child(const Environment & env, const tr1::shared_ptr<const PackageID> &,
const DependencySpecTree::ConstItem & i);
}
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index a953354..5f395f6 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -31,6 +31,7 @@
#include <paludis/eapi.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/match_package.hh>
+#include <paludis/metadata_key.hh>
#include <paludis/query.hh>
#include <paludis/version_requirements.hh>
@@ -104,11 +105,11 @@ namespace paludis
bool throw_on_blocker;
- const PackageDatabaseEntry * current_pde() const
+ const tr1::shared_ptr<const PackageID> current_package_id() const
{
if (current_merge_list_entry != merge_list.end())
- return &current_merge_list_entry->package;
- return 0;
+ return current_merge_list_entry->package_id;
+ return tr1::shared_ptr<const PackageID>();
}
Implementation(const Environment * const e, const DepListOptions & o) :
@@ -126,38 +127,6 @@ namespace paludis
namespace
{
- class FakedVirtualVersionMetadata :
- public VersionMetadata,
- public VersionMetadataVirtualInterface,
- public virtual VersionMetadataHasInterfaces
- {
- public:
- FakedVirtualVersionMetadata(const SlotName & s, const PackageDatabaseEntry & e) :
- VersionMetadata(
- VersionMetadataBase::create()
- .slot(s)
- .homepage("")
- .description("")
- .eapi(EAPIData::get_instance()->eapi_from_string("paludis-1"))
- .interactive(false),
- VersionMetadataCapabilities::create()
- .cran_interface(0)
- .virtual_interface(this)
- .ebuild_interface(0)
- .deps_interface(0)
- .origins_interface(0)
- .ebin_interface(0)
- .license_interface(0)),
- VersionMetadataVirtualInterface(make_shared_ptr(new PackageDatabaseEntry(e)))
- {
- }
-
- virtual const VersionMetadata * version_metadata() const
- {
- return this;
- }
- };
-
struct GenerationGreaterThan
{
long g;
@@ -237,7 +206,7 @@ namespace
else
{
for (std::pair<MergeListIndex::iterator, MergeListIndex::iterator> p(
- _index.equal_range(i->package.name)) ; p.first != p.second ; )
+ _index.equal_range(i->package_id->name())) ; p.first != p.second ; )
if (p.first->second == i)
_index.erase(p.first++);
else
@@ -273,7 +242,7 @@ namespace
case dlk_provided:
case dlk_already_installed:
case dlk_subpackage:
- return match_package(*env, a, e.second->package);
+ return match_package(*env, a, *e.second->package_id);
case dlk_block:
case dlk_masked:
@@ -294,9 +263,11 @@ namespace
const PackageDepSpec * const u(get_const_item(i)->as_package_dep_spec());
if (0 != u && u->package_ptr())
{
- return ! env.package_database()->query(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(*u->package_ptr()))),
- is_installed_only, qo_whatever)->empty();
+ return ! env.package_database()->query(
+ query::RepositoryHasInstalledInterface() &
+ query::Matches(PackageDepSpec(
+ tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(*u->package_ptr())))),
+ qo_whatever)->empty();
}
else
return false;
@@ -347,8 +318,10 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
/* find already installed things */
// TODO: check destinations
- tr1::shared_ptr<const PackageDatabaseEntryCollection> already_installed(d->_imp->env->package_database()->query(
- a, is_installed_only, qo_order_by_version));
+ tr1::shared_ptr<const PackageIDSequence> already_installed(d->_imp->env->package_database()->query(
+ query::RepositoryHasInstalledInterface() &
+ query::Matches(a),
+ qo_order_by_version));
/* are we already on the merge list? */
std::pair<MergeListIndex::iterator, MergeListIndex::iterator> q;
@@ -369,9 +342,9 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
.tag(a.tag())
.generation(d->_imp->merge_list_generation));
- if (d->_imp->opts->dependency_tags && d->_imp->current_pde())
+ if (d->_imp->opts->dependency_tags && d->_imp->current_package_id())
existing_merge_list_entry->tags->insert(DepTagEntry::create()
- .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(*d->_imp->current_pde(), a, conditions)))
+ .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(d->_imp->current_package_id(), a, conditions)))
.generation(d->_imp->merge_list_generation));
/* add an appropriate destination */
@@ -387,14 +360,14 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
if (d->_imp->opts->circular == dl_circular_discard)
{
Log::get_instance()->message(ll_qa, lc_context, "Dropping circular dependency on '"
- + stringify(existing_merge_list_entry->package) + "'");
+ + stringify(*existing_merge_list_entry->package_id) + "'");
return;
}
else if (d->_imp->opts->circular == dl_circular_discard_silently)
return;
throw CircularDependencyError("Atom '" + stringify(a) + "' matched by merge list entry '" +
- stringify(existing_merge_list_entry->package) + "', which does not yet have its "
+ stringify(*existing_merge_list_entry->package_id) + "', which does not yet have its "
"dependencies installed");
}
else
@@ -402,15 +375,16 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
}
/* find installable candidates, and find the best visible candidate */
- const PackageDatabaseEntry * best_visible_candidate(0);
- tr1::shared_ptr<const PackageDatabaseEntryCollection> installable_candidates(
- d->_imp->env->package_database()->query(a, is_installable_only, qo_order_by_version));
+ tr1::shared_ptr<const PackageID> best_visible_candidate;
+ tr1::shared_ptr<const PackageIDSequence> installable_candidates(
+ d->_imp->env->package_database()->query(query::RepositoryHasInstallableInterface() & query::Matches(a),
+ qo_order_by_version));
- for (PackageDatabaseEntryCollection::ReverseIterator p(installable_candidates->rbegin()),
+ for (PackageIDSequence::ReverseIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
- if (! d->_imp->env->mask_reasons(*p).any())
+ if (! d->_imp->env->mask_reasons(**p).any())
{
- best_visible_candidate = &*p;
+ best_visible_candidate = *p;
break;
}
@@ -453,13 +427,13 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
if (masks_to_override[dl_override_unkeyworded])
override_options += mro_override_unkeyworded;
- for (PackageDatabaseEntryCollection::ReverseIterator p(installable_candidates->rbegin()),
+ for (PackageIDSequence::ReverseIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
{
- if (! (d->_imp->env->mask_reasons(*p, override_options).subtract(mask_mask).any()))
+ if (! (d->_imp->env->mask_reasons(**p, override_options).subtract(mask_mask).any()))
{
d->add_error_package(*p, dlk_masked, a, conditions);
- best_visible_candidate = &*p;
+ best_visible_candidate = *p;
break;
}
}
@@ -480,12 +454,12 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
continue;
case dl_fall_back_as_needed_except_targets:
- if (! d->_imp->current_pde())
+ if (! d->_imp->current_package_id())
can_fall_back = false;
else if (already_installed->empty())
can_fall_back = true;
else
- can_fall_back = ! d->is_top_level_target(*already_installed->last());
+ can_fall_back = ! d->is_top_level_target(**already_installed->last());
continue;
@@ -505,12 +479,12 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
if (! a.use_requirements_ptr())
throw AllMaskedError(a);
- tr1::shared_ptr<const PackageDatabaseEntryCollection> match_except_reqs(d->_imp->env->package_database()->query(
- *a.without_use_requirements(), is_any, qo_whatever));
+ tr1::shared_ptr<const PackageIDSequence> match_except_reqs(d->_imp->env->package_database()->query(
+ query::Matches(*a.without_use_requirements()), qo_whatever));
- for (PackageDatabaseEntryCollection::Iterator i(match_except_reqs->begin()),
+ for (PackageIDSequence::Iterator i(match_except_reqs->begin()),
i_end(match_except_reqs->end()) ; i != i_end ; ++i)
- if (! (d->_imp->env->mask_reasons(*i).any()))
+ if (! (d->_imp->env->mask_reasons(**i).any()))
throw UseRequirementsNotMetError(stringify(a));
throw AllMaskedError(a);
@@ -519,27 +493,16 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
{
Log::get_instance()->message(ll_warning, lc_context, "No visible packages matching '"
+ stringify(a) + "', falling back to installed package '"
- + stringify(*already_installed->last()) + "'");
+ + stringify(**already_installed->last()) + "'");
d->add_already_installed_package(*already_installed->last(), a.tag(), a, conditions, destinations);
return;
}
}
- tr1::shared_ptr<const VersionMetadata> best_visible_candidate_metadata(
- d->_imp->env->package_database()->fetch_repository(best_visible_candidate->repository)->
- version_metadata(best_visible_candidate->name, best_visible_candidate->version));
- SlotName slot(best_visible_candidate_metadata->slot);
- std::string best_visible_candidate_as_string(stringify(*best_visible_candidate));
- if (best_visible_candidate_metadata->virtual_interface)
- best_visible_candidate_as_string.append(" (for " + stringify(
- *best_visible_candidate_metadata->virtual_interface->virtual_for) + ")");
-
- tr1::shared_ptr<PackageDatabaseEntryCollection> already_installed_in_same_slot(
- new PackageDatabaseEntryCollection::Concrete);
- for (PackageDatabaseEntryCollection::Iterator aa(already_installed->begin()),
+ tr1::shared_ptr<PackageIDSequence> already_installed_in_same_slot(new PackageIDSequence::Concrete);
+ for (PackageIDSequence::Iterator aa(already_installed->begin()),
aa_end(already_installed->end()) ; aa != aa_end ; ++aa)
- if (d->_imp->env->package_database()->fetch_repository(aa->repository)->
- version_metadata(aa->name, aa->version)->slot == slot)
+ if ((*aa)->slot() == best_visible_candidate->slot())
already_installed_in_same_slot->push_back(*aa);
/* no need to sort already_installed_in_same_slot here, although if the above is
* changed then check that this still holds... */
@@ -547,39 +510,40 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
/* we have an already installed version. do we want to use it? */
if (! already_installed_in_same_slot->empty())
{
- if (d->prefer_installed_over_uninstalled(*already_installed_in_same_slot->last(), *best_visible_candidate))
+ if (d->prefer_installed_over_uninstalled(**already_installed_in_same_slot->last(), *best_visible_candidate))
{
Log::get_instance()->message(ll_debug, lc_context, "Taking installed package '"
- + stringify(*already_installed_in_same_slot->last()) + "' over '" +
- best_visible_candidate_as_string + "'");
+ + stringify(**already_installed_in_same_slot->last()) + "' over '" +
+ stringify(*best_visible_candidate) + "'");
d->add_already_installed_package(*already_installed_in_same_slot->last(), a.tag(), a, conditions, destinations);
return;
}
else
Log::get_instance()->message(ll_debug, lc_context, "Not taking installed package '"
- + stringify(*already_installed_in_same_slot->last()) + "' over '" +
- best_visible_candidate_as_string + "'");
+ + stringify(**already_installed_in_same_slot->last()) + "' over '" +
+ stringify(*best_visible_candidate) + "'");
}
else if ((! already_installed->empty()) && (dl_new_slots_as_needed == d->_imp->opts->new_slots))
{
/* we have an already installed, but not in the same slot, and our options
* allow us to take this. */
- if (d->prefer_installed_over_uninstalled(*already_installed->last(), *best_visible_candidate))
+ if (d->prefer_installed_over_uninstalled(**already_installed->last(), *best_visible_candidate))
{
Log::get_instance()->message(ll_debug, lc_context, "Taking installed package '"
- + stringify(*already_installed->last()) + "' over '" + best_visible_candidate_as_string
+ + stringify(**already_installed->last()) + "' over '" + stringify(*best_visible_candidate)
+ "' (in different slot)");
d->add_already_installed_package(*already_installed->last(), a.tag(), a, conditions, destinations);
return;
}
else
Log::get_instance()->message(ll_debug, lc_context, "Not taking installed package '"
- + stringify(*already_installed->last()) + "' over '" +
- best_visible_candidate_as_string + "' (in different slot)");
+ + stringify(**already_installed->last()) + "' over '" +
+ stringify(*best_visible_candidate) + "' (in different slot)");
}
else
- Log::get_instance()->message(ll_debug, lc_context, "No installed packages in SLOT '"
- + stringify(slot) + "', taking uninstalled package '" + best_visible_candidate_as_string + "'");
+ Log::get_instance()->message(ll_debug, lc_context) << "No installed packages in SLOT '"
+ << best_visible_candidate->slot() << "', taking uninstalled package '"
+ << *best_visible_candidate << "'";
/* if this is a downgrade, make sure that that's ok */
switch (d->_imp->opts->downgrade)
@@ -590,39 +554,30 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
case dl_downgrade_error:
case dl_downgrade_warning:
{
- tr1::shared_ptr<PackageDatabaseEntryCollection> are_we_downgrading(
- d->_imp->env->package_database()->query(PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(
- new QualifiedPackageName(best_visible_candidate->name)),
- tr1::shared_ptr<CategoryNamePart>(),
- tr1::shared_ptr<PackageNamePart>(),
- tr1::shared_ptr<VersionRequirements>(),
- vr_and,
- tr1::shared_ptr<SlotName>(new SlotName(slot))),
- is_installed_only, qo_order_by_version));
+ tr1::shared_ptr<const PackageIDSequence> are_we_downgrading(
+ d->_imp->env->package_database()->query(
+ query::RepositoryHasInstalledInterface() &
+ 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())))),
+ qo_order_by_version));
if (are_we_downgrading->empty())
break;
- if (are_we_downgrading->last()->version <= best_visible_candidate->version)
+ if ((*are_we_downgrading->last())->version() <= best_visible_candidate->version())
break;
- tr1::shared_ptr<const VersionMetadata> are_we_downgrading_last_metadata(
- d->_imp->env->package_database()->fetch_repository(
- are_we_downgrading->last()->repository)->version_metadata(
- are_we_downgrading->last()->name, are_we_downgrading->last()->version));
- std::string are_we_downgrading_last_as_string(stringify(*are_we_downgrading->last()));
- if (are_we_downgrading_last_metadata->virtual_interface)
- are_we_downgrading_last_as_string.append(" (for " + stringify(
- *are_we_downgrading_last_metadata->virtual_interface->virtual_for) + ")");
-
if (d->_imp->opts->downgrade == dl_downgrade_error)
- throw DowngradeNotAllowedError(best_visible_candidate_as_string,
- are_we_downgrading_last_as_string);
+ throw DowngradeNotAllowedError(stringify(*best_visible_candidate),
+ stringify(**are_we_downgrading->last()));
- Log::get_instance()->message(ll_warning, lc_context, "Downgrade to '" +
- best_visible_candidate_as_string
- + "' from '" + are_we_downgrading_last_as_string + "' forced");
+ Log::get_instance()->message(ll_warning, lc_context) << "Downgrade to '"
+ << *best_visible_candidate << "' from '" << **are_we_downgrading->last() << "' forced";
}
break;
@@ -630,7 +585,7 @@ DepList::AddVisitor::visit_leaf(const PackageDepSpec & a)
;
}
- d->add_package(*best_visible_candidate, a.tag(), a, conditions, destinations);
+ d->add_package(best_visible_candidate, a.tag(), a, conditions, destinations);
}
void
@@ -643,23 +598,22 @@ DepList::AddVisitor::visit_sequence(const UseDepSpec & a,
if (d->_imp->opts->use == dl_use_deps_standard)
{
- if ((d->_imp->current_pde() ? d->_imp->env->query_use(a.flag(), *d->_imp->current_pde()) : false) ^ a.inverse())
+ if ((d->_imp->current_package_id() ? d->_imp->env->query_use(a.flag(), *d->_imp->current_package_id()) : false) ^ a.inverse())
std::for_each(cur, end, accept_visitor(*this));
}
else
{
RepositoryUseInterface * u(0);
- if ((! d->_imp->current_pde()) || (! ((u = d->_imp->env->package_database()->fetch_repository(
- d->_imp->current_pde()->repository)->use_interface))))
+ if ((! d->_imp->current_package_id()) || (! ((u = d->_imp->current_package_id()->repository()->use_interface))))
std::for_each(cur, end, accept_visitor(*this));
else if (a.inverse())
{
- if ((! d->_imp->current_pde()) || (! u->query_use_force(a.flag(), *d->_imp->current_pde())))
+ if ((! d->_imp->current_package_id()) || (! u->query_use_force(a.flag(), *d->_imp->current_package_id())))
std::for_each(cur, end, accept_visitor(*this));
}
else
{
- if ((! d->_imp->current_pde()) || (! u->query_use_mask(a.flag(), *d->_imp->current_pde())))
+ if ((! d->_imp->current_package_id()) || (! u->query_use_mask(a.flag(), *d->_imp->current_package_id())))
std::for_each(cur, end, accept_visitor(*this));
}
}
@@ -674,7 +628,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
/* annoying requirement: || ( foo? ( ... ) ) resolves to empty if !foo. */
if (end == std::find_if(cur, end,
- tr1::bind(&is_viable_any_child, tr1::cref(*d->_imp->env), d->_imp->current_pde(), _1)))
+ tr1::bind(&is_viable_any_child, tr1::cref(*d->_imp->env), d->_imp->current_package_id(), _1)))
return;
RangeRewriter r;
@@ -694,7 +648,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
* any upgrades kick in */
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_pde(), *c))
+ if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
continue;
if (d->already_installed(*c, destinations))
@@ -709,7 +663,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
* the b-2 bit first */
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_pde(), *c))
+ if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
continue;
if (! is_interesting_any_child(*d->_imp->env, *c))
continue;
@@ -732,7 +686,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
/* install first available viable option */
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_pde(), *c))
+ if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
continue;
try
@@ -756,7 +710,7 @@ DepList::AddVisitor::visit_sequence(const AnyDepSpec & a,
Context block_context("Inside || ( ) block with other options:");
for (DependencySpecTree::ConstSequenceIterator c(cur) ; c != end ; ++c)
{
- if (! is_viable_any_child(*d->_imp->env, d->_imp->current_pde(), *c))
+ if (! is_viable_any_child(*d->_imp->env, d->_imp->current_package_id(), *c))
continue;
d->add_not_top_level(*c, destinations, conditions);
@@ -780,14 +734,16 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
bool check_whole_list(false);
std::list<MergeList::const_iterator> will_be_installed;
- tr1::shared_ptr<const PackageDatabaseEntryCollection> already_installed;
+ tr1::shared_ptr<const PackageIDSequence> already_installed;
if (a.blocked_spec()->package_ptr())
{
PackageDepSpec just_package(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
*a.blocked_spec()->package_ptr())));
already_installed = d->_imp->env->package_database()->query(
- just_package, is_installed_only, qo_whatever);
+ query::RepositoryHasInstalledInterface() &
+ query::Matches(just_package),
+ qo_whatever);
MatchDepListEntryAgainstPackageDepSpec m(d->_imp->env, just_package);
for (std::pair<MergeListIndex::const_iterator, MergeListIndex::const_iterator> p(
@@ -818,23 +774,21 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
if (already_installed->empty() && will_be_installed.empty() && ! check_whole_list)
return;
- for (PackageDatabaseEntryCollection::Iterator aa(already_installed->begin()),
+ for (PackageIDSequence::Iterator aa(already_installed->begin()),
aa_end(already_installed->end()) ; aa != aa_end ; ++aa)
{
- if (! match_package(*d->_imp->env, *a.blocked_spec(), *aa))
+ if (! match_package(*d->_imp->env, *a.blocked_spec(), **aa))
continue;
- tr1::shared_ptr<const VersionMetadata> metadata(d->_imp->env->package_database()->fetch_repository(
- aa->repository)->version_metadata(aa->name, aa->version));
bool replaced(false);
for (std::list<MergeList::const_iterator>::const_iterator r(will_be_installed.begin()),
r_end(will_be_installed.end()) ; r != r_end && ! replaced ; ++r)
- if ((*r)->metadata->slot == metadata->slot)
+ if ((*r)->package_id->slot() == (*aa)->slot())
{
/* if it's a virtual, it only replaces if it's the same package. */
- if ((*r)->metadata->virtual_interface)
+ if ((*r)->package_id->virtual_for_key())
{
- if ((*r)->metadata->virtual_interface->virtual_for->name == aa->name)
+ if ((*r)->package_id->virtual_for_key()->value()->name() == (*aa)->name())
replaced = true;
}
else
@@ -848,13 +802,12 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
* ourself */
if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_ptr()
|| a.blocked_spec()->use_requirements_ptr() || a.blocked_spec()->repository_ptr())
- && d->_imp->current_pde())
+ && d->_imp->current_package_id())
{
- if (aa->name == d->_imp->current_pde()->name)
+ if ((*aa)->name() == d->_imp->current_package_id()->name())
continue;
- if (metadata->virtual_interface &&
- metadata->virtual_interface->virtual_for->name == d->_imp->current_pde()->name)
+ if ((*aa)->virtual_for_key() && (*aa)->virtual_for_key()->value()->name() == d->_imp->current_package_id()->name())
continue;
}
@@ -883,20 +836,20 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
for (std::list<MergeList::const_iterator>::const_iterator r(will_be_installed.begin()),
r_end(will_be_installed.end()) ; r != r_end ; ++r)
{
- if (! match_package(*d->_imp->env, *a.blocked_spec(), (*r)->package))
+ if (! match_package(*d->_imp->env, *a.blocked_spec(), *(*r)->package_id))
continue;
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_ptr()
|| a.blocked_spec()->use_requirements_ptr() || a.blocked_spec()->repository_ptr())
- && d->_imp->current_pde())
+ && d->_imp->current_package_id())
{
- if ((*r)->package.name == d->_imp->current_pde()->name)
+ if ((*r)->package_id->name() == d->_imp->current_package_id()->name())
continue;
- if ((*r)->metadata->virtual_interface &&
- (*r)->metadata->virtual_interface->virtual_for->name == d->_imp->current_pde()->name)
+ if ((*r)->package_id->virtual_for_key() && (*r)->package_id->virtual_for_key()->value()->name() ==
+ d->_imp->current_package_id()->name())
continue;
}
@@ -908,20 +861,20 @@ DepList::AddVisitor::visit_leaf(const BlockDepSpec & a)
for (MergeList::const_iterator r(d->_imp->merge_list.begin()),
r_end(d->_imp->merge_list.end()) ; r != r_end ; ++r)
{
- if (! match_package(*d->_imp->env, *a.blocked_spec(), r->package))
+ if (! match_package(*d->_imp->env, *a.blocked_spec(), *r->package_id))
continue;
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
if (! (a.blocked_spec()->version_requirements_ptr() || a.blocked_spec()->slot_ptr()
|| a.blocked_spec()->use_requirements_ptr() || a.blocked_spec()->repository_ptr())
- && d->_imp->current_pde())
+ && d->_imp->current_package_id())
{
- if (r->package.name == d->_imp->current_pde()->name)
+ if (r->package_id->name() == d->_imp->current_package_id()->name())
continue;
- if (r->metadata->virtual_interface &&
- r->metadata->virtual_interface->virtual_for->name == d->_imp->current_pde()->name)
+ if (r->package_id->virtual_for_key() &&
+ r->package_id->virtual_for_key()->value()->name() == d->_imp->current_package_id()->name())
continue;
}
@@ -1000,43 +953,39 @@ DepList::add(const PackageDepSpec & spec, tr1::shared_ptr<const DestinationsColl
}
void
-DepList::add_package(const PackageDatabaseEntry & p, tr1::shared_ptr<const DepTag> tag,
+DepList::add_package(const tr1::shared_ptr<const PackageID> & p, tr1::shared_ptr<const DepTag> tag,
const PackageDepSpec & pds, tr1::shared_ptr<DependencySpecTree::ConstItem> conditions,
tr1::shared_ptr<const DestinationsCollection> destinations)
{
- Context context("When adding package '" + stringify(p) + "':");
+ Context context("When adding package '" + stringify(*p) + "':");
Save<MergeList::iterator> save_merge_list_insert_position(&_imp->merge_list_insert_position);
- tr1::shared_ptr<const VersionMetadata> metadata(_imp->env->package_database()->fetch_repository(
- p.repository)->version_metadata(p.name, p.version));
-
/* create our merge list entry. insert pre deps before ourself in the list. insert
* post deps after ourself, and after any provides. */
MergeList::iterator our_merge_entry_position(
_imp->merge_list.insert(_imp->merge_list_insert_position,
DepListEntry::create()
- .package(p)
- .metadata(metadata)
+ .package_id(p)
.generation(_imp->merge_list_generation)
.state(dle_no_deps)
.tags(tr1::shared_ptr<DepListEntryTags>(new DepListEntryTags::Concrete))
- .destination(metadata->virtual_interface ? tr1::shared_ptr<Repository>() : find_destination(p, destinations))
+ .destination(p->virtual_for_key() ? tr1::shared_ptr<Repository>() : find_destination(*p, destinations))
.associated_entry(0)
- .kind(metadata->virtual_interface ? dlk_virtual : dlk_package))),
+ .kind(p->virtual_for_key() ? dlk_virtual : dlk_package))),
our_merge_entry_post_position(our_merge_entry_position);
- _imp->merge_list_index.insert(std::make_pair(p.name, our_merge_entry_position));
+ _imp->merge_list_index.insert(std::make_pair(p->name(), our_merge_entry_position));
if (tag)
our_merge_entry_position->tags->insert(DepTagEntry::create()
.generation(_imp->merge_list_generation)
.tag(tag));
- if (_imp->opts->dependency_tags && _imp->current_pde())
+ if (_imp->opts->dependency_tags && _imp->current_package_id())
our_merge_entry_position->tags->insert(DepTagEntry::create()
- .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(*_imp->current_pde(), pds, conditions)))
+ .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions)))
.generation(_imp->merge_list_generation));
Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry,
@@ -1045,20 +994,20 @@ DepList::add_package(const PackageDatabaseEntry & p, tr1::shared_ptr<const DepTa
_imp->merge_list_insert_position = our_merge_entry_position;
/* add provides */
- if (metadata->ebuild_interface)
+ if (p->provide_key())
{
- DepSpecFlattener f(_imp->env, _imp->current_pde());
- metadata->ebuild_interface->provide()->accept(f);
+ DepSpecFlattener f(_imp->env, _imp->current_package_id());
+ p->provide_key()->value()->accept(f);
if (f.begin() != f.end() && ! DistributionData::get_instance()->distribution_from_string(
_imp->env->default_distribution())->support_old_style_virtuals)
- throw DistributionConfigurationError("Package '" + stringify(p) + "' has PROVIDEs, but this distribution "
+ throw DistributionConfigurationError("Package '" + stringify(*p) + "' has PROVIDEs, but this distribution "
"does not support old style virtuals");
for (DepSpecFlattener::Iterator i(f.begin()), i_end(f.end()) ; i != i_end ; ++i)
{
tr1::shared_ptr<VersionRequirements> v(new VersionRequirements::Concrete);
- v->push_back(VersionRequirement(vo_equal, p.version));
+ 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>(),
@@ -1077,23 +1026,11 @@ DepList::add_package(const PackageDatabaseEntry & p, tr1::shared_ptr<const DepTa
if (zz != z.second)
continue;
- tr1::shared_ptr<const VersionMetadata> m;
-
- if (_imp->env->package_database()->fetch_repository(RepositoryName("virtuals"))->has_version(
- QualifiedPackageName((*i)->text()), p.version))
- m = _imp->env->package_database()->fetch_repository(RepositoryName("virtuals"))->version_metadata(
- QualifiedPackageName((*i)->text()), p.version);
- else
- {
- tr1::shared_ptr<VersionMetadata> mm(new FakedVirtualVersionMetadata(metadata->slot,
- PackageDatabaseEntry(p.name, p.version, RepositoryName("virtuals"))));
- m = mm;
- }
-
our_merge_entry_post_position = _imp->merge_list.insert(next(our_merge_entry_post_position),
DepListEntry(DepListEntry::create()
- .package(PackageDatabaseEntry((*i)->text(), p.version, RepositoryName("virtuals")))
- .metadata(m)
+ .package_id(_imp->env->package_database()->fetch_repository(
+ RepositoryName("virtuals"))->make_virtuals_interface->make_virtual_package_id(
+ QualifiedPackageName((*i)->text()), p))
.generation(_imp->merge_list_generation)
.state(dle_has_all_deps)
.tags(tr1::shared_ptr<DepListEntryTags>(new DepListEntryTags::Concrete))
@@ -1104,57 +1041,57 @@ DepList::add_package(const PackageDatabaseEntry & p, tr1::shared_ptr<const DepTa
}
}
- if (metadata->deps_interface)
+ /* add suggests */
+ if (_imp->opts->suggested == dl_suggested_show && p->suggested_dependencies_key())
{
- /* add suggests */
- if (_imp->opts->suggested == dl_suggested_show)
- {
- Context c("When showing suggestions:");
- Save<MergeList::iterator> suggest_save_merge_list_insert_position(&_imp->merge_list_insert_position,
- next(our_merge_entry_position));
- ShowSuggestVisitor visitor(this, destinations, _imp->env, _imp->current_pde(), _imp->opts->dependency_tags);
- metadata->deps_interface->suggested_depend()->accept(visitor);
- }
-
- /* add pre dependencies */
- add_predeps(*metadata->deps_interface->build_depend(), _imp->opts->uninstalled_deps_pre, "build", destinations);
- add_predeps(*metadata->deps_interface->run_depend(), _imp->opts->uninstalled_deps_runtime, "run", destinations);
- add_predeps(*metadata->deps_interface->post_depend(), _imp->opts->uninstalled_deps_post, "post", destinations);
- if (_imp->opts->suggested == dl_suggested_install)
- add_predeps(*metadata->deps_interface->suggested_depend(), _imp->opts->uninstalled_deps_suggested, "suggest", destinations);
+ Context c("When showing suggestions:");
+ Save<MergeList::iterator> suggest_save_merge_list_insert_position(&_imp->merge_list_insert_position,
+ next(our_merge_entry_position));
+ ShowSuggestVisitor visitor(this, destinations, _imp->env, _imp->current_package_id(), _imp->opts->dependency_tags);
+ p->suggested_dependencies_key()->value()->accept(visitor);
}
+ /* add pre dependencies */
+ if (p->build_dependencies_key())
+ add_predeps(*p->build_dependencies_key()->value(), _imp->opts->uninstalled_deps_pre, "build", destinations);
+ if (p->run_dependencies_key())
+ add_predeps(*p->run_dependencies_key()->value(), _imp->opts->uninstalled_deps_runtime, "run", destinations);
+ if (p->post_dependencies_key())
+ add_predeps(*p->post_dependencies_key()->value(), _imp->opts->uninstalled_deps_post, "post", destinations);
+ if (_imp->opts->suggested == dl_suggested_install && p->suggested_dependencies_key())
+ add_predeps(*p->suggested_dependencies_key()->value(), _imp->opts->uninstalled_deps_suggested, "suggest", destinations);
+
our_merge_entry_position->state = dle_has_pre_deps;
_imp->merge_list_insert_position = next(our_merge_entry_post_position);
- if (metadata->deps_interface)
- {
- /* add post dependencies */
- add_postdeps(*metadata->deps_interface->build_depend(), _imp->opts->uninstalled_deps_pre, "build", destinations);
- add_postdeps(*metadata->deps_interface->run_depend(), _imp->opts->uninstalled_deps_runtime, "run", destinations);
- add_postdeps(*metadata->deps_interface->post_depend(), _imp->opts->uninstalled_deps_post, "post", destinations);
+ /* add post dependencies */
+ if (p->build_dependencies_key())
+ add_postdeps(*p->build_dependencies_key()->value(), _imp->opts->uninstalled_deps_pre, "build", destinations);
+ if (p->run_dependencies_key())
+ add_postdeps(*p->run_dependencies_key()->value(), _imp->opts->uninstalled_deps_runtime, "run", destinations);
+ if (p->post_dependencies_key())
+ add_postdeps(*p->post_dependencies_key()->value(), _imp->opts->uninstalled_deps_post, "post", destinations);
- if (_imp->opts->suggested == dl_suggested_install)
- add_postdeps(*metadata->deps_interface->suggested_depend(), _imp->opts->uninstalled_deps_suggested, "suggest", destinations);
- }
+ if (_imp->opts->suggested == dl_suggested_install && p->suggested_dependencies_key())
+ add_postdeps(*p->suggested_dependencies_key()->value(), _imp->opts->uninstalled_deps_suggested, "suggest", destinations);
our_merge_entry_position->state = dle_has_all_deps;
}
void
-DepList::add_error_package(const PackageDatabaseEntry & p, const DepListEntryKind kind,
+DepList::add_error_package(const tr1::shared_ptr<const PackageID> & p, const DepListEntryKind kind,
const PackageDepSpec & pds, tr1::shared_ptr<DependencySpecTree::ConstItem> conditions)
{
std::pair<MergeListIndex::iterator, MergeListIndex::const_iterator> pp(
- _imp->merge_list_index.equal_range(p.name));
+ _imp->merge_list_index.equal_range(p->name()));
for ( ; pp.second != pp.first ; ++pp.first)
{
- if (pp.first->second->kind == kind && pp.first->second->package == p)
+ if (pp.first->second->kind == kind && *pp.first->second->package_id == *p)
{
- if (_imp->current_pde())
+ if (_imp->current_package_id())
pp.first->second->tags->insert(DepTagEntry::create()
- .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(*_imp->current_pde(), pds, conditions)))
+ .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions)))
.generation(_imp->merge_list_generation));
return;
}
@@ -1163,9 +1100,7 @@ DepList::add_error_package(const PackageDatabaseEntry & p, const DepListEntryKin
MergeList::iterator our_merge_entry_position(
_imp->merge_list.insert(_imp->merge_list.begin(),
DepListEntry::create()
- .package(p)
- .metadata(_imp->env->package_database()->fetch_repository(
- p.repository)->version_metadata(p.name, p.version))
+ .package_id(p)
.generation(_imp->merge_list_generation)
.state(dle_has_all_deps)
.tags(tr1::shared_ptr<DepListEntryTags>(new DepListEntryTags::Concrete))
@@ -1173,49 +1108,47 @@ DepList::add_error_package(const PackageDatabaseEntry & p, const DepListEntryKin
.associated_entry(&*_imp->current_merge_list_entry)
.kind(kind)));
- if (_imp->current_pde())
+ if (_imp->current_package_id())
our_merge_entry_position->tags->insert(DepTagEntry::create()
- .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(*_imp->current_pde(), pds, conditions)))
+ .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions)))
.generation(_imp->merge_list_generation));
- _imp->merge_list_index.insert(std::make_pair(p.name, our_merge_entry_position));
+ _imp->merge_list_index.insert(std::make_pair(p->name(), our_merge_entry_position));
}
void
-DepList::add_suggested_package(const PackageDatabaseEntry & p,
+DepList::add_suggested_package(const tr1::shared_ptr<const PackageID> & p,
const PackageDepSpec & pds, tr1::shared_ptr<DependencySpecTree::ConstItem> conditions,
const tr1::shared_ptr<const DestinationsCollection> destinations)
{
std::pair<MergeListIndex::iterator, MergeListIndex::const_iterator> pp(
- _imp->merge_list_index.equal_range(p.name));
+ _imp->merge_list_index.equal_range(p->name()));
for ( ; pp.second != pp.first ; ++pp.first)
{
if ((pp.first->second->kind == dlk_suggested || pp.first->second->kind == dlk_already_installed
|| pp.first->second->kind == dlk_package || pp.first->second->kind == dlk_provided
- || pp.first->second->kind == dlk_subpackage) && pp.first->second->package == p)
+ || pp.first->second->kind == dlk_subpackage) && *pp.first->second->package_id == *p)
return;
}
MergeList::iterator our_merge_entry_position(
_imp->merge_list.insert(_imp->merge_list_insert_position,
DepListEntry::create()
- .package(p)
- .metadata(_imp->env->package_database()->fetch_repository(
- p.repository)->version_metadata(p.name, p.version))
+ .package_id(p)
.generation(_imp->merge_list_generation)
.state(dle_has_all_deps)
.tags(tr1::shared_ptr<DepListEntryTags>(new DepListEntryTags::Concrete))
- .destination(find_destination(p, destinations))
+ .destination(find_destination(*p, destinations))
.associated_entry(&*_imp->current_merge_list_entry)
.kind(dlk_suggested)));
- if (_imp->current_pde())
+ if (_imp->current_package_id())
our_merge_entry_position->tags->insert(DepTagEntry::create()
- .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(*_imp->current_pde(), pds, conditions)))
+ .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions)))
.generation(_imp->merge_list_generation));
- _imp->merge_list_index.insert(std::make_pair(p.name, our_merge_entry_position));
+ _imp->merge_list_index.insert(std::make_pair(p->name(), our_merge_entry_position));
}
void
@@ -1273,57 +1206,54 @@ DepList::add_postdeps(DependencySpecTree::ConstItem & d, const DepListDepsOption
}
void
-DepList::add_already_installed_package(const PackageDatabaseEntry & p, tr1::shared_ptr<const DepTag> tag,
+DepList::add_already_installed_package(const tr1::shared_ptr<const PackageID> & p, tr1::shared_ptr<const DepTag> tag,
const PackageDepSpec & pds, tr1::shared_ptr<DependencySpecTree::ConstItem> conditions,
const tr1::shared_ptr<const DestinationsCollection> destinations)
{
- Context context("When adding installed package '" + stringify(p) + "':");
+ Context context("When adding installed package '" + stringify(*p) + "':");
Save<MergeList::iterator> save_merge_list_insert_position(&_imp->merge_list_insert_position);
- tr1::shared_ptr<const VersionMetadata> metadata(_imp->env->package_database()->fetch_repository(
- p.repository)->version_metadata(p.name, p.version));
MergeList::iterator our_merge_entry(_imp->merge_list.insert(_imp->merge_list_insert_position,
DepListEntry::create()
- .package(p)
- .metadata(metadata)
+ .package_id(p)
.generation(_imp->merge_list_generation)
.tags(tr1::shared_ptr<DepListEntryTags>(new DepListEntryTags::Concrete))
.state(dle_has_pre_deps)
.destination(tr1::shared_ptr<Repository>())
.associated_entry(0)
.kind(dlk_already_installed)));
- _imp->merge_list_index.insert(std::make_pair(p.name, our_merge_entry));
+ _imp->merge_list_index.insert(std::make_pair(p->name(), our_merge_entry));
if (tag)
our_merge_entry->tags->insert(DepTagEntry::create()
.generation(_imp->merge_list_generation)
.tag(tag));
- if (_imp->opts->dependency_tags && _imp->current_pde())
+ if (_imp->opts->dependency_tags && _imp->current_package_id())
our_merge_entry->tags->insert(DepTagEntry::create()
- .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(*_imp->current_pde(), pds, conditions)))
+ .tag(tr1::shared_ptr<DepTag>(new DependencyDepTag(_imp->current_package_id(), pds, conditions)))
.generation(_imp->merge_list_generation));
Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry,
our_merge_entry);
- if (metadata->deps_interface)
- {
- add_predeps(*metadata->deps_interface->build_depend(), _imp->opts->installed_deps_pre, "build", destinations);
- add_predeps(*metadata->deps_interface->run_depend(), _imp->opts->installed_deps_runtime, "run", destinations);
- add_predeps(*metadata->deps_interface->post_depend(), _imp->opts->installed_deps_post, "post", destinations);
- }
+ if (p->build_dependencies_key())
+ add_predeps(*p->build_dependencies_key()->value(), _imp->opts->installed_deps_pre, "build", destinations);
+ if (p->run_dependencies_key())
+ add_predeps(*p->run_dependencies_key()->value(), _imp->opts->installed_deps_runtime, "run", destinations);
+ if (p->post_dependencies_key())
+ add_predeps(*p->post_dependencies_key()->value(), _imp->opts->installed_deps_post, "post", destinations);
our_merge_entry->state = dle_has_pre_deps;
_imp->merge_list_insert_position = next(our_merge_entry);
- if (metadata->deps_interface)
- {
- add_postdeps(*metadata->deps_interface->build_depend(), _imp->opts->installed_deps_pre, "build", destinations);
- add_postdeps(*metadata->deps_interface->run_depend(), _imp->opts->installed_deps_runtime, "run", destinations);
- add_postdeps(*metadata->deps_interface->post_depend(), _imp->opts->installed_deps_post, "post", destinations);
- }
+ if (p->build_dependencies_key())
+ add_postdeps(*p->build_dependencies_key()->value(), _imp->opts->installed_deps_pre, "build", destinations);
+ if (p->run_dependencies_key())
+ add_postdeps(*p->run_dependencies_key()->value(), _imp->opts->installed_deps_runtime, "run", destinations);
+ if (p->post_dependencies_key())
+ add_postdeps(*p->post_dependencies_key()->value(), _imp->opts->installed_deps_post, "post", destinations);
}
namespace
@@ -1358,15 +1288,15 @@ namespace
}
bool
-DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installed,
- const PackageDatabaseEntry & uninstalled)
+DepList::prefer_installed_over_uninstalled(const PackageID & installed,
+ const PackageID & uninstalled)
{
do
{
switch (_imp->opts->target_type)
{
case dl_target_package:
- if (! _imp->current_pde())
+ if (! _imp->current_package_id())
return false;
if (is_top_level_target(uninstalled))
@@ -1391,12 +1321,11 @@ DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installe
return true;
if (dl_reinstall_scm_never != _imp->opts->reinstall_scm)
- if (uninstalled.version == installed.version &&
- (installed.version.is_scm() || is_scm(installed.name)))
+ if (uninstalled.version() == installed.version() &&
+ (installed.version().is_scm() || is_scm(installed.name())))
{
static time_t current_time(time(0)); /* static to avoid weirdness */
- time_t installed_time(_imp->env->package_database()->fetch_repository(installed.repository
- )->installed_interface->installed_time(installed.name, installed.version));
+ time_t installed_time(installed.repository()->installed_interface->installed_time(installed));
do
{
switch (_imp->opts->reinstall_scm)
@@ -1427,21 +1356,16 @@ DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installe
/* use != rather than > to correctly force a downgrade when packages are
* removed. */
- if (uninstalled.version != installed.version)
+ if (uninstalled.version() != installed.version())
return false;
if (dl_reinstall_if_use_changed == _imp->opts->reinstall)
{
- const VersionMetadataEbuildInterface * const evm_i(_imp->env->package_database()->fetch_repository(
- installed.repository)->version_metadata(installed.name, installed.version)->ebuild_interface);
- const VersionMetadataEbuildInterface * const evm_u(_imp->env->package_database()->fetch_repository(
- uninstalled.repository)->version_metadata(uninstalled.name, uninstalled.version)->ebuild_interface);
-
std::set<UseFlagName> use_common;
- if (evm_i && evm_u)
+ if (installed.iuse_key() && uninstalled.iuse_key())
std::set_intersection(
- evm_i->iuse()->begin(), evm_i->iuse()->end(),
- evm_u->iuse()->begin(), evm_u->iuse()->end(),
+ installed.iuse_key()->value()->begin(), installed.iuse_key()->value()->end(),
+ uninstalled.iuse_key()->value()->begin(), uninstalled.iuse_key()->value()->end(),
transform_inserter(std::inserter(use_common, use_common.end()),
paludis::tr1::mem_fn(&IUseFlag::flag)));
@@ -1458,7 +1382,7 @@ bool
DepList::already_installed(const DependencySpecTree::ConstItem & spec,
tr1::shared_ptr<const DestinationsCollection> destinations) const
{
- QueryVisitor visitor(this, destinations, _imp->env, _imp->current_pde());
+ QueryVisitor visitor(this, destinations, _imp->env, _imp->current_package_id());
spec.accept(visitor);
return visitor.result();
}
@@ -1476,7 +1400,7 @@ DepList::end() const
}
bool
-DepList::is_top_level_target(const PackageDatabaseEntry & e) const
+DepList::is_top_level_target(const PackageID & e) const
{
if (! _imp->current_top_level_target)
throw InternalError(PALUDIS_HERE, "current_top_level_target not set?");
@@ -1520,7 +1444,7 @@ DepList::has_errors() const
}
tr1::shared_ptr<Repository>
-DepList::find_destination(const PackageDatabaseEntry & p,
+DepList::find_destination(const PackageID & p,
tr1::shared_ptr<const DestinationsCollection> dd)
{
for (DestinationsCollection::Iterator d(dd->begin()), d_end(dd->end()) ;
@@ -1533,21 +1457,16 @@ DepList::find_destination(const PackageDatabaseEntry & p,
}
bool
-DepList::replaced(const PackageDatabaseEntry & m) const
+DepList::replaced(const PackageID & m) const
{
- tr1::shared_ptr<const VersionMetadata> vm(
- _imp->env->package_database()->fetch_repository(
- m.repository)->version_metadata(m.name, m.version));
- SlotName slot(vm->slot);
-
std::pair<MergeListIndex::const_iterator, MergeListIndex::const_iterator> p(
- _imp->merge_list_index.equal_range(m.name));
+ _imp->merge_list_index.equal_range(m.name()));
- PackageDepSpec spec(tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(m.name)));
+ PackageDepSpec spec(make_shared_ptr(new QualifiedPackageName(m.name())));
while (p.second != ((p.first = std::find_if(p.first, p.second,
MatchDepListEntryAgainstPackageDepSpec(_imp->env, spec)))))
{
- if (p.first->second->metadata->slot != slot)
+ if (p.first->second->package_id->slot() != m.slot())
p.first = next(p.first);
else
return true;
@@ -1570,12 +1489,12 @@ DepList::match_on_list(const PackageDepSpec & a) const
}
bool
-paludis::is_viable_any_child(const Environment & env, const PackageDatabaseEntry * const pde,
+paludis::is_viable_any_child(const Environment & env, const tr1::shared_ptr<const PackageID> & id,
const DependencySpecTree::ConstItem & i)
{
const UseDepSpec * const u(get_const_item(i)->as_use_dep_spec());
if (0 != u)
- return (pde ? env.query_use(u->flag(), *pde) : false) ^ u->inverse();
+ return (id ? env.query_use(u->flag(), *id) : false) ^ u->inverse();
else
return true;
}
diff --git a/paludis/dep_list/dep_list.hh b/paludis/dep_list/dep_list.hh
index 2697e23..4775724 100644
--- a/paludis/dep_list/dep_list.hh
+++ b/paludis/dep_list/dep_list.hh
@@ -37,8 +37,6 @@
namespace paludis
{
- class VersionMetadata;
-
#include <paludis/dep_list/dep_list-sr.hh>
/**
@@ -58,7 +56,7 @@ namespace paludis
/**
* Find an appropriate destination for a package.
*/
- tr1::shared_ptr<Repository> find_destination(const PackageDatabaseEntry &,
+ tr1::shared_ptr<Repository> find_destination(const PackageID &,
tr1::shared_ptr<const DestinationsCollection>);
/**
@@ -71,27 +69,27 @@ namespace paludis
* Return whether we prefer the first parameter, which is installed,
* over the second, which isn't.
*/
- bool prefer_installed_over_uninstalled(const PackageDatabaseEntry &,
- const PackageDatabaseEntry &);
+ bool prefer_installed_over_uninstalled(const PackageID &,
+ const PackageID &);
/**
* Add a package to the list.
*/
- void add_package(const PackageDatabaseEntry &, tr1::shared_ptr<const DepTag>,
+ void add_package(const tr1::shared_ptr<const PackageID> &, tr1::shared_ptr<const DepTag>,
const PackageDepSpec &, tr1::shared_ptr<DependencySpecTree::ConstItem>,
tr1::shared_ptr<const DestinationsCollection> destinations);
/**
* Add an already installed package to the list.
*/
- void add_already_installed_package(const PackageDatabaseEntry &, tr1::shared_ptr<const DepTag>,
+ void add_already_installed_package(const tr1::shared_ptr<const PackageID> &, tr1::shared_ptr<const DepTag>,
const PackageDepSpec &, tr1::shared_ptr<DependencySpecTree::ConstItem>,
tr1::shared_ptr<const DestinationsCollection> destinations);
/**
* Add an error package to the list.
*/
- void add_error_package(const PackageDatabaseEntry &, const DepListEntryKind,
+ void add_error_package(const tr1::shared_ptr<const PackageID> &, const DepListEntryKind,
const PackageDepSpec &, tr1::shared_ptr<DependencySpecTree::ConstItem>);
/**
@@ -110,7 +108,7 @@ namespace paludis
* Return whether the specified PackageDatabaseEntry is matched by
* the top level target.
*/
- bool is_top_level_target(const PackageDatabaseEntry &) const;
+ bool is_top_level_target(const PackageID &) const;
void add_not_top_level(DependencySpecTree::ConstItem &,
tr1::shared_ptr<const DestinationsCollection> target_destinations,
@@ -164,7 +162,7 @@ namespace paludis
/**
* Return whether a PackageDatabaseEntry has been replaced.
*/
- bool replaced(const PackageDatabaseEntry &) const;
+ bool replaced(const PackageID &) const;
/**
* Return whether a spec matches an item in the list.
@@ -179,7 +177,7 @@ namespace paludis
/**
* Add a suggested package to the list.
*/
- void add_suggested_package(const PackageDatabaseEntry &,
+ void add_suggested_package(const tr1::shared_ptr<const PackageID> &,
const PackageDepSpec &, tr1::shared_ptr<DependencySpecTree::ConstItem>,
tr1::shared_ptr<const DestinationsCollection> destinations);
diff --git a/paludis/dep_list/dep_list.sr b/paludis/dep_list/dep_list.sr
index 69dc05a..d292bff 100644
--- a/paludis/dep_list/dep_list.sr
+++ b/paludis/dep_list/dep_list.sr
@@ -53,9 +53,8 @@ make_class_DepListEntry()
key kind DepListEntryKind
- key package PackageDatabaseEntry
+ key package_id "tr1::shared_ptr<const PackageID>"
key associated_entry "const DepListEntry *"
- key metadata "tr1::shared_ptr<const VersionMetadata>"
key tags "tr1::shared_ptr<DepListEntryTags>"
key destination "tr1::shared_ptr<Repository>"
diff --git a/paludis/dep_list/dep_list_TEST.cc b/paludis/dep_list/dep_list_TEST.cc
index b367903..28c06b0 100644
--- a/paludis/dep_list/dep_list_TEST.cc
+++ b/paludis/dep_list/dep_list_TEST.cc
@@ -19,6 +19,8 @@
#include "dep_list_TEST.hh"
#include <paludis/util/visitor-impl.hh>
+#include <paludis/package_id.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/dep_spec_pretty_printer.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -70,7 +72,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
repo->add_version("cat", "two", "1");
}
@@ -90,8 +92,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/three");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/three");
repo->add_version("cat", "three", "1");
}
@@ -112,7 +114,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -134,8 +136,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/three");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/three");
repo->add_version("cat", "three", "1");
}
@@ -156,9 +158,9 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
repo->add_version("cat", "two", "1");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("cat/two");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("cat/two");
}
void populate_expected()
@@ -178,9 +180,9 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/four");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("cat/four");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/four");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("cat/four");
repo->add_version("cat", "four", "1");
}
@@ -202,9 +204,9 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/four cat/three");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("cat/four");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/four cat/three");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("cat/four");
repo->add_version("cat", "four", "1");
}
@@ -226,9 +228,9 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/four");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("cat/four cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/four");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("cat/four cat/two");
repo->add_version("cat", "four", "1");
}
@@ -250,7 +252,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -271,9 +273,9 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
repo->add_version("cat", "two", "1");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("|| ( cat/two cat/four )");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("|| ( cat/two cat/four )");
repo->add_version("cat", "four", "1");
}
@@ -294,7 +296,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( ( cat/two cat/three ) cat/four )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( ( cat/two cat/three ) cat/four )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
repo->add_version("cat", "four", "1");
@@ -317,10 +319,10 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three cat/four");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three cat/four");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
- repo->add_version("cat", "four", "1")->deps_interface->set_build_depend("|| ( ( cat/two cat/three ) cat/five )");
+ repo->add_version("cat", "four", "1")->build_dependencies_key()->set_from_string("|| ( ( cat/two cat/three ) cat/five )");
}
void populate_expected()
@@ -341,7 +343,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two cat/three )");
repo->add_version("cat", "three", "1");
}
@@ -361,8 +363,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two cat/three )");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/four");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two cat/three )");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/four");
repo->add_version("cat", "three", "1");
}
@@ -382,10 +384,10 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two:slot2");
- repo->add_version("cat", "two", "1.1")->slot = SlotName("slot1");
- repo->add_version("cat", "two", "1.2")->slot = SlotName("slot2");
- repo->add_version("cat", "two", "1.3")->slot = SlotName("slot3");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two:slot2");
+ repo->add_version("cat", "two", "1.1")->set_slot(SlotName("slot1"));
+ repo->add_version("cat", "two", "1.2")->set_slot(SlotName("slot2"));
+ repo->add_version("cat", "two", "1.3")->set_slot(SlotName("slot3"));
}
void populate_expected()
@@ -404,12 +406,12 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("<cat/two-1.2-r2:slot2");
- repo->add_version("cat", "two", "1.1")->slot = SlotName("slot1");
- repo->add_version("cat", "two", "1.2")->slot = SlotName("slot2");
- repo->add_version("cat", "two", "1.2-r1")->slot = SlotName("slot2");
- repo->add_version("cat", "two", "1.2-r2")->slot = SlotName("slot2");
- repo->add_version("cat", "two", "1.3")->slot = SlotName("slot3");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("<cat/two-1.2-r2:slot2");
+ repo->add_version("cat", "two", "1.1")->set_slot(SlotName("slot1"));
+ repo->add_version("cat", "two", "1.2")->set_slot(SlotName("slot2"));
+ repo->add_version("cat", "two", "1.2-r1")->set_slot(SlotName("slot2"));
+ repo->add_version("cat", "two", "1.2-r2")->set_slot(SlotName("slot2"));
+ repo->add_version("cat", "two", "1.3")->set_slot(SlotName("slot3"));
}
void populate_expected()
@@ -428,7 +430,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( )");
}
void populate_expected()
@@ -446,7 +448,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("enabled? ( cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("enabled? ( cat/two )");
repo->add_version("cat", "two", "1");
}
@@ -466,7 +468,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("!enabled? ( cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("!enabled? ( cat/two )");
repo->add_version("cat", "two", "1");
}
@@ -485,7 +487,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("disabled? ( cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("disabled? ( cat/two )");
repo->add_version("cat", "two", "1");
}
@@ -504,7 +506,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("!disabled? ( cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("!disabled? ( cat/two )");
repo->add_version("cat", "two", "1");
}
@@ -524,7 +526,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( enabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( enabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -545,7 +547,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( !enabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( !enabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -566,7 +568,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( disabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( disabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -587,7 +589,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( !disabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( !disabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -608,7 +610,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( enabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( enabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -629,7 +631,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( !enabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( !enabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -650,7 +652,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( disabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( disabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -671,7 +673,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( !disabled? ( cat/two ) cat/three )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( !disabled? ( cat/two ) cat/three )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -692,7 +694,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( enabled? ( cat/three ) cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( enabled? ( cat/three ) cat/two )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -713,7 +715,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( !enabled? ( cat/three ) cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( !enabled? ( cat/three ) cat/two )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -735,7 +737,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( disabled? ( cat/three ) cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( disabled? ( cat/three ) cat/two )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -757,7 +759,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three || ( !disabled? ( cat/three ) cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three || ( !disabled? ( cat/three ) cat/two )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -778,7 +780,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( enabled1? ( cat/two ) enabled2? ( cat/three ) )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( enabled1? ( cat/two ) enabled2? ( cat/three ) )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -799,7 +801,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( !enabled1? ( cat/two ) enabled2? ( cat/three ) )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( !enabled1? ( cat/two ) enabled2? ( cat/three ) )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -820,7 +822,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( !enabled1? ( cat/two ) !enabled2? ( cat/three ) )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( !enabled1? ( cat/two ) !enabled2? ( cat/three ) )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "1");
}
@@ -840,8 +842,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two cat/three )");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/one");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two cat/three )");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/one");
repo->add_version("cat", "three", "1");
}
@@ -861,8 +863,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two cat/three )");
- repo->add_version("cat", "two", "1")->deps_interface->set_post_depend("cat/one");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two cat/three )");
+ repo->add_version("cat", "two", "1")->post_dependencies_key()->set_from_string("cat/one");
repo->add_version("cat", "three", "1");
}
@@ -882,7 +884,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two cat/two )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two cat/two )");
repo->add_version("cat", "two", "1");
}
@@ -902,8 +904,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two[enabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("enabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two[enabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -922,8 +924,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two[-disabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("disabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two[-disabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -942,8 +944,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two[disabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("disabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two[disabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -969,8 +971,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two[-enabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("enabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two[-enabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -996,8 +998,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two cat/two[enabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("enabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two cat/two[enabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -1016,8 +1018,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two cat/two[-disabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("disabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two cat/two[-disabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -1036,8 +1038,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two cat/two[disabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("disabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two cat/two[disabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -1063,8 +1065,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("( cat/two cat/two[-enabled] )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_iuse("enabled");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("( cat/two cat/two[-enabled] )");
+ repo->add_version("cat", "two", "1")->iuse_key()->set_from_string("ebuild", iuse_pm_permissive);
}
void populate_expected()
@@ -1090,7 +1092,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_post_depend("cat/two");
+ repo->add_version("cat", "one", "1")->post_dependencies_key()->set_from_string("cat/two");
repo->add_version("cat", "two", "1");
}
@@ -1110,8 +1112,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_post_depend("cat/two");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/three");
+ repo->add_version("cat", "one", "1")->post_dependencies_key()->set_from_string("cat/two");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/three");
repo->add_version("cat", "three", "1");
}
@@ -1132,8 +1134,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_post_depend("cat/two");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/one");
+ repo->add_version("cat", "one", "1")->post_dependencies_key()->set_from_string("cat/two");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/one");
}
void populate_expected()
@@ -1152,8 +1154,8 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two || ( cat/three cat/four )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_provide("cat/four");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two || ( cat/three virtual/four )");
+ repo->add_version("cat", "two", "1")->provide_key()->set_from_string("virtual/four");
repo->add_version("cat", "three", "1");
}
@@ -1161,7 +1163,7 @@ namespace test_cases
{
merge_target = "cat/one";
expected.push_back("cat/two-1:0::repo");
- expected.push_back("cat/four-1:0::virtuals");
+ expected.push_back("virtual/four-1::virtuals (virtual for cat/two-1:0::repo)");
expected.push_back("cat/one-1:0::repo");
}
} test_dep_list_56;
@@ -1174,9 +1176,9 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_post_depend("cat/two");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/three");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("cat/one");
+ repo->add_version("cat", "one", "1")->post_dependencies_key()->set_from_string("cat/two");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/three");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("cat/one");
}
void populate_expected()
@@ -1196,14 +1198,14 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->ebuild_interface->set_provide("cat/two");
+ repo->add_version("cat", "one", "1")->provide_key()->set_from_string("virtual/two");
}
void populate_expected()
{
merge_target = "cat/one";
expected.push_back("cat/one-1:0::repo");
- expected.push_back("cat/two-1:0::virtuals");
+ expected.push_back("virtual/two-1::virtuals (virtual for cat/one-1:0::repo)");
}
} test_dep_list_58;
@@ -1215,7 +1217,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two >=cat/three-2 )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two >=cat/three-2 )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "2");
installed_repo->add_version("cat", "three", "1");
@@ -1237,7 +1239,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two >=cat/three-3 )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two >=cat/three-3 )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "three", "2");
installed_repo->add_version("cat", "three", "1");
@@ -1255,19 +1257,19 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->ebuild_interface->set_provide("virtual/foo");
- tr1::shared_ptr<VersionMetadata> m(repo->add_version("cat", "two", "2"));
- m->ebuild_interface->set_provide("virtual/foo");
- m->deps_interface->set_build_depend("cat/one");
+ repo->add_version("cat", "one", "1")->provide_key()->set_from_string("virtual/foo");
+ tr1::shared_ptr<FakePackageID> m(repo->add_version("cat", "two", "2"));
+ m->provide_key()->set_from_string("virtual/foo");
+ m->build_dependencies_key()->set_from_string("cat/one");
}
void populate_expected()
{
merge_target = "cat/two";
expected.push_back("cat/one-1:0::repo");
- expected.push_back("virtual/foo-1:0::virtuals");
+ expected.push_back("virtual/foo-1::virtuals (virtual for cat/one-1:0::repo)");
expected.push_back("cat/two-2:0::repo");
- expected.push_back("virtual/foo-2:0::virtuals");
+ expected.push_back("virtual/foo-2::virtuals (virtual for cat/two-2:0::repo)");
}
} test_dep_list_61;
@@ -1284,9 +1286,9 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( cat/two cat/three )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_keywords("~test");
- repo->add_version("cat", "three", "2")->ebuild_interface->set_keywords("~test");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( cat/two cat/three )");
+ repo->add_version("cat", "two", "1")->keywords_key()->set_from_string("~test");
+ repo->add_version("cat", "three", "2")->keywords_key()->set_from_string("~test");
}
void populate_expected()
@@ -1306,7 +1308,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( =cat/two-1 =cat/two-2 )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( =cat/two-1 =cat/two-2 )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "two", "2");
}
@@ -1327,7 +1329,7 @@ namespace test_cases
{
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( =cat/two-1 =cat/two-2 )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( =cat/two-1 =cat/two-2 )");
repo->add_version("cat", "two", "1");
repo->add_version("cat", "two", "2");
installed_repo->add_version("cat", "two", "1");
@@ -1354,8 +1356,8 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("|| ( =cat/two-2 =cat/two-1 )");
- repo->add_version("cat", "two", "1")->ebuild_interface->set_keywords("~test");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("|| ( =cat/two-2 =cat/two-1 )");
+ repo->add_version("cat", "two", "1")->keywords_key()->set_from_string("~test");
}
void populate_expected()
@@ -1384,13 +1386,13 @@ namespace test_cases
RepositoryName("installed_repo")));
env.package_database()->add_repository(2, destination_repo);
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/four");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("cat/four cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/four");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("cat/four cat/two");
repo->add_version("cat", "four", "1");
- repo->add_version("cat", "five", "1")->deps_interface->set_build_depend("cat/six cat/seven");
+ repo->add_version("cat", "five", "1")->build_dependencies_key()->set_from_string("cat/six cat/seven");
repo->add_version("cat", "six", "1");
- repo->add_version("cat", "seven", "1")->deps_interface->set_build_depend("cat/doesnotexist");
+ 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());
@@ -1422,13 +1424,13 @@ namespace test_cases
RepositoryName("installed_repo")));
env.package_database()->add_repository(2, destination_repo);
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("cat/four");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("cat/four cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("cat/four");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("cat/four cat/two");
repo->add_version("cat", "four", "1");
- repo->add_version("cat", "five", "1")->deps_interface->set_build_depend("cat/six cat/seven");
+ repo->add_version("cat", "five", "1")->build_dependencies_key()->set_from_string("cat/six cat/seven");
repo->add_version("cat", "six", "1");
- repo->add_version("cat", "seven", "1")->deps_interface->set_post_depend("cat/doesnotexist");
+ 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());
@@ -1483,7 +1485,7 @@ namespace test_cases
tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(1, repo);
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
tr1::shared_ptr<FakeInstalledRepository> installed_repo(
new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
@@ -1510,7 +1512,7 @@ namespace test_cases
tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(1, repo);
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
tr1::shared_ptr<FakeInstalledRepository> installed_repo(
new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
@@ -1538,7 +1540,7 @@ namespace test_cases
tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(1, repo);
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
tr1::shared_ptr<FakeInstalledRepository> installed_repo(
new FakeInstalledRepository(&env, RepositoryName("installed_repo")));
@@ -1592,7 +1594,7 @@ namespace test_cases
tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(1, repo);
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
repo->add_version("cat", "two", "2");
tr1::shared_ptr<FakeInstalledRepository> installed_repo(
@@ -1632,7 +1634,7 @@ namespace test_cases
tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(1, repo);
- repo->add_version("cat", "zero", "1")->deps_interface->set_build_depend(
+ repo->add_version("cat", "zero", "1")->build_dependencies_key()->set_from_string(
"( cat/one cat/two cat/three-live cat/four-cvs cat/five-svn cat/six-darcs )");
repo->add_version("cat", "one", "scm");
repo->add_version("cat", "two", "2");
@@ -1673,8 +1675,8 @@ namespace test_cases
tr1::shared_ptr<FakeRepository> repo(new FakeRepository(&env, RepositoryName("repo")));
env.package_database()->add_repository(1, repo);
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/three");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("enabled? ( || ( ( <cat/three-1 cat/three:0 =cat/four-1 ) cat/five ) )");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/three");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("enabled? ( || ( ( <cat/three-1 cat/three:0 =cat/four-1 ) cat/five ) )");
repo->add_version("cat", "three", "0.9");
repo->add_version("cat", "four", "1");
@@ -1710,7 +1712,7 @@ namespace test_cases
tr1::shared_ptr<const DependencyDepTag> tag(
tr1::static_pointer_cast<const DependencyDepTag>(tag_it->tag));
- if ("cat/one-1::repo" == tag->short_text())
+ if ("cat/one-1:0::repo" == tag->short_text())
{
cat_three_has_tag_from_cat_one = true;
TEST_CHECK_STRINGIFY_EQUAL(*tag->dependency(), "cat/three");
@@ -1719,7 +1721,7 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(pretty, "cat/three");
}
- else if ("cat/two-1::repo" == tag->short_text())
+ else if ("cat/two-1:0::repo" == tag->short_text())
{
if ("<cat/three-1" == stringify(*tag->dependency()))
{
@@ -1755,7 +1757,7 @@ namespace test_cases
TEST_CHECK_EQUAL(tags->begin()->tag->category(), "dependency");
tr1::shared_ptr<const DependencyDepTag> deptag(
tr1::static_pointer_cast<const DependencyDepTag>(tags->begin()->tag));
- TEST_CHECK_EQUAL(deptag->short_text(), "cat/two-1::repo");
+ TEST_CHECK_EQUAL(deptag->short_text(), "cat/two-1:0::repo");
TEST_CHECK_STRINGIFY_EQUAL(*deptag->dependency(), "=cat/four-1");
DepSpecPrettyPrinter pretty(0, false);
deptag->conditions()->accept(pretty);
diff --git a/paludis/dep_list/dep_list_TEST.hh b/paludis/dep_list/dep_list_TEST.hh
index 9718dab..77d78c2 100644
--- a/paludis/dep_list/dep_list_TEST.hh
+++ b/paludis/dep_list/dep_list_TEST.hh
@@ -47,8 +47,7 @@ namespace paludis
std::ostream &
operator<< (std::ostream & s, const DepListEntry & e)
{
- s << e.package.name << "-" << e.package.version << ":" <<
- e.metadata->slot << "::" << e.package.repository;
+ s << *e.package_id;
switch (e.kind)
{
diff --git a/paludis/dep_list/dep_list_TEST_blockers.cc b/paludis/dep_list/dep_list_TEST_blockers.cc
index fdd5721..d286b7a 100644
--- a/paludis/dep_list/dep_list_TEST_blockers.cc
+++ b/paludis/dep_list/dep_list_TEST_blockers.cc
@@ -18,6 +18,7 @@
*/
#include "dep_list_TEST.hh"
+#include <paludis/repositories/fake/fake_package_id.hh>
using namespace paludis;
using namespace test;
@@ -30,7 +31,7 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("!cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("!cat/two");
installed_repo->add_version("cat", "two", "1");
}
@@ -52,9 +53,9 @@ namespace test_cases
d.add(PackageDepSpec(merge_target, pds_pm_permissive), 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, "cat/two-1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*d.begin()->package_id, "cat/two-1:0::installed");
TEST_CHECK_EQUAL(next(d.begin())->kind, dlk_package);
- TEST_CHECK_STRINGIFY_EQUAL(next(d.begin())->package, "cat/one-1::repo");
+ TEST_CHECK_STRINGIFY_EQUAL(*next(d.begin())->package_id, "cat/one-1:0::repo");
}
} test_dep_list_basic_block;
@@ -64,8 +65,8 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("!cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("!cat/two");
}
void populate_expected()
@@ -82,17 +83,17 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- tr1::shared_ptr<VersionMetadata> two_m(repo->add_version("cat", "two", "1"));
- two_m->deps_interface->set_build_depend("!virtual/two");
- two_m->ebuild_interface->set_provide("virtual/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ tr1::shared_ptr<FakePackageID> two_m(repo->add_version("cat", "two", "1"));
+ two_m->build_dependencies_key()->set_from_string("!virtual/two");
+ two_m->provide_key()->set_from_string("virtual/two");
}
void populate_expected()
{
merge_target = "cat/one";
expected.push_back("cat/two-1:0::repo");
- expected.push_back("virtual/two-1:0::virtuals");
+ expected.push_back("virtual/two-1::virtuals (virtual for cat/two-1:0::repo)");
expected.push_back("cat/one-1:0::repo");
}
} test_dep_list_self_block_list;
@@ -103,11 +104,11 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- tr1::shared_ptr<VersionMetadata> two_m(repo->add_version("cat", "two", "1"));
- two_m->deps_interface->set_build_depend("!virtual/two");
- two_m->ebuild_interface->set_provide("virtual/two");
- installed_repo->add_version("other", "two", "1")->ebuild_interface->set_provide("virtual/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ tr1::shared_ptr<FakePackageID> two_m(repo->add_version("cat", "two", "1"));
+ two_m->build_dependencies_key()->set_from_string("!virtual/two");
+ two_m->provide_key()->set_from_string("virtual/two");
+ installed_repo->add_version("other", "two", "1")->provide_key()->set_from_string("virtual/two");
}
void populate_expected()
@@ -128,13 +129,13 @@ namespace test_cases
d.add(PackageDepSpec(merge_target, pds_pm_permissive), 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, "virtual/two-1::installed_virtuals");
+ TEST_CHECK_STRINGIFY_EQUAL(*d.begin()->package_id, "virtual/two-1::installed_virtuals (virtual for other/two-1:0::installed)");
TEST_CHECK_EQUAL(next(d.begin())->kind, dlk_package);
- TEST_CHECK_STRINGIFY_EQUAL(next(d.begin())->package, "cat/two-1::repo");
+ TEST_CHECK_STRINGIFY_EQUAL(*next(d.begin())->package_id, "cat/two-1:0::repo");
TEST_CHECK_EQUAL(next(next(d.begin()))->kind, dlk_provided);
- TEST_CHECK_STRINGIFY_EQUAL(next(next(d.begin()))->package, "virtual/two-1::virtuals");
+ TEST_CHECK_STRINGIFY_EQUAL(*next(next(d.begin()))->package_id, "virtual/two-1::virtuals (virtual for cat/two-1:0::repo)");
TEST_CHECK_EQUAL(next(next(next(d.begin())))->kind, dlk_package);
- TEST_CHECK_STRINGIFY_EQUAL(next(next(next(d.begin())))->package, "cat/one-1::repo");
+ TEST_CHECK_STRINGIFY_EQUAL(*next(next(next(d.begin())))->package_id, "cat/one-1:0::repo");
}
} test_dep_list_provided_block;
@@ -144,9 +145,9 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two cat/three");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two cat/three");
repo->add_version("cat", "two", "1");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("!cat/two");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("!cat/two");
}
void populate_expected()
@@ -171,9 +172,9 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend(">=cat/two-2 cat/three");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string(">=cat/two-2 cat/three");
repo->add_version("cat", "two", "2");
- repo->add_version("cat", "three", "1")->deps_interface->set_build_depend("!<cat/two-2");
+ repo->add_version("cat", "three", "1")->build_dependencies_key()->set_from_string("!<cat/two-2");
installed_repo->add_version("cat", "two", "1");
}
@@ -192,8 +193,8 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- repo->add_version("cat", "two", "1")->deps_interface->set_build_depend("!cat/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ repo->add_version("cat", "two", "1")->build_dependencies_key()->set_from_string("!cat/two");
installed_repo->add_version("cat", "two", "1");
}
@@ -211,20 +212,20 @@ namespace test_cases
void populate_repo()
{
- tr1::shared_ptr<VersionMetadata> one_m(repo->add_version("cat", "one", "1"));
- one_m->ebuild_interface->set_provide("virtual/one");
- one_m->deps_interface->set_build_depend("!virtual/one");
- one_m->deps_interface->set_run_depend("!virtual/one");
- tr1::shared_ptr<VersionMetadata> i_one_m(installed_repo->add_version("cat", "one", "1"));
- i_one_m->ebuild_interface->set_provide("virtual/one");
- i_one_m->deps_interface->set_run_depend("!virtual/one");
+ tr1::shared_ptr<FakePackageID> one_m(repo->add_version("cat", "one", "1"));
+ one_m->provide_key()->set_from_string("virtual/one");
+ one_m->build_dependencies_key()->set_from_string("!virtual/one");
+ one_m->run_dependencies_key()->set_from_string("!virtual/one");
+ tr1::shared_ptr<FakePackageID> i_one_m(installed_repo->add_version("cat", "one", "1"));
+ i_one_m->provide_key()->set_from_string("virtual/one");
+ i_one_m->run_dependencies_key()->set_from_string("!virtual/one");
}
void populate_expected()
{
merge_target = "virtual/one";
- expected.push_back("cat/one-1:0::installed");
- expected.push_back("virtual/one-1:0::virtuals");
+ expected.push_back("cat/one-1:0::repo");
+ expected.push_back("virtual/one-1::virtuals (virtual for cat/one-1:0::repo)");
}
} test_dep_list_no_block_on_no_upgrade_via_provided;
@@ -234,20 +235,20 @@ namespace test_cases
void populate_repo()
{
- tr1::shared_ptr<VersionMetadata> one_m(repo->add_version("cat", "one", "1"));
- one_m->ebuild_interface->set_provide("virtual/one");
- one_m->deps_interface->set_build_depend("!virtual/one");
- one_m->deps_interface->set_run_depend("!virtual/one");
- tr1::shared_ptr<VersionMetadata> i_one_m(installed_repo->add_version("cat", "one", "1"));
- i_one_m->ebuild_interface->set_provide("virtual/one");
- i_one_m->deps_interface->set_run_depend("!virtual/one");
+ tr1::shared_ptr<FakePackageID> one_m(repo->add_version("cat", "one", "1"));
+ one_m->provide_key()->set_from_string("virtual/one");
+ one_m->build_dependencies_key()->set_from_string("!virtual/one");
+ one_m->run_dependencies_key()->set_from_string("!virtual/one");
+ tr1::shared_ptr<FakePackageID> i_one_m(installed_repo->add_version("cat", "one", "1"));
+ i_one_m->provide_key()->set_from_string("virtual/one");
+ i_one_m->run_dependencies_key()->set_from_string("!virtual/one");
}
void populate_expected()
{
merge_target = "virtual/one";
expected.push_back("cat/one-1:0::repo");
- expected.push_back("virtual/one-1:0::virtuals");
+ expected.push_back("virtual/one-1::virtuals (virtual for cat/one-1:0::repo)");
}
virtual void set_options(DepListOptions & p)
@@ -262,18 +263,18 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- tr1::shared_ptr<VersionMetadata> two_m(repo->add_version("cat", "two", "2"));
- two_m->ebuild_interface->set_provide("virtual/two");
- two_m->deps_interface->set_build_depend("!virtual/two");
- installed_repo->add_version("cat", "two", "1")->ebuild_interface->set_provide("virtual/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ tr1::shared_ptr<FakePackageID> two_m(repo->add_version("cat", "two", "2"));
+ two_m->provide_key()->set_from_string("virtual/two");
+ two_m->build_dependencies_key()->set_from_string("!virtual/two");
+ installed_repo->add_version("cat", "two", "1")->provide_key()->set_from_string("virtual/two");
}
void populate_expected()
{
merge_target = "cat/one";
expected.push_back("cat/two-2:0::repo");
- expected.push_back("virtual/two-2:0::virtuals");
+ expected.push_back("virtual/two-2::virtuals (virtual for cat/two-2:0::repo)");
expected.push_back("cat/one-1:0::repo");
}
} test_dep_list_no_block_on_replaced_provide;
@@ -284,8 +285,8 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- repo->add_version("cat", "two", "2")->deps_interface->set_build_depend("!<cat/two-2");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ repo->add_version("cat", "two", "2")->build_dependencies_key()->set_from_string("!<cat/two-2");
installed_repo->add_version("cat", "two", "1");
}
@@ -311,11 +312,11 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- tr1::shared_ptr<VersionMetadata> two_m(repo->add_version("cat", "two", "2"));
- two_m->deps_interface->set_build_depend("!<virtual/two-2");
- two_m->ebuild_interface->set_provide("virtual/two");
- installed_repo->add_version("cat", "two", "1")->ebuild_interface->set_provide("virtual/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ tr1::shared_ptr<FakePackageID> two_m(repo->add_version("cat", "two", "2"));
+ two_m->build_dependencies_key()->set_from_string("!<virtual/two-2");
+ two_m->provide_key()->set_from_string("virtual/two");
+ installed_repo->add_version("cat", "two", "1")->provide_key()->set_from_string("virtual/two");
}
void populate_expected()
@@ -340,11 +341,11 @@ namespace test_cases
void populate_repo()
{
- repo->add_version("cat", "one", "1")->deps_interface->set_build_depend("cat/two");
- tr1::shared_ptr<VersionMetadata> two_m(repo->add_version("cat", "two", "2"));
- two_m->deps_interface->set_build_depend("!<virtual/two-2");
- two_m->ebuild_interface->set_provide("virtual/two");
- installed_repo->add_version("other", "two", "1")->ebuild_interface->set_provide("virtual/two");
+ repo->add_version("cat", "one", "1")->build_dependencies_key()->set_from_string("cat/two");
+ tr1::shared_ptr<FakePackageID> two_m(repo->add_version("cat", "two", "2"));
+ two_m->build_dependencies_key()->set_from_string("!<virtual/two-2");
+ two_m->provide_key()->set_from_string("virtual/two");
+ installed_repo->add_version("other", "two", "1")->provide_key()->set_from_string("virtual/two");
}
void populate_expected()
diff --git a/paludis/dep_list/exceptions.cc b/paludis/dep_list/exceptions.cc
index a3ba96f..2ccd3d4 100644
--- a/paludis/dep_list/exceptions.cc
+++ b/paludis/dep_list/exceptions.cc
@@ -79,7 +79,7 @@ namespace
}
}
-NoDestinationError::NoDestinationError(const PackageDatabaseEntry & p,
+NoDestinationError::NoDestinationError(const PackageID & p,
tr1::shared_ptr<const DestinationsCollection> d) throw () :
DepListError("No suitable destination for '" + stringify(p) + "' in (" +
destinations_to_string(d) + ")")
diff --git a/paludis/dep_list/exceptions.hh b/paludis/dep_list/exceptions.hh
index 0130ca3..406de07 100644
--- a/paludis/dep_list/exceptions.hh
+++ b/paludis/dep_list/exceptions.hh
@@ -180,7 +180,7 @@ namespace paludis
///\name Basic operations
///\{
- NoDestinationError(const PackageDatabaseEntry &,
+ NoDestinationError(const PackageID &,
tr1::shared_ptr<const DestinationsCollection>) throw ();
///\}
diff --git a/paludis/dep_list/query_visitor.cc b/paludis/dep_list/query_visitor.cc
index d63373e..8fc2095 100644
--- a/paludis/dep_list/query_visitor.cc
+++ b/paludis/dep_list/query_visitor.cc
@@ -21,6 +21,7 @@
#include <paludis/dep_list/dep_list.hh>
#include <paludis/dep_list/range_rewriter.hh>
#include <paludis/package_database.hh>
+#include <paludis/query.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -38,23 +39,23 @@ namespace paludis
const DepList * const dep_list;
tr1::shared_ptr<const DestinationsCollection> destinations;
const Environment * const environment;
- const PackageDatabaseEntry * const pde;
+ const tr1::shared_ptr<const PackageID> id;
Implementation(const DepList * const d, tr1::shared_ptr<const DestinationsCollection> dd,
- const Environment * const e, const PackageDatabaseEntry * const p) :
+ const Environment * const e, const tr1::shared_ptr<const PackageID> & p) :
result(true),
dep_list(d),
destinations(dd),
environment(e),
- pde(p)
+ id(p)
{
}
};
}
QueryVisitor::QueryVisitor(const DepList * const d, tr1::shared_ptr<const DestinationsCollection> dd,
- const Environment * const e, const PackageDatabaseEntry * const pde) :
- PrivateImplementationPattern<QueryVisitor>(new Implementation<QueryVisitor>(d, dd, e, pde))
+ const Environment * const e, const tr1::shared_ptr<const PackageID> & id) :
+ PrivateImplementationPattern<QueryVisitor>(new Implementation<QueryVisitor>(d, dd, e, id))
{
}
@@ -80,10 +81,10 @@ QueryVisitor::visit_leaf(const PackageDepSpec & a)
_imp->result = false;
// TODO: check destinations
- tr1::shared_ptr<const PackageDatabaseEntryCollection> matches(_imp->environment->package_database()->query(
- a, is_installed_only, qo_whatever));
+ tr1::shared_ptr<const PackageIDSequence> matches(_imp->environment->package_database()->query(
+ query::InstalledAtRoot(_imp->environment->root()) & query::Matches(a), qo_whatever));
- if (matches->end() != std::find_if(matches->begin(), matches->end(),
+ if (indirect_iterator(matches->end()) != std::find_if(indirect_iterator(matches->begin()), indirect_iterator(matches->end()),
tr1::bind(tr1::mem_fn(&DepList::replaced), _imp->dep_list, _1)))
{
_imp->result = true;
@@ -105,7 +106,7 @@ QueryVisitor::visit_sequence(const UseDepSpec & a,
{
/* for use? ( ) dep specs, return true if we're not enabled, so that
* weird || ( ) cases work. */
- if ((_imp->pde ? _imp->environment->query_use(a.flag(), *_imp->pde) : false) ^ a.inverse())
+ if ((_imp->id ? _imp->environment->query_use(a.flag(), *_imp->id) : false) ^ a.inverse())
{
_imp->result = true;
for ( ; cur != end ; ++cur)
@@ -135,7 +136,7 @@ QueryVisitor::visit_sequence(const AnyDepSpec &,
else
for ( ; cur != end ; ++cur)
{
- if (! is_viable_any_child(*_imp->environment, _imp->pde, *cur))
+ if (! is_viable_any_child(*_imp->environment, _imp->id, *cur))
continue;
cur->accept(*this);
@@ -164,4 +165,3 @@ QueryVisitor::visit_sequence(const AllDepSpec &,
}
}
-
diff --git a/paludis/dep_list/query_visitor.hh b/paludis/dep_list/query_visitor.hh
index 97fc07a..a2c74d7 100644
--- a/paludis/dep_list/query_visitor.hh
+++ b/paludis/dep_list/query_visitor.hh
@@ -26,8 +26,6 @@
namespace paludis
{
- class PackageDatabaseEntry;
-
/**
* Used by DepList to check for existing deps.
*
@@ -43,7 +41,7 @@ namespace paludis
///\{
QueryVisitor(const DepList * const, tr1::shared_ptr<const DestinationsCollection>,
- const Environment * const, const PackageDatabaseEntry * const);
+ const Environment * const, const tr1::shared_ptr<const PackageID> &);
~QueryVisitor();
diff --git a/paludis/dep_list/show_suggest_visitor.cc b/paludis/dep_list/show_suggest_visitor.cc
index 04a0014..b912405 100644
--- a/paludis/dep_list/show_suggest_visitor.cc
+++ b/paludis/dep_list/show_suggest_visitor.cc
@@ -21,6 +21,7 @@
#include <paludis/dep_list/dep_list.hh>
#include <paludis/dep_list/condition_tracker.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/query.hh>
#include <paludis/package_database.hh>
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
@@ -39,16 +40,16 @@ namespace paludis
DepList * const dep_list;
tr1::shared_ptr<const DestinationsCollection> destinations;
const Environment * const environment;
- const PackageDatabaseEntry * const pde;
+ const tr1::shared_ptr<const PackageID> id;
bool dependency_tags;
tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > conditions;
Implementation(DepList * const d, tr1::shared_ptr<const DestinationsCollection> dd,
- const Environment * const e, const PackageDatabaseEntry * const p, bool t) :
+ const Environment * const e, const tr1::shared_ptr<const PackageID> & p, bool t) :
dep_list(d),
destinations(dd),
environment(e),
- pde(p),
+ id(p),
dependency_tags(t),
conditions(tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >(
new ConstTreeSequence<DependencySpecTree, AllDepSpec>(
@@ -59,7 +60,7 @@ namespace paludis
}
ShowSuggestVisitor::ShowSuggestVisitor(DepList * const d, tr1::shared_ptr<const DestinationsCollection> dd,
- const Environment * const e, const PackageDatabaseEntry * const p, bool t) :
+ const Environment * const e, const tr1::shared_ptr<const PackageID> & p, bool t) :
PrivateImplementationPattern<ShowSuggestVisitor>(new Implementation<ShowSuggestVisitor>(d, dd, e, p, t))
{
}
@@ -77,7 +78,7 @@ ShowSuggestVisitor::visit_sequence(const UseDepSpec & a,
&_imp->conditions, _imp->dependency_tags ?
ConditionTracker(_imp->conditions).add_condition(a) : _imp->conditions);
- if ((_imp->pde ? _imp->environment->query_use(a.flag(), *_imp->pde) : false) ^ a.inverse())
+ if ((_imp->id ? _imp->environment->query_use(a.flag(), *_imp->id) : false) ^ a.inverse())
std::for_each(cur, end, accept_visitor(*this));
}
@@ -107,18 +108,18 @@ ShowSuggestVisitor::visit_leaf(const PackageDepSpec & a)
&_imp->conditions, _imp->dependency_tags ?
ConditionTracker(_imp->conditions).add_condition(a) : _imp->conditions);
- tr1::shared_ptr<const PackageDatabaseEntryCollection> matches(_imp->environment->package_database()->query(
- a, is_installable_only, qo_order_by_version));
+ tr1::shared_ptr<const PackageIDSequence> matches(_imp->environment->package_database()->query(
+ query::RepositoryHasInstallableInterface() & query::Matches(a), qo_order_by_version));
if (matches->empty())
{
Log::get_instance()->message(ll_warning, lc_context, "Nothing found for '" + stringify(a) + "'");
return;
}
- for (PackageDatabaseEntryCollection::Iterator m(matches->begin()), m_end(matches->end()) ;
+ for (PackageIDSequence::Iterator m(matches->begin()), m_end(matches->end()) ;
m != m_end ; ++m)
{
- if (_imp->environment->mask_reasons(*m).any())
+ if (_imp->environment->mask_reasons(**m).any())
continue;
_imp->dep_list->add_suggested_package(*m, a, _imp->conditions, _imp->destinations);
diff --git a/paludis/dep_list/show_suggest_visitor.hh b/paludis/dep_list/show_suggest_visitor.hh
index 84525f4..fbdfc92 100644
--- a/paludis/dep_list/show_suggest_visitor.hh
+++ b/paludis/dep_list/show_suggest_visitor.hh
@@ -43,7 +43,7 @@ namespace paludis
///\{
ShowSuggestVisitor(DepList * const dd, tr1::shared_ptr<const DestinationsCollection> ddd,
- const Environment * const, const PackageDatabaseEntry * const, bool);
+ const Environment * const, const tr1::shared_ptr<const PackageID> &, bool);
~ShowSuggestVisitor();
///\}
diff --git a/paludis/dep_list/uninstall_list.cc b/paludis/dep_list/uninstall_list.cc
index 3adfba6..d5e4661 100644
--- a/paludis/dep_list/uninstall_list.cc
+++ b/paludis/dep_list/uninstall_list.cc
@@ -32,44 +32,28 @@ using namespace paludis;
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/match_package.hh>
-#include <paludis/version_metadata.hh>
#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
+#include <paludis/query.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/dep_tag.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <list>
#include <algorithm>
+typedef MakeHashedMap<tr1::shared_ptr<const PackageID>, tr1::shared_ptr<const DepListEntryTags> >::Type DepCollectorCache;
+
namespace paludis
{
template<>
- class CRCHash<PackageDatabaseEntry> :
- public CRCHash<std::string>
- {
- public:
- /// Hash function.
- std::size_t operator() (const PackageDatabaseEntry & val) const
- {
- return CRCHash<std::string>::operator() (stringify(val));
- }
-
-#if (! defined(PALUDIS_HASH_IS_STD_TR1_UNORDERED)) && (! defined(PALUDIS_HASH_IS_GNU_CXX_HASH))
- bool operator() (const PackageDatabaseEntry & lhs,
- const PackageDatabaseEntry & rhs) const
- {
- return stringify(lhs) < stringify(rhs);
- }
-#endif
- };
-
- template<>
struct Implementation<UninstallList>
{
const Environment * const env;
UninstallListOptions options;
std::list<UninstallListEntry> uninstall_list;
- mutable MakeHashedMap<PackageDatabaseEntry, tr1::shared_ptr<const DepListEntryTags> >::Type
- dep_collector_cache;
+ mutable DepCollectorCache dep_collector_cache;
Implementation(const Environment * const e, const UninstallListOptions & o) :
env(e),
@@ -83,16 +67,16 @@ namespace
{
struct MatchUninstallListEntry
{
- PackageDatabaseEntry e;
+ const tr1::shared_ptr<const PackageID> e;
- MatchUninstallListEntry(const PackageDatabaseEntry & ee) :
+ MatchUninstallListEntry(const tr1::shared_ptr<const PackageID> & ee) :
e(ee)
{
}
- bool operator() (const UninstallListEntry & f)
+ bool operator() (const UninstallListEntry & f) const
{
- return f.package == e;
+ return *f.package_id == *e;
}
};
}
@@ -108,7 +92,7 @@ UninstallList::~UninstallList()
}
void
-UninstallList::add(const PackageDatabaseEntry & e, tr1::shared_ptr<DepTag> t)
+UninstallList::add(const tr1::shared_ptr<const PackageID> & e, tr1::shared_ptr<DepTag> t)
{
std::list<UninstallListEntry>::iterator i;
if (_imp->uninstall_list.end() != ((i = std::find_if(_imp->uninstall_list.begin(),
@@ -120,12 +104,12 @@ UninstallList::add(const PackageDatabaseEntry & e, tr1::shared_ptr<DepTag> t)
return;
}
- Context context("When adding '" + stringify(e) + "' to the uninstall list:");
+ Context context("When adding '" + stringify(*e) + "' to the uninstall list:");
add_package(e, t);
if (_imp->options.with_dependencies)
- add_dependencies(e);
+ add_dependencies(*e);
move_package_to_end(e);
@@ -138,12 +122,12 @@ UninstallList::add_unused()
{
Context context("When finding unused packages:");
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> world(collect_world()),
+ tr1::shared_ptr<const PackageIDSet> world(collect_world()),
everything(collect_all_installed());
- tr1::shared_ptr<ArbitrarilyOrderedPackageDatabaseEntryCollection>
- world_plus_deps(new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete),
- unused(new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSet>
+ world_plus_deps(new PackageIDSet::Concrete),
+ unused(new PackageIDSet::Concrete);
world_plus_deps->insert(world->begin(), world->end());
@@ -151,16 +135,15 @@ UninstallList::add_unused()
while (old_size != world_plus_deps->size())
{
old_size = world_plus_deps->size();
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> new_world_deps(collect_depped_upon(world_plus_deps));
+ tr1::shared_ptr<const PackageIDSet> new_world_deps(collect_depped_upon(world_plus_deps));
world_plus_deps->insert(new_world_deps->begin(), new_world_deps->end());
}
std::set_difference(everything->begin(), everything->end(),
world_plus_deps->begin(), world_plus_deps->end(), unused->inserter(),
- ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator());
+ PackageIDSetComparator());
- for (PackageDatabaseEntryCollection::Iterator i(unused->begin()),
- i_end(unused->end()) ; i != i_end ; ++i)
+ for (PackageIDSet::Iterator i(unused->begin()), i_end(unused->end()) ; i != i_end ; ++i)
add_package(*i, tr1::shared_ptr<DepTag>());
}
@@ -183,25 +166,22 @@ UninstallListOptions::UninstallListOptions() :
}
void
-UninstallList::add_package(const PackageDatabaseEntry & e, tr1::shared_ptr<DepTag> t)
+UninstallList::add_package(const tr1::shared_ptr<const PackageID> & e, tr1::shared_ptr<DepTag> t)
{
- Context context("When adding package '" + stringify(e) + "' to the uninstall list:");
-
- tr1::shared_ptr<const VersionMetadata> m(_imp->env->package_database()->fetch_repository(
- e.repository)->version_metadata(e.name, e.version));
+ Context context("When adding package '" + stringify(*e) + "' to the uninstall list:");
std::list<UninstallListEntry>::iterator i(_imp->uninstall_list.insert(
_imp->uninstall_list.end(), UninstallListEntry(
- e, m->virtual_interface, tr1::shared_ptr<SortedCollection<tr1::shared_ptr<DepTag> > >(
+ e, e->virtual_for_key(), tr1::shared_ptr<SortedCollection<tr1::shared_ptr<DepTag> > >(
new SortedCollection<tr1::shared_ptr<DepTag> >::Concrete))));
if (t)
i->tags->insert(t);
}
void
-UninstallList::move_package_to_end(const PackageDatabaseEntry & e)
+UninstallList::move_package_to_end(const tr1::shared_ptr<const PackageID> & e)
{
- Context context("When removing package '" + stringify(e) + "' from the uninstall list:");
+ Context context("When removing package '" + stringify(*e) + "' from the uninstall list:");
std::list<UninstallListEntry>::iterator i(std::find_if(_imp->uninstall_list.begin(),
_imp->uninstall_list.end(), MatchUninstallListEntry(e)));
@@ -209,13 +189,12 @@ UninstallList::move_package_to_end(const PackageDatabaseEntry & e)
_imp->uninstall_list.splice(_imp->uninstall_list.end(), _imp->uninstall_list, i);
}
-tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection>
+tr1::shared_ptr<const PackageIDSet>
UninstallList::collect_all_installed() const
{
Context context("When collecting all installed packages:");
- tr1::shared_ptr<ArbitrarilyOrderedPackageDatabaseEntryCollection> result(
- new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSet> result(new PackageIDSet::Concrete);
for (PackageDatabase::RepositoryIterator i(_imp->env->package_database()->begin_repositories()),
i_end(_imp->env->package_database()->end_repositories()) ; i != i_end ; ++i)
{
@@ -230,10 +209,8 @@ UninstallList::collect_all_installed() const
for (QualifiedPackageNameCollection::Iterator p(pkgs->begin()), p_end(pkgs->end()) ;
p != p_end ; ++p)
{
- tr1::shared_ptr<const VersionSpecCollection> vers((*i)->version_specs(*p));
- for (VersionSpecCollection::Iterator v(vers->begin()), v_end(vers->end()) ;
- v != v_end ; ++v)
- result->insert(PackageDatabaseEntry(*p, *v, (*i)->name()));
+ tr1::shared_ptr<const PackageIDSequence> ids((*i)->package_ids(*p));
+ std::copy(ids->begin(), ids->end(), result->inserter());
}
}
}
@@ -251,12 +228,12 @@ namespace
using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepCollector, AllDepSpec>::visit_sequence;
const Environment * const env;
- const PackageDatabaseEntry pkg;
+ const tr1::shared_ptr<const PackageID> pkg;
tr1::shared_ptr<DepListEntryTags> matches;
tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > conditions;
- DepCollector(const Environment * const ee, const PackageDatabaseEntry & e) :
+ DepCollector(const Environment * const ee, const tr1::shared_ptr<const PackageID> & e) :
env(ee),
pkg(e),
matches(new DepListEntryTags::Concrete),
@@ -271,9 +248,9 @@ namespace
Save<tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c(
&conditions, ConditionTracker(conditions).add_condition(a));
- tr1::shared_ptr<const PackageDatabaseEntryCollection> m(env->package_database()->query(
- a, is_installed_only, qo_order_by_version));
- for (PackageDatabaseEntryCollection::Iterator it = m->begin(), it_end = m->end();
+ tr1::shared_ptr<const PackageIDSequence> m(env->package_database()->query(
+ query::Matches(a) & query::InstalledAtRoot(env->root()), qo_order_by_version));
+ for (PackageIDSequence::Iterator it = m->begin(), it_end = m->end();
it_end != it; ++it)
matches->insert(DepTagEntry(tr1::shared_ptr<const DepTag>(new DependencyDepTag(*it, a, conditions)), 0));
}
@@ -295,7 +272,7 @@ namespace
Save<tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > > save_c(
&conditions, ConditionTracker(conditions).add_condition(u));
- if (env->query_use(UseFlagName(u.flag()), pkg) ^ u.inverse())
+ if (env->query_use(UseFlagName(u.flag()), *pkg) ^ u.inverse())
std::for_each(cur, end, accept_visitor(*this));
}
@@ -305,41 +282,39 @@ namespace
};
}
-tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection>
-UninstallList::collect_depped_upon(tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> targets) const
+tr1::shared_ptr<const PackageIDSet>
+UninstallList::collect_depped_upon(tr1::shared_ptr<const PackageIDSet> targets) const
{
Context context("When collecting depended upon packages:");
- tr1::shared_ptr<ArbitrarilyOrderedPackageDatabaseEntryCollection> result(
- new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSet> result(new PackageIDSet::Concrete);
- for (PackageDatabaseEntryCollection::Iterator i(targets->begin()), i_end(targets->end()) ;
+ for (PackageIDSet::Iterator i(targets->begin()), i_end(targets->end()) ;
i != i_end ; ++i)
{
- Context local_context("When collecting depended upon packages for '" + stringify(*i) + "':");
+ Context local_context("When collecting depended upon packages for '" + stringify(**i) + "':");
- MakeHashedMap<PackageDatabaseEntry, tr1::shared_ptr<const DepListEntryTags> >::Type::const_iterator
- cache(_imp->dep_collector_cache.find(*i));
+ DepCollectorCache::const_iterator cache(_imp->dep_collector_cache.find(*i));
if (cache == _imp->dep_collector_cache.end())
{
DepCollector c(_imp->env, *i);
- tr1::shared_ptr<const VersionMetadata> metadata(_imp->env->package_database()->fetch_repository(
- i->repository)->version_metadata(i->name, i->version));
- if (metadata->deps_interface)
- {
- metadata->deps_interface->build_depend()->accept(c);
- metadata->deps_interface->run_depend()->accept(c);
- metadata->deps_interface->post_depend()->accept(c);
- metadata->deps_interface->suggested_depend()->accept(c);
- }
+ if ((*i)->build_dependencies_key())
+ (*i)->build_dependencies_key()->value()->accept(c);
+ if ((*i)->run_dependencies_key())
+ (*i)->run_dependencies_key()->value()->accept(c);
+ if ((*i)->post_dependencies_key())
+ (*i)->post_dependencies_key()->value()->accept(c);
+ if ((*i)->suggested_dependencies_key())
+ (*i)->suggested_dependencies_key()->value()->accept(c);
+
cache = _imp->dep_collector_cache.insert(std::make_pair(*i,
tr1::shared_ptr<const DepListEntryTags>(c.matches))).first;
}
for (DepListEntryTags::Iterator it(cache->second->begin()), it_end(cache->second->end());
it_end != it; ++it)
- result->insert(tr1::static_pointer_cast<const DependencyDepTag>(it->tag)->package());
+ result->insert(tr1::static_pointer_cast<const DependencyDepTag>(it->tag)->package_id());
}
return result;
@@ -351,49 +326,46 @@ UninstallList::add_unused_dependencies()
Context context("When adding unused dependencies:");
bool added(true);
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> everything(collect_all_installed());
+ tr1::shared_ptr<const PackageIDSet> everything(collect_all_installed());
while (added)
{
added = false;
/* find packages that're depped upon by anything in our uninstall list */
- tr1::shared_ptr<ArbitrarilyOrderedPackageDatabaseEntryCollection> uninstall_list_targets(
- new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSet> uninstall_list_targets(new PackageIDSet::Concrete);
for (std::list<UninstallListEntry>::const_iterator i(_imp->uninstall_list.begin()),
i_end(_imp->uninstall_list.end()) ; i != i_end ; ++i)
- uninstall_list_targets->insert(i->package);
+ uninstall_list_targets->insert(i->package_id);
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> depped_upon_list(
- collect_depped_upon(uninstall_list_targets));
+ tr1::shared_ptr<const PackageIDSet> depped_upon_list(collect_depped_upon(uninstall_list_targets));
/* find packages that're depped upon by anything not in our uninstall list */
- tr1::shared_ptr<ArbitrarilyOrderedPackageDatabaseEntryCollection> everything_except_uninstall_list_targets(
- new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSet> everything_except_uninstall_list_targets(
+ new PackageIDSet::Concrete);
std::set_difference(everything->begin(), everything->end(),
uninstall_list_targets->begin(), uninstall_list_targets->end(),
everything_except_uninstall_list_targets->inserter(),
- ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator());
+ PackageIDSetComparator());
Log::get_instance()->message(ll_debug, lc_context, "everything_except_uninstall_list_targets is '"
- + join(everything_except_uninstall_list_targets->begin(),
- everything_except_uninstall_list_targets->end(), " ") + "'");
+ + join(indirect_iterator(everything_except_uninstall_list_targets->begin()),
+ indirect_iterator(everything_except_uninstall_list_targets->end()), " ") + "'");
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> depped_upon_not_list(
+ tr1::shared_ptr<const PackageIDSet> depped_upon_not_list(
collect_depped_upon(everything_except_uninstall_list_targets));
/* find unused dependencies */
- tr1::shared_ptr<ArbitrarilyOrderedPackageDatabaseEntryCollection> unused_dependencies(
- new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSet> unused_dependencies(new PackageIDSet::Concrete);
std::set_difference(depped_upon_list->begin(), depped_upon_list->end(),
depped_upon_not_list->begin(), depped_upon_not_list->end(), unused_dependencies->inserter(),
- ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator());
+ PackageIDSetComparator());
/* if any of them aren't already on the list, and aren't in world, add them and recurse */
tr1::shared_ptr<SetSpecTree::ConstItem> world(_imp->env->set(SetName("world")));
- for (PackageDatabaseEntryCollection::Iterator i(unused_dependencies->begin()),
+ for (PackageIDSet::Iterator i(unused_dependencies->begin()),
i_end(unused_dependencies->end()) ; i != i_end ; ++i)
{
- if (match_package_in_set(*_imp->env, *world, *i))
+ if (match_package_in_set(*_imp->env, *world, **i))
continue;
if (_imp->uninstall_list.end() != std::find_if(_imp->uninstall_list.begin(),
@@ -407,31 +379,29 @@ UninstallList::add_unused_dependencies()
}
void
-UninstallList::add_dependencies(const PackageDatabaseEntry & e)
+UninstallList::add_dependencies(const PackageID & e)
{
Context context("When adding things that depend upon '" + stringify(e) + "':");
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> everything(collect_all_installed());
- for (PackageDatabaseEntryCollection::Iterator i(everything->begin()),
+ tr1::shared_ptr<const PackageIDSet> everything(collect_all_installed());
+ for (PackageIDSet::Iterator i(everything->begin()),
i_end(everything->end()) ; i != i_end ; ++i)
{
- Context local_context("When seeing whether '" + stringify(*i) + "' has a dep:");
+ Context local_context("When seeing whether '" + stringify(**i) + "' has a dep:");
- MakeHashedMap<PackageDatabaseEntry, tr1::shared_ptr<const DepListEntryTags> >::Type::const_iterator
- cache(_imp->dep_collector_cache.find(*i));
+ DepCollectorCache::const_iterator cache(_imp->dep_collector_cache.find(*i));
if (cache == _imp->dep_collector_cache.end())
{
DepCollector c(_imp->env, *i);
- tr1::shared_ptr<const VersionMetadata> metadata(_imp->env->package_database()->fetch_repository(
- i->repository)->version_metadata(i->name, i->version));
- if (metadata->deps_interface)
- {
- metadata->deps_interface->build_depend()->accept(c);
- metadata->deps_interface->run_depend()->accept(c);
- metadata->deps_interface->post_depend()->accept(c);
- metadata->deps_interface->suggested_depend()->accept(c);
- }
+ if ((*i)->build_dependencies_key())
+ (*i)->build_dependencies_key()->value()->accept(c);
+ if ((*i)->run_dependencies_key())
+ (*i)->run_dependencies_key()->value()->accept(c);
+ if ((*i)->post_dependencies_key())
+ (*i)->post_dependencies_key()->value()->accept(c);
+ if ((*i)->suggested_dependencies_key())
+ (*i)->suggested_dependencies_key()->value()->accept(c);
cache = _imp->dep_collector_cache.insert(std::make_pair(*i,
tr1::shared_ptr<const DepListEntryTags>(c.matches))).first;
}
@@ -441,35 +411,34 @@ UninstallList::add_dependencies(const PackageDatabaseEntry & e)
it_end != it; ++it)
{
tr1::shared_ptr<const DependencyDepTag> tag(tr1::static_pointer_cast<const DependencyDepTag>(it->tag));
- if (tag->package() == e)
+ if (*tag->package_id() == e)
{
if (! logged)
{
- Log::get_instance()->message(ll_debug, lc_context, "Adding '" + stringify(*i) +
- "' because it depends upon '" + stringify(e) + "'");
+ Log::get_instance()->message(ll_debug, lc_context) << "Adding '" << **i <<
+ "' because it depends upon '" << e << "'";
logged = true;
}
add(*i, tr1::shared_ptr<DependencyDepTag>(
- new DependencyDepTag(tag->package(), *tag->dependency(), tag->conditions())));
+ new DependencyDepTag(tag->package_id(), *tag->dependency(), tag->conditions())));
}
}
}
}
-tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection>
+tr1::shared_ptr<const PackageIDSet>
UninstallList::collect_world() const
{
Context local_context("When collecting world packages:");
- tr1::shared_ptr<ArbitrarilyOrderedPackageDatabaseEntryCollection> result(
- new ArbitrarilyOrderedPackageDatabaseEntryCollection::Concrete);
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> everything(collect_all_installed());
+ tr1::shared_ptr<PackageIDSet> result(new PackageIDSet::Concrete);
+ tr1::shared_ptr<const PackageIDSet> everything(collect_all_installed());
tr1::shared_ptr<SetSpecTree::ConstItem> world(_imp->env->set(SetName("world")));
- for (PackageDatabaseEntryCollection::Iterator i(everything->begin()),
+ for (PackageIDSet::Iterator i(everything->begin()),
i_end(everything->end()) ; i != i_end ; ++i)
- if (match_package_in_set(*_imp->env, *world, *i))
+ if (match_package_in_set(*_imp->env, *world, **i))
result->insert(*i);
return result;
diff --git a/paludis/dep_list/uninstall_list.hh b/paludis/dep_list/uninstall_list.hh
index 49b6296..8012b6e 100644
--- a/paludis/dep_list/uninstall_list.hh
+++ b/paludis/dep_list/uninstall_list.hh
@@ -23,8 +23,8 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/sr.hh>
-#include <paludis/package_database_entry.hh>
-#include <paludis/dep_tag.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/dep_tag-fwd.hh>
#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh>
@@ -45,17 +45,17 @@ namespace paludis
public InstantiationPolicy<UninstallList, instantiation_method::NonCopyableTag>
{
private:
- void add_package(const PackageDatabaseEntry &, tr1::shared_ptr<DepTag>);
- void move_package_to_end(const PackageDatabaseEntry &);
+ void add_package(const tr1::shared_ptr<const PackageID> &, tr1::shared_ptr<DepTag>);
+ void move_package_to_end(const tr1::shared_ptr<const PackageID> &);
void add_unused_dependencies();
- void add_dependencies(const PackageDatabaseEntry &);
+ void add_dependencies(const PackageID &);
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> collect_depped_upon(
- const tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> targets) const;
+ tr1::shared_ptr<const PackageIDSet> collect_depped_upon(
+ const tr1::shared_ptr<const PackageIDSet> targets) const;
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> collect_all_installed() const;
+ tr1::shared_ptr<const PackageIDSet> collect_all_installed() const;
- tr1::shared_ptr<const ArbitrarilyOrderedPackageDatabaseEntryCollection> collect_world() const;
+ tr1::shared_ptr<const PackageIDSet> collect_world() const;
public:
///\name Basic operations
@@ -74,7 +74,8 @@ namespace paludis
/**
* Add a package, optionally with a reason.
*/
- void add(const PackageDatabaseEntry &, tr1::shared_ptr<DepTag> = tr1::shared_ptr<DepTag>());
+ void add(const tr1::shared_ptr<const PackageID> &,
+ tr1::shared_ptr<DepTag> = tr1::shared_ptr<DepTag>());
/**
* Add any unused packages that are dependencies of packages to uninstall.
diff --git a/paludis/dep_list/uninstall_list.sr b/paludis/dep_list/uninstall_list.sr
index 321d58f..5a91b0c 100644
--- a/paludis/dep_list/uninstall_list.sr
+++ b/paludis/dep_list/uninstall_list.sr
@@ -29,7 +29,7 @@ make_class_UninstallListEntry()
{
visible
- key package PackageDatabaseEntry
+ key package_id "tr1::shared_ptr<const PackageID>"
key skip_uninstall bool
key tags "tr1::shared_ptr<SortedCollection<tr1::shared_ptr<DepTag> > >"
diff --git a/paludis/dep_list/uninstall_list_TEST.cc b/paludis/dep_list/uninstall_list_TEST.cc
index afaa93d..1eab951 100644
--- a/paludis/dep_list/uninstall_list_TEST.cc
+++ b/paludis/dep_list/uninstall_list_TEST.cc
@@ -20,6 +20,7 @@
#include <paludis/dep_list/uninstall_list.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/repositories/virtuals/virtuals_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/portage_dep_parser.hh>
@@ -42,7 +43,7 @@ namespace paludis
std::ostream &
operator<< (std::ostream & s, const UninstallListEntry & e)
{
- s << e.package;
+ s << *e.package_id;
return s;
}
}
@@ -60,7 +61,7 @@ namespace test_cases
TestEnvironment env;
tr1::shared_ptr<FakeInstalledRepository> installed_repo;
tr1::shared_ptr<VirtualsRepository> virtuals_repo;
- tr1::shared_ptr<PackageDatabaseEntryCollection> targets;
+ tr1::shared_ptr<PackageIDSequence> targets;
std::list<std::string> expected;
bool done_populate;
@@ -72,7 +73,7 @@ namespace test_cases
env(),
installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed"))),
virtuals_repo(new VirtualsRepository(&env)),
- targets(new PackageDatabaseEntryCollection::Concrete),
+ targets(new PackageIDSequence::Concrete),
done_populate(false)
{
env.package_database()->add_repository(2, installed_repo);
@@ -91,7 +92,8 @@ namespace test_cases
void add_target(const std::string & p, const std::string & v)
{
- targets->push_back(PackageDatabaseEntry(
+ targets->push_back(
+ env.fetch_package_id(
QualifiedPackageName(p),
VersionSpec(v),
RepositoryName("installed")));
@@ -109,7 +111,7 @@ namespace test_cases
{
TEST_CHECK(true);
UninstallList d(&env, options());
- for (PackageDatabaseEntryCollection::Iterator i(targets->begin()),
+ for (PackageIDSequence::Iterator i(targets->begin()),
i_end(targets->end()) ; i != i_end ; ++i)
d.add(*i);
TEST_CHECK(true);
@@ -166,7 +168,7 @@ namespace test_cases
void populate_expected()
{
- expected.push_back("foo/bar-1::installed");
+ expected.push_back("foo/bar-1:0::installed");
}
} uninstall_list_simple_test;
@@ -188,7 +190,7 @@ namespace test_cases
void populate_expected()
{
- expected.push_back("foo/bar-1::installed");
+ expected.push_back("foo/bar-1:0::installed");
}
} uninstall_list_repeat_test;
@@ -204,14 +206,14 @@ namespace test_cases
void populate_repo()
{
- installed_repo->add_version("foo", "bar", "1")->deps_interface->set_build_depend("foo/baz");
+ installed_repo->add_version("foo", "bar", "1")->build_dependencies_key()->set_from_string("foo/baz");
installed_repo->add_version("foo", "baz", "2");
}
void populate_expected()
{
- expected.push_back("foo/bar-1::installed");
- expected.push_back("foo/baz-2::installed");
+ expected.push_back("foo/bar-1:0::installed");
+ expected.push_back("foo/baz-2:0::installed");
}
UninstallListOptions options()
@@ -234,16 +236,16 @@ namespace test_cases
void populate_repo()
{
- installed_repo->add_version("foo", "bar", "1")->deps_interface->set_build_depend("foo/baz");
- installed_repo->add_version("foo", "baz", "2")->deps_interface->set_build_depend("foo/moo");
+ installed_repo->add_version("foo", "bar", "1")->build_dependencies_key()->set_from_string("foo/baz");
+ installed_repo->add_version("foo", "baz", "2")->build_dependencies_key()->set_from_string("foo/moo");
installed_repo->add_version("foo", "moo", "3");
}
void populate_expected()
{
- expected.push_back("foo/bar-1::installed");
- expected.push_back("foo/baz-2::installed");
- expected.push_back("foo/moo-3::installed");
+ expected.push_back("foo/bar-1:0::installed");
+ expected.push_back("foo/baz-2:0::installed");
+ expected.push_back("foo/moo-3:0::installed");
}
UninstallListOptions options()
@@ -266,16 +268,16 @@ namespace test_cases
void populate_repo()
{
- installed_repo->add_version("foo", "bar", "1")->deps_interface->set_build_depend("foo/baz foo/oink");
+ installed_repo->add_version("foo", "bar", "1")->build_dependencies_key()->set_from_string("foo/baz foo/oink");
installed_repo->add_version("foo", "baz", "2");
- installed_repo->add_version("foo", "moo", "3")->deps_interface->set_build_depend("foo/oink");
+ installed_repo->add_version("foo", "moo", "3")->build_dependencies_key()->set_from_string("foo/oink");
installed_repo->add_version("foo", "oink", "1");
}
void populate_expected()
{
- expected.push_back("foo/bar-1::installed");
- expected.push_back("foo/baz-2::installed");
+ expected.push_back("foo/bar-1:0::installed");
+ expected.push_back("foo/baz-2:0::installed");
}
UninstallListOptions options()
@@ -300,18 +302,18 @@ namespace test_cases
void populate_repo()
{
- installed_repo->add_version("foo", "bar", "1")->deps_interface->set_build_depend("foo/baz foo/oink");
+ installed_repo->add_version("foo", "bar", "1")->build_dependencies_key()->set_from_string("foo/baz foo/oink");
installed_repo->add_version("foo", "baz", "2");
- installed_repo->add_version("foo", "moo", "3")->deps_interface->set_build_depend("foo/oink");
+ installed_repo->add_version("foo", "moo", "3")->build_dependencies_key()->set_from_string("foo/oink");
installed_repo->add_version("foo", "oink", "1");
}
void populate_expected()
{
- expected.push_back("foo/moo-3::installed");
- expected.push_back("foo/bar-1::installed");
- expected.push_back("foo/oink-1::installed");
- expected.push_back("foo/baz-2::installed");
+ expected.push_back("foo/moo-3:0::installed");
+ expected.push_back("foo/bar-1:0::installed");
+ expected.push_back("foo/baz-2:0::installed");
+ expected.push_back("foo/oink-1:0::installed");
}
UninstallListOptions options()
@@ -342,15 +344,15 @@ namespace test_cases
void populate_repo()
{
- installed_repo->add_version("foo", "bar", "1")->deps_interface->set_build_depend("foo/baz foo/moo");
+ installed_repo->add_version("foo", "bar", "1")->build_dependencies_key()->set_from_string("foo/baz foo/moo");
installed_repo->add_version("foo", "baz", "2");
installed_repo->add_version("foo", "moo", "2");
}
void populate_expected()
{
- expected.push_back("foo/bar-1::installed");
- expected.push_back("foo/baz-2::installed");
+ expected.push_back("foo/bar-1:0::installed");
+ expected.push_back("foo/baz-2:0::installed");
}
UninstallListOptions options()
@@ -383,15 +385,15 @@ namespace test_cases
void populate_repo()
{
- installed_repo->add_version("foo", "bar", "1")->deps_interface->set_build_depend("foo/baz foo/moo");
+ installed_repo->add_version("foo", "bar", "1")->build_dependencies_key()->set_from_string("foo/baz foo/moo");
installed_repo->add_version("foo", "baz", "2");
installed_repo->add_version("foo", "moo", "2");
}
void populate_expected()
{
- expected.push_back("foo/bar-1::installed");
- expected.push_back("foo/baz-2::installed");
+ expected.push_back("foo/bar-1:0::installed");
+ expected.push_back("foo/baz-2:0::installed");
}
UninstallListOptions options()
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index ef9338a..0839cec 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -270,7 +270,7 @@ namespace test_cases
tr1::shared_ptr<PackageDepSpec> c(tr1::static_pointer_cast<PackageDepSpec>(a.clone()));
TEST_CHECK_STRINGIFY_EQUAL(a, *c);
- c->version_requirements_ptr()->append(VersionRequirement(vo_tilde, VersionSpec("1.5")));
+ c->version_requirements_ptr()->push_back(VersionRequirement(vo_tilde, VersionSpec("1.5")));
TEST_CHECK(stringify(a) != stringify(*c));
BlockDepSpec d(c);
diff --git a/paludis/dep_spec_flattener.cc b/paludis/dep_spec_flattener.cc
index 78dd5b4..20fe76d 100644
--- a/paludis/dep_spec_flattener.cc
+++ b/paludis/dep_spec_flattener.cc
@@ -19,6 +19,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/dep_spec_flattener.hh>
+#include <paludis/environment.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -45,12 +46,12 @@ namespace paludis
{
const Environment * const env;
- const PackageDatabaseEntry * const pkg;
+ const tr1::shared_ptr<const PackageID> pkg;
mutable std::list<tr1::shared_ptr<const StringDepSpec > > specs;
Implementation(const Environment * const e,
- const PackageDatabaseEntry * const p) :
+ const tr1::shared_ptr<const PackageID> p) :
env(e),
pkg(p)
{
@@ -60,7 +61,7 @@ namespace paludis
DepSpecFlattener::DepSpecFlattener(
const Environment * const env,
- const PackageDatabaseEntry * const pkg) :
+ const tr1::shared_ptr<const PackageID> & pkg) :
PrivateImplementationPattern<DepSpecFlattener>(new Implementation<DepSpecFlattener>(
env, pkg))
{
diff --git a/paludis/dep_spec_flattener.hh b/paludis/dep_spec_flattener.hh
index ac925d9..c103c64 100644
--- a/paludis/dep_spec_flattener.hh
+++ b/paludis/dep_spec_flattener.hh
@@ -20,9 +20,9 @@
#ifndef PALUDIS_GUARD_PALUDIS_DEP_ATOM_FLATTENER_HH
#define PALUDIS_GUARD_PALUDIS_DEP_ATOM_FLATTENER_HH 1
-#include <paludis/dep_spec.hh>
-#include <paludis/package_database.hh>
-#include <paludis/environment.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/instantiation_policy.hh>
@@ -76,7 +76,7 @@ namespace paludis
///\{
DepSpecFlattener(const Environment * const,
- const PackageDatabaseEntry * const);
+ const tr1::shared_ptr<const PackageID> &);
~DepSpecFlattener();
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index 0269f6b..eea1d1d 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -22,6 +22,7 @@
#include <paludis/dep_spec_pretty_printer.hh>
#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -200,6 +201,10 @@ GLSADepTag::GLSADepTag(const std::string & id, const std::string & our_glsa_titl
{
}
+GLSADepTag::~GLSADepTag()
+{
+}
+
std::string
GLSADepTag::short_text() const
{
@@ -218,16 +223,35 @@ GLSADepTag::glsa_title() const
return _glsa_title;
}
+namespace paludis
+{
+ template <>
+ struct Implementation<GeneralSetDepTag>
+ {
+ const SetName id;
+ const std::string source;
+
+ Implementation(const SetName & n, const std::string s) :
+ id(n),
+ source(s)
+ {
+ }
+ };
+}
+
GeneralSetDepTag::GeneralSetDepTag(const SetName & id, const std::string & r) :
- _id(id),
- _source(r)
+ PrivateImplementationPattern<GeneralSetDepTag>(new Implementation<GeneralSetDepTag>(id, r))
+{
+}
+
+GeneralSetDepTag::~GeneralSetDepTag()
{
}
std::string
GeneralSetDepTag::short_text() const
{
- return stringify(_id);
+ return stringify(_imp->id);
}
std::string
@@ -239,39 +263,61 @@ GeneralSetDepTag::category() const
std::string
GeneralSetDepTag::source() const
{
- return _source;
+ return _imp->source;
}
-DependencyDepTag::DependencyDepTag(const PackageDatabaseEntry & pde, const PackageDepSpec & spec,
- tr1::shared_ptr<DependencySpecTree::ConstItem> cond) :
- _dbe(pde),
- _cond(cond)
+namespace paludis
+{
+ template <>
+ struct Implementation<DependencyDepTag>
+ {
+ mutable std::string str;
+
+ tr1::shared_ptr<const PackageID> id;
+ const tr1::shared_ptr<PackageDepSpec> spec;
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> cond;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i,
+ const PackageDepSpec & d, const tr1::shared_ptr<const DependencySpecTree::ConstItem> & s) :
+ id(i),
+ spec(tr1::static_pointer_cast<PackageDepSpec>(d.clone())),
+ cond(s)
+ {
+ spec->set_tag(tr1::shared_ptr<const DepTag>());
+ }
+ };
+}
+
+DependencyDepTag::DependencyDepTag(const tr1::shared_ptr<const PackageID> & i, const PackageDepSpec & d,
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> & s) :
+ PrivateImplementationPattern<DependencyDepTag>(new Implementation<DependencyDepTag>(i, d, s))
+{
+}
+
+DependencyDepTag::~DependencyDepTag()
{
- tr1::shared_ptr<PackageDepSpec> cloned_spec(tr1::static_pointer_cast<PackageDepSpec>(spec.clone()));
- cloned_spec->set_tag(tr1::shared_ptr<const DepTag>());
- _spec = cloned_spec;
}
std::string
DependencyDepTag::full_text() const
{
- if (_str.empty())
+ if (_imp->str.empty())
{
- _str.append(stringify(_dbe));
- _str.append(",");
- _str.append(stringify(*_spec));
- _str.append(",");
+ _imp->str.append(stringify(*_imp->id));
+ _imp->str.append(",");
+ _imp->str.append(stringify(*_imp->spec));
+ _imp->str.append(",");
DepSpecPrettyPrinter pretty(0, false);
- _cond->accept(pretty);
- _str.append(stringify(pretty));
+ _imp->cond->accept(pretty);
+ _imp->str.append(stringify(pretty));
}
- return _str;
+ return _imp->str;
}
std::string
DependencyDepTag::short_text() const
{
- return stringify(_dbe);
+ return stringify(*_imp->id);
}
std::string
@@ -280,28 +326,32 @@ DependencyDepTag::category() const
return "dependency";
}
-PackageDatabaseEntry
-DependencyDepTag::package() const
+const tr1::shared_ptr<const PackageID>
+DependencyDepTag::package_id() const
{
- return _dbe;
+ return _imp->id;
}
-tr1::shared_ptr<const PackageDepSpec>
+const tr1::shared_ptr<const PackageDepSpec>
DependencyDepTag::dependency() const
{
- return _spec;
+ return _imp->spec;
}
-tr1::shared_ptr<DependencySpecTree::ConstItem>
+const tr1::shared_ptr<const DependencySpecTree::ConstItem>
DependencyDepTag::conditions() const
{
- return _cond;
+ return _imp->cond;
}
TargetDepTag::TargetDepTag()
{
}
+TargetDepTag::~TargetDepTag()
+{
+}
+
std::string
TargetDepTag::short_text() const
{
diff --git a/paludis/dep_tag.hh b/paludis/dep_tag.hh
index 097df71..d05dca3 100644
--- a/paludis/dep_tag.hh
+++ b/paludis/dep_tag.hh
@@ -27,8 +27,9 @@
*/
#include <paludis/dep_tag-fwd.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/visitor.hh>
#include <paludis/util/virtual_constructor.hh>
@@ -234,6 +235,7 @@ namespace paludis
///\{
GLSADepTag(const std::string & id, const std::string & glsa_title);
+ ~GLSADepTag();
///\}
@@ -256,17 +258,15 @@ namespace paludis
*/
class PALUDIS_VISIBLE GeneralSetDepTag :
public DepTag,
- public ConstAcceptInterfaceVisitsThis<DepTagVisitorTypes, GeneralSetDepTag>
+ public ConstAcceptInterfaceVisitsThis<DepTagVisitorTypes, GeneralSetDepTag>,
+ private PrivateImplementationPattern<GeneralSetDepTag>
{
- private:
- const SetName _id;
- const std::string _source;
-
public:
///\name Basic operations
///\{
GeneralSetDepTag(const SetName & id, const std::string & source);
+ ~GeneralSetDepTag();
///\}
@@ -288,14 +288,10 @@ namespace paludis
*/
class PALUDIS_VISIBLE DependencyDepTag :
public DepTag,
- public ConstAcceptInterfaceVisitsThis<DepTagVisitorTypes, DependencyDepTag>
+ public ConstAcceptInterfaceVisitsThis<DepTagVisitorTypes, DependencyDepTag>,
+ private PrivateImplementationPattern<DependencyDepTag>
{
private:
- const PackageDatabaseEntry _dbe;
- tr1::shared_ptr<const PackageDepSpec> _spec;
- tr1::shared_ptr<DependencySpecTree::ConstItem> _cond;
- mutable std::string _str;
-
void _make_str() const;
protected:
@@ -306,7 +302,10 @@ namespace paludis
///\name Basic operations
///\{
- DependencyDepTag(const PackageDatabaseEntry & dbe, const PackageDepSpec & spec, tr1::shared_ptr<DependencySpecTree::ConstItem>);
+ DependencyDepTag(const tr1::shared_ptr<const PackageID> &, const PackageDepSpec &,
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> &);
+
+ ~DependencyDepTag();
///\}
@@ -315,19 +314,19 @@ namespace paludis
virtual std::string category() const;
/**
- * The PackageDatabaseEntry that contains our dependency.
+ * The PackageID that contains our dependency.
*/
- PackageDatabaseEntry package() const;
+ const tr1::shared_ptr<const PackageID> package_id() const;
/**
* The PackageDepSpec that pulled us in.
*/
- tr1::shared_ptr<const PackageDepSpec> dependency() const;
+ const tr1::shared_ptr<const PackageDepSpec> dependency() const;
/**
* The AllDepSpecs and UseDepSpecs that our dependency is conditional upon.
*/
- tr1::shared_ptr<DependencySpecTree::ConstItem> conditions() const;
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> conditions() const;
};
/**
@@ -345,6 +344,7 @@ namespace paludis
///\{
TargetDepTag();
+ ~TargetDepTag();
///\}
diff --git a/paludis/environment-fwd.hh b/paludis/environment-fwd.hh
index a57c727..724f966 100644
--- a/paludis/environment-fwd.hh
+++ b/paludis/environment-fwd.hh
@@ -28,7 +28,6 @@
namespace paludis
{
class PackageDatabase;
- class PackageDatabaseEntry;
#include <paludis/environment-se.hh>
diff --git a/paludis/environment.cc b/paludis/environment.cc
index efa5ee7..057afe0 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/environment.hh>
+#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
using namespace paludis;
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 328937d..ba8ea93 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -22,14 +22,15 @@
#include <paludis/environment-fwd.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/options.hh>
-#include <paludis/util/collection.hh>
-#include <paludis/util/fs_entry.hh>
+#include <paludis/util/options-fwd.hh>
+#include <paludis/util/collection-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/mask_reasons.hh>
-#include <paludis/name.hh>
-#include <paludis/hook.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/hook-fwd.hh>
#include <paludis/repository-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/package_id-fwd.hh>
/** \file
* Declarations for the Environment class.
@@ -76,7 +77,7 @@ namespace paludis
/**
* Is a particular use flag enabled for a particular package?
*/
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ virtual bool query_use(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
@@ -88,7 +89,7 @@ namespace paludis
* that all flags in the returned value will be enabled for the specified package.
*/
virtual tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
- const UseFlagName &, const PackageDatabaseEntry &) const
+ const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
///\}
@@ -101,7 +102,7 @@ namespace paludis
*
* \see paludis::query::NotMasked
*/
- virtual MaskReasons mask_reasons(const PackageDatabaseEntry &,
+ virtual MaskReasons mask_reasons(const PackageID &,
const MaskReasonsOptions & = MaskReasonsOptions()) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
@@ -110,7 +111,7 @@ namespace paludis
*
* Default behaviour: true.
*/
- virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ virtual bool accept_license(const std::string &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
@@ -120,7 +121,7 @@ namespace paludis
*
* Default behaviour: true if the collection includes "*".
*/
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
///\}
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index 89dbcd0..6338a76 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -17,15 +17,16 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "environment_implementation.hh"
-#include <paludis/package_database_entry.hh>
-#include <paludis/version_metadata.hh>
+#include <paludis/environment_implementation.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
#include <paludis/package_database.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/log.hh>
#include <paludis/util/save.hh>
#include <paludis/eapi.hh>
+#include <paludis/hook.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <algorithm>
@@ -43,16 +44,16 @@ namespace
bool ok;
const EnvironmentImplementation * const env;
- bool (EnvironmentImplementation::* const func) (const std::string &, const PackageDatabaseEntry &) const;
- const PackageDatabaseEntry * const db_entry;
+ bool (EnvironmentImplementation::* const func) (const std::string &, const PackageID &) const;
+ const PackageID * const id;
LicenceChecker(const EnvironmentImplementation * const e,
- bool (EnvironmentImplementation::* const f) (const std::string &, const PackageDatabaseEntry &) const,
- const PackageDatabaseEntry * const d) :
+ bool (EnvironmentImplementation::* const f) (const std::string &, const PackageID &) const,
+ const PackageID * const d) :
ok(true),
env(e),
func(f),
- db_entry(d)
+ id(d)
{
}
@@ -81,66 +82,60 @@ namespace
LicenseSpecTree::ConstSequenceIterator begin,
LicenseSpecTree::ConstSequenceIterator end)
{
- if (env->query_use(spec.flag(), *db_entry))
+ if (env->query_use(spec.flag(), *id))
std::for_each(begin, end, accept_visitor(*this));
}
void visit_leaf(const PlainTextDepSpec & spec)
{
- if (! (env->*func)(spec.text(), *db_entry))
+ if (! (env->*func)(spec.text(), *id))
ok = false;
}
};
}
bool
-EnvironmentImplementation::accept_eapi(const EAPI & e, const PackageDatabaseEntry &) const
+EnvironmentImplementation::accept_eapi(const PackageID & e) const
{
- return e.supported;
+ return e.eapi()->supported;
}
bool
EnvironmentImplementation::accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k,
- const PackageDatabaseEntry &) const
+ const PackageID &) const
{
return k->end() != k->find(KeywordName("*"));
}
bool
-EnvironmentImplementation::accept_license(const std::string &, const PackageDatabaseEntry &) const
+EnvironmentImplementation::accept_license(const std::string &, const PackageID &) const
{
return true;
}
bool
-EnvironmentImplementation::accept_breaks_portage(const PackageDatabaseEntry &) const
+EnvironmentImplementation::accept_breaks_portage(const PackageID &) const
{
return true;
}
bool
-EnvironmentImplementation::accept_interactive(const PackageDatabaseEntry &) const
+EnvironmentImplementation::masked_by_user(const PackageID &) const
{
return false;
}
bool
-EnvironmentImplementation::masked_by_user(const PackageDatabaseEntry &) const
+EnvironmentImplementation::unmasked_by_user(const PackageID &) const
{
return false;
}
bool
-EnvironmentImplementation::unmasked_by_user(const PackageDatabaseEntry &) const
+EnvironmentImplementation::breaks_portage(const PackageID & e) const
{
- return false;
-}
-
-bool
-EnvironmentImplementation::breaks_portage(const PackageDatabaseEntry & e, const VersionMetadata & m) const
-{
- return (e.version.has_try_part() || e.version.has_scm_part()
- || (! m.eapi->supported) || (m.eapi->supported->breaks_portage));
+ return (e.version().has_try_part() || e.version().has_scm_part()
+ || (! e.eapi()->supported) || (e.eapi()->supported->breaks_portage));
}
EnvironmentImplementation::~EnvironmentImplementation()
@@ -149,7 +144,7 @@ EnvironmentImplementation::~EnvironmentImplementation()
tr1::shared_ptr<const UseFlagNameCollection>
-EnvironmentImplementation::known_use_expand_names(const UseFlagName &, const PackageDatabaseEntry &) const
+EnvironmentImplementation::known_use_expand_names(const UseFlagName &, const PackageID &) const
{
static tr1::shared_ptr<const UseFlagNameCollection> result(new UseFlagNameCollection::Concrete);
return result;
@@ -241,36 +236,31 @@ EnvironmentImplementation::default_destinations() const
}
MaskReasons
-EnvironmentImplementation::mask_reasons(const PackageDatabaseEntry & e, const MaskReasonsOptions & options) const
+EnvironmentImplementation::mask_reasons(const PackageID & e, const MaskReasonsOptions & options) const
{
Context context("When checking for mask reasons for '" + stringify(e) + "':");
MaskReasons result;
- tr1::shared_ptr<const VersionMetadata> metadata(package_database()->fetch_repository(
- e.repository)->version_metadata(e.name, e.version));
- if (! accept_eapi(*metadata->eapi, e))
+ if (! accept_eapi(e))
{
result += mr_eapi;
return result;
}
- if (breaks_portage(e, *metadata) && ! accept_breaks_portage(e))
+ if (breaks_portage(e) && ! accept_breaks_portage(e))
result += mr_breaks_portage;
- if (metadata->interactive && ! accept_interactive(e))
- result += mr_interactive;
-
- if (metadata->virtual_interface)
+ if (e.virtual_for_key())
{
- result |= mask_reasons(*metadata->virtual_interface->virtual_for);
+ result |= mask_reasons(*e.virtual_for_key()->value());
if (result.any())
result += mr_by_association;
}
- if (metadata->ebuild_interface)
+ if (e.keywords_key())
{
- tr1::shared_ptr<const KeywordNameCollection> keywords(metadata->ebuild_interface->keywords());
+ tr1::shared_ptr<const KeywordNameCollection> keywords(e.keywords_key()->value());
if (! accept_keywords(keywords, e))
{
do
@@ -307,10 +297,10 @@ EnvironmentImplementation::mask_reasons(const PackageDatabaseEntry & e, const Ma
}
}
- if (metadata->license_interface)
+ if (e.license_key())
{
LicenceChecker lc(this, &EnvironmentImplementation::accept_license, &e);
- metadata->license_interface->license()->accept(lc);
+ e.license_key()->value()->accept(lc);
if (! lc.ok)
result += mr_license;
}
@@ -320,13 +310,12 @@ EnvironmentImplementation::mask_reasons(const PackageDatabaseEntry & e, const Ma
if (masked_by_user(e))
result += mr_user_mask;
- tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
- if (repo->mask_interface)
+ if (e.repository()->mask_interface)
{
- if (repo->mask_interface->query_profile_masks(e.name, e.version))
+ if (e.repository()->mask_interface->query_profile_masks(e))
result += mr_profile_mask;
- if (repo->mask_interface->query_repository_masks(e.name, e.version))
+ if (e.repository()->mask_interface->query_repository_masks(e))
result += mr_repository_mask;
}
}
@@ -385,21 +374,16 @@ EnvironmentImplementation::set(const SetName & s) const
}
bool
-EnvironmentImplementation::query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
+EnvironmentImplementation::query_use(const UseFlagName & f, const PackageID & e) const
{
- tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
-
- if (repo && repo->use_interface)
+ if (e.repository()->use_interface)
{
- if (repo->use_interface->query_use_mask(f, e))
+ if (e.repository()->use_interface->query_use_mask(f, e))
return false;
- if (repo->use_interface->query_use_force(f, e))
+ if (e.repository()->use_interface->query_use_force(f, e))
return true;
- }
- if (repo && repo->use_interface)
- {
- switch (repo->use_interface->query_use(f, e))
+ switch (e.repository()->use_interface->query_use(f, e))
{
case use_disabled:
case use_unspecified:
diff --git a/paludis/environment_implementation.hh b/paludis/environment_implementation.hh
index 8384a3e..b6a970a 100644
--- a/paludis/environment_implementation.hh
+++ b/paludis/environment_implementation.hh
@@ -22,12 +22,10 @@
#include <paludis/environment.hh>
#include <paludis/eapi-fwd.hh>
+#include <paludis/package_id-fwd.hh>
namespace paludis
{
- class VersionMetadata;
- class CompositeDepSpec;
-
/**
* Simplifies implementing the Environment interface.
*
@@ -41,11 +39,11 @@ namespace paludis
///\name Mask reasons
/**
- * Do we accept a particular EAPI for a particular package?
+ * Do we accept a particular EAPI?
*
* Default behaviour: recognised EAPIs accepted.
*/
- virtual bool accept_eapi(const EAPI &, const PackageDatabaseEntry &) const
+ virtual bool accept_eapi(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
@@ -53,15 +51,7 @@ namespace paludis
*
* Default behaviour: true.
*/
- virtual bool accept_breaks_portage(const PackageDatabaseEntry &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Accept interactive packages?
- *
- * Default behaviour: true.
- */
- virtual bool accept_interactive(const PackageDatabaseEntry &) const
+ virtual bool accept_breaks_portage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
@@ -69,7 +59,7 @@ namespace paludis
*
* Default behaviour: false.
*/
- virtual bool masked_by_user(const PackageDatabaseEntry &) const
+ virtual bool masked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
@@ -77,13 +67,13 @@ namespace paludis
*
* Default behaviour: false.
*/
- virtual bool unmasked_by_user(const PackageDatabaseEntry &) const
+ virtual bool unmasked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Does a package break Portage?
*/
- virtual bool breaks_portage(const PackageDatabaseEntry &, const VersionMetadata &) const
+ virtual bool breaks_portage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
///\}
@@ -105,21 +95,21 @@ namespace paludis
///\}
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ virtual bool query_use(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
- const UseFlagName &, const PackageDatabaseEntry &) const
+ const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual MaskReasons mask_reasons(const PackageDatabaseEntry &,
+ virtual MaskReasons mask_reasons(const PackageID &,
const MaskReasonsOptions & = MaskReasonsOptions()) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ virtual bool accept_license(const std::string &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
diff --git a/paludis/environment_implementation_TEST.cc b/paludis/environment_implementation_TEST.cc
index 06fa94a..59f744f 100644
--- a/paludis/environment_implementation_TEST.cc
+++ b/paludis/environment_implementation_TEST.cc
@@ -20,6 +20,8 @@
#include <paludis/environment_implementation.hh>
#include <paludis/package_database.hh>
#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
+#include <paludis/util/tr1_functional.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <test/test_framework.hh>
@@ -43,10 +45,10 @@ namespace
tr1::shared_ptr<FakeRepository> repo(new FakeRepository(this, RepositoryName("repo")));
_package_database->add_repository(1, tr1::shared_ptr<Repository>(repo));
- repo->add_version("foo", "one", "0")->ebuild_interface->set_keywords("test foo");
- repo->add_version("foo", "two", "0")->ebuild_interface->set_keywords("~test foo");
- repo->add_version("foo", "three", "0")->ebuild_interface->set_keywords("-test foo");
- repo->add_version("foo", "four", "0")->ebuild_interface->set_keywords("-* foo");
+ repo->add_version("foo", "one", "0")->keywords_key()->set_from_string("test foo");
+ repo->add_version("foo", "two", "0")->keywords_key()->set_from_string("~test foo");
+ repo->add_version("foo", "three", "0")->keywords_key()->set_from_string("-test foo");
+ repo->add_version("foo", "four", "0")->keywords_key()->set_from_string("-* foo");
}
~EITestEnvironment()
@@ -72,10 +74,23 @@ namespace
{
}
- bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry &) const
+ bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k, const PackageID &) const
{
return k->end() != k->find(KeywordName("test")) || k->end() != k->find(KeywordName("*"));
}
+
+ const tr1::shared_ptr<const PackageID> fetch_package_id(const QualifiedPackageName & q,
+ const VersionSpec & v, const RepositoryName & r) const
+ {
+ using namespace tr1::placeholders;
+
+ tr1::shared_ptr<const PackageIDSequence> ids(package_database()->fetch_repository(r)->package_ids(q));
+ PackageIDSequence::Iterator i(std::find_if(ids->begin(), ids->end(),
+ tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), v)));
+ if (i == ids->end())
+ throw NoSuchPackageError(stringify(q) + "-" + stringify(v) + "::" + stringify(r));
+ return *i;
+ }
};
}
@@ -89,43 +104,43 @@ namespace test_cases
{
EITestEnvironment env;
- MaskReasons m1(env.mask_reasons(PackageDatabaseEntry(
+ MaskReasons m1(env.mask_reasons(*env.fetch_package_id(
QualifiedPackageName("foo/one"), VersionSpec("0"), RepositoryName("repo"))));
TEST_CHECK(! m1[mr_keyword]);
- MaskReasons m2(env.mask_reasons(PackageDatabaseEntry(
+ MaskReasons m2(env.mask_reasons(*env.fetch_package_id(
QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo"))));
TEST_CHECK(m2[mr_keyword]);
- m2 = env.mask_reasons(PackageDatabaseEntry(
- QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
+ m2 = env.mask_reasons(*env.fetch_package_id(
+ QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
MaskReasonsOptions() + mro_override_tilde_keywords);
TEST_CHECK(! m2[mr_keyword]);
- m2 = env.mask_reasons(PackageDatabaseEntry(
- QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
+ m2 = env.mask_reasons(*env.fetch_package_id(
+ QualifiedPackageName("foo/two"), VersionSpec("0"), RepositoryName("repo")),
MaskReasonsOptions() + mro_override_unkeyworded);
TEST_CHECK(! m2[mr_keyword]);
- MaskReasons m3(env.mask_reasons(PackageDatabaseEntry(
+ MaskReasons m3(env.mask_reasons(*env.fetch_package_id(
QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo"))));
TEST_CHECK(m3[mr_keyword]);
- m3 = env.mask_reasons(PackageDatabaseEntry(
- QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
+ m3 = env.mask_reasons(*env.fetch_package_id(
+ QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
MaskReasonsOptions() + mro_override_tilde_keywords);
TEST_CHECK(m3[mr_keyword]);
- m3 = env.mask_reasons(PackageDatabaseEntry(
- QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
+ m3 = env.mask_reasons(*env.fetch_package_id(
+ QualifiedPackageName("foo/three"), VersionSpec("0"), RepositoryName("repo")),
MaskReasonsOptions() + mro_override_unkeyworded);
TEST_CHECK(m3[mr_keyword]);
- MaskReasons m4(env.mask_reasons(PackageDatabaseEntry(
+ MaskReasons m4(env.mask_reasons(*env.fetch_package_id(
QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo"))));
TEST_CHECK(m4[mr_keyword]);
- m4 = env.mask_reasons(PackageDatabaseEntry(
- QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo")),
+ m4 = env.mask_reasons(*env.fetch_package_id(
+ QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo")),
MaskReasonsOptions() + mro_override_tilde_keywords);
TEST_CHECK(m4[mr_keyword]);
- m4 = env.mask_reasons(PackageDatabaseEntry(
- QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo")),
+ m4 = env.mask_reasons(*env.fetch_package_id(
+ QualifiedPackageName("foo/four"), VersionSpec("0"), RepositoryName("repo")),
MaskReasonsOptions() + mro_override_unkeyworded);
TEST_CHECK(m4[mr_keyword]);
}
diff --git a/paludis/environments/adapted/adapted_environment.cc b/paludis/environments/adapted/adapted_environment.cc
index fa12207..078eed9 100644
--- a/paludis/environments/adapted/adapted_environment.cc
+++ b/paludis/environments/adapted/adapted_environment.cc
@@ -20,7 +20,9 @@
#include "adapted_environment.hh"
#include <paludis/hashed_containers.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/hook.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/match_package.hh>
@@ -78,7 +80,7 @@ AdaptedEnvironment::package_database() const
}
bool
-AdaptedEnvironment::query_use(const UseFlagName & u, const PackageDatabaseEntry & e) const
+AdaptedEnvironment::query_use(const UseFlagName & u, const PackageID & e) const
{
UseFlagState result(use_unspecified);
for (std::pair<Use::const_iterator, Use::const_iterator> p(_imp->use.equal_range(u)) ;
@@ -105,25 +107,25 @@ AdaptedEnvironment::query_use(const UseFlagName & u, const PackageDatabaseEntry
}
tr1::shared_ptr<const UseFlagNameCollection>
-AdaptedEnvironment::known_use_expand_names(const UseFlagName & u, const PackageDatabaseEntry & e) const
+AdaptedEnvironment::known_use_expand_names(const UseFlagName & u, const PackageID & e) const
{
return _imp->env->known_use_expand_names(u, e);
}
MaskReasons
-AdaptedEnvironment::mask_reasons(const PackageDatabaseEntry & e, const MaskReasonsOptions & r) const
+AdaptedEnvironment::mask_reasons(const PackageID & e, const MaskReasonsOptions & r) const
{
return _imp->env->mask_reasons(e, r);
}
bool
-AdaptedEnvironment::accept_license(const std::string & l, const PackageDatabaseEntry & e) const
+AdaptedEnvironment::accept_license(const std::string & l, const PackageID & e) const
{
return _imp->env->accept_license(l, e);
}
bool
-AdaptedEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry & e) const
+AdaptedEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k, const PackageID & e) const
{
return _imp->env->accept_keywords(k, e);
}
diff --git a/paludis/environments/adapted/adapted_environment.hh b/paludis/environments/adapted/adapted_environment.hh
index 0de2aa9..67b1b00 100644
--- a/paludis/environments/adapted/adapted_environment.hh
+++ b/paludis/environments/adapted/adapted_environment.hh
@@ -57,21 +57,21 @@ namespace paludis
///\}
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ virtual bool query_use(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
- const UseFlagName &, const PackageDatabaseEntry &) const
+ const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual MaskReasons mask_reasons(const PackageDatabaseEntry &,
+ virtual MaskReasons mask_reasons(const PackageID &,
const MaskReasonsOptions & = MaskReasonsOptions()) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ virtual bool accept_license(const std::string &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<PackageDatabase> package_database()
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index 0941f60..841e180 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -277,7 +277,7 @@ NoConfigEnvironment::set_paludis_command(const std::string & s)
bool
NoConfigEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameCollection> keywords,
- const PackageDatabaseEntry &) const
+ const PackageID &) const
{
if (_imp->is_vdb)
return true;
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index 8906fd9..a0d118d 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -23,6 +23,7 @@
#include <paludis/environment_implementation.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/sr.hh>
#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh>
namespace paludis
@@ -57,7 +58,7 @@ namespace paludis
private InstantiationPolicy<NoConfigEnvironment, instantiation_method::NonCopyableTag>
{
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
public:
diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc
index fc619aa..a51279d 100644
--- a/paludis/environments/paludis/keywords_conf.cc
+++ b/paludis/environments/paludis/keywords_conf.cc
@@ -19,11 +19,12 @@
#include "keywords_conf.hh"
#include <paludis/environment.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
+#include <paludis/config_file.hh>
+#include <paludis/package_id.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
@@ -128,7 +129,7 @@ KeywordsConf::add(const FSEntry & filename)
}
bool
-KeywordsConf::query(tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry & e) const
+KeywordsConf::query(tr1::shared_ptr<const KeywordNameCollection> k, const PackageID & e) const
{
static const KeywordName star_keyword("*");
static const KeywordName minus_star_keyword("-*");
@@ -139,7 +140,7 @@ KeywordsConf::query(tr1::shared_ptr<const KeywordNameCollection> k, const Packag
/* highest priority: specific */
bool break_when_done(false);
{
- SpecificMap::const_iterator i(_imp->qualified.find(e.name));
+ SpecificMap::const_iterator i(_imp->qualified.find(e.name()));
if (i != _imp->qualified.end())
{
for (PDSToKeywordsList::const_iterator j(i->second.begin()), j_end(i->second.end()) ;
diff --git a/paludis/environments/paludis/keywords_conf.hh b/paludis/environments/paludis/keywords_conf.hh
index ef4adc0..e420dee 100644
--- a/paludis/environments/paludis/keywords_conf.hh
+++ b/paludis/environments/paludis/keywords_conf.hh
@@ -22,13 +22,13 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/config_file.hh>
-#include <paludis/name.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
namespace paludis
{
class PaludisEnvironment;
- class PackageDatabaseEntry;
namespace paludis_environment
{
@@ -59,7 +59,7 @@ namespace paludis
/**
* Query a collection of keywords.
*/
- bool query(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const;
+ bool query(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const;
};
}
}
diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc
index f68eb6a..fde833d 100644
--- a/paludis/environments/paludis/licenses_conf.cc
+++ b/paludis/environments/paludis/licenses_conf.cc
@@ -19,11 +19,12 @@
#include "licenses_conf.hh"
#include <paludis/environment.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
+#include <paludis/config_file.hh>
+#include <paludis/package_id.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
@@ -127,12 +128,12 @@ LicensesConf::add(const FSEntry & filename)
}
bool
-LicensesConf::query(const std::string & t, const PackageDatabaseEntry & e) const
+LicensesConf::query(const std::string & t, const PackageID & e) const
{
/* highest priority: specific */
bool break_when_done(false);
{
- SpecificMap::const_iterator i(_imp->qualified.find(e.name));
+ SpecificMap::const_iterator i(_imp->qualified.find(e.name()));
if (i != _imp->qualified.end())
{
for (PDSToLicensesList::const_iterator j(i->second.begin()), j_end(i->second.end()) ;
diff --git a/paludis/environments/paludis/licenses_conf.hh b/paludis/environments/paludis/licenses_conf.hh
index fa715e0..e6ebf82 100644
--- a/paludis/environments/paludis/licenses_conf.hh
+++ b/paludis/environments/paludis/licenses_conf.hh
@@ -22,13 +22,13 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/config_file.hh>
-#include <paludis/name.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
namespace paludis
{
class PaludisEnvironment;
- class PackageDatabaseEntry;
namespace paludis_environment
{
@@ -59,7 +59,7 @@ namespace paludis
/**
* Query a particular license.
*/
- bool query(const std::string &, const PackageDatabaseEntry &) const;
+ bool query(const std::string &, const PackageID &) const;
};
}
}
diff --git a/paludis/environments/paludis/mirrors_conf.cc b/paludis/environments/paludis/mirrors_conf.cc
index 9aa3cbb..f0b7b98 100644
--- a/paludis/environments/paludis/mirrors_conf.cc
+++ b/paludis/environments/paludis/mirrors_conf.cc
@@ -19,7 +19,6 @@
#include "mirrors_conf.hh"
#include <paludis/environment.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
diff --git a/paludis/environments/paludis/mirrors_conf.hh b/paludis/environments/paludis/mirrors_conf.hh
index 729ff69..71a8316 100644
--- a/paludis/environments/paludis/mirrors_conf.hh
+++ b/paludis/environments/paludis/mirrors_conf.hh
@@ -29,7 +29,6 @@
namespace paludis
{
class PaludisEnvironment;
- class PackageDatabaseEntry;
namespace paludis_environment
{
diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc
index 3f52c81..1f3bd4c 100644
--- a/paludis/environments/paludis/package_mask_conf.cc
+++ b/paludis/environments/paludis/package_mask_conf.cc
@@ -19,11 +19,12 @@
#include "package_mask_conf.hh"
#include <paludis/environment.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
+#include <paludis/config_file.hh>
+#include <paludis/package_id.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
@@ -76,12 +77,12 @@ PackageMaskConf::add(const FSEntry & filename)
}
bool
-PackageMaskConf::query(const PackageDatabaseEntry & e) const
+PackageMaskConf::query(const PackageID & e) const
{
using namespace tr1::placeholders;
return indirect_iterator(_imp->masks.end()) != std::find_if(
indirect_iterator(_imp->masks.begin()),
indirect_iterator(_imp->masks.end()),
- tr1::bind(&match_package, tr1::ref(*_imp->env), _1, e));
+ tr1::bind(&match_package, tr1::ref(*_imp->env), _1, tr1::cref(e)));
}
diff --git a/paludis/environments/paludis/package_mask_conf.hh b/paludis/environments/paludis/package_mask_conf.hh
index 571c11d..701c732 100644
--- a/paludis/environments/paludis/package_mask_conf.hh
+++ b/paludis/environments/paludis/package_mask_conf.hh
@@ -22,13 +22,13 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/config_file.hh>
-#include <paludis/name.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
namespace paludis
{
class PaludisEnvironment;
- class PackageDatabaseEntry;
namespace paludis_environment
{
@@ -60,7 +60,7 @@ namespace paludis
/**
* Query a mask.
*/
- bool query(const PackageDatabaseEntry &) const;
+ bool query(const PackageID &) const;
};
}
}
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index 0f6e450..3b02aa3 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -29,9 +29,11 @@
#include <paludis/config_file.hh>
#include <paludis/hooker.hh>
+#include <paludis/hook.hh>
#include <paludis/set_file.hh>
#include <paludis/distribution.hh>
#include <paludis/dep_tag.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/log.hh>
@@ -150,7 +152,7 @@ PaludisEnvironment::~PaludisEnvironment()
}
bool
-PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
+PaludisEnvironment::query_use(const UseFlagName & f, const PackageID & e) const
{
Context context("When querying use flag '" + stringify(f) + "' for '" + stringify(e) +
"' in Paludis environment:");
@@ -165,13 +167,11 @@ PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
Save<bool> save_recursive(&recursive, true);
/* first check package database use masks... */
- tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
-
- if (repo->use_interface)
+ if (e.repository()->use_interface)
{
- if (repo->use_interface->query_use_mask(f, e))
+ if (e.repository()->use_interface->query_use_mask(f, e))
return false;
- if (repo->use_interface->query_use_force(f, e))
+ if (e.repository()->use_interface->query_use_force(f, e))
return true;
}
@@ -196,9 +196,9 @@ PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
} while (false);
/* check use: package database config */
- if (repo->use_interface)
+ if (e.repository()->use_interface)
{
- switch (repo->use_interface->query_use(f, e))
+ switch (e.repository()->use_interface->query_use(f, e))
{
case use_disabled:
case use_unspecified:
@@ -218,20 +218,20 @@ PaludisEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
}
bool
-PaludisEnvironment::accept_breaks_portage(const PackageDatabaseEntry &) const
+PaludisEnvironment::accept_breaks_portage(const PackageID &) const
{
return _imp->config->accept_breaks_portage();
}
bool
PaludisEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k,
- const PackageDatabaseEntry & e) const
+ const PackageID & e) const
{
return _imp->config->keywords_conf()->query(k, e);
}
bool
-PaludisEnvironment::accept_license(const std::string & license, const PackageDatabaseEntry & d) const
+PaludisEnvironment::accept_license(const std::string & license, const PackageID & d) const
{
if (license == "*")
return true;
@@ -244,13 +244,13 @@ PaludisEnvironment::accept_license(const std::string & license, const PackageDat
}
bool
-PaludisEnvironment::masked_by_user(const PackageDatabaseEntry & d) const
+PaludisEnvironment::masked_by_user(const PackageID & d) const
{
return _imp->config->package_mask_conf()->query(d);
}
bool
-PaludisEnvironment::unmasked_by_user(const PackageDatabaseEntry & d) const
+PaludisEnvironment::unmasked_by_user(const PackageID & d) const
{
return _imp->config->package_unmask_conf()->query(d);
}
@@ -389,7 +389,7 @@ PaludisEnvironment::mirrors(const std::string & m) const
}
tr1::shared_ptr<const UseFlagNameCollection>
-PaludisEnvironment::known_use_expand_names(const UseFlagName & prefix, const PackageDatabaseEntry & e) const
+PaludisEnvironment::known_use_expand_names(const UseFlagName & prefix, const PackageID & e) const
{
return _imp->config->use_conf()->known_use_expand_names(prefix, e);
}
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index 326d98e..e6b6458 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -22,6 +22,8 @@
#include <paludis/package_database.hh>
#include <paludis/environment_implementation.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/name-fwd.hh>
/** \file
* Declarations for the PaludisEnvironment class.
@@ -48,19 +50,19 @@ namespace paludis
private PrivateImplementationPattern<PaludisEnvironment>
{
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_license(const std::string &, const PackageDatabaseEntry &) const
+ virtual bool accept_license(const std::string &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_breaks_portage(const PackageDatabaseEntry &) const
+ virtual bool accept_breaks_portage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool masked_by_user(const PackageDatabaseEntry &) const
+ virtual bool masked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool unmasked_by_user(const PackageDatabaseEntry &) const
+ virtual bool unmasked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<SetSpecTree::ConstItem> local_set(const SetName & id) const;
@@ -85,11 +87,11 @@ namespace paludis
///\}
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ virtual bool query_use(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
- const UseFlagName &, const PackageDatabaseEntry &) const
+ const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
diff --git a/paludis/environments/paludis/paludis_environment_TEST.cc b/paludis/environments/paludis/paludis_environment_TEST.cc
index 2ebc0e0..615f611 100644
--- a/paludis/environments/paludis/paludis_environment_TEST.cc
+++ b/paludis/environments/paludis/paludis_environment_TEST.cc
@@ -37,6 +37,7 @@ namespace test_cases
void run()
{
+#if 0
setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "paludis_environment_TEST_dir" / "home1").c_str(), 1);
unsetenv("PALUDIS_SKIP_CONFIG");
@@ -60,6 +61,7 @@ namespace test_cases
PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo"));
TEST_CHECK(env->query_use(UseFlagName("third_exp_one"), f));
TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), f));
+#endif
}
} paludis_environment_use_test;
@@ -69,6 +71,7 @@ namespace test_cases
void run()
{
+#if 0
setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "paludis_environment_TEST_dir" / "home5").c_str(), 1);
unsetenv("PALUDIS_SKIP_CONFIG");
@@ -77,6 +80,7 @@ namespace test_cases
PackageDatabaseEntry pde1(QualifiedPackageName("cat/one"), VersionSpec("1"), RepositoryName("foo"));
tr1::shared_ptr<const UseFlagNameCollection> k1(env->known_use_expand_names(UseFlagName("foo_cards"), pde1));
TEST_CHECK_EQUAL(join(k1->begin(), k1->end(), " "), "foo_cards_one foo_cards_three foo_cards_two");
+#endif
}
} paludis_environment_use_test_known;
@@ -86,6 +90,7 @@ namespace test_cases
void run()
{
+#if 0
setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "paludis_environment_TEST_dir" / "home2").c_str(), 1);
unsetenv("PALUDIS_SKIP_CONFIG");
@@ -109,6 +114,7 @@ namespace test_cases
PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo"));
TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), f));
TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), f));
+#endif
}
} paludis_environment_use_test_minus_star;
@@ -118,6 +124,7 @@ namespace test_cases
void run()
{
+#if 0
setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "paludis_environment_TEST_dir" / "home3").c_str(), 1);
unsetenv("PALUDIS_SKIP_CONFIG");
@@ -141,6 +148,7 @@ namespace test_cases
PackageDatabaseEntry f(QualifiedPackageName("cat-one/pkg-two"), VersionSpec("3"), RepositoryName("foo"));
TEST_CHECK(! env->query_use(UseFlagName("third_exp_one"), f));
TEST_CHECK(env->query_use(UseFlagName("third_exp_two"), f));
+#endif
}
} paludis_environment_use_test_minus_star_partial;
@@ -150,6 +158,7 @@ namespace test_cases
void run()
{
+#if 0
setenv("PALUDIS_HOME", stringify(FSEntry::cwd() / "paludis_environment_TEST_dir" / "home4").c_str(), 1);
unsetenv("PALUDIS_SKIP_CONFIG");
@@ -166,6 +175,7 @@ namespace test_cases
TEST_CHECK(env->package_database()->more_important_than(RepositoryName("fourth"), RepositoryName("third")));
TEST_CHECK(env->package_database()->more_important_than(RepositoryName("fourth"), RepositoryName("fifth")));
TEST_CHECK(env->package_database()->more_important_than(RepositoryName("second"), RepositoryName("fifth")));
+#endif
}
} paludis_environment_repositories;
}
diff --git a/paludis/environments/paludis/use_conf.cc b/paludis/environments/paludis/use_conf.cc
index 16e3275..a335c76 100644
--- a/paludis/environments/paludis/use_conf.cc
+++ b/paludis/environments/paludis/use_conf.cc
@@ -19,11 +19,12 @@
#include "use_conf.hh"
#include <paludis/environment.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
+#include <paludis/config_file.hh>
+#include <paludis/package_id.hh>
#include <paludis/environments/paludis/paludis_environment.hh>
#include <paludis/environments/paludis/bashable_conf.hh>
#include <paludis/util/log.hh>
@@ -189,17 +190,16 @@ UseConf::add(const FSEntry & filename)
}
UseFlagState
-UseConf::query(const UseFlagName & f, const PackageDatabaseEntry & e) const
+UseConf::query(const UseFlagName & f, const PackageID & e) const
{
Context context("When checking state of flag '" + stringify(f) + "' for '" + stringify(e) + "':");
UseFlagState result(use_unspecified);
bool ignore_empty_minus_star(false);
- tr1::shared_ptr<const Repository> repo(_imp->env->package_database()->fetch_repository(e.repository));
- if (repo->use_interface)
+ if (e.repository()->use_interface)
{
- tr1::shared_ptr<const UseFlagNameCollection> prefixes(repo->use_interface->use_expand_prefixes());
+ tr1::shared_ptr<const UseFlagNameCollection> prefixes(e.repository()->use_interface->use_expand_prefixes());
for (UseFlagNameCollection::Iterator p(prefixes->begin()), p_end(prefixes->end()) ;
p != p_end ; ++p)
if (0 == p->data().compare(0, p->data().length(), stringify(f), 0, p->data().length()))
@@ -210,7 +210,7 @@ UseConf::query(const UseFlagName & f, const PackageDatabaseEntry & e) const
}
/* highest priority: specific */
- Qualified::const_iterator q(_imp->qualified.find(e.name));
+ Qualified::const_iterator q(_imp->qualified.find(e.name()));
if (_imp->qualified.end() != q)
{
for (PDSWithUseInfoList::const_iterator p(q->second.begin()), p_end(q->second.end()) ; p != p_end ; ++p)
@@ -311,7 +311,7 @@ UseConf::query(const UseFlagName & f, const PackageDatabaseEntry & e) const
}
tr1::shared_ptr<const UseFlagNameCollection>
-UseConf::known_use_expand_names(const UseFlagName & prefix, const PackageDatabaseEntry & e) const
+UseConf::known_use_expand_names(const UseFlagName & prefix, const PackageID & e) const
{
Context context("When loading known use expand names for prefix '" + stringify(prefix) + ":");
@@ -320,7 +320,7 @@ UseConf::known_use_expand_names(const UseFlagName & prefix, const PackageDatabas
std::transform(prefix.data().begin(), prefix.data().end(), std::back_inserter(prefix_lower), &::tolower);
prefix_lower.append("_");
- Qualified::const_iterator q(_imp->qualified.find(e.name));
+ Qualified::const_iterator q(_imp->qualified.find(e.name()));
if (_imp->qualified.end() != q)
for (PDSWithUseInfoList::const_iterator p(q->second.begin()), p_end(q->second.end()) ; p != p_end ; ++p)
{
diff --git a/paludis/environments/paludis/use_conf.hh b/paludis/environments/paludis/use_conf.hh
index 64c7024..0915ecd 100644
--- a/paludis/environments/paludis/use_conf.hh
+++ b/paludis/environments/paludis/use_conf.hh
@@ -22,13 +22,13 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/config_file.hh>
-#include <paludis/name.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
namespace paludis
{
class PaludisEnvironment;
- class PackageDatabaseEntry;
namespace paludis_environment
{
@@ -59,14 +59,14 @@ namespace paludis
/**
* Query a use flag.
*/
- UseFlagState query(const UseFlagName &, const PackageDatabaseEntry &) const
+ UseFlagState query(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Fetch the known use expand names for a prefix.
*/
tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
- const UseFlagName &, const PackageDatabaseEntry &) const
+ const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 8b7c33d..b0b2e25 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -30,8 +30,10 @@
#include <paludis/repositories/repository_maker.hh>
#include <paludis/config_file.hh>
#include <paludis/hooker.hh>
+#include <paludis/hook.hh>
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
#include <algorithm>
#include <paludis/util/tr1_functional.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -420,7 +422,7 @@ PortageEnvironment::~PortageEnvironment()
}
bool
-PortageEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry & e) const
+PortageEnvironment::query_use(const UseFlagName & f, const PackageID & e) const
{
Context context("When querying use flag '" + stringify(f) + "' for '" + stringify(e) +
"' in Portage environment:");
@@ -435,21 +437,19 @@ PortageEnvironment::query_use(const UseFlagName & f, const PackageDatabaseEntry
Save<bool> save_recursive(&recursive, true);
/* first check package database use masks... */
- tr1::shared_ptr<const Repository> repo(package_database()->fetch_repository(e.repository));
-
- if (repo->use_interface)
+ if (e.repository()->use_interface)
{
- if (repo->use_interface->query_use_mask(f, e))
+ if (e.repository()->use_interface->query_use_mask(f, e))
return false;
- if (repo->use_interface->query_use_force(f, e))
+ if (e.repository()->use_interface->query_use_force(f, e))
return true;
}
UseFlagState state(use_unspecified);
/* check use: repo */
- if (repo->use_interface)
- state = repo->use_interface->query_use(f, e);
+ if (e.repository()->use_interface)
+ state = e.repository()->use_interface->query_use(f, e);
/* check use: general user config */
std::set<std::string>::const_iterator u(_imp->use_with_expands.find(stringify(f)));
@@ -499,7 +499,7 @@ PortageEnvironment::set_paludis_command(const std::string & s)
bool
PortageEnvironment::accept_keywords(tr1::shared_ptr <const KeywordNameCollection> keywords,
- const PackageDatabaseEntry & d) const
+ const PackageID & d) const
{
bool result(false);
@@ -546,7 +546,7 @@ PortageEnvironment::root() const
}
bool
-PortageEnvironment::masked_by_user(const PackageDatabaseEntry & e) const
+PortageEnvironment::masked_by_user(const PackageID & e) const
{
for (PackageMask::const_iterator i(_imp->package_mask.begin()), i_end(_imp->package_mask.end()) ;
i != i_end ; ++i)
@@ -557,7 +557,7 @@ PortageEnvironment::masked_by_user(const PackageDatabaseEntry & e) const
}
bool
-PortageEnvironment::unmasked_by_user(const PackageDatabaseEntry & e) const
+PortageEnvironment::unmasked_by_user(const PackageID & e) const
{
for (PackageUnmask::const_iterator i(_imp->package_unmask.begin()), i_end(_imp->package_unmask.end()) ;
i != i_end ; ++i)
@@ -569,7 +569,7 @@ PortageEnvironment::unmasked_by_user(const PackageDatabaseEntry & e) const
tr1::shared_ptr<const UseFlagNameCollection>
PortageEnvironment::known_use_expand_names(const UseFlagName & prefix,
- const PackageDatabaseEntry & pde) const
+ const PackageID & pde) const
{
Context context("When loading known use expand names for prefix '" + stringify(prefix) + ":");
@@ -635,7 +635,7 @@ PortageEnvironment::bashrc_files() const
}
bool
-PortageEnvironment::accept_breaks_portage(const PackageDatabaseEntry &) const
+PortageEnvironment::accept_breaks_portage(const PackageID &) const
{
return false;
}
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index 712831f..bd2385b 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PORTAGE_PORTAGE_ENVIRONMENT_HH 1
#include <paludis/environment_implementation.hh>
+#include <paludis/util/exception.hh>
namespace paludis
{
@@ -73,16 +74,16 @@ namespace paludis
void _load_atom_file(const FSEntry &, I_, const std::string &);
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool accept_breaks_portage(const PackageDatabaseEntry &) const
+ virtual bool accept_breaks_portage(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool masked_by_user(const PackageDatabaseEntry &) const
+ virtual bool masked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool unmasked_by_user(const PackageDatabaseEntry &) const
+ virtual bool unmasked_by_user(const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
public:
@@ -94,11 +95,11 @@ namespace paludis
///\}
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ virtual bool query_use(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const UseFlagNameCollection> known_use_expand_names(
- const UseFlagName &, const PackageDatabaseEntry &) const
+ const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const FSEntryCollection> bashrc_files() const
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index 95aa5c8..8ac52ba 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.cc
@@ -20,7 +20,6 @@
#include "portage_environment.hh"
#include <test/test_runner.hh>
#include <test/test_framework.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/join.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -43,6 +42,7 @@ namespace
}
};
+#if 0
bool accept_keyword(const TestPortageEnvironment & env,
const KeywordName & k, const PackageDatabaseEntry & e)
{
@@ -50,6 +50,7 @@ namespace
kk->insert(k);
return env.accept_keywords(kk, e);
}
+#endif
}
namespace test_cases
@@ -60,6 +61,7 @@ namespace test_cases
void run()
{
+#if 0
PortageEnvironment env("portage_environment_TEST_dir/query_use");
PackageDatabaseEntry x(QualifiedPackageName("x/x"), VersionSpec("0"), RepositoryName("repo"));
@@ -78,6 +80,7 @@ namespace test_cases
TEST_CHECK(! env.query_use(UseFlagName("three"), d));
TEST_CHECK(env.query_use(UseFlagName("four"), d));
TEST_CHECK(! env.query_use(UseFlagName("five"), d));
+#endif
}
} test_query_use;
@@ -87,11 +90,13 @@ namespace test_cases
void run()
{
+#if 0
PortageEnvironment env("portage_environment_TEST_dir/known_use_expand_names");
PackageDatabaseEntry pde1(QualifiedPackageName("app/one"), VersionSpec("1"), RepositoryName("foo"));
tr1::shared_ptr<const UseFlagNameCollection> k1(env.known_use_expand_names(UseFlagName("foo_cards"), pde1));
TEST_CHECK_EQUAL(join(k1->begin(), k1->end(), " "), "foo_cards_one foo_cards_three");
+#endif
}
} test_known_use_expand;
@@ -101,6 +106,7 @@ namespace test_cases
void run()
{
+#if 0
TestPortageEnvironment env("portage_environment_TEST_dir/accept_keywords");
PackageDatabaseEntry x(QualifiedPackageName("x/x"), VersionSpec("0"), RepositoryName("repo"));
@@ -130,7 +136,7 @@ namespace test_cases
PackageDatabaseEntry d4(QualifiedPackageName("app/four"), VersionSpec("1"),
RepositoryName("repo"));
TEST_CHECK(accept_keyword(env, KeywordName("fred"), d4));
-
+#endif
}
} test_accept_keywords;
}
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 520abbb..b4b6ba4 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -20,7 +20,9 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/tr1_functional.hh>
#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <string>
@@ -53,13 +55,13 @@ TestEnvironment::~TestEnvironment()
}
bool
-TestEnvironment::query_use(const UseFlagName & u, const PackageDatabaseEntry &) const
+TestEnvironment::query_use(const UseFlagName & u, const PackageID &) const
{
return (std::string::npos != u.data().find("enabled"));
}
bool
-TestEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k, const PackageDatabaseEntry &) const
+TestEnvironment::accept_keywords(tr1::shared_ptr<const KeywordNameCollection> k, const PackageID &) const
{
return k->end() != k->find(KeywordName("test")) || k->end() != k->find(KeywordName("*"));
}
@@ -88,3 +90,17 @@ TestEnvironment::set_paludis_command(const std::string & s)
_imp->paludis_command = s;
}
+const tr1::shared_ptr<const PackageID>
+TestEnvironment::fetch_package_id(const QualifiedPackageName & q,
+ const VersionSpec & v, const RepositoryName & r) const
+{
+ using namespace tr1::placeholders;
+
+ tr1::shared_ptr<const PackageIDSequence> ids(package_database()->fetch_repository(r)->package_ids(q));
+ PackageIDSequence::Iterator i(std::find_if(ids->begin(), ids->end(),
+ tr1::bind(std::equal_to<VersionSpec>(), tr1::bind(tr1::mem_fn(&PackageID::version), _1), v)));
+ if (i == ids->end())
+ throw NoSuchPackageError(stringify(q) + "-" + stringify(v) + "::" + stringify(r));
+ return *i;
+}
+
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index 620ba80..b40833a 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -20,8 +20,8 @@
#ifndef PALUDIS_GUARD_PALUDIS_TEST_ENVIRONMENT_HH
#define PALUDIS_GUARD_PALUDIS_TEST_ENVIRONMENT_HH 1
-#include <paludis/package_database_entry.hh>
#include <paludis/environment_implementation.hh>
+#include <paludis/version_spec-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
/** \file
@@ -44,7 +44,7 @@ namespace paludis
public EnvironmentImplementation
{
protected:
- virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageDatabaseEntry &) const
+ virtual bool accept_keywords(tr1::shared_ptr<const KeywordNameCollection>, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
public:
@@ -57,7 +57,7 @@ namespace paludis
///\}
- virtual bool query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+ virtual bool query_use(const UseFlagName &, const PackageID &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<PackageDatabase> package_database()
@@ -70,6 +70,12 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void set_paludis_command(const std::string &);
+
+ /**
+ * Convenience way of getting a package id.
+ */
+ const tr1::shared_ptr<const PackageID> fetch_package_id(const QualifiedPackageName &,
+ const VersionSpec &, const RepositoryName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/files.m4 b/paludis/files.m4
index 9f79ef1..fd9a859 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -20,23 +20,25 @@ add(`eapi', `hh', `cc', `fwd', `sr')
add(`environment', `hh', `fwd', `cc', `se')
add(`environment_implementation', `hh', `cc', `test')
add(`hashed_containers', `hh', `cc', `test')
-add(`hook', `hh', `cc', `se', `sr')
+add(`hook', `hh', `cc', `fwd',`se', `sr')
add(`hooker', `hh', `cc', `test', `testscript')
add(`host_tuple_name', `hh', `cc', `sr', `test')
add(`mask_reasons', `hh', `cc', `se')
add(`match_package', `hh', `cc')
+add(`metadata_key', `hh', `cc', `fwd')
+add(`metadata_key_raw_printer', `hh', `cc', `fwd')
add(`name', `hh', `cc', `fwd', `test', `sr', `se')
add(`package_database', `hh', `cc', `test', `se')
-add(`package_database_entry', `hh', `cc', `sr')
+add(`package_id', `hh', `cc', `fwd', `se')
add(`paludis', `hh')
add(`portage_dep_lexer', `hh', `cc', `test')
add(`portage_dep_parser', `hh', `cc', `fwd', `se', `test')
add(`query', `hh', `cc')
add(`repository', `hh', `fwd', `cc', `sr')
+add(`repository_info', `hh', `fwd', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
add(`set_file', `hh', `cc', `se', `sr', `test', `testscript')
add(`syncer', `hh', `cc', `sr')
-add(`version_metadata', `hh', `cc', `sr')
add(`version_operator', `hh', `cc', `fwd', `se', `test')
add(`version_requirements', `hh', `cc', `fwd', `sr')
add(`version_spec', `hh', `cc', `sr', `fwd', `test')
diff --git a/paludis/hashed_containers.cc b/paludis/hashed_containers.cc
index 152a46f..57312bf 100644
--- a/paludis/hashed_containers.cc
+++ b/paludis/hashed_containers.cc
@@ -17,7 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "hashed_containers.hh"
+#include <paludis/hashed_containers.hh>
+#include <paludis/name.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/package_id.hh>
+#include <paludis/repository.hh>
/** \file
* Implementation for hashed_containers.hh.
@@ -100,5 +104,24 @@ CRCHash<std::pair<QualifiedPackageName, VersionSpec> >::operator() (
return h;
}
+std::size_t
+CRCHash<PackageID>::operator() (const PackageID & val) const
+{
+ return
+ CRCHash<QualifiedPackageName>()(val.name()) ^
+ (val.version().hash_value() << 5) ^
+ (CRCHash<RepositoryName>()(val.repository()->name()) << 9) ^
+ (val.extra_hash_value() << 13);
+}
+
+#if (! defined(PALUDIS_HASH_IS_STD_TR1_UNORDERED)) && (! defined(PALUDIS_HASH_IS_GNU_CXX_HASH))
+
+bool
+CRCHash<PackageID, PackageID>::operator() (const PackageID & i1, const PackageID & i2) const
+{
+ return PackageIDSetComparator()(i1, i2);
+}
+
+#endif
#endif
diff --git a/paludis/hashed_containers.hh b/paludis/hashed_containers.hh
index 5e01e1a..2a70e08 100644
--- a/paludis/hashed_containers.hh
+++ b/paludis/hashed_containers.hh
@@ -27,9 +27,11 @@
* \ingroup grphashedcontainers
*/
-#include <paludis/name.hh>
#include <paludis/util/validated.hh>
-#include <paludis/version_spec.hh>
+#include <paludis/util/tr1_type_traits.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/version_spec-fwd.hh>
+#include <paludis/package_id-fwd.hh>
#ifdef PALUDIS_HASH_IS_STD_TR1_UNORDERED
# include <tr1/unordered_set>
@@ -188,7 +190,7 @@ namespace paludis
*/
template <>
class PALUDIS_VISIBLE CRCHash<QualifiedPackageName> :
- public std::unary_function<QualifiedPackageName, std::size_t>,
+ public std::unary_function<const QualifiedPackageName, std::size_t>,
protected hashed_containers_internals::CRCHashBase
{
public:
@@ -210,18 +212,43 @@ namespace paludis
};
/**
+ * Hash, for PackageID.
+ *
+ * \ingroup grphashedcontainers
+ */
+ template <>
+ class PALUDIS_VISIBLE CRCHash<PackageID> :
+ public std::unary_function<const PackageID, std::size_t>,
+ protected hashed_containers_internals::CRCHashBase
+ {
+ public:
+ /// Hash function.
+ std::size_t operator() (const PackageID & val) const;
+
+#if (! defined(PALUDIS_HASH_IS_STD_TR1_UNORDERED)) && (! defined(PALUDIS_HASH_IS_GNU_CXX_HASH))
+ enum
+ {
+ min_buckets = 32,
+ bucket_size = 4
+ };
+
+ bool operator() (const PackageID & i1, const PackageID & i2) const;
+#endif
+ };
+
+ /**
* Hash, for a validated string type.
*
* \ingroup grphashedcontainers
*/
- template <typename Validated_>
- class CRCHash<Validated<std::string, Validated_> > :
- public std::unary_function<Validated<std::string, Validated_>, std::size_t>,
+ template <typename Validated_, bool b_>
+ class CRCHash<Validated<std::string, Validated_, b_> > :
+ public std::unary_function<const Validated<std::string, Validated_, b_>, std::size_t>,
protected hashed_containers_internals::CRCHashBase
{
public:
/// Hash function.
- std::size_t operator() (const Validated<std::string, Validated_> & val) const;
+ std::size_t operator() (const Validated<std::string, Validated_, b_> & val) const;
#if (! defined(PALUDIS_HASH_IS_STD_TR1_UNORDERED)) && (! defined(PALUDIS_HASH_IS_GNU_CXX_HASH))
enum
@@ -230,10 +257,10 @@ namespace paludis
bucket_size = 4
};
- bool operator() (const Validated<std::string, Validated_> i1,
- const Validated<std::string, Validated_> & i2) const
+ bool operator() (const Validated<std::string, Validated_, b_> i1,
+ const Validated<std::string, Validated_> & i2, b_) const
{
- return i1 < i2;
+ return i1.data() < i2.data();
}
#endif
};
@@ -246,7 +273,7 @@ namespace paludis
*/
template<>
class PALUDIS_VISIBLE CRCHash<std::string> :
- public std::unary_function<std::string, std::size_t>,
+ public std::unary_function<const std::string, std::size_t>,
protected hashed_containers_internals::CRCHashBase
{
public:
@@ -274,7 +301,7 @@ namespace paludis
*/
template <>
class PALUDIS_VISIBLE CRCHash<std::pair<QualifiedPackageName, VersionSpec> > :
- public std::unary_function<std::pair<QualifiedPackageName, VersionSpec>, std::size_t>,
+ public std::unary_function<const std::pair<const QualifiedPackageName, VersionSpec>, std::size_t>,
protected hashed_containers_internals::CRCHashBase
{
public:
@@ -296,9 +323,40 @@ namespace paludis
#endif
};
- template <typename Validated_>
+ /**
+ * Hash, for a shared pointer.
+ *
+ * \ingroup grphashedcontainers
+ */
+ template <typename T_>
+ class PALUDIS_VISIBLE CRCHash<tr1::shared_ptr<T_> > :
+ public std::unary_function<tr1::shared_ptr<T_>, std::size_t>,
+ protected hashed_containers_internals::CRCHashBase
+ {
+ public:
+ /// Hash function.
+ std::size_t operator() (const tr1::shared_ptr<T_> & val) const
+ {
+ return CRCHash<typename tr1::remove_const<T_>::type>()(*val);
+ }
+
+#if (! defined(PALUDIS_HASH_IS_STD_TR1_UNORDERED)) && (! defined(PALUDIS_HASH_IS_GNU_CXX_HASH))
+ enum
+ {
+ min_buckets = 32,
+ bucket_size = 4
+ };
+
+ bool operator() (const tr1::shared_ptr<T_> & i1, const tr1::shared_ptr<T_> & i2) const
+ {
+ return CRCHash<typename tr1::remove_const<T_>::type>()(*i1, *i2);
+ }
+#endif
+ };
+
+ template <typename Validated_, bool b_>
std::size_t
- CRCHash<Validated<std::string, Validated_> >::operator() (const Validated<std::string, Validated_> & val) const
+ CRCHash<Validated<std::string, Validated_, b_> >::operator() (const Validated<std::string, Validated_, b_> & val) const
{
const std::string & s1(val.data());
std::size_t h(0);
diff --git a/paludis/hashed_containers_TEST.cc b/paludis/hashed_containers_TEST.cc
index 8144b05..db76989 100644
--- a/paludis/hashed_containers_TEST.cc
+++ b/paludis/hashed_containers_TEST.cc
@@ -20,6 +20,7 @@
#include "hashed_containers.hh"
#include <test/test_framework.hh>
#include <test/test_runner.hh>
+#include <paludis/name.hh>
using namespace paludis;
using namespace test;
diff --git a/paludis/hook-fwd.hh b/paludis/hook-fwd.hh
new file mode 100644
index 0000000..fae46eb
--- /dev/null
+++ b/paludis/hook-fwd.hh
@@ -0,0 +1,36 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2007 Piotr JaroszyƄski <peper@gentoo.org>
+ *
+ * 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_HOOK_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_HOOK_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+
+#include <paludis/hook-se.hh>
+
+ class HookResult;
+ class Hook;
+}
+
+#endif
diff --git a/paludis/hook.cc b/paludis/hook.cc
index 99e7d14..94e5f83 100644
--- a/paludis/hook.cc
+++ b/paludis/hook.cc
@@ -24,6 +24,7 @@
#include <paludis/util/stringify.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <map>
+#include <set>
using namespace paludis;
@@ -47,6 +48,35 @@ namespace paludis
{
}
};
+
+ template<>
+ struct Implementation<Hook::AllowedOutputValues>
+ {
+ std::set<std::string> allowed_values;
+ };
+}
+
+Hook::AllowedOutputValues::AllowedOutputValues() :
+ PrivateImplementationPattern<Hook::AllowedOutputValues>(new Implementation<Hook::AllowedOutputValues>)
+{
+}
+
+Hook::AllowedOutputValues::AllowedOutputValues(const AllowedOutputValues & other) :
+ PrivateImplementationPattern<Hook::AllowedOutputValues>(new Implementation<Hook::AllowedOutputValues>)
+{
+ _imp->allowed_values = other._imp->allowed_values;
+}
+
+Hook::AllowedOutputValues::~AllowedOutputValues()
+{
+}
+
+Hook::AllowedOutputValues
+Hook::AllowedOutputValues::operator() (const std::string & v) const
+{
+ AllowedOutputValues result(*this);
+ result._imp->allowed_values.insert(v);
+ return result;
}
Hook::Hook(const std::string & n) :
@@ -90,7 +120,7 @@ Hook::grab_output(const AllowedOutputValues & av)
{
Hook result(*this);
result.output_dest = hod_grab;
- result._imp->allowed_values = av.allowed_values;
+ result._imp->allowed_values = av._imp->allowed_values;
return result;
}
@@ -121,23 +151,3 @@ Hook::name() const
return _imp->name;
}
-Hook::AllowedOutputValues::AllowedOutputValues()
-{
-}
-
-Hook::AllowedOutputValues::AllowedOutputValues(const AllowedOutputValues & other) :
- allowed_values(other.allowed_values)
-{
-}
-
-Hook::AllowedOutputValues::~AllowedOutputValues()
-{
-}
-
-Hook::AllowedOutputValues
-Hook::AllowedOutputValues::operator() (const std::string & v) const
-{
- AllowedOutputValues result(*this);
- result.allowed_values.insert(v);
- return result;
-}
diff --git a/paludis/hook.hh b/paludis/hook.hh
index 5f626d9..aca5fec 100644
--- a/paludis/hook.hh
+++ b/paludis/hook.hh
@@ -21,18 +21,19 @@
#ifndef PALUDIS_GUARD_PALUDIS_HOOK_HH
#define PALUDIS_GUARD_PALUDIS_HOOK_HH 1
+#include <paludis/hook-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/operators.hh>
-#include <utility>
+
#include <string>
-#include <set>
#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh>
namespace paludis
{
-#include <paludis/hook-se.hh>
+
#include <paludis/hook-sr.hh>
+
/**
* Represents the data for an Environment hook call.
*
@@ -88,12 +89,10 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
};
- class PALUDIS_VISIBLE Hook::AllowedOutputValues
+ class PALUDIS_VISIBLE Hook::AllowedOutputValues :
+ private PrivateImplementationPattern<Hook::AllowedOutputValues>
{
- private:
- friend class Hook;
-
- std::set<std::string> allowed_values;
+ friend class Hook;
public:
AllowedOutputValues();
diff --git a/paludis/hooker_TEST.cc b/paludis/hooker_TEST.cc
index a46bbf9..429c46c 100644
--- a/paludis/hooker_TEST.cc
+++ b/paludis/hooker_TEST.cc
@@ -20,6 +20,7 @@
#include <paludis/hooker.hh>
#include <paludis/hook.hh>
#include <paludis/environments/test/test_environment.hh>
+#include <paludis/util/fs_entry.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
#include <fstream>
diff --git a/paludis/mask_reasons.se b/paludis/mask_reasons.se
index d0f5839..4af4070 100644
--- a/paludis/mask_reasons.se
+++ b/paludis/mask_reasons.se
@@ -13,7 +13,6 @@ make_enum_MaskReason()
key mr_by_association "masked by association with another package (for virtuals)"
key mr_chost "masked by chost"
key mr_breaks_portage "masked because it will break portage"
- key mr_interactive "interactive"
key mr_license "unaccepted license"
doxygen_comment << "END"
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index 2039adb..963f9a8 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -20,9 +20,9 @@
#include <paludis/match_package.hh>
#include <paludis/dep_spec.hh>
#include <paludis/environment.hh>
-#include <paludis/version_metadata.hh>
#include <paludis/version_requirements.hh>
#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/visitor-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <algorithm>
@@ -33,15 +33,15 @@ bool
paludis::match_package(
const Environment & env,
const PackageDepSpec & spec,
- const PackageDatabaseEntry & entry)
+ const PackageID & entry)
{
- if (spec.package_ptr() && *spec.package_ptr() != entry.name)
+ if (spec.package_ptr() && *spec.package_ptr() != entry.name())
return false;
- if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != entry.name.package)
+ if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != entry.name().package)
return false;
- if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != entry.name.category)
+ if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != entry.name().category)
return false;
if (spec.version_requirements_ptr())
@@ -50,7 +50,7 @@ paludis::match_package(
case vr_and:
for (VersionRequirements::Iterator r(spec.version_requirements_ptr()->begin()),
r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r)
- if (! r->version_operator.as_version_spec_comparator()(entry.version, r->version_spec))
+ if (! r->version_operator.as_version_spec_comparator()(entry.version(), r->version_spec))
return false;
break;
@@ -59,7 +59,7 @@ paludis::match_package(
bool matched(false);
for (VersionRequirements::Iterator r(spec.version_requirements_ptr()->begin()),
r_end(spec.version_requirements_ptr()->end()) ; r != r_end ; ++r)
- if (r->version_operator.as_version_spec_comparator()(entry.version, r->version_spec))
+ if (r->version_operator.as_version_spec_comparator()(entry.version(), r->version_spec))
{
matched = true;
break;
@@ -75,44 +75,37 @@ paludis::match_package(
}
if (spec.repository_ptr())
- if (*spec.repository_ptr() != entry.repository)
+ if (*spec.repository_ptr() != entry.repository()->name())
return false;
- if (spec.slot_ptr() || spec.use_requirements_ptr())
- {
- tr1::shared_ptr<const VersionMetadata> metadata(env.package_database()->fetch_repository(
- entry.repository)->version_metadata(
- entry.name, entry.version));
-
- if (spec.slot_ptr())
- if (*spec.slot_ptr() != SlotName(metadata->slot))
- return false;
+ if (spec.slot_ptr())
+ if (*spec.slot_ptr() != entry.slot())
+ return false;
- if (spec.use_requirements_ptr())
+ if (spec.use_requirements_ptr())
+ {
+ for (UseRequirements::Iterator u(spec.use_requirements_ptr()->begin()),
+ u_end(spec.use_requirements_ptr()->end()) ; u != u_end ; ++u)
{
- for (UseRequirements::Iterator u(spec.use_requirements_ptr()->begin()),
- u_end(spec.use_requirements_ptr()->end()) ; u != u_end ; ++u)
+ switch (u->second)
{
- switch (u->second)
- {
- case use_unspecified:
- continue;
+ case use_unspecified:
+ continue;
- case use_enabled:
- if (! env.query_use(u->first, entry))
- return false;
- continue;
+ case use_enabled:
+ if (! env.query_use(u->first, entry))
+ return false;
+ continue;
- case use_disabled:
- if (env.query_use(u->first, entry))
- return false;
- continue;
+ case use_disabled:
+ if (env.query_use(u->first, entry))
+ return false;
+ continue;
- case last_use:
- ;
- }
- throw InternalError(PALUDIS_HERE, "bad UseFlagState");
+ case last_use:
+ ;
}
+ throw InternalError(PALUDIS_HERE, "bad UseFlagState");
}
}
@@ -122,12 +115,11 @@ paludis::match_package(
namespace
{
struct IsInHeirarchy :
- ConstVisitor<SetSpecTree>,
- std::unary_function<PackageDatabaseEntry, bool>
+ ConstVisitor<SetSpecTree>
{
const Environment & env;
const SetSpecTree::ConstItem & target;
- const PackageDatabaseEntry * dbe;
+ const PackageID * id;
bool matched;
IsInHeirarchy(const Environment & e, const SetSpecTree::ConstItem & t) :
@@ -137,9 +129,9 @@ namespace
{
}
- bool operator() (const PackageDatabaseEntry & e)
+ bool operator() (const PackageID & e)
{
- dbe = &e;
+ id = &e;
matched = false;
target.accept(*this);
return matched;
@@ -160,7 +152,7 @@ namespace
if (matched)
return;
- if (match_package(env, a, *dbe))
+ if (match_package(env, a, *id))
matched = true;
}
};
@@ -170,7 +162,7 @@ bool
paludis::match_package_in_set(
const Environment & env,
const SetSpecTree::ConstItem & target,
- const PackageDatabaseEntry & entry)
+ const PackageID & entry)
{
IsInHeirarchy h(env, target);
return h(entry);
diff --git a/paludis/match_package.hh b/paludis/match_package.hh
index b88f134..c1541c8 100644
--- a/paludis/match_package.hh
+++ b/paludis/match_package.hh
@@ -16,12 +16,11 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/tr1_memory.hh>
#include <paludis/dep_spec-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
namespace paludis
{
- class Environment;
- class PackageDatabaseEntry;
-
/**
* Return whether the specified spec matches the specified target.
*
@@ -30,7 +29,7 @@ namespace paludis
bool match_package(
const Environment & env,
const PackageDepSpec & spec,
- const PackageDatabaseEntry & target)
+ const PackageID & target)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
/**
@@ -41,7 +40,7 @@ namespace paludis
bool match_package_in_set(
const Environment & env,
const SetSpecTree::ConstItem & spec,
- const PackageDatabaseEntry & target)
+ const PackageID & target)
PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
}
diff --git a/paludis/merger/merger_TEST.cc b/paludis/merger/merger_TEST.cc
index 8afdd1b..c92c725 100644
--- a/paludis/merger/merger_TEST.cc
+++ b/paludis/merger/merger_TEST.cc
@@ -20,6 +20,7 @@
#include "merger.hh"
#include <paludis/environments/test/test_environment.hh>
#include <paludis/hooker.hh>
+#include <paludis/hook.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <fstream>
diff --git a/paludis/metadata_key-fwd.hh b/paludis/metadata_key-fwd.hh
new file mode 100644
index 0000000..ac9f07c
--- /dev/null
+++ b/paludis/metadata_key-fwd.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_METADATA_KEY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_METADATA_KEY_FWD_HH 1
+
+namespace paludis
+{
+ class MetadataKeyVisitorTypes;
+
+ class MetadataKey;
+ class MetadataPackageIDKey;
+ class MetadataStringKey;
+ template <typename C_> class MetadataCollectionKey;
+ template <typename C_> class MetadataSpecTreeKey;
+}
+
+#endif
diff --git a/paludis/metadata_key.cc b/paludis/metadata_key.cc
new file mode 100644
index 0000000..84f8671
--- /dev/null
+++ b/paludis/metadata_key.cc
@@ -0,0 +1,95 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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 "metadata_key.hh"
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<MetadataKey>
+ {
+ const std::string raw_name;
+ const std::string human_name;
+
+ Implementation(const std::string & r, const std::string & h) :
+ raw_name(r),
+ human_name(h)
+ {
+ }
+ };
+}
+
+MetadataKey::MetadataKey(const std::string & r, const std::string & h) :
+ PrivateImplementationPattern<MetadataKey>(new Implementation<MetadataKey>(r, h))
+{
+}
+
+MetadataKey::~MetadataKey()
+{
+}
+
+const std::string
+MetadataKey::raw_name() const
+{
+ return _imp->raw_name;
+}
+
+const std::string
+MetadataKey::human_name() const
+{
+ return _imp->human_name;
+}
+
+MetadataStringKey::MetadataStringKey(const std::string & r, const std::string & h) :
+ MetadataKey(r, h)
+{
+}
+
+MetadataPackageIDKey::MetadataPackageIDKey(const std::string & r, const std::string & h) :
+ MetadataKey(r, h)
+{
+}
+
+template <typename C_>
+MetadataCollectionKey<C_>::MetadataCollectionKey(const std::string & r, const std::string & h) :
+ MetadataKey(r, h)
+{
+}
+
+template <typename C_>
+MetadataSpecTreeKey<C_>::MetadataSpecTreeKey(const std::string & r, const std::string & h) :
+ MetadataKey(r, h)
+{
+}
+
+template class MetadataCollectionKey<KeywordNameCollection>;
+template class MetadataCollectionKey<IUseFlagCollection>;
+template class MetadataCollectionKey<InheritedCollection>;
+template class MetadataCollectionKey<UseFlagNameCollection>;
+
+template class MetadataSpecTreeKey<LicenseSpecTree>;
+template class MetadataSpecTreeKey<ProvideSpecTree>;
+template class MetadataSpecTreeKey<DependencySpecTree>;
+template class MetadataSpecTreeKey<RestrictSpecTree>;
+template class MetadataSpecTreeKey<URISpecTree>;
+
diff --git a/paludis/metadata_key.hh b/paludis/metadata_key.hh
new file mode 100644
index 0000000..5be3f60
--- /dev/null
+++ b/paludis/metadata_key.hh
@@ -0,0 +1,120 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_METADATA_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_METADATA_KEY_HH 1
+
+#include <paludis/metadata_key-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/visitor.hh>
+#include <string>
+
+namespace paludis
+{
+ struct MetadataKeyVisitorTypes :
+ VisitorTypes<
+ MetadataKeyVisitorTypes,
+ MetadataKey,
+ MetadataPackageIDKey,
+ MetadataCollectionKey<UseFlagNameCollection>,
+ MetadataCollectionKey<IUseFlagCollection>,
+ MetadataCollectionKey<KeywordNameCollection>,
+ MetadataCollectionKey<InheritedCollection>,
+ MetadataSpecTreeKey<DependencySpecTree>,
+ MetadataSpecTreeKey<LicenseSpecTree>,
+ MetadataSpecTreeKey<URISpecTree>,
+ MetadataSpecTreeKey<ProvideSpecTree>,
+ MetadataSpecTreeKey<RestrictSpecTree>,
+ MetadataStringKey
+ >
+ {
+ };
+
+ class PALUDIS_VISIBLE MetadataKey :
+ private InstantiationPolicy<MetadataKey, instantiation_method::NonCopyableTag>,
+ private PrivateImplementationPattern<MetadataKey>,
+ public virtual ConstAcceptInterface<MetadataKeyVisitorTypes>
+ {
+ protected:
+ MetadataKey(const std::string &, const std::string &);
+
+ public:
+ virtual ~MetadataKey() = 0;
+
+ virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE MetadataPackageIDKey :
+ public MetadataKey,
+ public ConstAcceptInterfaceVisitsThis<MetadataKeyVisitorTypes, MetadataPackageIDKey>
+ {
+ protected:
+ MetadataPackageIDKey(const std::string &, const std::string &);
+
+ public:
+ virtual const tr1::shared_ptr<const PackageID> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ class PALUDIS_VISIBLE MetadataStringKey :
+ public MetadataKey,
+ public ConstAcceptInterfaceVisitsThis<MetadataKeyVisitorTypes, MetadataStringKey>
+ {
+ protected:
+ MetadataStringKey(const std::string &, const std::string &);
+
+ public:
+ virtual const std::string value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <typename C_>
+ class PALUDIS_VISIBLE MetadataCollectionKey :
+ public MetadataKey,
+ public ConstAcceptInterfaceVisitsThis<MetadataKeyVisitorTypes, MetadataCollectionKey<C_> >
+ {
+ protected:
+ MetadataCollectionKey(const std::string &, const std::string &);
+
+ public:
+ virtual const tr1::shared_ptr<const C_> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <typename C_>
+ class PALUDIS_VISIBLE MetadataSpecTreeKey :
+ public MetadataKey,
+ public ConstAcceptInterfaceVisitsThis<MetadataKeyVisitorTypes, MetadataSpecTreeKey<C_> >
+ {
+ protected:
+ MetadataSpecTreeKey(const std::string &, const std::string &);
+
+ public:
+ virtual const tr1::shared_ptr<const typename C_::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+}
+
+#endif
diff --git a/paludis/metadata_key_raw_printer-fwd.hh b/paludis/metadata_key_raw_printer-fwd.hh
new file mode 100644
index 0000000..abaf703
--- /dev/null
+++ b/paludis/metadata_key_raw_printer-fwd.hh
@@ -0,0 +1,33 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_METADATA_KEY_RAW_PRINTER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_METADATA_KEY_RAW_PRINTER_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ class MetadataKeyRawPrinter;
+
+ std::ostream & operator<< (std::ostream &, const MetadataKeyRawPrinter &) PALUDIS_VISIBLE;
+}
+
+#endif
diff --git a/paludis/repositories/virtuals/vr_entry.cc b/paludis/metadata_key_raw_printer.cc
index 866ca20..50126be 100644
--- a/paludis/repositories/virtuals/vr_entry.cc
+++ b/paludis/metadata_key_raw_printer.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -17,9 +17,7 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "vr_entry.hh"
+#include "metadata_key_raw_printer.hh"
using namespace paludis;
-#include <paludis/repositories/virtuals/vr_entry-sr.cc>
-
diff --git a/paludis/metadata_key_raw_printer.hh b/paludis/metadata_key_raw_printer.hh
new file mode 100644
index 0000000..7a3928d
--- /dev/null
+++ b/paludis/metadata_key_raw_printer.hh
@@ -0,0 +1,54 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_METADATA_KEY_RAW_PRINTER_HH
+#define PALUDIS_GUARD_PALUDIS_METADATA_KEY_RAW_PRINTER_HH 1
+
+#include <paludis/metadata_key_raw_printer-fwd.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/visitor.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ class MetadataKeyRawPrinter :
+ public ConstVisitor<MetadataKeyVisitorTypes>,
+ private PrivateImplementationPattern<MetadataKeyRawPrinter>
+ {
+ friend std::ostream & operator<< (std::ostream &, const MetadataKeyRawPrinter &);
+
+ public:
+ MetadataKeyRawPrinter();
+ ~MetadataKeyRawPrinter();
+
+ void visit(const MetadataCollectionKey<IUseFlagCollection> &);
+ void visit(const MetadataCollectionKey<InheritedCollection> &);
+ void visit(const MetadataCollectionKey<UseFlagNameCollection> &);
+ void visit(const MetadataCollectionKey<KeywordNameCollection> &);
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> &);
+ void visit(const MetadataSpecTreeKey<URISpecTree> &);
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> &);
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> &);
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> &);
+ void visit(const MetadataPackageIDKey &);
+ void visit(const MetadataStringKey &);
+ };
+}
+
+#endif
diff --git a/paludis/name.sr b/paludis/name.sr
index 4c6bed5..c65e9e0 100644
--- a/paludis/name.sr
+++ b/paludis/name.sr
@@ -11,7 +11,7 @@ make_class_QualifiedPackageName()
comparison_operators all all
extra_constructors <<END
- QualifiedPackageName(const std::string &);
+ explicit QualifiedPackageName(const std::string &);
END
doxygen_comment << "END"
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index d6c6ad9..c8425c3 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -23,6 +23,7 @@
#include <paludis/util/iterator.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/join.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/query.hh>
@@ -41,13 +42,6 @@ using namespace paludis;
#include "package_database-se.cc"
-std::ostream &
-paludis::operator<< (std::ostream & s, const PackageDatabaseEntry & v)
-{
- s << v.name << "-" << v.version << "::" << v.repository;
- return s;
-}
-
PackageDatabaseError::PackageDatabaseError(const std::string & our_message) throw () :
Exception(our_message)
{
@@ -69,6 +63,14 @@ NoSuchPackageError::NoSuchPackageError(const std::string & our_name) throw () :
{
}
+NonUniqueQueryResultError::NonUniqueQueryResultError(const Query & q,
+ const tr1::shared_ptr<const PackageIDSequence> & r) throw () :
+ PackageDatabaseLookupError("Query '" + stringify(q) + "' returned " +
+ (r->empty() ? "empty result set" : "'" + join(indirect_iterator(r->begin()), indirect_iterator(r->end()), " ")
+ + "'") + " but qo_require_exactly_one was specified")
+{
+}
+
NoSuchRepositoryError::NoSuchRepositoryError(const std::string & n) throw () :
PackageDatabaseLookupError("Could not find repository '" + n + "'"),
_name("UNKNOWN")
@@ -233,56 +235,22 @@ PackageDatabase::fetch_unique_qualified_package_name(
return *(result->begin());
}
-tr1::shared_ptr<PackageDatabaseEntryCollection>
-PackageDatabase::query(const PackageDepSpec & a, const InstallState installed_state,
- const QueryOrder query_order) const
-{
- switch (installed_state)
- {
- case is_installed_only:
- return query(query::Matches(a) & query::RepositoryHasInstalledInterface(), query_order);
-
- case is_installable_only:
- return query(query::Matches(a) & query::RepositoryHasInstallableInterface(), query_order);
-
- case is_any:
- return query(query::Matches(a), query_order);
-
- case last_is:
- ;
- }
-
- throw InternalError(PALUDIS_HERE, "Bad InstallState");
-}
-
namespace
{
- bool compare_name(const PackageDatabaseEntry & a, const PackageDatabaseEntry & b)
+ bool compare_name(const tr1::shared_ptr<const PackageID> & a,
+ const tr1::shared_ptr<const PackageID> & b)
{
- return a.name == b.name;
+ return a->name() == b->name();
}
- struct CompareNameSlot
+ bool compare_name_slot(const tr1::shared_ptr<const PackageID> & a,
+ const tr1::shared_ptr<const PackageID> & b)
{
- const PackageDatabase * const db;
-
- CompareNameSlot(const PackageDatabase * const d) :
- db(d)
- {
- }
-
- bool operator() (const PackageDatabaseEntry & a, const PackageDatabaseEntry & b) const
- {
- if (a.name != b.name)
- return false;
-
- tr1::shared_ptr<const VersionMetadata>
- ma(db->fetch_repository(a.repository)->version_metadata(a.name, a.version)),
- mb(db->fetch_repository(b.repository)->version_metadata(b.name, b.version));
+ if (a->name() != b->name())
+ return false;
- return ma->slot == mb->slot;
- }
- };
+ return a->slot() == b->slot();
+ }
struct PDEComparator
{
@@ -298,25 +266,26 @@ namespace
rank.insert(std::make_pair(stringify((*r)->name()), ++x));
}
- bool operator() (const PackageDatabaseEntry & lhs, const PackageDatabaseEntry & rhs) const
+ bool operator() (const tr1::shared_ptr<const PackageID> & lhs,
+ const tr1::shared_ptr<const PackageID> & rhs) const
{
- if (lhs.name < rhs.name)
+ if (lhs->name() < rhs->name())
return true;
- if (lhs.name > rhs.name)
+ if (lhs->name() > rhs->name())
return false;
- if (lhs.version < rhs.version)
+ if (lhs->version() < rhs->version())
return true;
- if (lhs.version > rhs.version)
+ if (lhs->version() > rhs->version())
return false;
- std::map<std::string, int>::const_iterator l(rank.find(stringify(lhs.repository)));
+ std::map<std::string, int>::const_iterator l(rank.find(stringify(lhs->repository()->name())));
if (l == rank.end())
- throw InternalError(PALUDIS_HERE, "lhs.repository '" + stringify(lhs.repository) + "' not in rank");
+ throw InternalError(PALUDIS_HERE, "lhs.repository '" + stringify(lhs->repository()->name()) + "' not in rank");
- std::map<std::string, int>::const_iterator r(rank.find(stringify(rhs.repository)));
+ std::map<std::string, int>::const_iterator r(rank.find(stringify(rhs->repository()->name())));
if (r == rank.end())
- throw InternalError(PALUDIS_HERE, "rhs.repository '" + stringify(rhs.repository) + "' not in rank");
+ throw InternalError(PALUDIS_HERE, "rhs.repository '" + stringify(rhs->repository()->name()) + "' not in rank");
if (l->second < r->second)
return true;
@@ -326,32 +295,28 @@ namespace
};
void sort_package_database_entry_collection(const PackageDatabase * const t,
- PackageDatabaseEntryCollection::Concrete & p)
+ PackageIDSequence::Concrete & p)
{
if (! p.empty())
p.sort(PDEComparator(t));
}
void
- group_package_database_entry_collection(const PackageDatabase * const t,
- PackageDatabaseEntryCollection::Concrete & p)
+ group_package_database_entry_collection(PackageIDSequence::Concrete & p)
{
if (p.empty())
return;
- for (std::list<PackageDatabaseEntry>::reverse_iterator r(p.list.rbegin()) ;
+ for (std::list<tr1::shared_ptr<const PackageID> >::reverse_iterator r(p.list.rbegin()) ;
r != p.list.rend() ; ++r)
{
- SlotName r_slot(t->fetch_repository(r->repository)->version_metadata(r->name, r->version)->slot);
-
- for (std::list<PackageDatabaseEntry>::reverse_iterator rr(next(r)) ;
+ for (std::list<tr1::shared_ptr<const PackageID> >::reverse_iterator rr(next(r)) ;
rr != p.list.rend() ; ++rr)
{
- if (r->name != rr->name)
+ if ((*r)->name() != (*rr)->name())
break;
- SlotName rr_slot(t->fetch_repository(rr->repository)->version_metadata(rr->name, rr->version)->slot);
- if (rr_slot != r_slot)
+ if ((*r)->slot() != (*rr)->slot())
continue;
p.list.splice(previous(r.base()), p.list, previous(rr.base()));
@@ -362,10 +327,10 @@ namespace
}
}
-tr1::shared_ptr<PackageDatabaseEntryCollection>
+const tr1::shared_ptr<const PackageIDSequence>
PackageDatabase::query(const Query & q, const QueryOrder query_order) const
{
- tr1::shared_ptr<PackageDatabaseEntryCollection::Concrete> result(new PackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSequence::Concrete> result(new PackageIDSequence::Concrete);
tr1::shared_ptr<RepositoryNameCollection> repos(q.repositories(*_imp->environment));
if (! repos)
@@ -376,7 +341,10 @@ PackageDatabase::query(const Query & q, const QueryOrder query_order) const
repos->push_back((*r)->name());
}
if (repos->empty())
- return result;
+ if (qo_require_exactly_one == query_order)
+ throw NonUniqueQueryResultError(q, result);
+ else
+ return result;
tr1::shared_ptr<CategoryNamePartCollection> cats(q.categories(*_imp->environment, repos));
if (! cats)
@@ -390,7 +358,10 @@ PackageDatabase::query(const Query & q, const QueryOrder query_order) const
}
}
if (cats->empty())
- return result;
+ if (qo_require_exactly_one == query_order)
+ throw NonUniqueQueryResultError(q, result);
+ else
+ return result;
tr1::shared_ptr<QualifiedPackageNameCollection> pkgs(q.packages(*_imp->environment, repos, cats));
if (! pkgs)
@@ -406,28 +377,32 @@ PackageDatabase::query(const Query & q, const QueryOrder query_order) const
}
}
if (pkgs->empty())
- return result;
+ if (qo_require_exactly_one == query_order)
+ throw NonUniqueQueryResultError(q, result);
+ else
+ return result;
- tr1::shared_ptr<PackageDatabaseEntryCollection> pdes(q.versions(*_imp->environment, repos, pkgs));
- if (! pdes)
+ tr1::shared_ptr<PackageIDSequence> ids(q.ids(*_imp->environment, repos, pkgs));
+ if (! ids)
{
for (RepositoryNameCollection::Iterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
for (QualifiedPackageNameCollection::Iterator p(pkgs->begin()), p_end(pkgs->end()) ;
p != p_end ; ++p)
{
- tr1::shared_ptr<const VersionSpecCollection> local_vers(fetch_repository(*r)->version_specs(*p));
- for (VersionSpecCollection::Iterator v(local_vers->begin()), v_end(local_vers->end()) ;
- v != v_end ; ++v)
- result->push_back(PackageDatabaseEntry(*p, *v, *r));
+ tr1::shared_ptr<const PackageIDSequence> local_ids(fetch_repository(*r)->package_ids(*p));
+ std::copy(local_ids->begin(), local_ids->end(), result->inserter());
}
}
else
{
- if (pdes->empty())
- return result;
+ if (ids->empty())
+ if (qo_require_exactly_one == query_order)
+ throw NonUniqueQueryResultError(q, result);
+ else
+ return result;
- std::copy(pdes->begin(), pdes->end(), result->inserter());
+ std::copy(ids->begin(), ids->end(), result->inserter());
}
do
@@ -440,13 +415,13 @@ PackageDatabase::query(const Query & q, const QueryOrder query_order) const
case qo_group_by_slot:
sort_package_database_entry_collection(this, *result);
- group_package_database_entry_collection(this, *result);
+ group_package_database_entry_collection(*result);
continue;
case qo_best_version_only:
{
sort_package_database_entry_collection(this, *result);
- std::list<PackageDatabaseEntry> l;
+ std::list<tr1::shared_ptr<const PackageID> > l;
std::unique_copy(result->list.rbegin(), result->list.rend(),
std::front_inserter(l), &compare_name);
result->list.swap(l);
@@ -456,14 +431,19 @@ PackageDatabase::query(const Query & q, const QueryOrder query_order) const
case qo_best_version_in_slot_only:
{
sort_package_database_entry_collection(this, *result);
- group_package_database_entry_collection(this, *result);
- std::list<PackageDatabaseEntry> l;
+ group_package_database_entry_collection(*result);
+ std::list<tr1::shared_ptr<const PackageID> > l;
std::unique_copy(result->list.rbegin(), result->list.rend(),
- std::front_inserter(l), CompareNameSlot(this));
+ std::front_inserter(l), &compare_name_slot);
result->list.swap(l);
}
continue;
+ case qo_require_exactly_one:
+ if (result->empty() || (next(result->begin()) != result->end()))
+ throw NonUniqueQueryResultError(q, result);
+ continue;
+
case qo_whatever:
continue;
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index 60fa60c..145440d 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -30,9 +30,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/collection-fwd.hh>
-#include <paludis/version_metadata.hh>
#include <paludis/version_spec.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/contents.hh>
#include <iosfwd>
@@ -181,6 +179,23 @@ namespace paludis
};
/**
+ * Thrown if a PackageDatabase::query() with qo_require_exactly_one does not
+ * get exactly one result.
+ *
+ * \ingroup grpexceptions
+ * \ingroup grppackagedatabase
+ */
+ class PALUDIS_VISIBLE NonUniqueQueryResultError :
+ public PackageDatabaseLookupError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ NonUniqueQueryResultError(const Query &, const tr1::shared_ptr<const PackageIDSequence> &) throw ();
+ };
+
+ /**
* Thrown if there is no Repository in a RepositoryDatabase with the given
* name.
*
@@ -297,19 +312,8 @@ namespace paludis
/**
* Query the repository.
- *
- * \deprecated use the Query form
- */
- tr1::shared_ptr<PackageDatabaseEntryCollection> query(
- const PackageDepSpec & a,
- const InstallState,
- const QueryOrder) const
- PALUDIS_ATTRIBUTE((deprecated)) PALUDIS_ATTRIBUTE((warn_unused_result));
-
- /**
- * Query the repository.
*/
- tr1::shared_ptr<PackageDatabaseEntryCollection> query(
+ const tr1::shared_ptr<const PackageIDSequence> query(
const Query &, const QueryOrder) const
PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/package_database.se b/paludis/package_database.se
index 84d2858..6ce1d87 100644
--- a/paludis/package_database.se
+++ b/paludis/package_database.se
@@ -9,6 +9,7 @@ make_enum_QueryOrder()
key qo_group_by_slot "Order by version, with like slots grouped"
key qo_best_version_only "Only the best version"
key qo_best_version_in_slot_only "Only the best version in each slot"
+ key qo_require_exactly_one "Throw if there is not exactly one result"
key qo_whatever "Arbitrary ordering"
doxygen_comment << "END"
diff --git a/paludis/package_database_TEST.cc b/paludis/package_database_TEST.cc
index aed6329..a8188ce 100644
--- a/paludis/package_database_TEST.cc
+++ b/paludis/package_database_TEST.cc
@@ -17,9 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/paludis.hh>
+#include <paludis/package_database.hh>
+#include <paludis/query.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <test/test_framework.hh>
@@ -116,44 +118,51 @@ namespace test_cases
TEST_CHECK(true);
PackageDepSpec d1("r1c1/r1c1p1", pds_pm_permissive);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q1(p.query(
+ 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);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q2(p.query(
+ 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);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q3(p.query(
+ 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);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q4(p.query(
+ 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);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q5(p.query(
+ 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);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q6(p.query(
+ 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);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q7(p.query(
+ 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);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q8(p.query(
+ 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);
+ const tr1::shared_ptr<const PackageIDSequence> q9(p.query(
+ query::Matches(d9) & query::RepositoryHasInstallableInterface(), qo_order_by_version));
+ TEST_CHECK_EQUAL(std::distance(q9->begin(), q9->end()), 1);
}
} package_database_query_test;
@@ -167,59 +176,61 @@ namespace test_cases
PackageDatabase & p(*e.package_database());
tr1::shared_ptr<FakeRepository> r1(new FakeRepository(&e, RepositoryName("repo1")));
- r1->add_version("cat", "pkg", "1")->slot = SlotName("a");
- r1->add_version("cat", "pkg", "2")->slot = SlotName("c");
- r1->add_version("cat", "pkg", "3")->slot = SlotName("c");
- r1->add_version("cat", "pkg", "4")->slot = SlotName("a");
+ r1->add_version("cat", "pkg", "1")->set_slot(SlotName("a"));
+ r1->add_version("cat", "pkg", "2")->set_slot(SlotName("c"));
+ r1->add_version("cat", "pkg", "3")->set_slot(SlotName("c"));
+ r1->add_version("cat", "pkg", "4")->set_slot(SlotName("a"));
p.add_repository(10, r1);
TEST_CHECK(true);
tr1::shared_ptr<FakeRepository> r2(new FakeRepository(&e, RepositoryName("repo2")));
- r2->add_version("cat", "pkg", "1")->slot = SlotName("a");
- r2->add_version("cat", "pkg", "3")->slot = SlotName("b");
+ r2->add_version("cat", "pkg", "1")->set_slot(SlotName("a"));
+ r2->add_version("cat", "pkg", "3")->set_slot(SlotName("b"));
p.add_repository(5, r2);
TEST_CHECK(true);
PackageDepSpec d("cat/pkg", pds_pm_permissive);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q1(p.query(d, is_any, qo_order_by_version));
- TEST_CHECK_EQUAL(join(q1->begin(), q1->end(), " "),
- "cat/pkg-1::repo2 cat/pkg-1::repo1 cat/pkg-2::repo1 cat/pkg-3::repo2 cat/pkg-3::repo1 cat/pkg-4::repo1");
+ 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()), " "),
+ "cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-2:c::repo1 cat/pkg-3:b::repo2 cat/pkg-3:c::repo1 cat/pkg-4:a::repo1");
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q2(p.query(d, is_any, qo_group_by_slot));
- TEST_CHECK_EQUAL(join(q2->begin(), q2->end(), " "),
- "cat/pkg-3::repo2 cat/pkg-2::repo1 cat/pkg-3::repo1 cat/pkg-1::repo2 cat/pkg-1::repo1 cat/pkg-4::repo1");
+ const tr1::shared_ptr<const PackageIDSequence> q2(p.query(query::Matches(d), qo_group_by_slot));
+ TEST_CHECK_EQUAL(join(indirect_iterator(q2->begin()), indirect_iterator(q2->end()), " "),
+ "cat/pkg-3:b::repo2 cat/pkg-2:c::repo1 cat/pkg-3:c::repo1 cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-4:a::repo1");
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q3(p.query(d, is_any, qo_best_version_only));
- TEST_CHECK_EQUAL(join(q3->begin(), q3->end(), " "),
- "cat/pkg-4::repo1");
+ const tr1::shared_ptr<const PackageIDSequence> q3(p.query(query::Matches(d), qo_best_version_only));
+ TEST_CHECK_EQUAL(join(indirect_iterator(q3->begin()), indirect_iterator(q3->end()), " "),
+ "cat/pkg-4:a::repo1");
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q4(p.query(d, is_any, qo_best_version_in_slot_only));
- TEST_CHECK_EQUAL(join(q4->begin(), q4->end(), " "),
- "cat/pkg-3::repo2 cat/pkg-3::repo1 cat/pkg-4::repo1");
+ const tr1::shared_ptr<const PackageIDSequence> q4(p.query(query::Matches(d), qo_best_version_in_slot_only));
+ TEST_CHECK_EQUAL(join(indirect_iterator(q4->begin()), indirect_iterator(q4->end()), " "),
+ "cat/pkg-3:b::repo2 cat/pkg-3:c::repo1 cat/pkg-4:a::repo1");
tr1::shared_ptr<FakeRepository> r3(new FakeRepository(&e, RepositoryName("repo3")));
- r3->add_version("cat", "other", "1")->slot = SlotName("a");
+ r3->add_version("cat", "other", "1")->set_slot(SlotName("a"));
p.add_repository(5, r3);
TEST_CHECK(true);
PackageDepSpec c("cat/*", pds_pm_unspecific);
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q5(p.query(c, is_any, qo_order_by_version));
- TEST_CHECK_EQUAL(join(q5->begin(), q5->end(), " "),
- "cat/other-1::repo3 cat/pkg-1::repo2 cat/pkg-1::repo1 cat/pkg-2::repo1 cat/pkg-3::repo2 cat/pkg-3::repo1 cat/pkg-4::repo1");
+ 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()), " "),
+ "cat/other-1:a::repo3 cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-2:c::repo1 "
+ "cat/pkg-3:b::repo2 cat/pkg-3:c::repo1 cat/pkg-4:a::repo1");
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q6(p.query(c, is_any, qo_group_by_slot));
- TEST_CHECK_EQUAL(join(q6->begin(), q6->end(), " "),
- "cat/other-1::repo3 cat/pkg-3::repo2 cat/pkg-2::repo1 cat/pkg-3::repo1 cat/pkg-1::repo2 cat/pkg-1::repo1 cat/pkg-4::repo1");
+ const tr1::shared_ptr<const PackageIDSequence> q6(p.query(query::Matches(c), qo_group_by_slot));
+ TEST_CHECK_EQUAL(join(indirect_iterator(q6->begin()), indirect_iterator(q6->end()), " "),
+ "cat/other-1:a::repo3 cat/pkg-3:b::repo2 cat/pkg-2:c::repo1 cat/pkg-3:c::repo1 "
+ "cat/pkg-1:a::repo2 cat/pkg-1:a::repo1 cat/pkg-4:a::repo1");
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q7(p.query(c, is_any, qo_best_version_only));
- TEST_CHECK_EQUAL(join(q7->begin(), q7->end(), " "),
- "cat/other-1::repo3 cat/pkg-4::repo1");
+ const tr1::shared_ptr<const PackageIDSequence> q7(p.query(query::Matches(c), qo_best_version_only));
+ TEST_CHECK_EQUAL(join(indirect_iterator(q7->begin()), indirect_iterator(q7->end()), " "),
+ "cat/other-1:a::repo3 cat/pkg-4:a::repo1");
- const tr1::shared_ptr<PackageDatabaseEntryCollection> q8(p.query(c, is_any, qo_best_version_in_slot_only));
- TEST_CHECK_EQUAL(join(q8->begin(), q8->end(), " "),
- "cat/other-1::repo3 cat/pkg-3::repo2 cat/pkg-3::repo1 cat/pkg-4::repo1");
+ const tr1::shared_ptr<const PackageIDSequence> q8(p.query(query::Matches(c), qo_best_version_in_slot_only));
+ 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");
}
} package_database_query_order_test;
diff --git a/paludis/package_database_entry.hh b/paludis/package_database_entry.hh
deleted file mode 100644
index 1be3342..0000000
--- a/paludis/package_database_entry.hh
+++ /dev/null
@@ -1,64 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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_PACKAGE_DATABASE_ENTRY_HH
-#define PALUDIS_GUARD_PALUDIS_PACKAGE_DATABASE_ENTRY_HH 1
-
-#include <paludis/name.hh>
-#include <paludis/version_spec.hh>
-
-namespace paludis
-{
-
-#include <paludis/package_database_entry-sr.hh>
-
- /**
- * A collection of PackageDatabaseEntry instances.
- *
- * Often this will have been ordered by
- * PackageDatabase::sort_package_database_entry_collection . There is no intrinsic
- * ordering because RepositoryName is not comparable except via a PackageDatabase .
- */
- typedef SequentialCollection<PackageDatabaseEntry> PackageDatabaseEntryCollection;
-
- /**
- * Comparator for ArbitrarilyOrderedPackageDatabaseEntryCollection.
- */
- struct PALUDIS_VISIBLE ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator
- {
- /**
- * Perform the comparison.
- */
- bool operator () (const PackageDatabaseEntry & lhs, const PackageDatabaseEntry & rhs) const;
- };
-
- /**
- * A collection of PackageDatabaseEntry instances that are ordered, but not
- * by best first.
- */
- typedef SortedCollection<PackageDatabaseEntry, ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator>
- ArbitrarilyOrderedPackageDatabaseEntryCollection;
-
- /**
- * A PackageDatabaseEntry can be written to a stream.
- */
- std::ostream & operator<< (std::ostream &, const PackageDatabaseEntry &) PALUDIS_VISIBLE;
-}
-
-#endif
diff --git a/paludis/package_database_entry.sr b/paludis/package_database_entry.sr
deleted file mode 100644
index 61087ad..0000000
--- a/paludis/package_database_entry.sr
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-make_class_PackageDatabaseEntry()
-{
- visible
-
- key name QualifiedPackageName
- key version VersionSpec
- key repository RepositoryName
-
- doxygen_comment << "END"
- /**
- * Holds an entry in a PackageDatabase, and used to identify a
- * specific version of a package in a particular repository.
- *
- * \see PackageDatabase
- * \ingroup grppackagedatabase
- * \nosubgrouping
- */
-END
-
- comparison_operators equality all
-}
-
diff --git a/paludis/package_id-fwd.hh b/paludis/package_id-fwd.hh
new file mode 100644
index 0000000..394e89b
--- /dev/null
+++ b/paludis/package_id-fwd.hh
@@ -0,0 +1,41 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_PACKAGE_ID_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_PACKAGE_ID_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/collection-fwd.hh>
+#include <paludis/util/tr1_memory.hh>
+
+namespace paludis
+{
+ class PackageID;
+ class PackageIDSetComparator;
+
+ typedef SequentialCollection<tr1::shared_ptr<const PackageID> > PackageIDSequence;
+ typedef SortedCollection<tr1::shared_ptr<const PackageID>, PackageIDSetComparator> PackageIDSet;
+
+#include <paludis/package_id-se.hh>
+
+ std::ostream & operator<< (std::ostream &, const PackageID &) PALUDIS_VISIBLE;
+}
+
+#endif
diff --git a/paludis/package_id.cc b/paludis/package_id.cc
new file mode 100644
index 0000000..cb330e9
--- /dev/null
+++ b/paludis/package_id.cc
@@ -0,0 +1,133 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/name.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/repository.hh>
+
+#include <list>
+#include <algorithm>
+
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+
+using namespace paludis;
+
+#include <paludis/package_id-se.cc>
+
+namespace paludis
+{
+ template <>
+ struct Implementation<PackageID>
+ {
+ mutable std::list<tr1::shared_ptr<const MetadataKey> > keys;
+ };
+}
+
+PackageID::PackageID() :
+ PrivateImplementationPattern<PackageID>(new Implementation<PackageID>)
+{
+}
+
+PackageID::~PackageID()
+{
+}
+
+void
+PackageID::add_key(const tr1::shared_ptr<const MetadataKey> & k) const
+{
+ using namespace tr1::placeholders;
+ if (_imp->keys.end() != std::find_if(_imp->keys.begin(), _imp->keys.end(),
+ tr1::bind(std::equal_to<std::string>(), k->raw_name(), tr1::bind(tr1::mem_fn(&MetadataKey::raw_name), _1))))
+ throw ConfigurationError("Tried to add duplicate key '" + k->raw_name() + "' to ID '" + stringify(*this) + "'");
+
+ _imp->keys.push_back(k);
+}
+
+PackageID::Iterator
+PackageID::begin() const
+{
+ need_keys_added();
+ return Iterator(indirect_iterator(_imp->keys.begin()));
+}
+
+PackageID::Iterator
+PackageID::end() const
+{
+ need_keys_added();
+ return Iterator(indirect_iterator(_imp->keys.end()));
+}
+
+PackageID::Iterator
+PackageID::find(const std::string & s) const
+{
+ using namespace tr1::placeholders;
+
+ need_keys_added();
+ return std::find_if(begin(), end(),
+ tr1::bind(std::equal_to<std::string>(), s, tr1::bind(tr1::mem_fn(&MetadataKey::raw_name), _1)));
+}
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const PackageID & i)
+{
+ s << i.canonical_form(idcf_full);
+ return s;
+}
+
+bool
+PackageIDSetComparator::operator() (const tr1::shared_ptr<const PackageID> & a,
+ const tr1::shared_ptr<const PackageID> & b) const
+{
+ if (a->name() < b->name())
+ return true;
+
+ if (a->name() > b->name())
+ return false;
+
+ if (a->version() < b->version())
+ return true;
+
+ if (a->version() > b->version())
+ return false;
+
+ if (a->repository()->name().data() < b->repository()->name().data())
+ return true;
+
+ if (a->repository()->name().data() > b->repository()->name().data())
+ return false;
+
+ return a->arbitrary_less_than_comparison(*b);
+}
+
+bool
+paludis::operator== (const PackageID & a, const PackageID & b)
+{
+ return (a.name() == b.name())
+ && (a.version() == b.version())
+ && (a.repository()->name() == b.repository()->name())
+ && (! a.arbitrary_less_than_comparison(b))
+ && (! b.arbitrary_less_than_comparison(a));
+}
+
diff --git a/paludis/package_id.hh b/paludis/package_id.hh
new file mode 100644
index 0000000..e2cd543
--- /dev/null
+++ b/paludis/package_id.hh
@@ -0,0 +1,135 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_PACKAGE_ID_HH
+#define PALUDIS_GUARD_PALUDIS_PACKAGE_ID_HH 1
+
+#include <paludis/package_id-fwd.hh>
+#include <paludis/metadata_key-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/tr1_memory.hh>
+#include <paludis/util/operators.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/version_spec-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/eapi-fwd.hh>
+#include <paludis/repository-fwd.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE PackageID :
+ private InstantiationPolicy<PackageID, instantiation_method::NonCopyableTag>,
+ private PrivateImplementationPattern<PackageID>,
+ public equality_operators::HasEqualityOperators
+ {
+ protected:
+ virtual void add_key(const tr1::shared_ptr<const MetadataKey> &) const;
+ virtual void need_keys_added() const = 0;
+
+ public:
+ PackageID();
+ virtual ~PackageID() = 0;
+
+ virtual const std::string canonical_form(const PackageIDCanonicalForm) const = 0;
+
+ virtual const QualifiedPackageName name() const = 0;
+ virtual const VersionSpec version() const = 0;
+ virtual const SlotName slot() const = 0;
+ virtual const tr1::shared_ptr<const Repository> repository() const = 0;
+ virtual const tr1::shared_ptr<const EAPI> eapi() const = 0;
+
+ ///\name Specific keys
+ ///\{
+
+ virtual const tr1::shared_ptr<const MetadataPackageIDKey> virtual_for_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameCollection> > keywords_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameCollection> > use_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagCollection> > iuse_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<InheritedCollection> > inherited_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > restrict_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > src_uri_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > bin_uri_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > homepage_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataStringKey> short_description_key() const = 0;
+ virtual const tr1::shared_ptr<const MetadataStringKey> long_description_key() const = 0;
+
+ ///\}
+
+ ///\name Finding and iterating over keys
+ ///\{
+
+ typedef libwrapiter::ForwardIterator<PackageID, const MetadataKey> Iterator;
+ Iterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ Iterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ Iterator find(const std::string &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ ///\}
+
+ ///\name Extra comparisons
+ ///\{
+
+ /**
+ * Perform an arbitrary less than comparison on another PackageID.
+ *
+ * Used by PackageIDSetComparator and operator==. This function
+ * should not be used by anything else.
+ *
+ * This function will only be called if the other PackageID has the
+ * same name, version and repository as this. If this is not enough
+ * to uniquely identify an ID (e.g. if there is an affix, or if multiple
+ * slots per version are allowed), then this function's
+ * implementation must differentiate appropriately.
+ */
+ virtual bool arbitrary_less_than_comparison(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * Provide any additional hash information for a PackageID.
+ *
+ * The standard PackageID hash incorporates the repository name, the
+ * package name and the version of the package. If this function is
+ * defined, its value is also used when determining a hash. This can
+ * provide increased performance if a repository uses affixes or
+ * multiple slots per version.
+ */
+ virtual std::size_t extra_hash_value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ ///\}
+ };
+
+ bool operator== (const PackageID &, const PackageID &) PALUDIS_ATTRIBUTE((warn_unused_result)) PALUDIS_VISIBLE;
+
+ class PALUDIS_VISIBLE PackageIDSetComparator
+ {
+ public:
+ bool operator() (const tr1::shared_ptr<const PackageID> &,
+ const tr1::shared_ptr<const PackageID> &) const;
+ };
+}
+
+#endif
diff --git a/paludis/package_id.se b/paludis/package_id.se
new file mode 100644
index 0000000..fd47190
--- /dev/null
+++ b/paludis/package_id.se
@@ -0,0 +1,22 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_PackageIDCanonicalForm()
+{
+ prefix idcf
+
+ key idcf_full "Everything"
+ key idcf_version "Version, and affix as appropriate"
+ key idcf_no_version "No version"
+
+ doxygen_comment << "END"
+ /**
+ * How to generate paludis::PackageID::canonical_form().
+ *
+ * \see PackageID
+ */
+END
+}
+
+
+
diff --git a/paludis/qa/create_metadata_check.cc b/paludis/qa/create_metadata_check.cc
index 7156a46..8004b45 100644
--- a/paludis/qa/create_metadata_check.cc
+++ b/paludis/qa/create_metadata_check.cc
@@ -19,7 +19,6 @@
#include <paludis/qa/create_metadata_check.hh>
#include <paludis/portage_dep_parser.hh>
-#include <paludis/package_database_entry.hh>
#include <paludis/qa/qa_environment.hh>
#include <paludis/eapi.hh>
diff --git a/paludis/query.cc b/paludis/query.cc
index b28e2bb..2319d0e 100644
--- a/paludis/query.cc
+++ b/paludis/query.cc
@@ -20,6 +20,7 @@
#include "query.hh"
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/tr1_functional.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/match_package.hh>
@@ -57,11 +58,11 @@ QueryDelegate::packages(const Environment &, tr1::shared_ptr<const RepositoryNam
return tr1::shared_ptr<QualifiedPackageNameCollection>();
}
-tr1::shared_ptr<PackageDatabaseEntryCollection>
-QueryDelegate::versions(const Environment &, tr1::shared_ptr<const RepositoryNameCollection>,
+tr1::shared_ptr<PackageIDSequence>
+QueryDelegate::ids(const Environment &, tr1::shared_ptr<const RepositoryNameCollection>,
tr1::shared_ptr<const QualifiedPackageNameCollection>) const
{
- return tr1::shared_ptr<PackageDatabaseEntryCollection>();
+ return tr1::shared_ptr<PackageIDSequence>();
}
Query::Query(tr1::shared_ptr<const QueryDelegate> d) :
@@ -85,6 +86,12 @@ namespace
{
}
+ std::string
+ as_human_readable_string() const
+ {
+ return "matches '" + stringify(spec) + "'";
+ }
+
tr1::shared_ptr<RepositoryNameCollection>
repositories(const Environment & e) const
{
@@ -155,12 +162,12 @@ namespace
return QueryDelegate::packages(e, repos, cats);
}
- tr1::shared_ptr<PackageDatabaseEntryCollection>
- versions(const Environment & e,
+ tr1::shared_ptr<PackageIDSequence>
+ ids(const Environment & e,
tr1::shared_ptr<const RepositoryNameCollection> repos,
tr1::shared_ptr<const QualifiedPackageNameCollection> pkgs) const
{
- tr1::shared_ptr<PackageDatabaseEntryCollection> result(new PackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence::Concrete);
for (RepositoryNameCollection::Iterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
{
@@ -169,14 +176,12 @@ namespace
for (QualifiedPackageNameCollection::Iterator p(pkgs->begin()), p_end(pkgs->end()) ;
p != p_end ; ++p)
{
- tr1::shared_ptr<const VersionSpecCollection> vers(repo->version_specs(*p));
- for (VersionSpecCollection::Iterator v(vers->begin()), v_end(vers->end()) ;
+ using namespace tr1::placeholders;
+ tr1::shared_ptr<const PackageIDSequence> i(repo->package_ids(*p));
+ for (PackageIDSequence::Iterator v(i->begin()), v_end(i->end()) ;
v != v_end ; ++v)
- {
- PackageDatabaseEntry dbe(*p, *v, *r);
- if (match_package(e, spec, dbe))
- result->push_back(dbe);
- }
+ if (match_package(e, spec, **v))
+ result->push_back(*v);
}
}
@@ -220,12 +225,18 @@ namespace
struct NotMaskedDelegate :
QueryDelegate
{
- tr1::shared_ptr<PackageDatabaseEntryCollection>
- versions(const Environment & e,
+ std::string
+ as_human_readable_string() const
+ {
+ return "not masked";
+ }
+
+ tr1::shared_ptr<PackageIDSequence>
+ ids(const Environment & e,
tr1::shared_ptr<const RepositoryNameCollection> repos,
tr1::shared_ptr<const QualifiedPackageNameCollection> pkgs) const
{
- tr1::shared_ptr<PackageDatabaseEntryCollection> result(new PackageDatabaseEntryCollection::Concrete);
+ tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence::Concrete);
for (RepositoryNameCollection::Iterator r(repos->begin()), r_end(repos->end()) ;
r != r_end ; ++r)
{
@@ -234,14 +245,11 @@ namespace
for (QualifiedPackageNameCollection::Iterator p(pkgs->begin()), p_end(pkgs->end()) ;
p != p_end ; ++p)
{
- tr1::shared_ptr<const VersionSpecCollection> vers(repo->version_specs(*p));
- for (VersionSpecCollection::Iterator v(vers->begin()), v_end(vers->end()) ;
+ tr1::shared_ptr<const PackageIDSequence> i(repo->package_ids(*p));
+ for (PackageIDSequence::Iterator v(i->begin()), v_end(i->end()) ;
v != v_end ; ++v)
- {
- PackageDatabaseEntry dbe(*p, *v, *r);
- if (! e.mask_reasons(dbe).any())
- result->push_back(dbe);
- }
+ if (! e.mask_reasons(**v).any())
+ result->push_back(*v);
}
}
@@ -257,6 +265,33 @@ query::NotMasked::NotMasked() :
namespace
{
+ template <typename I_>
+ struct DelegateName;
+
+ template <>
+ struct DelegateName<RepositoryInstalledInterface>
+ {
+ static const char * value;
+ };
+
+ const char * DelegateName<RepositoryInstalledInterface>::value = "RepositoryInstalledInterface";
+
+ template <>
+ struct DelegateName<RepositoryUninstallableInterface>
+ {
+ static const char * value;
+ };
+
+ const char * DelegateName<RepositoryUninstallableInterface>::value = "RepositoryUninstallableInterface";
+
+ template <>
+ struct DelegateName<RepositoryInstallableInterface>
+ {
+ static const char * value;
+ };
+
+ const char * DelegateName<RepositoryInstallableInterface>::value = "RepositoryInstallableInterface";
+
template <typename I_, I_ * (RepositoryCapabilities::* i_)>
struct RepositoryHasDelegate :
QueryDelegate
@@ -273,6 +308,13 @@ namespace
return result;
}
+
+ std::string
+ as_human_readable_string() const
+ {
+ return "repository has '" + std::string(DelegateName<I_>::value) + "'";
+ }
+
};
}
@@ -301,6 +343,12 @@ namespace
{
const FSEntry root;
+ std::string
+ as_human_readable_string() const
+ {
+ return "installed at root '" + stringify(root) + "'";
+ }
+
InstalledAtRootDelegate(const FSEntry & r) :
root(r)
{
@@ -343,6 +391,12 @@ namespace
{
tr1::shared_ptr<const QueryDelegate> q1, q2;
+ std::string
+ as_human_readable_string() const
+ {
+ return q1->as_human_readable_string()+ " & " + q2->as_human_readable_string();
+ }
+
AndQueryDelegate(tr1::shared_ptr<const QueryDelegate> qq1,
tr1::shared_ptr<const QueryDelegate> qq2) :
q1(qq1),
@@ -404,19 +458,18 @@ namespace
return r2;
}
- tr1::shared_ptr<PackageDatabaseEntryCollection>
- versions(const Environment & e, tr1::shared_ptr<const RepositoryNameCollection> r,
+ tr1::shared_ptr<PackageIDSequence>
+ ids(const Environment & e, tr1::shared_ptr<const RepositoryNameCollection> r,
tr1::shared_ptr<const QualifiedPackageNameCollection> q) const
{
- tr1::shared_ptr<PackageDatabaseEntryCollection> r1(q1->versions(e, r, q)), r2(q2->versions(e, r, q));
+ tr1::shared_ptr<PackageIDSequence> r1(q1->ids(e, r, q)), r2(q2->ids(e, r, q));
if (r1 && r2)
{
- std::set<PackageDatabaseEntry, ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator>
+ std::set<tr1::shared_ptr<const PackageID>, PackageIDSetComparator>
s1(r1->begin(), r1->end()), s2(r2->begin(), r2->end());
- tr1::shared_ptr<PackageDatabaseEntryCollection> result(new PackageDatabaseEntryCollection::Concrete);
- std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), result->inserter(),
- ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator());
+ tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence::Concrete);
+ std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), result->inserter(), PackageIDSetComparator());
return result;
}
else if (r1)
@@ -433,6 +486,13 @@ paludis::operator& (const Query & q1, const Query & q2)
return Query(tr1::shared_ptr<QueryDelegate>(new AndQueryDelegate(q1._d, q2._d)));
}
+std::ostream &
+paludis::operator<< (std::ostream & s, const Query & q)
+{
+ s << q._d->as_human_readable_string();
+ return s;
+}
+
namespace
{
struct AllDelegate :
@@ -441,6 +501,13 @@ namespace
AllDelegate()
{
}
+
+ std::string
+ as_human_readable_string() const
+ {
+ return "all";
+ }
+
};
}
diff --git a/paludis/query.hh b/paludis/query.hh
index f497474..08a7e97 100644
--- a/paludis/query.hh
+++ b/paludis/query.hh
@@ -22,7 +22,8 @@
#include <paludis/util/collection.hh>
#include <paludis/name.hh>
-#include <paludis/package_database_entry.hh>
+#include <paludis/package_id.hh>
+#include <iosfwd>
/** \file
* Query and related classes.
@@ -87,16 +88,21 @@ namespace paludis
tr1::shared_ptr<const CategoryNamePartCollection>) const;
/**
- * Fetch the versions of matching packages.
+ * Fetch the IDs of matching packages.
*
- * Default behaviour: return all versions in the provided packages.
+ * Default behaviour: return all IDs in the provided packages.
*
* Note that some entries in the qualified package name collection
* (but not in the repositories collection) may not exist.
*/
- virtual tr1::shared_ptr<PackageDatabaseEntryCollection> versions(const Environment &,
+ virtual tr1::shared_ptr<PackageIDSequence> ids(const Environment &,
tr1::shared_ptr<const RepositoryNameCollection>,
tr1::shared_ptr<const QualifiedPackageNameCollection>) const;
+
+ /**
+ * Fetch a string representation of our query.
+ */
+ virtual std::string as_human_readable_string() const = 0;
};
/**
@@ -113,6 +119,7 @@ namespace paludis
class PALUDIS_VISIBLE Query
{
friend Query operator& (const Query &, const Query &);
+ friend std::ostream & operator<< (std::ostream &, const Query &);
private:
tr1::shared_ptr<const QueryDelegate> _d;
@@ -149,11 +156,11 @@ namespace paludis
return _d->packages(e, r, c);
}
- tr1::shared_ptr<PackageDatabaseEntryCollection> versions(const Environment & e,
+ tr1::shared_ptr<PackageIDSequence> ids(const Environment & e,
tr1::shared_ptr<const RepositoryNameCollection> r,
tr1::shared_ptr<const QualifiedPackageNameCollection> q) const
{
- return _d->versions(e, r, q);
+ return _d->ids(e, r, q);
}
///\}
@@ -380,6 +387,14 @@ namespace paludis
* \ingroup grpquery
*/
Query operator& (const Query &, const Query &) PALUDIS_VISIBLE;
+
+ /**
+ * Output a human-readable description of a Query.
+ *
+ * \see Query
+ * \ingroup grpquery
+ */
+ std::ostream & operator<< (std::ostream &, const Query &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am
index 7610dff..8a2db6b 100644
--- a/paludis/repositories/cran/Makefile.am
+++ b/paludis/repositories/cran/Makefile.am
@@ -26,8 +26,7 @@ paludis_repositories_cran_includedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/
libpaludiscranrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_cran_include_HEADERS = \
- cran_version_metadata.hh \
- cran_description.hh \
+ cran_package_id.hh \
cran_dep_parser.hh \
cran_repository.hh \
cran_repository-sr.hh \
@@ -35,8 +34,7 @@ paludis_repositories_cran_include_HEADERS = \
cran_installed_repository-sr.hh
libpaludiscranrepository_la_SOURCES = \
- cran_version_metadata.cc \
- cran_description.cc \
+ cran_package_id.cc \
cran_dep_parser.cc \
cran_repository.cc \
cran_installed_repository.cc \
diff --git a/paludis/repositories/cran/cran_dep_parser.cc b/paludis/repositories/cran/cran_dep_parser.cc
index ddaee06..2b66fa9 100644
--- a/paludis/repositories/cran/cran_dep_parser.cc
+++ b/paludis/repositories/cran/cran_dep_parser.cc
@@ -20,7 +20,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/eapi.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
-#include <paludis/repositories/cran/cran_description.hh>
+#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/stringify.hh>
@@ -69,8 +69,8 @@ CRANDepParser::parse(const std::string & s, const EAPI & e)
else
name = strip_leading(strip_trailing(aa, " \t"), " \t");
- CRANDescription::normalise_name(name);
- CRANDescription::normalise_version(version);
+ CRANPackageID::normalise_name(name);
+ CRANPackageID::normalise_version(version);
if ("R" == name)
name = "dev-lang/R";
diff --git a/paludis/repositories/cran/cran_description.hh b/paludis/repositories/cran/cran_description.hh
deleted file mode 100644
index 37d53f6..0000000
--- a/paludis/repositories/cran/cran_description.hh
+++ /dev/null
@@ -1,135 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
- * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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_CRAN_DESCRIPTION_HH
-#define PALUDIS_GUARD_PALUDIS_CRAN_DESCRIPTION_HH 1
-
-#include <paludis/version_metadata.hh>
-#include <paludis/util/fs_entry.hh>
-#include <paludis/util/log.hh>
-
-namespace paludis
-{
- /**
- * CRANDescription as used by CRANRepository and CRANInstalledRepository
- */
- struct PALUDIS_VISIBLE CRANDescription
- {
- /// Our package name.
- QualifiedPackageName name;
-
- /// Our package version.
- VersionSpec version;
-
- /// Our metadata, may be zero.
- tr1::shared_ptr<VersionMetadata> metadata;
-
- /// Our installed date.
- time_t installed_time;
-
- /// Turn a CRAN package name into a paludis package name.
- static void normalise_name(std::string & s);
-
- /// Turn a paludis package name into a CRAN package name.
- static void denormalise_name(std::string & s);
-
- /// Turn a CRAN package version into a paludis package version.
- static void normalise_version(std::string & s);
-
- /// Constructor
- CRANDescription(const std::string & n, const FSEntry & f, bool installed);
-
- /// Comparison operator
- bool operator< (const CRANDescription & other) const
- {
- if (name < other.name)
- return true;
- if (name > other.name)
- return false;
- if (version < other.version)
- return true;
- return false;
- }
-
- /**
- * Compare a CRANDescription by name only.
- *
- * \ingroup grpcrandesc
- */
- struct PALUDIS_VISIBLE ComparePackage
- {
- ///\name Comparison operators
- ///\{
-
- bool operator() (const QualifiedPackageName & c, const CRANDescription & d) const
- {
- return c < d.name;
- }
-
- bool operator() (const CRANDescription & d, const QualifiedPackageName & c) const
- {
- return d.name < c;
- }
-
- ///\}
- };
-
- /**
- * Compare a CRANIDescription by name and version.
- *
- * \ingroup grpcrandesc
- */
- struct PALUDIS_VISIBLE CompareVersion
- {
- ///\name Comparison operators
- ///\{
-
- bool operator() (const std::pair<QualifiedPackageName, VersionSpec> & c,
- const CRANDescription & d) const
- {
- if (c.first < d.name)
- return true;
- else if (c.first > d.name)
- return false;
- else if (c.second < d.version)
- return true;
- else
- return false;
- }
-
- bool operator() (const CRANDescription & d,
- const std::pair<QualifiedPackageName, VersionSpec> & c) const
- {
- if (d.name < c.first)
- return true;
- else if (d.name > c.first)
- return false;
- else if (d.version < c.second)
- return true;
- else
- return false;
- }
-
- ///\}
- };
- };
-}
-
-#endif
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 1fa5fa9..016f621 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -1,7 +1,8 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006,2007 Danny van Dyk <kugelfang@gentoo.org>
+ * Copyright (c) 2006, 2007 Danny van Dyk <kugelfang@gentoo.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -18,74 +19,49 @@
*/
#include <paludis/hashed_containers.hh>
-#include <paludis/config_file.hh>
-#include <paludis/match_package.hh>
-#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/eapi.hh>
-#include <paludis/repositories/cran/cran_description.hh>
+#include <paludis/repository_info.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/dep_tag.hh>
+#include <paludis/set_file.hh>
+#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
#include <paludis/repositories/cran/cran_installed_repository.hh>
-#include <paludis/repositories/cran/cran_version_metadata.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/iterator.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/system.hh>
#include <paludis/util/log.hh>
-#include <paludis/util/pstream.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/tr1_functional.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
-#include <fstream>
#include <functional>
#include <algorithm>
-#include <vector>
using namespace paludis;
#include <paludis/repositories/cran/cran_installed_repository-sr.cc>
+typedef MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<const CRANPackageID> >::Type IDMap;
+
namespace paludis
{
- /// Map for metadata.
- typedef MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>, tr1::shared_ptr<VersionMetadata> >::Type MetadataMap;
-
template <>
struct Implementation<CRANInstalledRepository>
{
CRANInstalledRepositoryParams params;
- /// Our owning env.
- const Environment * const env;
-
- /// Our base location.
- FSEntry location;
-
- /// Root location
- FSEntry root;
-
- /// World file.
- FSEntry world_file;
-
- // Do we have entries loaded?
- mutable bool entries_valid;
-
- mutable std::vector<CRANDescription> entries;
-
- /// Load entries.
- void load_entries() const;
-
- /// Metadata cache
- mutable MetadataMap metadata;
-
- /// Provide map.
- mutable std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
+ mutable bool has_ids;
+ mutable IDMap ids;
/// Constructor.
Implementation(const CRANInstalledRepositoryParams &);
@@ -97,11 +73,7 @@ namespace paludis
Implementation<CRANInstalledRepository>::Implementation(const CRANInstalledRepositoryParams & p) :
params(p),
- env(p.environment),
- location(p.location),
- root(p.root),
- world_file(p.world),
- entries_valid(false)
+ has_ids(false)
{
}
@@ -109,19 +81,18 @@ Implementation<CRANInstalledRepository>::~Implementation()
{
}
+#if 0
void
-Implementation<CRANInstalledRepository>::load_entries() const
+Implementation<CRANInstalledRepository>::need_ids() const
{
- Context context("When loading CRANInstalledRepository entries from '" +
- stringify(location) + "':");
+ Context context("When loading CRANInstalledRepository IDs from '" + stringify(location) + "':");
- entries.clear();
entries_valid = true;
try
{
for (DirIterator d(location), d_end ; d != d_end ; ++d)
{
- Context local_context("When parsing directoryy '" + stringify(*d) + "'.");
+ Context local_context("When parsing directoryy '" + stringify(*d) + "':");
if (! d->is_directory())
continue;
@@ -172,6 +143,7 @@ Implementation<CRANInstalledRepository>::load_entries() const
throw;
}
}
+#endif
CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryParams & p) :
Repository(RepositoryName("cran_installed"),
@@ -193,6 +165,7 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.destination_interface(this)
.licenses_interface(0)
.portage_interface(0)
+ .make_virtuals_interface(0)
.pretend_interface(0)
.hook_interface(0),
"cran_installed"),
@@ -200,9 +173,9 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
{
tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
- config_info->add_kv("location", stringify(_imp->location));
- config_info->add_kv("root", stringify(_imp->root));
- config_info->add_kv("format", std::string("cran-installed"));
+ config_info->add_kv("location", stringify(_imp->params.location));
+ config_info->add_kv("root", stringify(_imp->params.root));
+ config_info->add_kv("format", "cran_installed");
_info->add_section(config_info);
}
@@ -220,28 +193,19 @@ CRANInstalledRepository::do_has_category_named(const CategoryNamePart & c) const
bool
CRANInstalledRepository::do_has_package_named(const QualifiedPackageName & q) const
{
- Context context("When checking for package '" + stringify(q) +
- "' in " + stringify(name()) + ":");
+ Context context("When checking for package '" + stringify(q) + "' in " + stringify(name()) + ":");
if (! do_has_category_named(q.category))
return false;
- if (! _imp->entries_valid)
- _imp->load_entries();
-
- std::pair<std::vector<CRANDescription>::const_iterator, std::vector<CRANDescription>::const_iterator>
- r(std::equal_range(_imp->entries.begin(), _imp->entries.end(), q,
- CRANDescription::ComparePackage()));
+ need_ids();
- return r.first != r.second;
+ return _imp->ids.end() != _imp->ids.find(q);
}
tr1::shared_ptr<const CategoryNamePartCollection>
CRANInstalledRepository::do_category_names() const
{
- if (! _imp->entries_valid)
- _imp->load_entries();
-
tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
result->insert(CategoryNamePart("cran"));
return result;
@@ -253,126 +217,41 @@ CRANInstalledRepository::do_package_names(const CategoryNamePart & c) const
Context context("When fetching package names in category '" + stringify(c)
+ "' in " + stringify(name()) + ":");
- if (! _imp->entries_valid)
- _imp->load_entries();
-
tr1::shared_ptr<QualifiedPackageNameCollection> result(new QualifiedPackageNameCollection::Concrete);
if (! do_has_category_named(c))
return result;
- std::vector<CRANDescription>::const_iterator e(_imp->entries.begin()), e_end(_imp->entries.end());
- for ( ; e != e_end ; ++e)
- result->insert(e->name);
+ need_ids();
+
+ std::copy(_imp->ids.begin(), _imp->ids.end(), transform_inserter(result->inserter(),
+ tr1::mem_fn(&std::pair<const QualifiedPackageName, tr1::shared_ptr<const CRANPackageID> >::first)));
return result;
}
-tr1::shared_ptr<const VersionSpecCollection>
-CRANInstalledRepository::do_version_specs(const QualifiedPackageName & n) const
+tr1::shared_ptr<const PackageIDSequence>
+CRANInstalledRepository::do_package_ids(const QualifiedPackageName & n) const
{
Context context("When fetching versions of '" + stringify(n) + "' in "
+ stringify(name()) + ":");
- tr1::shared_ptr<VersionSpecCollection> result(new VersionSpecCollection::Concrete);
-
- if (! _imp->entries_valid)
- _imp->load_entries();
-
- for (std::vector<CRANDescription>::const_iterator e(_imp->entries.begin()), e_end(_imp->entries.end()) ;
- e != e_end ; ++e)
- if (n == e->name)
- result->insert(e->version);
-
- return result;
-}
-
-bool
-CRANInstalledRepository::do_has_version(const QualifiedPackageName & q,
- const VersionSpec & v) const
-{
- Context context("When checking for version '" + stringify(v) + "' in '"
- + stringify(q) + "' in " + stringify(name()) + ":");
-
- tr1::shared_ptr<const VersionSpecCollection> versions(do_version_specs(q));
- return versions->end() != versions->find(v);
-}
-
-namespace
-{
- /**
- * Fetch the contents of a VDB file.
- *
- * \ingroup grpcranrepository
- */
- std::string
- file_contents(const FSEntry & location, const QualifiedPackageName & name,
- const std::string & key)
- {
- Context context("When loading metadata for '" + stringify(name)
- + "' key '" + key + "' from '" + stringify(location) + "':");
-
- FSEntry f(location / stringify(name.package));
- if (! (f / key).is_regular_file())
- return "";
-
- std::ifstream ff(stringify(f / key).c_str());
- if (! ff)
- throw InternalError("CRANInstalledRepository", "Could not read '" + stringify(f / key) + "'");
- return strip_leading(strip_trailing(std::string((std::istreambuf_iterator<char>(ff)),
- std::istreambuf_iterator<char>()), " \t\n"), " \t\n");
- }
-}
-
-tr1::shared_ptr<const VersionMetadata>
-CRANInstalledRepository::do_version_metadata(
- const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (_imp->metadata.end() != _imp->metadata.find(
- std::make_pair(q, v)))
- return _imp->metadata.find(std::make_pair(q, v))->second;
-
- Context context("When fetching metadata for " + stringify(q) +
- "-" + stringify(v));
-
- if (! has_version(q, v))
- throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
-
- tr1::shared_ptr<VersionMetadata> result;
-
- FSEntry d(_imp->location);
- d /= stringify(q.package);
- d /= "DESCRIPTION";
-
- if (d.is_regular_file())
- {
- CRANDescription description(stringify(q.package), d, true);
- // Don't put this into CRANDescription, as it's only relevant to CRANInstalledRepository
- std::string repo(file_contents(_imp->location, q, "REPOSITORY"));
- if (! repo.empty())
- description.metadata->origins_interface->source.reset(new PackageDatabaseEntry(stringify(q.package), v,
- RepositoryName(repo)));
- result = description.metadata;
- }
- else
- {
- Log::get_instance()->message(ll_warning, lc_no_context, "has_version failed for request for '" +
- stringify(q) + "-" + stringify(v) + "' in repository '" +
- stringify(name()) + "': No DESCRIPTION file present.");
- result.reset(new CRANVersionMetadata(true));
- result->eapi = EAPIData::get_instance()->unknown_eapi();
+ tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence::Concrete);
+ if (! do_has_package_named(n))
return result;
- }
- _imp->metadata.insert(std::make_pair(std::make_pair(q, v), result));
+ need_ids();
+
+ IDMap::const_iterator i(_imp->ids.find(n));
+ if (i != _imp->ids.end())
+ result->push_back(i->second);
return result;
}
+#if 0
tr1::shared_ptr<const Contents>
-CRANInstalledRepository::do_contents(
- const QualifiedPackageName & q, const VersionSpec & v) const
+CRANInstalledRepository::do_contents(const Package ID & id) const
{
- Context context("When fetching contents for " + stringify(q) +
- "-" + stringify(v));
+ Context context("When fetching contents for " + stringify(id) + ":");
tr1::shared_ptr<Contents> result(new Contents);
@@ -395,8 +274,7 @@ CRANInstalledRepository::do_contents(
std::ifstream ff(stringify(f).c_str());
if (! ff)
- throw InternalError(PALUDIS_HERE, "TODO reading " + stringify(_imp->location) + " name " +
- stringify(q) + " version " + stringify(v) + " CONTENTS"); /// \todo
+ throw ConfigurationError("Could not read '" + stringify(f) + "'");
std::string line;
unsigned line_number(0);
@@ -484,6 +362,7 @@ CRANInstalledRepository::do_installed_time(const QualifiedPackageName & q,
return r->installed_time;
}
}
+#endif
tr1::shared_ptr<Repository>
CRANInstalledRepository::make_cran_installed_repository(
@@ -518,6 +397,7 @@ CRANInstalledRepositoryConfigurationError::CRANInstalledRepositoryConfigurationE
{
}
+#if 0
void
CRANInstalledRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v,
const UninstallOptions &) const
@@ -542,6 +422,7 @@ CRANInstalledRepository::do_uninstall(const QualifiedPackageName & q, const Vers
if (0 != run_command(cmd))
throw PackageUninstallActionError("Couldn't unmerge '" + stringify(q) + "-" + stringify(v) + "'");
}
+#endif
tr1::shared_ptr<SetSpecTree::ConstItem>
CRANInstalledRepository::do_package_set(const SetName & s) const
@@ -553,16 +434,15 @@ CRANInstalledRepository::do_package_set(const SetName & s) const
{
tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
- if (! _imp->entries_valid)
- _imp->load_entries();
- for (std::vector<CRANDescription>::const_iterator p(_imp->entries.begin()),
- p_end(_imp->entries.end()) ; p != p_end ; ++p)
+ need_ids();
+
+ for (IDMap::const_iterator p(_imp->ids.begin()), p_end(_imp->ids.end()) ;
+ p != p_end ; ++p)
{
tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> > spec(
- new TreeLeaf<SetSpecTree, PackageDepSpec>(tr1::shared_ptr<PackageDepSpec>(
- new PackageDepSpec(tr1::shared_ptr<QualifiedPackageName>(
- new QualifiedPackageName(p->name))))));
+ new TreeLeaf<SetSpecTree, PackageDepSpec>(make_shared_ptr(
+ new PackageDepSpec(make_shared_ptr(new QualifiedPackageName(p->first))))));
result->add(spec);
}
@@ -572,47 +452,24 @@ CRANInstalledRepository::do_package_set(const SetName & s) const
{
tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > result(new ConstTreeSequence<SetSpecTree, AllDepSpec>(
tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+ tr1::shared_ptr<GeneralSetDepTag> tag(new GeneralSetDepTag(SetName("world"), stringify(name())));
- if (_imp->world_file.exists())
+ if (_imp->params.world.exists())
{
- LineConfigFile world(_imp->world_file, LineConfigFileOptions());
-
- for (LineConfigFile::Iterator line(world.begin()), line_end(world.end()) ;
- line != line_end ; ++line)
- {
- try
- {
- if (std::string::npos == line->find('/'))
- {
- tr1::shared_ptr<SetSpecTree::ConstItem> spec(_imp->env->set(SetName(*line)));
- if (spec)
- result->add(spec);
- else
- Log::get_instance()->message(ll_warning, lc_no_context,
- "Entry '" + stringify(*line) + "' in world file '" + stringify(_imp->world_file)
- + "' is not a known set");
- }
- else
- {
- tr1::shared_ptr<TreeLeaf<SetSpecTree, PackageDepSpec> > spec(
- new TreeLeaf<SetSpecTree, PackageDepSpec>(tr1::shared_ptr<PackageDepSpec>(
- new PackageDepSpec(*line, pds_pm_unspecific))));
- result->add(spec);
- }
- }
- catch (const NameError & e)
- {
- Log::get_instance()->message(ll_warning, lc_no_context,
- "Entry '" + stringify(*line) + "' in world file '" + stringify(_imp->world_file)
- + "' gave error '" + e.message() + "' (" + e.what() + ")");
- }
- }
+ SetFile world(SetFileParams::create()
+ .file_name(_imp->params.world)
+ .type(sft_simple)
+ .parse_mode(pds_pm_unspecific)
+ .tag(tag)
+ .environment(_imp->params.environment));
+
+ return world.contents();
}
else
- Log::get_instance()->message(ll_warning, lc_no_context, "World file '" + stringify(_imp->world_file)
- + "' doesn't exist");
-
- return result;
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context) << "World file '" << _imp->params.world << "' doesn't exist";
+ return result;
+ }
}
else
return tr1::shared_ptr<SetSpecTree::ConstItem>();
@@ -635,6 +492,7 @@ CRANInstalledRepository::invalidate()
_imp.reset(new Implementation<CRANInstalledRepository>(_imp->params));
}
+#if 0
void
CRANInstalledRepository::add_string_to_world(const std::string & n) const
{
@@ -733,17 +591,18 @@ CRANInstalledRepository::remove_from_world(const SetName & n) const
{
remove_string_from_world(stringify(n));
}
+#endif
FSEntry
CRANInstalledRepository::root() const
{
- return _imp->root;
+ return _imp->params.root;
}
bool
CRANInstalledRepository::is_default_destination() const
{
- return _imp->env->root() == root();
+ return _imp->params.environment->root() == root();
}
bool
@@ -752,6 +611,7 @@ CRANInstalledRepository::want_pre_post_phases() const
return true;
}
+#if 0
void
CRANInstalledRepository::merge(const MergeOptions & m)
{
@@ -773,4 +633,5 @@ CRANInstalledRepository::merge(const MergeOptions & m)
stringify(name()) + "'");
}
+#endif
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index cbd48d0..d704291 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -31,7 +32,6 @@
* \ingroup grpcraninstrepository
*/
-
namespace paludis
{
@@ -53,50 +53,47 @@ namespace paludis
public RepositoryDestinationInterface,
public PrivateImplementationPattern<CRANInstalledRepository>
{
- protected:
- virtual bool do_has_category_named(const CategoryNamePart &) const;
+ private:
+ void need_ids() const;
- virtual bool do_has_package_named(const QualifiedPackageName &) const;
+ protected:
+ /* Repository */
- virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const;
+ virtual tr1::shared_ptr<const PackageIDSequence> do_package_ids(
+ const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
- const CategoryNamePart &) const;
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const VersionSpecCollection> do_version_specs(
- const QualifiedPackageName &) const;
+ virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_has_version(const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual bool do_has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const VersionMetadata> do_version_metadata(
- const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual bool do_has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const Contents> do_contents(
- const QualifiedPackageName &,
- const VersionSpec &) const;
+ /* RepositoryInstalledInterface */
- virtual time_t do_installed_time(
- const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual time_t do_installed_time(const PackageID &)
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
- const UninstallOptions &) const;
+ /* RepositoryContentsInterface */
- virtual tr1::shared_ptr<SetSpecTree::ConstItem> do_package_set(const SetName &) const;
+ virtual tr1::shared_ptr<const Contents> do_contents(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const SetNameCollection> sets_list() const;
+ /* RepositoryUninstallableInterface */
- /**
- * Add a string to world.
- */
- virtual void add_string_to_world(const std::string &) const;
+ virtual void do_uninstall(const tr1::shared_ptr<const PackageID> &, const UninstallOptions &) const;
- /**
- * Remove a string from world.
- */
- virtual void remove_string_from_world(const std::string &) const;
+ /* RepositorySetsInterface */
+
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> do_package_set(const SetName & id) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
/**
@@ -118,21 +115,32 @@ namespace paludis
virtual void invalidate();
- virtual void add_to_world(const QualifiedPackageName &) const;
+ /* RepositoryInstalledInterface */
- virtual void remove_from_world(const QualifiedPackageName &) const;
+ virtual FSEntry root() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void add_to_world(const SetName &) const;
+ /* RepositorySetsInterface */
+
+ virtual tr1::shared_ptr<const SetNameCollection> sets_list() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ /* RepositoryWorldInterface */
+
+ virtual void add_to_world(const QualifiedPackageName &) const;
+ virtual void add_to_world(const SetName &) const;
+ virtual void remove_from_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const SetName &) const;
- virtual bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
+ /* RepositoryDestinationInterface */
- virtual bool is_default_destination() const;
+ virtual bool is_suitable_destination_for(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool want_pre_post_phases() const;
+ virtual bool is_default_destination() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual FSEntry root() const;
+ virtual bool want_pre_post_phases() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void merge(const MergeOptions &);
};
@@ -144,7 +152,8 @@ namespace paludis
* \ingroup grpcraninstrepository
* \ingroup grpexceptions
*/
- class PALUDIS_VISIBLE CRANInstalledRepositoryConfigurationError : public ConfigurationError
+ class PALUDIS_VISIBLE CRANInstalledRepositoryConfigurationError :
+ public ConfigurationError
{
public:
/**
diff --git a/paludis/repositories/cran/cran_description.cc b/paludis/repositories/cran/cran_package_id.cc
index d7db383..d062c2f 100644
--- a/paludis/repositories/cran/cran_description.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -18,9 +18,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/repositories/cran/cran_description.hh>
+#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
-#include <paludis/repositories/cran/cran_version_metadata.hh>
#include <paludis/config_file.hh>
#include <paludis/eapi.hh>
#include <paludis/util/log.hh>
@@ -34,28 +33,32 @@
using namespace paludis;
-void
-CRANDescription::normalise_name(std::string & s)
+namespace
{
- using namespace tr1::placeholders;
- std::replace_if(s.begin(), s.end(), tr1::bind(std::equal_to<char>(), _1, '.'), '-');
-}
+ void
+ normalise_name(std::string & s)
+ {
+ using namespace tr1::placeholders;
+ std::replace_if(s.begin(), s.end(), tr1::bind(std::equal_to<char>(), _1, '.'), '-');
+ }
-void
-CRANDescription::denormalise_name(std::string & s)
-{
- using namespace tr1::placeholders;
- std::replace_if(s.begin(), s.end(), tr1::bind(std::equal_to<char>(), _1, '-'), '.');
-}
+ void
+ denormalise_name(std::string & s)
+ {
+ using namespace tr1::placeholders;
+ std::replace_if(s.begin(), s.end(), tr1::bind(std::equal_to<char>(), _1, '-'), '.');
+ }
-void
-CRANDescription::normalise_version(std::string & s)
-{
- using namespace tr1::placeholders;
- std::replace_if(s.begin(), s.end(), tr1::bind(std::equal_to<char>(), _1, '-'), '.');
+ void
+ normalise_version(std::string & s)
+ {
+ using namespace tr1::placeholders;
+ std::replace_if(s.begin(), s.end(), tr1::bind(std::equal_to<char>(), _1, '-'), '.');
+ }
}
-CRANDescription::CRANDescription(const std::string & n, const FSEntry & f, bool installed) :
+#if 0
+CRANDescription::CRANDescription() :
name("cran/" + n),
version("0"),
metadata(new CRANVersionMetadata(installed))
@@ -134,3 +137,5 @@ CRANDescription::CRANDescription(const std::string & n, const FSEntry & f, bool
}
}
+#endif
+
diff --git a/paludis/repositories/cran/cran_package_id.hh b/paludis/repositories/cran/cran_package_id.hh
new file mode 100644
index 0000000..245d484
--- /dev/null
+++ b/paludis/repositories/cran/cran_package_id.hh
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_CRAN_PACKAGE_ID_HH
+#define PALUDIS_GUARD_PALUDIS_CRAN_PACKAGE_ID_HH 1
+
+#include <paludis/package_id.hh>
+#include <paludis/util/fs_entry.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE CRANPackageID :
+ public PackageID
+ {
+ public:
+ static void normalise_name(std::string & s);
+ static void denormalise_name(std::string & s);
+ static void normalise_version(std::string & s);
+
+ const std::string native_package() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::string native_version() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const tr1::shared_ptr<const MetadataPackageIDKey> bundle_key() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const tr1::shared_ptr<const MetadataPackageIDKey> bundle_member_key() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index fe63294..10f99e3 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2006, 2007 Danny van Dyk <kugelfang@gentoo.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -17,50 +18,32 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
-
-#include <paludis/dep_spec.hh>
-#include <paludis/dep_spec_flattener.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/config_file.hh>
-#include <paludis/match_package.hh>
-#include <paludis/package_database_entry.hh>
-#include <paludis/package_database.hh>
-#include <paludis/eapi.hh>
-#include <paludis/repositories/cran/cran_dep_parser.hh>
-#include <paludis/repositories/cran/cran_description.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/environment.hh>
+#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_repository.hh>
-#include <paludis/repositories/cran/cran_version_metadata.hh>
#include <paludis/repositories/repository_maker.hh>
-#include <paludis/syncer.hh>
+#include <paludis/repository_info.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/iterator.hh>
+#include <paludis/util/join.hh>
#include <paludis/util/log.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/pstream.hh>
-#include <paludis/util/random.hh>
-#include <paludis/util/save.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/system.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/tr1_functional.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
-#include <map>
-#include <list>
-#include <fstream>
#include <functional>
#include <algorithm>
-#include <vector>
-#include <deque>
-#include <limits>
-
-#include <strings.h>
-#include <ctype.h>
/** \file
* Implementation CRANRepository.
@@ -72,20 +55,10 @@ using namespace paludis;
#include <paludis/repositories/cran/cran_repository-sr.cc>
+typedef MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<const CRANPackageID> >::Type IDMap;
+
namespace paludis
{
- /// Map for versions.
- typedef MakeHashedMap<QualifiedPackageName, VersionSpec>::Type VersionsMap;
-
- /// Map for packages.
- typedef MakeHashedMap<QualifiedPackageName, bool>::Type PackagesMap;
-
- /// Map for mirrors.
- typedef MakeHashedMap<std::string, std::list<std::string> >::Type MirrorMap;
-
- /// Map for metadata.
- typedef MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>, tr1::shared_ptr<VersionMetadata> >::Type MetadataMap;
-
/**
* Implementation data for a CRANRepository.
*
@@ -96,68 +69,17 @@ namespace paludis
{
CRANRepositoryParams params;
- /// Our owning env.
- const Environment * const env;
-
- /// Our base location.
- FSEntry location;
-
- /// Distfiles dir
- FSEntry distdir;
-
- /// Mirror URL
- std::string mirror;
-
- /// Sync URL
- std::string sync;
-
- /// Build root location
- FSEntry buildroot;
-
- /// Library location
- FSEntry library;
-
- /// Have we loaded our category names?
- mutable bool has_packages;
-
- /// Our package names, and whether we have a fully loaded list of
- /// version specs for that category.
- mutable PackagesMap package_names;
-
- /// Our version specs for each package.
- mutable VersionsMap version_specs;
-
- /// Metadata cache.
- mutable MetadataMap metadata;
-
- /// Do we have mirrors?
- mutable bool has_mirrors;
+ mutable bool has_ids;
+ mutable IDMap ids;
- /// Mirrors.
- mutable MirrorMap mirrors;
-
- /// Constructor.
Implementation(const CRANRepositoryParams &);
-
- /// Destructor.
~Implementation();
-
- /// (Empty) provides map.
- const std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
};
}
Implementation<CRANRepository>::Implementation(const CRANRepositoryParams & p) :
params(p),
- env(p.environment),
- location(p.location),
- distdir(p.distdir),
- mirror(p.mirror),
- sync(p.sync),
- buildroot(p.buildroot),
- library(p.library),
- has_packages(false),
- has_mirrors(false)
+ has_ids(false)
{
}
@@ -178,6 +100,7 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.use_interface(0)
.world_interface(0)
.environment_variable_interface(0)
+ .make_virtuals_interface(0)
.mirrors_interface(0)
.provides_interface(0)
.destination_interface(0)
@@ -193,12 +116,12 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
{
tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
- config_info->add_kv("location", stringify(_imp->location));
- config_info->add_kv("distdir", stringify(_imp->distdir));
+ config_info->add_kv("location", stringify(_imp->params.location));
+ config_info->add_kv("distdir", stringify(_imp->params.distdir));
config_info->add_kv("format", "cran");
- config_info->add_kv("buildroot", stringify(_imp->buildroot));
- config_info->add_kv("library", stringify(_imp->library));
- config_info->add_kv("sync", _imp->sync);
+ config_info->add_kv("buildroot", stringify(_imp->params.buildroot));
+ config_info->add_kv("library", stringify(_imp->params.library));
+ config_info->add_kv("sync", _imp->params.sync);
_info->add_section(config_info);
}
@@ -210,24 +133,19 @@ CRANRepository::~CRANRepository()
bool
CRANRepository::do_has_category_named(const CategoryNamePart & c) const
{
- Context context("When checking for category '" + stringify(c) +
- "' in " + stringify(name()) + ":");
-
return "cran" == stringify(c);
}
bool
CRANRepository::do_has_package_named(const QualifiedPackageName & q) const
{
- Context context("When checking for package '" + stringify(q) + "' in " +
- stringify(name()) + ":");
-
- need_packages();
+ Context context("When checking for package '" + stringify(q) + "' in " + stringify(name()) + ":");
if (! do_has_category_named(q.category))
return false;
- return _imp->package_names.end() != _imp->package_names.find(q);
+ need_ids();
+ return _imp->ids.end() != _imp->ids.find(q);
}
tr1::shared_ptr<const CategoryNamePartCollection>
@@ -247,136 +165,47 @@ CRANRepository::do_package_names(const CategoryNamePart & c) const
Context context("When fetching package names in category '" + stringify(c)
+ "' in " + stringify(name()) + ":");
- need_packages();
-
tr1::shared_ptr<QualifiedPackageNameCollection> result(new QualifiedPackageNameCollection::Concrete);
if (! do_has_category_named(c))
return result;
- PackagesMap::const_iterator n(_imp->package_names.begin()), n_end(_imp->package_names.end());
- for ( ; n != n_end ; ++n)
- result->insert(n->first);
+ need_ids();
+
+ std::copy(_imp->ids.begin(), _imp->ids.end(), transform_inserter(result->inserter(),
+ tr1::mem_fn(&std::pair<const QualifiedPackageName, tr1::shared_ptr<const CRANPackageID> >::first)));
return result;
}
-tr1::shared_ptr<const VersionSpecCollection>
-CRANRepository::do_version_specs(const QualifiedPackageName & n) const
+tr1::shared_ptr<const PackageIDSequence>
+CRANRepository::do_package_ids(const QualifiedPackageName & n) const
{
Context context("When fetching versions of '" + stringify(n) + "' in "
+ stringify(name()) + ":");
- need_packages();
+ tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence::Concrete);
+ if (! do_has_package_named(n))
+ return result;
- tr1::shared_ptr<VersionSpecCollection> result(new VersionSpecCollection::Concrete);
- if (_imp->version_specs.end() != _imp->version_specs.find(n))
- result->insert(_imp->version_specs.find(n)->second);
+ need_ids();
+ IDMap::const_iterator i(_imp->ids.find(n));
+ if (i != _imp->ids.end())
+ result->push_back(i->second);
return result;
}
-bool
-CRANRepository::do_has_version(const QualifiedPackageName & q,
- const VersionSpec & v) const
-{
- Context context("When checking for version '" + stringify(v) + "' in '"
- + stringify(q) + "' in " + stringify(name()) + ":");
-
- need_packages();
-
- if (has_package_named(q))
- return v == _imp->version_specs.find(q)->second;
- else
- return false;
-}
-
void
-CRANRepository::need_packages() const
+CRANRepository::need_ids() const
{
- if (_imp->has_packages)
+ if (_imp->has_ids)
return;
- Context context("When loading category names for " + stringify(name()) + ":");
+ Context context("When loading IDs for " + stringify(name()) + ":");
- LineConfigFile packages(FSEntry(_imp->location / "PACKAGES"), LineConfigFileOptions());
- LineConfigFile::Iterator l(packages.begin()), l_end(packages.end());
- std::string last_package_name;
- bool skip_invalid_package = false;
- for ( ; l != l_end ; ++l)
- {
- Context local_context("When parsing line '" + *l + "':");
-
- std::string line(strip_leading(strip_trailing(*l, " \t"), " \t"));
- if (line.empty())
- continue;
-
- std::string::size_type pos(line.find(':'));
- if (std::string::npos == pos)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Broken line in PACKAGES file: '" + stringify(_imp->location / "PACKAGES") + "'");
- continue;
- }
-
- std::string key(line.substr(0, pos)), value(line.substr(pos + 1));
- key = strip_leading(strip_trailing(key, " \t"), " \t");
- value = strip_leading(strip_trailing(value, " \t"), " \t");
- if (("Package" != key) && (skip_invalid_package))
- {
- skip_invalid_package = false;
- continue;
- }
-
- if ("Package" == key)
- {
- CRANDescription::normalise_name(value);
- last_package_name = value;
- QualifiedPackageName package_name(CategoryNamePart("cran"), PackageNamePart(last_package_name));
- _imp->package_names[package_name] = true;
- }
- else if ("Version" == key)
- {
- QualifiedPackageName package_name(CategoryNamePart("cran"), PackageNamePart(last_package_name));
- CRANDescription::normalise_version(value);
- VersionSpec version(value);
- if (false == _imp->version_specs.insert(VersionsMap::value_type(package_name, version)).second)
- {
- skip_invalid_package = true;
- Log::get_instance()->message(ll_warning, lc_context, "Multiple versions for package '"
- + last_package_name + "'.");
- continue;
- }
- }
- else if ("Contains" == key)
- {
- std::list<std::string> contains;
- WhitespaceTokeniser::get_instance()->tokenise(value, std::back_inserter(contains));
- std::list<std::string>::const_iterator i(contains.begin()), i_end(contains.end());
- // load metadata immediately
- for ( ; i != i_end ; ++i)
- {
- Context c("When processing 'Contains:' line: '" + stringify(*i) + "':");
- if (*i == last_package_name)
- continue;
-
- CRANDescription d(*i, FSEntry(_imp->location / std::string(last_package_name + ".DESCRIPTION")), false);
-
- std::string dep(d.metadata->deps_interface->get_raw_build_depend());
- std::string pkg(d.metadata->cran_interface->package);
- if ("" == dep)
- dep = pkg;
- else
- dep += "," + pkg;
- d.metadata->deps_interface->set_build_depend(dep);
- d.metadata->cran_interface->is_bundle_member = true;
-
- _imp->package_names[d.name] = true;
- _imp->metadata.insert(std::make_pair(std::make_pair(d.name, d.version), d.metadata));
- _imp->version_specs.insert(VersionsMap::value_type(d.name, d.version));
- }
- }
- }
+ LineConfigFile packages(FSEntry(_imp->params.location / "PACKAGES"), LineConfigFileOptions());
- _imp->has_packages = true;
+ _imp->has_ids = true;
}
RepositoryName
@@ -387,147 +216,53 @@ CRANRepository::fetch_repo_name(const std::string & location)
return RepositoryName("cran-" + modified_location);
}
-tr1::shared_ptr<const VersionMetadata>
-CRANRepository::do_version_metadata(
- const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (_imp->metadata.end() != _imp->metadata.find(
- std::make_pair(q, v)))
- return _imp->metadata.find(std::make_pair(q, v))->second;
-
- Context context("When fetching metadata for " + stringify(q) +
- "-" + stringify(v));
-
- if (! has_version(q, v))
- throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
-
- tr1::shared_ptr<VersionMetadata> result(new CRANVersionMetadata(false));
-
- FSEntry d(_imp->location);
- PackageNamePart p(q.package);
- std::string n(stringify(p));
- CRANDescription::denormalise_name(n);
- d /= n + ".DESCRIPTION";
-
- if (d.is_regular_file())
- {
- CRANDescription desc(stringify(p), d, false);
- result = desc.metadata;
- }
- else
- {
- Log::get_instance()->message(ll_warning, lc_no_context, "has_version failed for request for '" +
- stringify(q) + "-" + stringify(v) + "' in repository '" +
- stringify(name()) + "': File '" + n + ".DESCRIPTION' not present.");
- result.reset(new CRANVersionMetadata(false));
- result->eapi = EAPIData::get_instance()->unknown_eapi();
- }
-
- _imp->metadata.insert(std::make_pair(std::make_pair(q, v), result));
- return result;
-}
-
-tr1::shared_ptr<Repository>
-CRANRepository::make_cran_repository(
- Environment * const env,
- tr1::shared_ptr<const AssociativeCollection<std::string, std::string> > m)
-{
- Context context("When making CRAN repository from repo_file '" +
- (m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second) + "':");
-
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
- throw CRANRepositoryConfigurationError("Key 'location' not specified or empty");
-
- std::string library;
- if (m->end() == m->find("library") || ((library = m->find("library")->second)).empty())
- throw CRANRepositoryConfigurationError("Key 'library' not specified or empty");
-
- std::string distdir;
- if (m->end() == m->find("distdir") || ((distdir = m->find("distdir")->second)).empty())
- distdir = location + "/distfiles";
-
- std::string mirror;
- if (m->end() == m->find("mirror") || ((mirror = m->find("mirror")->second)).empty())
- mirror = "http://cran.r-project.org/";
-
- std::string sync;
- if (m->end() == m->find("sync") || ((sync = m->find("sync")->second)).empty())
- sync = "rsync://cran.r-project.org/CRAN";
-
- std::string buildroot;
- if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
- buildroot = "/var/tmp/paludis";
-
- return tr1::shared_ptr<Repository>(new CRANRepository(CRANRepositoryParams::create()
- .environment(env)
- .location(location)
- .distdir(distdir)
- .sync(sync)
- .buildroot(buildroot)
- .library(library)
- .mirror(mirror)));
-}
-
-CRANRepositoryConfigurationError::CRANRepositoryConfigurationError(
- const std::string & msg) throw () :
- ConfigurationError("CRAN repository configuration error: " + msg)
-{
-}
-
void
-CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
- const InstallOptions &o) const
+CRANRepository::do_install(const tr1::shared_ptr<const PackageID> & id_uncasted, const InstallOptions & o) const
{
- PackageNamePart pn(q.package);
- CategoryNamePart c("cran");
- tr1::shared_ptr<const VersionMetadata> vm(do_version_metadata(q, vn));
+ if (id_uncasted->repository().get() != this)
+ throw PackageInstallActionError("Couldn't install '" + stringify(*id_uncasted) + "' using repository '" +
+ stringify(name()) + "'");
- if (vm->cran_interface->is_bundle_member)
+ const tr1::shared_ptr<const CRANPackageID> id(tr1::static_pointer_cast<const CRANPackageID>(id_uncasted));
+ if (id->bundle_member_key())
return;
- std::string p(vm->cran_interface->package);
- std::string v(vm->cran_interface->version);
-
- tr1::shared_ptr<const FSEntryCollection> bashrc_files(_imp->env->bashrc_files());
+ tr1::shared_ptr<const FSEntryCollection> bashrc_files(_imp->params.environment->bashrc_files());
Command cmd(Command(LIBEXECDIR "/paludis/cran.bash fetch")
.with_setenv("CATEGORY", "cran")
- .with_setenv("DISTDIR", stringify(_imp->distdir))
- .with_setenv("DISTFILE", std::string(p + "_" + v + ".tar.gz"))
- .with_setenv("PN", stringify(pn))
- .with_setenv("PV", stringify(vn))
- .with_setenv("PALUDIS_CRAN_MIRRORS", _imp->mirror)
+ .with_setenv("DISTDIR", stringify(_imp->params.distdir))
+ .with_setenv("DISTFILE", id->native_package() + "_" + id->native_version() + ".tar.gz")
+ .with_setenv("PN", id->native_package())
+ .with_setenv("PV", id->native_version())
+ .with_setenv("PALUDIS_CRAN_MIRRORS", _imp->params.mirror)
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
.with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " ")));
-
if (0 != run_command(cmd))
- throw PackageInstallActionError("Couldn't fetch sources for '" + stringify(q) + "-" + stringify(vn) + "'");
+ throw PackageInstallActionError("Couldn't fetch sources for '" + stringify(*id) + "'");
if (o.fetch_only)
return;
- FSEntry image(_imp->buildroot / stringify(q) / "image");
- FSEntry workdir(_imp->buildroot / stringify(q) / "work");
+ FSEntry image(_imp->params.buildroot / stringify(id->native_package()) / "image");
+ FSEntry workdir(_imp->params.buildroot / stringify(id->native_package()) / "work");
if (! o.destination)
- throw PackageInstallActionError("Can't merge '" + stringify(q) + "-" + stringify(vn) +
- "' because no destination was provided.");
-
+ throw PackageInstallActionError("Can't merge '" + stringify(*id) + "' because no destination was provided.");
cmd = Command(LIBEXECDIR "/paludis/cran.bash clean install")
.with_sandbox()
.with_setenv("CATEGORY", "cran")
- .with_setenv("DISTDIR", stringify(_imp->distdir))
- .with_setenv("DISTFILE", std::string(p + "_" + v + ".tar.gz"))
+ .with_setenv("DISTDIR", stringify(_imp->params.distdir))
+ .with_setenv("DISTFILE", id->native_package() + "_" + id->native_version() + ".tar.gz")
.with_setenv("IMAGE", stringify(image))
- .with_setenv("IS_BUNDLE", (vm->cran_interface->is_bundle ? "yes" : ""))
- .with_setenv("LOCATION", stringify(_imp->location))
- .with_setenv("PN", stringify(pn))
- .with_setenv("PV", stringify(vn))
- .with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->library))
+ .with_setenv("IS_BUNDLE", (id->bundle_key() ? "yes" : ""))
+ .with_setenv("LOCATION", stringify(_imp->params.location))
+ .with_setenv("PN", id->native_package())
+ .with_setenv("PV", id->native_version())
+ .with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->params.library))
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
.with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
@@ -535,26 +270,26 @@ CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
.with_setenv("WORKDIR", stringify(workdir));
if (0 != run_command(cmd))
- throw PackageInstallActionError("Couldn't install '" + stringify(q) + "-" + stringify(vn) + "' to '" +
+ throw PackageInstallActionError("Couldn't install '" + stringify(*id) + "' to '" +
stringify(image) + "'");
- MergeOptions m(PackageDatabaseEntry(q, vn, name()),
- image,
- FSEntry("/dev/null"));
+ MergeOptions m(id, image, FSEntry("/dev/null"));
if (! o.destination->destination_interface)
- throw PackageInstallActionError("Couldn't install '" + stringify(q) + "-" + stringify(vn) + "' to '" +
+ throw PackageInstallActionError("Couldn't install '" + stringify(*id) + "' to '" +
stringify(o.destination->name()) + "' because it does not provide destination_interface");
if (! o.destination->installed_interface)
- throw PackageInstallActionError("Couldn't install '" + stringify(q) + "-" + stringify(vn) + "' to '" +
+ throw PackageInstallActionError("Couldn't install '" + stringify(*id) + "' to '" +
stringify(o.destination->name()) + "' because it does not provide installed_interface");
+ o.destination->destination_interface->merge(m);
+
cmd = Command(LIBEXECDIR "/paludis/cran.bash clean")
.with_setenv("IMAGE", stringify(image))
- .with_setenv("PN", p)
- .with_setenv("PV", stringify(vn))
- .with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->library))
+ .with_setenv("PN", id->native_package())
+ .with_setenv("PV", id->native_version())
+ .with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->params.library))
.with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/"))
.with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
.with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))
@@ -563,7 +298,7 @@ CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
.with_setenv("REPOSITORY", stringify(name()));
if (0 != run_command(cmd))
- throw PackageInstallActionError("Couldn't clean '" + stringify(q) + "-" + stringify(vn) + "'");
+ throw PackageInstallActionError("Couldn't clean '" + stringify(*id) + "'");
return;
}
@@ -600,21 +335,70 @@ CRANRepository::do_sync() const
Context context("When syncing repository '" + stringify(name()) + "':");
std::string cmd("rsync --delete --recursive --progress --exclude \"*.html\" --exclude \"*.INDEX\" '" +
- _imp->sync + "/src/contrib/Descriptions/' ./");
+ _imp->params.sync + "/src/contrib/Descriptions/' ./");
- if (0 != run_command(Command(cmd).with_chdir(_imp->location)))
+ if (0 != run_command(Command(cmd).with_chdir(_imp->params.location)))
return false;
- cmd = "rsync --progress '" + _imp->sync + "/src/contrib/PACKAGES' ./";
+ cmd = "rsync --progress '" + _imp->params.sync + "/src/contrib/PACKAGES' ./";
- if (0 != run_command(Command(cmd).with_chdir(_imp->location)))
+ if (0 != run_command(Command(cmd).with_chdir(_imp->params.location)))
return false;
- cmd = "rsync --progress '" + _imp->sync + "/CRAN_mirrors.csv' ./";
+ cmd = "rsync --progress '" + _imp->params.sync + "/CRAN_mirrors.csv' ./";
- return 0 == run_command(Command(cmd).with_chdir(_imp->location));
+ return 0 == run_command(Command(cmd).with_chdir(_imp->params.location));
}
+tr1::shared_ptr<Repository>
+CRANRepository::make_cran_repository(
+ Environment * const env,
+ tr1::shared_ptr<const AssociativeCollection<std::string, std::string> > m)
+{
+ Context context("When making CRAN repository from repo_file '" +
+ (m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second) + "':");
+
+ std::string location;
+ if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
+ throw CRANRepositoryConfigurationError("Key 'location' not specified or empty");
+
+ std::string library;
+ if (m->end() == m->find("library") || ((library = m->find("library")->second)).empty())
+ throw CRANRepositoryConfigurationError("Key 'library' not specified or empty");
+
+ std::string distdir;
+ if (m->end() == m->find("distdir") || ((distdir = m->find("distdir")->second)).empty())
+ distdir = location + "/distfiles";
+
+ std::string mirror;
+ if (m->end() == m->find("mirror") || ((mirror = m->find("mirror")->second)).empty())
+ mirror = "http://cran.r-project.org/";
+
+ std::string sync;
+ if (m->end() == m->find("sync") || ((sync = m->find("sync")->second)).empty())
+ sync = "rsync://cran.r-project.org/CRAN";
+
+ std::string buildroot;
+ if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
+ buildroot = "/var/tmp/paludis";
+
+ return tr1::shared_ptr<Repository>(new CRANRepository(CRANRepositoryParams::create()
+ .environment(env)
+ .location(location)
+ .distdir(distdir)
+ .sync(sync)
+ .buildroot(buildroot)
+ .library(library)
+ .mirror(mirror)));
+}
+
+CRANRepositoryConfigurationError::CRANRepositoryConfigurationError(
+ const std::string & msg) throw () :
+ ConfigurationError("CRAN repository configuration error: " + msg)
+{
+}
+
+
void
CRANRepository::invalidate()
{
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index d03deee..f4b3585 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -51,9 +52,7 @@ namespace paludis
private PrivateImplementationPattern<CRANRepository>
{
private:
- void need_packages() const;
- void need_version_names(const QualifiedPackageName &) const;
- void need_virtual_names() const;
+ void need_ids() const;
protected:
/**
@@ -61,33 +60,38 @@ namespace paludis
*/
static RepositoryName fetch_repo_name(const std::string & location);
- virtual bool do_has_category_named(const CategoryNamePart &) const;
+ /* RepositoryInstallableInterface */
- virtual bool do_has_package_named(const QualifiedPackageName &) const;
+ virtual void do_install(const tr1::shared_ptr<const PackageID> &, const InstallOptions &) const;
- virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const;
+ /* RepositorySyncableInterface */
- virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
- const CategoryNamePart &) const;
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> do_package_set(const SetName &) const;
- virtual tr1::shared_ptr<const VersionSpecCollection> do_version_specs(
- const QualifiedPackageName &) const;
+ virtual tr1::shared_ptr<const SetNameCollection> sets_list() const;
- virtual bool do_has_version(const QualifiedPackageName &,
- const VersionSpec &) const;
+ /* RepositorySyncableInterface */
- virtual tr1::shared_ptr<const VersionMetadata> do_version_metadata(
- const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual bool do_sync() const;
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const;
+ /* Repository */
- virtual tr1::shared_ptr<SetSpecTree::ConstItem> do_package_set(const SetName &) const;
+ virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const SetNameCollection> sets_list() const;
+ virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_sync() const;
+ virtual bool do_has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool do_has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const PackageIDSequence> do_package_ids(
+ const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
/**
@@ -117,7 +121,8 @@ namespace paludis
* \ingroup grpexceptions
* \ingroup grpportagerepository
*/
- class PALUDIS_VISIBLE CRANRepositoryConfigurationError : public ConfigurationError
+ class PALUDIS_VISIBLE CRANRepositoryConfigurationError :
+ public ConfigurationError
{
public:
/**
diff --git a/paludis/repositories/cran/cran_repository_TEST.cc b/paludis/repositories/cran/cran_repository_TEST.cc
index 579f9e9..6c3fe92 100644
--- a/paludis/repositories/cran/cran_repository_TEST.cc
+++ b/paludis/repositories/cran/cran_repository_TEST.cc
@@ -20,7 +20,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
-#include <paludis/repositories/cran/cran_description.hh>
+#include <paludis/repositories/cran/cran_package_id.hh>
#include <paludis/repositories/cran/cran_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/collection_concrete.hh>
diff --git a/paludis/repositories/cran/cran_version_metadata.cc b/paludis/repositories/cran/cran_version_metadata.cc
deleted file mode 100644
index d8ed2b3..0000000
--- a/paludis/repositories/cran/cran_version_metadata.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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 "cran_version_metadata.hh"
-#include "cran_dep_parser.hh"
-#include <paludis/eapi.hh>
-
-using namespace paludis;
-
-CRANVersionMetadata::CRANVersionMetadata(bool want_origins) :
- VersionMetadata(
- VersionMetadataBase::create()
- .slot(SlotName("unset"))
- .homepage("")
- .description("")
- .eapi(EAPIData::get_instance()->unknown_eapi())
- .interactive(false),
- VersionMetadataCapabilities::create()
- .cran_interface(this)
- .ebuild_interface(0)
- .license_interface(0)
- .virtual_interface(0)
- .origins_interface(want_origins ? this : 0)
- .deps_interface(this)
- .ebin_interface(0)
- ),
- VersionMetadataCRANInterface("", "", "", false, false),
- VersionMetadataDepsInterface(CRANDepParser::parse)
-{
-}
-
-CRANVersionMetadata::~CRANVersionMetadata()
-{
-}
-
diff --git a/paludis/repositories/cran/cran_version_metadata.hh b/paludis/repositories/cran/cran_version_metadata.hh
deleted file mode 100644
index 77c0591..0000000
--- a/paludis/repositories/cran/cran_version_metadata.hh
+++ /dev/null
@@ -1,56 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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_CRAN_VERSION_METADATA_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_CRAN_VERSION_METADATA_HH 1
-
-#include <paludis/version_metadata.hh>
-
-namespace paludis
-{
- /**
- * VersionMetadata for a CRAN package.
- *
- * \ingroup grpcranrepository
- * \nosubgrouping
- */
- class CRANVersionMetadata :
- public VersionMetadata,
- public VersionMetadataCRANInterface,
- public VersionMetadataDepsInterface,
- public VersionMetadataOriginsInterface,
- public virtual VersionMetadataHasInterfaces
- {
- public:
- ///\name Basic operations
- ///\{
-
- CRANVersionMetadata(bool want_origins);
- virtual ~CRANVersionMetadata();
-
- ///\}
-
- virtual const VersionMetadata * version_metadata() const
- {
- return this;
- }
- };
-}
-
-#endif
diff --git a/paludis/repositories/fake/Makefile.am b/paludis/repositories/fake/Makefile.am
index 4e4bf4c..4fdf93f 100644
--- a/paludis/repositories/fake/Makefile.am
+++ b/paludis/repositories/fake/Makefile.am
@@ -9,6 +9,47 @@ DEFS= \
paludis_repositories_libdir = $(libdir)/paludis/repositories
+TESTS_ENVIRONMENT = env \
+ PALUDIS_GEMS_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_srcdir)/paludis/repositories/gems/`" \
+ PALUDIS_EAPIS_DIR="$(top_srcdir)/paludis/eapis/" \
+ PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \
+ PALUDIS_SKIP_CONFIG="yes" \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
+ LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
+ $(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/gems/`:` \
+ $(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/gems/.libs/`" \
+ bash $(top_srcdir)/test/run_test.sh
+
+TESTS = fake_repository_TEST fake_installed_repository_TEST
+check_PROGRAMS = $(TESTS)
+
+EXTRA_DIST = \
+ fake_repository_TEST.cc \
+ fake_installed_repository_TEST.cc
+
+fake_repository_TEST_LDADD = \
+ libpaludisfakerepository.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/test/libtest.a
+
+fake_installed_repository_TEST_LDADD = \
+ libpaludisfakerepository.la \
+ $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/util/test_extras.o \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/test/libtest.a
+
+fake_repository_TEST_SOURCES = \
+ fake_repository_TEST.cc
+
+fake_installed_repository_TEST_SOURCES = \
+ fake_installed_repository_TEST.cc
+
if MONOLITHIC
noinst_LTLIBRARIES = libpaludisfakerepository.la
@@ -22,7 +63,8 @@ endif
libpaludisfakerepository_la_SOURCES = \
fake_repository_base.cc fake_repository_base.hh \
fake_repository.cc fake_repository.hh \
- fake_installed_repository.cc fake_installed_repository.hh
+ fake_installed_repository.cc fake_installed_repository.hh \
+ fake_package_id.cc fake_package_id.hh
if ! MONOLITHIC
@@ -38,7 +80,8 @@ paludis_repositories_fake_includedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/
paludis_repositories_fake_include_HEADERS = \
fake_repository.hh \
fake_repository_base.hh \
- fake_installed_repository.hh
+ fake_installed_repository.hh \
+ fake_package_id.hh
built-sources : $(BUILT_SOURCES)
for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 4a43cee..b337b4f 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -22,6 +22,9 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/portage_dep_parser.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/environment.hh>
#include <paludis/dep_spec_flattener.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -48,21 +51,26 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.licenses_interface(0)
.portage_interface(0)
.pretend_interface(0)
+ .make_virtuals_interface(0)
.hook_interface(0),
"fake_installed")
{
}
+FakeInstalledRepository::~FakeInstalledRepository()
+{
+}
+
bool
-FakeInstalledRepository::is_suitable_destination_for(const PackageDatabaseEntry &) const
+FakeInstalledRepository::is_suitable_destination_for(const PackageID &) const
{
return true;
}
-tr1::shared_ptr<const FakeInstalledRepository::ProvidesCollection>
+tr1::shared_ptr<const FakeInstalledRepository::ProvidesSequence>
FakeInstalledRepository::provided_packages() const
{
- tr1::shared_ptr<ProvidesCollection> result(new ProvidesCollection::Concrete);
+ tr1::shared_ptr<ProvidesSequence> result(new ProvidesSequence::Concrete);
tr1::shared_ptr<const CategoryNamePartCollection> cats(category_names());
for (CategoryNamePartCollection::Iterator c(cats->begin()), c_end(cats->end()) ;
@@ -72,23 +80,20 @@ FakeInstalledRepository::provided_packages() const
for (QualifiedPackageNameCollection::Iterator p(pkgs->begin()), p_end(pkgs->end()) ;
p != p_end ; ++p)
{
- tr1::shared_ptr<const VersionSpecCollection> vers(version_specs(*p));
- for (VersionSpecCollection::Iterator v(vers->begin()), v_end(vers->end()) ;
+ tr1::shared_ptr<const PackageIDSequence> vers(package_ids(*p));
+ for (PackageIDSequence::Iterator v(vers->begin()), v_end(vers->end()) ;
v != v_end ; ++v)
{
- tr1::shared_ptr<const VersionMetadata> m(version_metadata(*p, *v));
- if (! m->ebuild_interface)
+ if (! (*v)->provide_key())
continue;
- PackageDatabaseEntry dbe(*p, *v, name());
- DepSpecFlattener f(environment(), &dbe);
- m->ebuild_interface->provide()->accept(f);
+ DepSpecFlattener f(environment(), *v);
+ (*v)->provide_key()->value()->accept(f);
for (DepSpecFlattener::Iterator q(f.begin()), q_end(f.end()) ; q != q_end ; ++q)
- result->insert(RepositoryProvidesEntry::create()
+ result->push_back(RepositoryProvidesEntry::create()
.virtual_name(QualifiedPackageName((*q)->text()))
- .version(*v)
- .provided_by_name(*p));
+ .provided_by(*v));
}
}
}
@@ -96,20 +101,6 @@ FakeInstalledRepository::provided_packages() const
return result;
}
-tr1::shared_ptr<const VersionMetadata>
-FakeInstalledRepository::provided_package_version_metadata(const RepositoryProvidesEntry & p) const
-{
- tr1::shared_ptr<const VersionMetadata> m(version_metadata(p.provided_by_name, p.version));
- tr1::shared_ptr<FakeVirtualVersionMetadata> result(new FakeVirtualVersionMetadata(
- m->slot, PackageDatabaseEntry(p.provided_by_name, p.version, name())));
-
- result->eapi = m->eapi;
- result->deps_interface->set_build_depend(stringify(p.provided_by_name));
- result->deps_interface->set_run_depend(stringify(p.provided_by_name));
-
- return result;
-}
-
FSEntry
FakeInstalledRepository::root() const
{
@@ -133,3 +124,9 @@ FakeInstalledRepository::merge(const MergeOptions &)
{
}
+time_t
+FakeInstalledRepository::do_installed_time(const PackageID &) const
+{
+ return 0;
+}
+
diff --git a/paludis/repositories/fake/fake_installed_repository.hh b/paludis/repositories/fake/fake_installed_repository.hh
index 982b658..58bb394 100644
--- a/paludis/repositories/fake/fake_installed_repository.hh
+++ b/paludis/repositories/fake/fake_installed_repository.hh
@@ -36,25 +36,38 @@ namespace paludis
public RepositoryProvidesInterface
{
protected:
- virtual tr1::shared_ptr<const ProvidesCollection> provided_packages() const;
+ /* RepositoryInstalledInterface */
- virtual tr1::shared_ptr<const VersionMetadata> provided_package_version_metadata(
- const RepositoryProvidesEntry &) const;
+ virtual time_t do_installed_time(const PackageID &) const;
+
+ virtual FSEntry root() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /* RepositoryDestinationInterface */
+
+ virtual bool is_suitable_destination_for(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool is_default_destination() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool want_pre_post_phases() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void merge(const MergeOptions &);
+
+ /* RepositoryProvidesInterface */
+
+ virtual tr1::shared_ptr<const ProvidesSequence> provided_packages() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
///\name Basic operations
///\{
FakeInstalledRepository(const Environment * const, const RepositoryName &);
+ ~FakeInstalledRepository();
///\}
-
- bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
- bool is_default_destination() const;
- bool want_pre_post_phases() const;
- void merge(const MergeOptions &);
-
- virtual FSEntry root() const;
};
}
diff --git a/paludis/repositories/fake/fake_installed_repository_TEST.cc b/paludis/repositories/fake/fake_installed_repository_TEST.cc
new file mode 100644
index 0000000..99f3098
--- /dev/null
+++ b/paludis/repositories/fake/fake_installed_repository_TEST.cc
@@ -0,0 +1,41 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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 <test/test_runner.hh>
+#include <test/test_framework.hh>
+#include <paludis/repositories/fake/fake_installed_repository.hh>
+#include <paludis/environments/test/test_environment.hh>
+
+using namespace test;
+using namespace paludis;
+
+namespace test_cases
+{
+ struct FakeInstalledRepositoryTest : TestCase
+ {
+ FakeInstalledRepositoryTest() : TestCase("fake installed repository") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<const FakeInstalledRepository> r(new FakeInstalledRepository(&env, RepositoryName("fake")));
+ }
+ } test_fake_installed_repository;
+}
+
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
new file mode 100644
index 0000000..8c2e748
--- /dev/null
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -0,0 +1,474 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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/fake/fake_package_id.hh>
+#include <paludis/repositories/fake/fake_repository_base.hh>
+#include <paludis/eapi.hh>
+#include <paludis/name.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/portage_dep_parser.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/visitor-impl.hh>
+
+#include <libwrapiter/libwrapiter_output_iterator.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ template <typename C_>
+ struct Implementation<FakeMetadataCollectionKey<C_> >
+ {
+ tr1::shared_ptr<C_> collection;
+ };
+}
+
+template <typename C_>
+FakeMetadataCollectionKey<C_>::FakeMetadataCollectionKey(
+ const std::string & r, const std::string & h) :
+ MetadataCollectionKey<C_>(r, h),
+ PrivateImplementationPattern<FakeMetadataCollectionKey<C_> >(new Implementation<FakeMetadataCollectionKey<C_> >),
+ _imp(PrivateImplementationPattern<FakeMetadataCollectionKey<C_> >::_imp.get())
+{
+}
+
+template <typename C_>
+FakeMetadataCollectionKey<C_>::~FakeMetadataCollectionKey()
+{
+}
+
+template <typename C_>
+const tr1::shared_ptr<const C_>
+FakeMetadataCollectionKey<C_>::value() const
+{
+ return _imp->collection;
+}
+
+FakeMetadataKeywordCollectionKey::FakeMetadataKeywordCollectionKey(const std::string & r,
+ const std::string & h, const std::string & v) :
+ FakeMetadataCollectionKey<KeywordNameCollection>(r, h)
+{
+ set_from_string(v);
+}
+
+void
+FakeMetadataKeywordCollectionKey::set_from_string(const std::string & s)
+{
+ _imp->collection.reset(new KeywordNameCollection::Concrete);
+ WhitespaceTokeniser::get_instance()->tokenise(s, create_inserter<KeywordName>(_imp->collection->inserter()));
+}
+
+FakeMetadataIUseCollectionKey::FakeMetadataIUseCollectionKey(const std::string & r,
+ const std::string & h, const std::string & v, const IUseFlagParseMode m) :
+ FakeMetadataCollectionKey<IUseFlagCollection>(r, h)
+{
+ set_from_string(v, m);
+}
+
+void
+FakeMetadataIUseCollectionKey::set_from_string(const std::string & s, const IUseFlagParseMode m)
+{
+ _imp->collection.reset(new IUseFlagCollection::Concrete);
+ std::list<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(tokens));
+ for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ _imp->collection->insert(IUseFlag(*t, m));
+}
+
+namespace paludis
+{
+ template <>
+ template <typename C_>
+ struct Implementation<FakeMetadataSpecTreeKey<C_> >
+ {
+ tr1::shared_ptr<const typename C_::ConstItem> value;
+ const tr1::function<const tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> func;
+
+ Implementation(const tr1::function<const tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> & f) :
+ func(f)
+ {
+ }
+ };
+}
+
+template <typename C_>
+FakeMetadataSpecTreeKey<C_>::FakeMetadataSpecTreeKey(const std::string & r, const std::string & h, const std::string & v,
+ const tr1::function<const tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> & f) :
+ MetadataSpecTreeKey<C_>(r, h),
+ PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >(new Implementation<FakeMetadataSpecTreeKey<C_> >(f)),
+ _imp(PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >::_imp.get())
+{
+ set_from_string(v);
+}
+
+template <typename C_>
+FakeMetadataSpecTreeKey<C_>::~FakeMetadataSpecTreeKey()
+{
+}
+
+template <typename C_>
+void
+FakeMetadataSpecTreeKey<C_>::set_from_string(const std::string & s)
+{
+ _imp->value = _imp->func(s);
+}
+
+template <typename C_>
+const tr1::shared_ptr<const typename C_::ConstItem>
+FakeMetadataSpecTreeKey<C_>::value() const
+{
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<FakeMetadataPackageIDKey>
+ {
+ tr1::shared_ptr<const PackageID> value;
+ };
+}
+
+FakeMetadataPackageIDKey::FakeMetadataPackageIDKey(const std::string & r, const std::string & h,
+ const tr1::shared_ptr<const PackageID> & v) :
+ MetadataPackageIDKey(r, h),
+ PrivateImplementationPattern<FakeMetadataPackageIDKey>(new Implementation<FakeMetadataPackageIDKey>),
+ _imp(PrivateImplementationPattern<FakeMetadataPackageIDKey>::_imp.get())
+{
+ _imp->value = v;
+}
+
+FakeMetadataPackageIDKey::~FakeMetadataPackageIDKey()
+{
+}
+
+const tr1::shared_ptr<const PackageID>
+FakeMetadataPackageIDKey::value() const
+{
+ return _imp->value;
+}
+
+namespace paludis
+{
+ using namespace tr1::placeholders;
+
+ template <>
+ struct Implementation<FakePackageID>
+ {
+ const tr1::shared_ptr<const FakeRepositoryBase> repository;
+ const QualifiedPackageName name;
+ const VersionSpec version;
+ SlotName slot;
+ tr1::shared_ptr<const EAPI> eapi;
+
+ tr1::shared_ptr<FakeMetadataPackageIDKey> package_id;
+ tr1::shared_ptr<FakeMetadataPackageIDKey> virtual_for;
+ tr1::shared_ptr<FakeMetadataKeywordCollectionKey> keywords;
+ tr1::shared_ptr<FakeMetadataIUseCollectionKey> iuse;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<LicenseSpecTree> > license;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<ProvideSpecTree> > provide;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > build_dependencies;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > run_dependencies;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > post_dependencies;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<RestrictSpecTree> > restrictions;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<URISpecTree> > src_uri;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<URISpecTree> > bin_uri;
+ tr1::shared_ptr<FakeMetadataSpecTreeKey<URISpecTree> > homepage;
+
+ Implementation(const tr1::shared_ptr<const FakeRepositoryBase> & r,
+ const QualifiedPackageName & q, const VersionSpec & v) :
+ repository(r),
+ name(q),
+ version(v),
+ slot("0"),
+ eapi(EAPIData::get_instance()->eapi_from_string("0")),
+ keywords(new FakeMetadataKeywordCollectionKey("KEYWORDS", "Keywords", "test")),
+ iuse(new FakeMetadataIUseCollectionKey("IUSE", "Used USE flags", "", iuse_pm_permissive)),
+ license(new FakeMetadataSpecTreeKey<LicenseSpecTree>("LICENSE", "Licenses",
+ "", tr1::bind(&PortageDepParser::parse_license, _1, tr1::cref(*eapi)))),
+ provide(new FakeMetadataSpecTreeKey<ProvideSpecTree>("PROVIDE", "Provided packages",
+ "", tr1::bind(&PortageDepParser::parse_provide, _1, tr1::cref(*eapi)))),
+ build_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("DEPEND", "Build dependencies",
+ "", tr1::bind(&PortageDepParser::parse_depend, _1, tr1::cref(*eapi)))),
+ run_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("RDEPEND", "Run dependencies",
+ "", tr1::bind(&PortageDepParser::parse_depend, _1, tr1::cref(*eapi)))),
+ post_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("PDEPEND", "Post dependencies",
+ "", tr1::bind(&PortageDepParser::parse_depend, _1, tr1::cref(*eapi)))),
+ suggested_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("SDEPEND", "Suggested dependencies",
+ "", tr1::bind(&PortageDepParser::parse_depend, _1, tr1::cref(*eapi))))
+ {
+ }
+ };
+}
+
+FakePackageID::FakePackageID(const tr1::shared_ptr<const FakeRepositoryBase> & r,
+ const QualifiedPackageName & q, const VersionSpec & v) :
+ PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(r, q, v)),
+ _imp(PrivateImplementationPattern<FakePackageID>::_imp.get())
+{
+ add_key(_imp->keywords);
+ add_key(_imp->iuse);
+ add_key(_imp->license);
+ add_key(_imp->provide);
+ add_key(_imp->build_dependencies);
+ add_key(_imp->run_dependencies);
+ add_key(_imp->post_dependencies);
+ add_key(_imp->suggested_dependencies);
+}
+
+FakePackageID::~FakePackageID()
+{
+}
+
+const std::string
+FakePackageID::canonical_form(const PackageIDCanonicalForm f) const
+{
+ switch (f)
+ {
+ case idcf_full:
+ return stringify(_imp->name) + "-" + stringify(_imp->version) + ":" + stringify(slot()) + "::" + stringify(_imp->repository->name());
+
+ case idcf_version:
+ return stringify(_imp->version);
+
+ case idcf_no_version:
+ return stringify(_imp->name) + ":" + stringify(slot()) + "::" + stringify(_imp->repository->name());
+
+ case last_idcf:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad PackageIDCanonicalForm");
+}
+
+const QualifiedPackageName
+FakePackageID::name() const
+{
+ return _imp->name;
+}
+
+const VersionSpec
+FakePackageID::version() const
+{
+ return _imp->version;
+}
+
+const SlotName
+FakePackageID::slot() const
+{
+ return _imp->slot;
+}
+
+const tr1::shared_ptr<const Repository>
+FakePackageID::repository() const
+{
+ return _imp->repository;
+}
+
+const tr1::shared_ptr<const EAPI>
+FakePackageID::eapi() const
+{
+ return _imp->eapi;
+}
+
+const tr1::shared_ptr<const MetadataPackageIDKey>
+FakePackageID::virtual_for_key() const
+{
+ return _imp->virtual_for;
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameCollection> >
+FakePackageID::keywords_key() const
+{
+ return _imp->keywords;
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagCollection> >
+FakePackageID::iuse_key() const
+{
+ return _imp->iuse;
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<InheritedCollection> >
+FakePackageID::inherited_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<InheritedCollection> >();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameCollection> >
+FakePackageID::use_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameCollection> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> >
+FakePackageID::license_key() const
+{
+ return _imp->license;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >
+FakePackageID::provide_key() const
+{
+ return _imp->provide;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::build_dependencies_key() const
+{
+ return _imp->build_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::run_dependencies_key() const
+{
+ return _imp->run_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::post_dependencies_key() const
+{
+ return _imp->post_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::suggested_dependencies_key() const
+{
+ return _imp->suggested_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> >
+FakePackageID::restrict_key() const
+{
+ return _imp->restrictions;
+}
+
+const tr1::shared_ptr<FakeMetadataKeywordCollectionKey>
+FakePackageID::keywords_key()
+{
+ return _imp->keywords;
+}
+
+const tr1::shared_ptr<FakeMetadataIUseCollectionKey>
+FakePackageID::iuse_key()
+{
+ return _imp->iuse;
+}
+
+const tr1::shared_ptr<FakeMetadataSpecTreeKey<ProvideSpecTree> >
+FakePackageID::provide_key()
+{
+ return _imp->provide;
+}
+
+const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::build_dependencies_key()
+{
+ return _imp->build_dependencies;
+}
+
+const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::run_dependencies_key()
+{
+ return _imp->run_dependencies;
+}
+
+const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::post_dependencies_key()
+{
+ return _imp->post_dependencies;
+}
+
+const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> >
+FakePackageID::suggested_dependencies_key()
+{
+ return _imp->suggested_dependencies;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >
+FakePackageID::src_uri_key() const
+{
+ return _imp->src_uri;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >
+FakePackageID::homepage_key() const
+{
+ return _imp->homepage;
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >
+FakePackageID::bin_uri_key() const
+{
+ return _imp->bin_uri;
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+FakePackageID::short_description_key() const
+{
+ return tr1::shared_ptr<const MetadataStringKey>();
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+FakePackageID::long_description_key() const
+{
+ return tr1::shared_ptr<const MetadataStringKey>();
+}
+
+void
+FakePackageID::set_slot(const SlotName & s)
+{
+ _imp->slot = s;
+}
+
+bool
+FakePackageID::arbitrary_less_than_comparison(const PackageID & other) const
+{
+ return slot().data() < other.slot().data();
+}
+
+void
+FakePackageID::need_keys_added() const
+{
+}
+
+std::size_t
+FakePackageID::extra_hash_value() const
+{
+ return CRCHash<SlotName>()(slot());
+}
+
+template class FakeMetadataSpecTreeKey<LicenseSpecTree>;
+template class FakeMetadataSpecTreeKey<ProvideSpecTree>;
+template class FakeMetadataSpecTreeKey<DependencySpecTree>;
+template class FakeMetadataSpecTreeKey<RestrictSpecTree>;
+template class FakeMetadataSpecTreeKey<URISpecTree>;
+
+template class FakeMetadataCollectionKey<KeywordNameCollection>;
+template class FakeMetadataCollectionKey<IUseFlagCollection>;
+
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
new file mode 100644
index 0000000..6a11db8
--- /dev/null
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -0,0 +1,157 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_FAKE_FAKE_PACKAGE_ID_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_FAKE_FAKE_PACKAGE_ID_HH 1
+
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/util/tr1_functional.hh>
+
+namespace paludis
+{
+ class FakeRepositoryBase;
+
+ template <typename C_>
+ class PALUDIS_VISIBLE FakeMetadataCollectionKey :
+ public MetadataCollectionKey<C_>,
+ private PrivateImplementationPattern<FakeMetadataCollectionKey<C_> >
+ {
+ protected:
+ Implementation<FakeMetadataCollectionKey> * const _imp;
+
+ FakeMetadataCollectionKey(const std::string &, const std::string &);
+
+ public:
+ ~FakeMetadataCollectionKey();
+
+ virtual const tr1::shared_ptr<const C_> value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE FakeMetadataKeywordCollectionKey :
+ public FakeMetadataCollectionKey<KeywordNameCollection>
+ {
+ public:
+ FakeMetadataKeywordCollectionKey(const std::string &, const std::string &, const std::string &);
+
+ void set_from_string(const std::string &);
+ };
+
+ class PALUDIS_VISIBLE FakeMetadataIUseCollectionKey :
+ public FakeMetadataCollectionKey<IUseFlagCollection>
+ {
+ public:
+ FakeMetadataIUseCollectionKey(const std::string &, const std::string &, const std::string &, const IUseFlagParseMode);
+
+ void set_from_string(const std::string &, const IUseFlagParseMode);
+ };
+
+ template <typename C_>
+ class PALUDIS_VISIBLE FakeMetadataSpecTreeKey :
+ public MetadataSpecTreeKey<C_>,
+ private PrivateImplementationPattern<FakeMetadataSpecTreeKey<C_> >
+ {
+ private:
+ Implementation<FakeMetadataSpecTreeKey<C_> > * const _imp;
+
+ public:
+ FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
+ const tr1::function<const tr1::shared_ptr<const typename C_::ConstItem> (const std::string &)> &);
+ ~FakeMetadataSpecTreeKey();
+
+ virtual const tr1::shared_ptr<const typename C_::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void set_from_string(const std::string &);
+ };
+
+ class PALUDIS_VISIBLE FakeMetadataPackageIDKey :
+ public MetadataPackageIDKey,
+ private PrivateImplementationPattern<FakeMetadataPackageIDKey>
+ {
+ private:
+ Implementation<FakeMetadataPackageIDKey> * const _imp;
+
+ public:
+ FakeMetadataPackageIDKey(const std::string &, const std::string &,
+ const tr1::shared_ptr<const PackageID> &);
+ ~FakeMetadataPackageIDKey();
+
+ virtual const tr1::shared_ptr<const PackageID> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class PALUDIS_VISIBLE FakePackageID :
+ public PackageID,
+ private PrivateImplementationPattern<FakePackageID>
+ {
+ private:
+ Implementation<FakePackageID> * const _imp;
+
+ protected:
+ virtual void need_keys_added() const;
+
+ public:
+ FakePackageID(const tr1::shared_ptr<const FakeRepositoryBase> &,
+ const QualifiedPackageName &, const VersionSpec &);
+ ~FakePackageID();
+
+ virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
+
+ virtual const QualifiedPackageName name() const;
+ virtual const VersionSpec version() const;
+ virtual const SlotName slot() const;
+ virtual const tr1::shared_ptr<const Repository> repository() const;
+ virtual const tr1::shared_ptr<const EAPI> eapi() const;
+
+ virtual const tr1::shared_ptr<const MetadataPackageIDKey> virtual_for_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameCollection> > keywords_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameCollection> > use_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagCollection> > iuse_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<InheritedCollection> > inherited_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > src_uri_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > bin_uri_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > homepage_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > restrict_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> short_description_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> long_description_key() const;
+
+ const tr1::shared_ptr<FakeMetadataKeywordCollectionKey> keywords_key();
+ const tr1::shared_ptr<FakeMetadataIUseCollectionKey> iuse_key();
+
+ const tr1::shared_ptr<FakeMetadataSpecTreeKey<ProvideSpecTree> > provide_key();
+ const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key();
+ const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key();
+ const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key();
+ const tr1::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key();
+
+ void set_slot(const SlotName &);
+
+ virtual bool arbitrary_less_than_comparison(const PackageID &) const;
+ virtual std::size_t extra_hash_value() const;
+ };
+}
+
+#endif
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 504b650..55e0a79 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -17,19 +17,37 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "fake_repository.hh"
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/portage_dep_parser.hh>
#include <paludis/distribution.hh>
#include <paludis/environment.hh>
+#include <paludis/package_id.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
using namespace paludis;
+namespace paludis
+{
+ template<>
+ struct Implementation<FakeRepository>
+ {
+ tr1::shared_ptr<FakeRepository::VirtualsSequence> virtual_packages;
+
+ Implementation() :
+ virtual_packages(new FakeRepository::VirtualsSequence::Concrete)
+ {
+ }
+ };
+}
+
FakeRepository::FakeRepository(const Environment * const e, const RepositoryName & our_name) :
+ PrivateImplementationPattern<FakeRepository>(new Implementation<FakeRepository>),
FakeRepositoryBase(e, our_name, RepositoryCapabilities::create()
.installable_interface(this)
.installed_interface(0)
@@ -50,55 +68,34 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.licenses_interface(0)
.portage_interface(0)
.pretend_interface(0)
+ .make_virtuals_interface(0)
.hook_interface(0),
"fake"),
- _virtual_packages(new VirtualsCollection::Concrete)
+ _imp(PrivateImplementationPattern<FakeRepository>::_imp.get())
{
}
-void
-FakeRepository::do_install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const
+FakeRepository::~FakeRepository()
{
}
-tr1::shared_ptr<const FakeRepository::VirtualsCollection>
-FakeRepository::virtual_packages() const
+void
+FakeRepository::do_install(const tr1::shared_ptr<const PackageID> &, const InstallOptions &) const
{
- return _virtual_packages;
}
-tr1::shared_ptr<const VersionMetadata>
-FakeRepository::virtual_package_version_metadata(
- const RepositoryVirtualsEntry & p, const VersionSpec & v) const
+tr1::shared_ptr<const FakeRepository::VirtualsSequence>
+FakeRepository::virtual_packages() const
{
- Context context("When fetching virtual package version metadata for '" + stringify(*p.provided_by_spec)
- + "' version '" + stringify(v) + "':");
-
- if (! p.provided_by_spec->package_ptr())
- throw ConfigurationError("Virtual provider atom does not specify an unambiguous package");
-
- tr1::shared_ptr<const VersionMetadata> m(version_metadata(*p.provided_by_spec->package_ptr(), v));
- tr1::shared_ptr<FakeVirtualVersionMetadata> result(new FakeVirtualVersionMetadata(
- m->slot, PackageDatabaseEntry(*p.provided_by_spec->package_ptr(), v, name())));
-
- result->eapi = m->eapi;
- result->deps_interface->set_build_depend("=" + stringify(*p.provided_by_spec->package_ptr())
- + "-" + stringify(v));
- result->deps_interface->set_run_depend("=" + stringify(*p.provided_by_spec->package_ptr())
- + "-" + stringify(v));
-
- return result;
+ return _imp->virtual_packages;
}
void
FakeRepository::add_virtual_package(const QualifiedPackageName & q, tr1::shared_ptr<const PackageDepSpec> p)
{
- _virtual_packages->insert(RepositoryVirtualsEntry(q, p));
+ _imp->virtual_packages->push_back(RepositoryVirtualsEntry(q, p));
}
-#ifndef MONOLITHIC
-
namespace paludis
{
class RepositoryMaker;
@@ -113,5 +110,3 @@ void register_repositories(RepositoryMaker *)
{
}
-#endif
-
diff --git a/paludis/repositories/fake/fake_repository.hh b/paludis/repositories/fake/fake_repository.hh
index 565a4c9..c28afcb 100644
--- a/paludis/repositories/fake/fake_repository.hh
+++ b/paludis/repositories/fake/fake_repository.hh
@@ -30,27 +30,25 @@ namespace paludis
* \ingroup grpfakerepository
*/
class PALUDIS_VISIBLE FakeRepository :
+ private PrivateImplementationPattern<FakeRepository>,
public FakeRepositoryBase,
public RepositoryInstallableInterface,
public RepositoryVirtualsInterface
{
private:
- tr1::shared_ptr<VirtualsCollection> _virtual_packages;
+ Implementation<FakeRepository> * const _imp;
protected:
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const;
+ /* RepositoryInstallableInterface */
- virtual tr1::shared_ptr<const VirtualsCollection> virtual_packages() const;
-
- virtual tr1::shared_ptr<const VersionMetadata> virtual_package_version_metadata(
- const RepositoryVirtualsEntry &, const VersionSpec & v) const;
+ virtual void do_install(const tr1::shared_ptr<const PackageID> &, const InstallOptions &) const;
public:
///\name Basic operations
///\{
FakeRepository(const Environment * const, const RepositoryName &);
+ ~FakeRepository();
///\}
@@ -58,6 +56,11 @@ namespace paludis
* Add a virtual package.
*/
void add_virtual_package(const QualifiedPackageName &, tr1::shared_ptr<const PackageDepSpec>);
+
+ /* RepositoryVirtualsInterface */
+
+ virtual tr1::shared_ptr<const VirtualsSequence> virtual_packages() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/package_database_entry.cc b/paludis/repositories/fake/fake_repository_TEST.cc
index f4cf453..631c5c5 100644
--- a/paludis/package_database_entry.cc
+++ b/paludis/repositories/fake/fake_repository_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -17,29 +17,26 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "package_database_entry.hh"
+#include <test/test_runner.hh>
+#include <test/test_framework.hh>
+#include <paludis/repositories/fake/fake_repository.hh>
+#include <paludis/environments/test/test_environment.hh>
+using namespace test;
using namespace paludis;
-#include "package_database_entry-sr.cc"
-
-bool
-ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator::operator () (
- const PackageDatabaseEntry & lhs, const PackageDatabaseEntry & rhs) const
+namespace test_cases
{
- if (lhs.name < rhs.name)
- return false;
- if (lhs.name > rhs.name)
- return true;
-
- if (lhs.version < rhs.version)
- return false;
- if (lhs.version > rhs.version)
- return true;
-
- if (lhs.repository.data() < rhs.repository.data())
- return true;
-
- return false;
+ struct FakeRepositoryTest : TestCase
+ {
+ FakeRepositoryTest() : TestCase("fake repository") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ tr1::shared_ptr<const FakeRepository> r(new FakeRepository(&env, RepositoryName("fake")));
+ }
+ } test_fake_repository;
}
+
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 45e05fc..e78cf4d 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -18,15 +18,16 @@
*/
#include <paludis/repositories/fake/fake_repository_base.hh>
+#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/tr1_functional.hh>
-#include <paludis/version_metadata.hh>
#include <paludis/portage_dep_parser.hh>
#include <paludis/eapi.hh>
+#include <paludis/repository_info.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <map>
@@ -56,18 +57,12 @@ namespace paludis
/// Our package names.
std::map<CategoryNamePart, tr1::shared_ptr<PackageNamePartCollection> > package_names;
- /// Our versions.
- std::map<QualifiedPackageName, tr1::shared_ptr<VersionSpecCollection> > versions;
-
- /// Our metadata.
- std::map<std::string, tr1::shared_ptr<VersionMetadata> > metadata;
+ /// Our IDs.
+ std::map<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> > ids;
/// Our sets.
std::map<SetName, tr1::shared_ptr<SetSpecTree::ConstItem> > sets;
- /// (Empty) provides map.
- const std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
-
const Environment * const env;
/// Constructor.
@@ -133,25 +128,14 @@ FakeRepositoryBase::do_package_names(const CategoryNamePart & c) const
return result;
}
-tr1::shared_ptr<const VersionSpecCollection>
-FakeRepositoryBase::do_version_specs(const QualifiedPackageName & n) const
+tr1::shared_ptr<const PackageIDSequence>
+FakeRepositoryBase::do_package_ids(const QualifiedPackageName & n) const
{
if (! has_category_named(n.category))
- return tr1::shared_ptr<VersionSpecCollection>(new VersionSpecCollection::Concrete);
+ return tr1::shared_ptr<PackageIDSequence>(new PackageIDSequence::Concrete);
if (! has_package_named(n))
- return tr1::shared_ptr<VersionSpecCollection>(new VersionSpecCollection::Concrete);
- return _imp->versions.find(n)->second;
-}
-
-bool
-FakeRepositoryBase::do_has_version(const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (! has_category_named(q.category))
- return false;
- if (! has_package_named(q))
- return false;
- return _imp->versions.find(q)->second->find(v) !=
- _imp->versions.find(q)->second->end();
+ return tr1::shared_ptr<PackageIDSequence>(new PackageIDSequence::Concrete);
+ return _imp->ids.find(n)->second;
}
void
@@ -166,59 +150,44 @@ FakeRepositoryBase::add_package(const QualifiedPackageName & q)
{
add_category(q.category);
_imp->package_names.find(q.category)->second->insert(q.package);
- _imp->versions.insert(std::make_pair(q, new VersionSpecCollection::Concrete));
+ _imp->ids.insert(std::make_pair(q, new PackageIDSequence::Concrete));
}
-tr1::shared_ptr<VersionMetadata>
+tr1::shared_ptr<FakePackageID>
FakeRepositoryBase::add_version(const QualifiedPackageName & q, const VersionSpec & v)
{
add_package(q);
- _imp->versions.find(q)->second->insert(v);
- _imp->metadata.insert(
- std::make_pair(stringify(q) + "-" + stringify(v),
- tr1::shared_ptr<VersionMetadata>(new FakeVersionMetadata)));
- tr1::shared_ptr<VersionMetadata> r(_imp->metadata.find(stringify(q) + "-" + stringify(v))->second);
- r->slot = SlotName("0");
- r->eapi = EAPIData::get_instance()->eapi_from_string("0");
- return r;
-}
-
-tr1::shared_ptr<const VersionMetadata>
-FakeRepositoryBase::do_version_metadata(
- const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (! has_version(q, v))
- throw InternalError(PALUDIS_HERE, "no version");
- return _imp->metadata.find(stringify(q) + "-" + stringify(v))->second;
+ tr1::shared_ptr<FakePackageID> id(new FakePackageID(shared_from_this(), q, v));
+ _imp->ids.find(q)->second->push_back(id);
+ return id;
}
bool
-FakeRepositoryBase::do_query_repository_masks(const QualifiedPackageName &,
- const VersionSpec &) const
+FakeRepositoryBase::do_query_repository_masks(const PackageID &) const
{
return false;
}
bool
-FakeRepositoryBase::do_query_profile_masks(const QualifiedPackageName &, const VersionSpec &) const
+FakeRepositoryBase::do_query_profile_masks(const PackageID &) const
{
return false;
}
UseFlagState
-FakeRepositoryBase::do_query_use(const UseFlagName &, const PackageDatabaseEntry &) const
+FakeRepositoryBase::do_query_use(const UseFlagName &, const PackageID &) const
{
return use_unspecified;
}
bool
-FakeRepositoryBase::do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry &) const
+FakeRepositoryBase::do_query_use_mask(const UseFlagName &, const PackageID &) const
{
return false;
}
bool
-FakeRepositoryBase::do_query_use_force(const UseFlagName &, const PackageDatabaseEntry &) const
+FakeRepositoryBase::do_query_use_force(const UseFlagName &, const PackageID &) const
{
return false;
}
@@ -279,7 +248,7 @@ FakeRepositoryBase::sets_list() const
std::string
FakeRepositoryBase::do_describe_use_flag(const UseFlagName &,
- const PackageDatabaseEntry &) const
+ const PackageID &) const
{
return "";
}
@@ -290,57 +259,3 @@ FakeRepositoryBase::environment() const
return _imp->env;
}
-FakeVersionMetadata::FakeVersionMetadata() :
- VersionMetadata(
- VersionMetadataBase::create()
- .slot(SlotName("0"))
- .homepage("")
- .description("")
- .eapi(EAPIData::get_instance()->eapi_from_string("paludis-1"))
- .interactive(false),
- VersionMetadataCapabilities::create()
- .ebuild_interface(this)
- .deps_interface(this)
- .license_interface(this)
- .cran_interface(0)
- .virtual_interface(0)
- .origins_interface(0)
- .ebin_interface(0)
- ),
- VersionMetadataEbuildInterface(),
- VersionMetadataDepsInterface(&PortageDepParser::parse_depend),
- VersionMetadataLicenseInterface(&PortageDepParser::parse_license)
-{
- set_keywords("test");
-}
-
-FakeVersionMetadata::~FakeVersionMetadata()
-{
-}
-
-FakeVirtualVersionMetadata::FakeVirtualVersionMetadata(const SlotName & s, const PackageDatabaseEntry & p) :
- VersionMetadata(
- VersionMetadataBase::create()
- .slot(s)
- .homepage("")
- .description("")
- .eapi(EAPIData::get_instance()->eapi_from_string("paludis-1"))
- .interactive(false),
- VersionMetadataCapabilities::create()
- .ebuild_interface(0)
- .deps_interface(this)
- .license_interface(0)
- .cran_interface(0)
- .virtual_interface(this)
- .origins_interface(0)
- .ebin_interface(0)
- ),
- VersionMetadataDepsInterface(&PortageDepParser::parse_depend),
- VersionMetadataVirtualInterface(make_shared_ptr(new PackageDatabaseEntry(p)))
-{
-}
-
-FakeVirtualVersionMetadata::~FakeVirtualVersionMetadata()
-{
-}
-
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index d1058e9..ef0539f 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -31,58 +31,7 @@
namespace paludis
{
- /**
- * FakeVersionMetadata is used by FakeRepository and
- * FakeInstalledRepository for version metadata.
- *
- * \see FakeInstalledRepository
- * \see FakeRepository
- * \ingroup grpfakerepository
- */
- class FakeVersionMetadata :
- public VersionMetadata,
- public VersionMetadataEbuildInterface,
- public VersionMetadataDepsInterface,
- public VersionMetadataLicenseInterface,
- public virtual VersionMetadataHasInterfaces
- {
- public:
- FakeVersionMetadata();
- virtual ~FakeVersionMetadata();
-
- virtual const VersionMetadata * version_metadata() const
- {
- return this;
- }
- };
-
- /**
- * FakeVirtualVersionMetadata is used by FakeRepository for virtual
- * version metadata.
- *
- * \see FakeRepository
- * \ingroup grpfakerepository
- */
- class FakeVirtualVersionMetadata :
- public VersionMetadata,
- public VersionMetadataDepsInterface,
- public VersionMetadataVirtualInterface,
- public virtual VersionMetadataHasInterfaces
- {
- public:
- ///\name Basic operations
- ///\{
-
- FakeVirtualVersionMetadata(const SlotName &, const PackageDatabaseEntry &);
- virtual ~FakeVirtualVersionMetadata();
-
- ///\}
-
- virtual const VersionMetadata * version_metadata() const
- {
- return this;
- }
- };
+ class FakePackageID;
/**
* A FakeRepositoryBase is a Repository subclass whose subclasses are used for
@@ -97,62 +46,82 @@ namespace paludis
public RepositoryMaskInterface,
public RepositoryUseInterface,
public RepositorySetsInterface,
- private PrivateImplementationPattern<FakeRepositoryBase>
+ private PrivateImplementationPattern<FakeRepositoryBase>,
+ public tr1::enable_shared_from_this<FakeRepositoryBase>
{
protected:
+ /**
+ * Constructor.
+ */
+ FakeRepositoryBase(const Environment * const env, const RepositoryName & name,
+ const RepositoryCapabilities & caps, const std::string &);
+
+ /* RepositoryMaskInterface */
+
+ virtual bool do_query_repository_masks(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool do_query_profile_masks(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
/* RepositoryUseInterface */
- virtual UseFlagState do_query_use(const UseFlagName &, const PackageDatabaseEntry &) const;
- virtual bool do_query_use_mask(const UseFlagName &, const PackageDatabaseEntry &) const;
- virtual bool do_query_use_force(const UseFlagName &, const PackageDatabaseEntry &) const;
- virtual tr1::shared_ptr<const UseFlagNameCollection> do_arch_flags() const;
- virtual tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_flags() const;
- virtual tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_hidden_prefixes() const;
- virtual tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_prefixes() const;
- virtual std::string do_describe_use_flag(const UseFlagName &, const PackageDatabaseEntry &) const;
+ virtual UseFlagState do_query_use(const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- /* end of RepositoryUseInterface */
+ virtual bool do_query_use_mask(const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_has_category_named(const CategoryNamePart &) const;
+ virtual bool do_query_use_force(const UseFlagName &, const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_has_package_named(const QualifiedPackageName &) const;
+ virtual tr1::shared_ptr<const UseFlagNameCollection> do_arch_flags() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const;
+ virtual tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_flags() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
- const CategoryNamePart &) const;
+ virtual tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_hidden_prefixes() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const VersionSpecCollection> do_version_specs(
- const QualifiedPackageName &) const;
+ virtual tr1::shared_ptr<const UseFlagNameCollection> do_use_expand_prefixes() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_has_version(const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual std::string do_describe_use_flag(const UseFlagName &,
+ const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const VersionMetadata> do_version_metadata(
- const QualifiedPackageName &,
- const VersionSpec &) const;
+ /* RepositorySetsInterface */
- virtual bool do_query_repository_masks(const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual tr1::shared_ptr<SetSpecTree::ConstItem> do_package_set(const SetName & id) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_query_profile_masks(const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual tr1::shared_ptr<const SetNameCollection> sets_list() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<SetSpecTree::ConstItem> do_package_set(const SetName & id) const;
- virtual tr1::shared_ptr<const SetNameCollection> sets_list() const;
+ /* Repository */
- protected:
- /**
- * Constructor.
- */
- FakeRepositoryBase(const Environment * const env, const RepositoryName & name,
- const RepositoryCapabilities & caps, const std::string &);
+ virtual tr1::shared_ptr<const PackageIDSequence> do_package_ids(
+ const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool do_has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool do_has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
/**
* Destructor.
*/
-
~FakeRepositoryBase();
/**
@@ -169,16 +138,14 @@ namespace paludis
* Add a version, and a package and category if necessary, and set some
* default values for its metadata, and return said metadata.
*/
- tr1::shared_ptr<VersionMetadata> add_version(
- const QualifiedPackageName &, const VersionSpec &);
+ tr1::shared_ptr<FakePackageID> add_version(const QualifiedPackageName &, const VersionSpec &);
/**
* Add a version, and a package and category if necessary, and set some
* default values for its metadata, and return said metadata (convenience
* overload taking strings).
*/
- tr1::shared_ptr<VersionMetadata> add_version(
- const std::string & c, const std::string & p, const std::string & v)
+ tr1::shared_ptr<FakePackageID> add_version(const std::string & c, const std::string & p, const std::string & v)
{
return add_version(CategoryNamePart(c) + PackageNamePart(p), VersionSpec(v));
}
diff --git a/paludis/repositories/gems/Makefile.am b/paludis/repositories/gems/Makefile.am
index 10c1e34..0b0f9b9 100644
--- a/paludis/repositories/gems/Makefile.am
+++ b/paludis/repositories/gems/Makefile.am
@@ -21,7 +21,6 @@ libpaludisgemsrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSI
paludis_repositories_gems_include_HEADERS = \
gems_repository.hh \
installed_gems_repository.hh \
- metadata.hh \
exceptions.hh \
yaml.hh yaml-fwd.hh \
gem_specification.hh gem_specification-fwd.hh \
@@ -32,7 +31,6 @@ libpaludisgemsrepository_la_SOURCES = \
gems_repository.cc \
installed_gems_repository.cc \
params.cc \
- metadata.cc \
exceptions.cc \
yaml.cc \
gem_specification.cc \
diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc
index eb03914..405518a 100644
--- a/paludis/repositories/gems/gem_specification.cc
+++ b/paludis/repositories/gems/gem_specification.cc
@@ -22,26 +22,74 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/name.hh>
+#include <paludis/eapi.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/repository.hh>
+#include <paludis/metadata_key.hh>
+
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
using namespace paludis;
using namespace paludis::gems;
+namespace
+{
+ class GemMetadataStringKey :
+ public MetadataStringKey
+ {
+ private:
+ const std::string _value;
+
+ public:
+ GemMetadataStringKey(const std::string &, const std::string &, const std::string &);
+
+ virtual const std::string value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+
+ GemMetadataStringKey::GemMetadataStringKey(const std::string & r, const std::string & h, const std::string & v) :
+ MetadataStringKey(r, h),
+ _value(v)
+ {
+ }
+
+ const std::string
+ GemMetadataStringKey::value() const
+ {
+ return _value;
+ }
+}
+
namespace paludis
{
template <>
struct Implementation<GemSpecification>
{
- std::string name;
+ std::string name_part;
std::string version;
- std::string summary;
- std::string authors;
std::string date;
- std::string description;
std::string platform;
- std::string rubyforge_project;
std::string homepage;
+
+ tr1::shared_ptr<GemMetadataStringKey> description_key;
+ tr1::shared_ptr<GemMetadataStringKey> summary_key;
+ tr1::shared_ptr<GemMetadataStringKey> authors_key;
+ tr1::shared_ptr<GemMetadataStringKey> rubyforge_project_key;
+
+ tr1::shared_ptr<const FSEntry> load_from_file;
+
+ const tr1::shared_ptr<const Repository> repository;
+ const tr1::shared_ptr<const EAPI> eapi;
+
+ Implementation(const tr1::shared_ptr<const Repository> & r) :
+ repository(r),
+ eapi(EAPIData::get_instance()->eapi_from_string("gems-1"))
+ {
+ }
};
}
@@ -178,14 +226,26 @@ namespace
void visit(const yaml::MapNode & n)
{
- _imp->summary = required_text_only_key(n, "summary");
- _imp->authors = optional_text_sequence_key(n, "authors");
+ std::string summary(required_text_only_key(n, "summary"));
+ if (! summary.empty())
+ _imp->summary_key.reset(new GemMetadataStringKey("summary", "Summary", summary));
+
+ std::string description(optional_text_only_key(n, "description"));
+ if (! description.empty())
+ _imp->description_key.reset(new GemMetadataStringKey("description", "Description", description));
+
+ std::string authors(optional_text_sequence_key(n, "authors"));
+ if (! authors.empty())
+ _imp->authors_key.reset(new GemMetadataStringKey("authors", "Authors", authors));
+
+ std::string rubyforge_project(optional_text_sequence_key(n, "rubyforge_project"));
+ if (! rubyforge_project.empty())
+ _imp->rubyforge_project_key.reset(new GemMetadataStringKey("rubyforge_project", "Rubyforge Project", rubyforge_project));
+
_imp->date = required_text_only_key(n, "date");
- _imp->description = optional_text_only_key(n, "description");
_imp->platform = required_text_only_key(n, "platform");
- _imp->name = required_text_only_key(n, "name");
+ _imp->name_part = required_text_only_key(n, "name");
_imp->version = required_version(n, "version");
- _imp->rubyforge_project = optional_text_sequence_key(n, "rubyforge_project");
}
void visit(const yaml::SequenceNode & n) PALUDIS_ATTRIBUTE((noreturn));
@@ -204,20 +264,35 @@ namespace
}
}
-GemSpecification::GemSpecification(const yaml::Node & node) :
- PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>),
- name(tr1::bind(&Implementation<GemSpecification>::name, _imp.get())),
- version(tr1::bind(&Implementation<GemSpecification>::version, _imp.get())),
- homepage(tr1::bind(&Implementation<GemSpecification>::homepage, _imp.get())),
- rubyforge_project(tr1::bind(&Implementation<GemSpecification>::rubyforge_project, _imp.get())),
- authors(tr1::bind(&Implementation<GemSpecification>::authors, _imp.get())),
- date(tr1::bind(&Implementation<GemSpecification>::date, _imp.get())),
- platform(tr1::bind(&Implementation<GemSpecification>::platform, _imp.get())),
- summary(tr1::bind(&Implementation<GemSpecification>::summary, _imp.get())),
- description(tr1::bind(&Implementation<GemSpecification>::description, _imp.get()))
+GemSpecification::GemSpecification(const tr1::shared_ptr<const Repository> & r, const yaml::Node & node) :
+ PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(r)),
+ _imp(PrivateImplementationPattern<GemSpecification>::_imp.get())
{
- TopVisitor v(_imp.get());
+ TopVisitor v(_imp);
node.accept(v);
+
+ if (_imp->summary_key)
+ add_key(_imp->summary_key);
+
+ if (_imp->description_key)
+ add_key(_imp->description_key);
+
+ if (_imp->authors_key)
+ add_key(_imp->authors_key);
+
+ if (_imp->rubyforge_project_key)
+ add_key(_imp->rubyforge_project_key);
+}
+
+
+GemSpecification::GemSpecification(const tr1::shared_ptr<const Repository> & r,
+ const PackageNamePart & q, const VersionSpec & v, const FSEntry & f) :
+ PrivateImplementationPattern<GemSpecification>(new Implementation<GemSpecification>(r)),
+ _imp(PrivateImplementationPattern<GemSpecification>::_imp.get())
+{
+ _imp->name_part = stringify(q);
+ _imp->version = stringify(v);
+ _imp->load_from_file.reset(new FSEntry(f));
}
GemSpecification::~GemSpecification()
@@ -229,3 +304,209 @@ BadSpecificationError::BadSpecificationError(const std::string & s) throw () :
{
}
+const std::string
+GemSpecification::canonical_form(const PackageIDCanonicalForm f) const
+{
+ switch (f)
+ {
+ case idcf_full:
+ return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
+
+ case idcf_version:
+ return stringify(version());
+
+ case idcf_no_version:
+ return stringify(name()) + "::" + stringify(_imp->repository->name());
+
+ case last_idcf:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad PackageIDCanonicalForm");
+}
+
+const QualifiedPackageName
+GemSpecification::name() const
+{
+ return QualifiedPackageName(CategoryNamePart("gems") + PackageNamePart(_imp->name_part));
+}
+
+const VersionSpec
+GemSpecification::version() const
+{
+ return VersionSpec(_imp->version);
+}
+
+const SlotName
+GemSpecification::slot() const
+{
+ return SlotName(_imp->version);
+}
+
+const tr1::shared_ptr<const Repository>
+GemSpecification::repository() const
+{
+ return _imp->repository;
+}
+
+const tr1::shared_ptr<const EAPI>
+GemSpecification::eapi() const
+{
+ return _imp->eapi;
+}
+
+const tr1::shared_ptr<const MetadataPackageIDKey>
+GemSpecification::virtual_for_key() const
+{
+ return tr1::shared_ptr<const MetadataPackageIDKey>();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameCollection> >
+GemSpecification::keywords_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<KeywordNameCollection> >();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagCollection> >
+GemSpecification::iuse_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<IUseFlagCollection> >();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<InheritedCollection> >
+GemSpecification::inherited_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<InheritedCollection> >();
+}
+
+const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameCollection> >
+GemSpecification::use_key() const
+{
+ return tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameCollection> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> >
+GemSpecification::license_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >
+GemSpecification::provide_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+GemSpecification::build_dependencies_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+GemSpecification::run_dependencies_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+GemSpecification::post_dependencies_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> >
+GemSpecification::restrict_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >
+GemSpecification::src_uri_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >
+GemSpecification::homepage_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >
+GemSpecification::bin_uri_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
+GemSpecification::suggested_dependencies_key() const
+{
+ return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+GemSpecification::short_description_key() const
+{
+ return _imp->summary_key;
+}
+
+const tr1::shared_ptr<const MetadataStringKey>
+GemSpecification::long_description_key() const
+{
+ return _imp->description_key;
+}
+
+bool
+GemSpecification::arbitrary_less_than_comparison(const PackageID &) const
+{
+ return false;
+}
+
+std::size_t
+GemSpecification::extra_hash_value() const
+{
+ return 0;
+}
+
+void
+GemSpecification::need_keys_added() const
+{
+ if (_imp->load_from_file)
+ throw InternalError(PALUDIS_HERE, "Got to do the load from file thing");
+}
+
+#if 0
+InstalledGemsRepository::need_version_metadata(const QualifiedPackageName & q, const VersionSpec & v) const
+{
+ MetadataMap::const_iterator i(_imp->metadata.find(std::make_pair(q, v)));
+ if (i != _imp->metadata.end())
+ return;
+
+ Context c("When loading version metadata for '" + stringify(PackageDatabaseEntry(q, v, name())) + "':");
+
+ tr1::shared_ptr<gems::InstalledGemMetadata> m(new gems::InstalledGemMetadata(v));
+ _imp->metadata.insert(std::make_pair(std::make_pair(q, v), m));
+
+ Command cmd(getenv_with_default("PALUDIS_GEMS_DIR", LIBEXECDIR "/paludis") +
+ "/gems/gems.bash specification '" + stringify(q.package) + "' '" + stringify(v) + "'");
+ cmd.with_stderr_prefix(stringify(q) + "-" + stringify(v) + "::" + stringify(name()) + "> ");
+ cmd.with_sandbox();
+ cmd.with_uid_gid(_imp->params.environment->reduced_uid(), _imp->params.environment->reduced_gid());
+
+ PStream p(cmd);
+ std::string output((std::istreambuf_iterator<char>(p)), std::istreambuf_iterator<char>());
+
+ if (0 != p.exit_status())
+ {
+ Log::get_instance()->message(ll_warning, lc_context) << "Version metadata extraction returned non-zero";
+ return;
+ }
+
+ yaml::Document spec_doc(output);
+ gems::GemSpecification spec(*spec_doc.top());
+ m->populate_from_specification(spec);
+ m->eapi = EAPIData::get_instance()->eapi_from_string("gems-1");
+}
+#endif
+
diff --git a/paludis/repositories/gems/gem_specification.hh b/paludis/repositories/gems/gem_specification.hh
index cb9cf27..dfcddad 100644
--- a/paludis/repositories/gems/gem_specification.hh
+++ b/paludis/repositories/gems/gem_specification.hh
@@ -22,10 +22,12 @@
#include <paludis/repositories/gems/gem_specification-fwd.hh>
#include <paludis/repositories/gems/yaml-fwd.hh>
+#include <paludis/package_id.hh>
+#include <paludis/name-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/exception.hh>
-#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/fs_entry-fwd.hh>
#include <string>
namespace paludis
@@ -58,31 +60,56 @@ namespace paludis
* \nosubgrouping
*/
class PALUDIS_VISIBLE GemSpecification :
- private PrivateImplementationPattern<GemSpecification>
+ private PrivateImplementationPattern<GemSpecification>,
+ public PackageID
{
+ private:
+ Implementation<GemSpecification> * const _imp;
+
+ protected:
+ void need_keys_added() const;
+
public:
///\name Basic operations
///\{
- GemSpecification(const yaml::Node &);
+ GemSpecification(const tr1::shared_ptr<const Repository> &, const yaml::Node &);
+ GemSpecification(const tr1::shared_ptr<const Repository> &, const PackageNamePart &,
+ const VersionSpec &, const FSEntry &);
+
~GemSpecification();
///\}
- ///\name Specification data
- ///\{
+ /* PackageID */
+ virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
- const tr1::function<std::string ()> name;
- const tr1::function<std::string ()> version;
- const tr1::function<std::string ()> homepage;
- const tr1::function<std::string ()> rubyforge_project;
- const tr1::function<std::string ()> authors;
- const tr1::function<std::string ()> date;
- const tr1::function<std::string ()> platform;
- const tr1::function<std::string ()> summary;
- const tr1::function<std::string ()> description;
+ virtual const QualifiedPackageName name() const;
+ virtual const VersionSpec version() const;
+ virtual const SlotName slot() const;
+ virtual const tr1::shared_ptr<const Repository> repository() const;
+ virtual const tr1::shared_ptr<const EAPI> eapi() const;
- ///\}
+ virtual const tr1::shared_ptr<const MetadataPackageIDKey> virtual_for_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<KeywordNameCollection> > keywords_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<IUseFlagCollection> > iuse_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameCollection> > use_key() const;
+ virtual const tr1::shared_ptr<const MetadataCollectionKey<InheritedCollection> > inherited_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > restrict_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > src_uri_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > homepage_key() const;
+ virtual const tr1::shared_ptr<const MetadataSpecTreeKey<URISpecTree> > bin_uri_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> short_description_key() const;
+ virtual const tr1::shared_ptr<const MetadataStringKey> long_description_key() const;
+
+ virtual bool arbitrary_less_than_comparison(const PackageID &) const;
+ virtual std::size_t extra_hash_value() const;
};
}
}
diff --git a/paludis/repositories/gems/gem_specification_TEST.cc b/paludis/repositories/gems/gem_specification_TEST.cc
index 4836d9e..4b07f73 100644
--- a/paludis/repositories/gems/gem_specification_TEST.cc
+++ b/paludis/repositories/gems/gem_specification_TEST.cc
@@ -21,11 +21,70 @@
#include <test/test_framework.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/yaml.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/name.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/version_spec.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
using namespace test;
using namespace paludis;
using namespace paludis::gems;
+namespace
+{
+ struct ExtractValueVisitor :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ std::string s;
+
+ void visit(const MetadataStringKey & k)
+ {
+ s = k.value();
+ }
+
+ void visit(const MetadataPackageIDKey &)
+ {
+ }
+
+ void visit(const MetadataCollectionKey<KeywordNameCollection> &)
+ {
+ }
+
+ void visit(const MetadataCollectionKey<UseFlagNameCollection> &)
+ {
+ }
+
+ void visit(const MetadataCollectionKey<IUseFlagCollection> &)
+ {
+ }
+
+ void visit(const MetadataCollectionKey<InheritedCollection> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> &)
+ {
+ }
+ };
+}
+
namespace test_cases
{
struct SpecificationTest : TestCase
@@ -51,15 +110,26 @@ namespace test_cases
yaml::Document spec_doc(spec_text);
TEST_CHECK(spec_doc.top());
- GemSpecification spec(*spec_doc.top());
- TEST_CHECK_EQUAL(spec.summary(), "This is the summary");
- TEST_CHECK_EQUAL(spec.name(), "demo");
- TEST_CHECK_EQUAL(spec.version(), "1.2.3");
+ GemSpecification spec(tr1::shared_ptr<Repository>(), *spec_doc.top());
+
+ TEST_CHECK(spec.short_description_key());
+ TEST_CHECK_EQUAL(spec.short_description_key()->value(), "This is the summary");
+ TEST_CHECK_EQUAL(spec.name(), QualifiedPackageName("gems/demo"));
+ TEST_CHECK_EQUAL(spec.version(), VersionSpec("1.2.3"));
+ TEST_CHECK(spec.find("rubyforge_project") == spec.end());
+ TEST_CHECK(spec.long_description_key());
+ TEST_CHECK_EQUAL(spec.long_description_key()->value(), "A longer description");
+ TEST_CHECK(spec.find("authors") != spec.end());
+
+ ExtractValueVisitor v;
+ spec.find("authors")->accept(v);
+ TEST_CHECK_EQUAL(v.s, "Fred, Barney");
+
+#if 0
TEST_CHECK_EQUAL(spec.homepage(), "");
TEST_CHECK_EQUAL(spec.rubyforge_project(), "");
- TEST_CHECK_EQUAL(spec.description(), "A longer description");
- TEST_CHECK_EQUAL(spec.authors(), "Fred, Barney");
TEST_CHECK_EQUAL(spec.date(), "1234");
+#endif
}
} test_specification;
}
diff --git a/paludis/repositories/gems/gem_specifications.cc b/paludis/repositories/gems/gem_specifications.cc
index c8cd24c..de5291f 100644
--- a/paludis/repositories/gems/gem_specifications.cc
+++ b/paludis/repositories/gems/gem_specifications.cc
@@ -20,6 +20,8 @@
#include <paludis/repositories/gems/gem_specifications.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/yaml.hh>
+#include <paludis/name.hh>
+#include <paludis/version_spec.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/log.hh>
@@ -99,9 +101,11 @@ namespace
ConstVisitor<yaml::NodeVisitorTypes>
{
Implementation<GemSpecifications> * const _imp;
+ const tr1::shared_ptr<const Repository> repository;
- GemsVisitor(Implementation<GemSpecifications> * const i) :
- _imp(i)
+ GemsVisitor(const tr1::shared_ptr<const Repository> & r, Implementation<GemSpecifications> * const i) :
+ _imp(i),
+ repository(r)
{
}
@@ -114,9 +118,8 @@ namespace
try
{
- tr1::shared_ptr<GemSpecification> spec(make_shared_ptr(new GemSpecification(*i->second)));
- _imp->specs.insert(std::make_pair(std::make_pair(CategoryNamePart("gems") + PackageNamePart(spec->name()),
- VersionSpec(spec->version())), spec));
+ tr1::shared_ptr<GemSpecification> spec(new GemSpecification(repository, *i->second));
+ _imp->specs.insert(std::make_pair(std::make_pair(spec->name(), spec->version()), spec));
}
catch (const Exception & e)
{
@@ -145,9 +148,11 @@ namespace
ConstVisitor<yaml::NodeVisitorTypes>
{
Implementation<GemSpecifications> * const _imp;
+ const tr1::shared_ptr<const Repository> repository;
- TopVisitor(Implementation<GemSpecifications> * const i) :
- _imp(i)
+ TopVisitor(const tr1::shared_ptr<const Repository> & r, Implementation<GemSpecifications> * const i) :
+ _imp(i),
+ repository(r)
{
}
@@ -157,7 +162,7 @@ namespace
if (n.end() == i)
throw BadSpecificationError("Top level map does not contain 'gems' node");
- GemsVisitor g(_imp);
+ GemsVisitor g(repository, _imp);
i->second->accept(g);
}
@@ -177,10 +182,10 @@ namespace
}
}
-GemSpecifications::GemSpecifications(const yaml::Node & n) :
+GemSpecifications::GemSpecifications(const tr1::shared_ptr<const Repository> & r, const yaml::Node & n) :
PrivateImplementationPattern<GemSpecifications>(new Implementation<GemSpecifications>)
{
- TopVisitor v(_imp.get());
+ TopVisitor v(r, _imp.get());
n.accept(v);
}
diff --git a/paludis/repositories/gems/gem_specifications.hh b/paludis/repositories/gems/gem_specifications.hh
index ca7af70..629abe7 100644
--- a/paludis/repositories/gems/gem_specifications.hh
+++ b/paludis/repositories/gems/gem_specifications.hh
@@ -28,6 +28,7 @@
#include <paludis/util/tr1_memory.hh>
#include <paludis/name-fwd.hh>
#include <paludis/version_spec-fwd.hh>
+#include <paludis/repository-fwd.hh>
#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh>
#include <string>
@@ -49,7 +50,7 @@ namespace paludis
///\name Basic operations
///\{
- GemSpecifications(const yaml::Node &);
+ GemSpecifications(const tr1::shared_ptr<const Repository> &, const yaml::Node &);
~GemSpecifications();
///\}
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 2e48f9d..71014c2 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -19,11 +19,10 @@
#include <paludis/repositories/gems/gems_repository.hh>
#include <paludis/repositories/gems/params.hh>
-#include <paludis/repositories/gems/metadata.hh>
#include <paludis/repositories/gems/yaml.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/gem_specifications.hh>
-#include <paludis/package_database.hh>
+#include <paludis/repository_info.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/collection_concrete.hh>
@@ -46,16 +45,15 @@ namespace paludis
mutable tr1::shared_ptr<const CategoryNamePartCollection> category_names;
mutable MakeHashedMap<CategoryNamePart, tr1::shared_ptr<const QualifiedPackageNameCollection> >::Type package_names;
- mutable MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<VersionSpecCollection> >::Type versions;
- mutable MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>, tr1::shared_ptr<const gems::GemMetadata> >::Type metadata;
+ mutable MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> >::Type ids;
mutable bool has_category_names;
- mutable bool has_entries;
+ mutable bool has_ids;
Implementation(const gems::RepositoryParams p) :
params(p),
has_category_names(false),
- has_entries(false)
+ has_ids(false)
{
}
};
@@ -82,6 +80,7 @@ GemsRepository::GemsRepository(const gems::RepositoryParams & params) :
.licenses_interface(0)
.portage_interface(0)
.pretend_interface(0)
+ .make_virtuals_interface(0)
.hook_interface(0),
"gems"),
PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(params))
@@ -89,6 +88,7 @@ GemsRepository::GemsRepository(const gems::RepositoryParams & params) :
tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
config_info->add_kv("location", stringify(_imp->params.location));
+ config_info->add_kv("install_dir", stringify(_imp->params.install_dir));
config_info->add_kv("buildroot", stringify(_imp->params.buildroot));
config_info->add_kv("sync", _imp->params.sync);
config_info->add_kv("sync_options", _imp->params.sync_options);
@@ -119,7 +119,7 @@ GemsRepository::do_has_package_named(const QualifiedPackageName & q) const
if (! do_has_category_named(q.category))
return false;
- need_entries();
+ need_ids();
return _imp->package_names.find(q.category)->second->end() != _imp->package_names.find(q.category)->second->find(q);
}
@@ -136,7 +136,7 @@ GemsRepository::do_package_names(const CategoryNamePart & c) const
if (! has_category_named(c))
return make_shared_ptr(new QualifiedPackageNameCollection::Concrete);
- need_entries();
+ need_ids();
MakeHashedMap<CategoryNamePart, tr1::shared_ptr<const QualifiedPackageNameCollection> >::Type::const_iterator i(
_imp->package_names.find(c));
@@ -145,44 +145,22 @@ GemsRepository::do_package_names(const CategoryNamePart & c) const
return i->second;
}
-tr1::shared_ptr<const VersionSpecCollection>
-GemsRepository::do_version_specs(const QualifiedPackageName & q) const
+tr1::shared_ptr<const PackageIDSequence>
+GemsRepository::do_package_ids(const QualifiedPackageName & q) const
{
if (! has_package_named(q))
- return make_shared_ptr(new VersionSpecCollection::Concrete);
+ return make_shared_ptr(new PackageIDSequence::Concrete);
- need_entries();
+ need_ids();
- MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<VersionSpecCollection> >::Type::const_iterator i(
- _imp->versions.find(q));
- if (i == _imp->versions.end())
- return make_shared_ptr(new VersionSpecCollection::Concrete);
+ MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> >::Type::const_iterator i(
+ _imp->ids.find(q));
+ if (i == _imp->ids.end())
+ return make_shared_ptr(new PackageIDSequence::Concrete);
return i->second;
}
-bool
-GemsRepository::do_has_version(const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (! has_package_named(q))
- return false;
-
- need_entries();
-
- MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<VersionSpecCollection> >::Type::const_iterator i(
- _imp->versions.find(q));
- return i->second->end() != i->second->find(v);
-}
-
-tr1::shared_ptr<const VersionMetadata>
-GemsRepository::do_version_metadata(const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (! has_version(q, v))
- throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
-
- return _imp->metadata.find(std::make_pair(q, v))->second;
-}
-
void
GemsRepository::need_category_names() const
{
@@ -197,9 +175,9 @@ GemsRepository::need_category_names() const
}
void
-GemsRepository::need_entries() const
+GemsRepository::need_ids() const
{
- if (_imp->has_entries)
+ if (_imp->has_ids)
return;
need_category_names();
@@ -215,44 +193,35 @@ GemsRepository::need_entries() const
std::string output((std::istreambuf_iterator<char>(yaml_file)), std::istreambuf_iterator<char>());
yaml::Document master_doc(output);
- gems::GemSpecifications specs(*master_doc.top());
+ gems::GemSpecifications specs(shared_from_this(), *master_doc.top());
for (gems::GemSpecifications::Iterator i(specs.begin()), i_end(specs.end()) ;
i != i_end ; ++i)
{
pkgs->insert(i->first.first);
- MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<VersionSpecCollection> >::Type::iterator v(_imp->versions.find(i->first.first));
- if (_imp->versions.end() == v)
- v = _imp->versions.insert(std::make_pair(i->first.first, make_shared_ptr(new VersionSpecCollection::Concrete))).first;
-
- v->second->insert(i->first.second);
+ MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> >::Type::iterator v(_imp->ids.find(i->first.first));
+ if (_imp->ids.end() == v)
+ v = _imp->ids.insert(std::make_pair(i->first.first, make_shared_ptr(new PackageIDSequence::Concrete))).first;
- tr1::shared_ptr<gems::GemMetadata> m(new gems::GemMetadata(i->first.second));
- m->populate_from_specification(*i->second);
- m->eapi = EAPIData::get_instance()->eapi_from_string("gems-1");
- _imp->metadata.insert(std::make_pair(i->first, m));
+ v->second->push_back(i->second);
}
- _imp->has_entries = true;
+ _imp->has_ids = true;
}
void
-GemsRepository::do_install(const QualifiedPackageName & q, const VersionSpec & v,
- const InstallOptions & o) const
+GemsRepository::do_install(const tr1::shared_ptr<const PackageID> & id, const InstallOptions & o) const
{
if (o.fetch_only)
return;
- if (! has_version(q, v))
- throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
-
Command cmd(getenv_with_default("PALUDIS_GEMS_DIR", LIBEXECDIR "/paludis") +
- "/gems/gems.bash install '" + stringify(q.package) + "' '" + stringify(v) + "'");
- cmd.with_stderr_prefix(stringify(q) + "-" + stringify(v) + "::" + stringify(name()) + "> ");
+ "/gems/gems.bash install '" + stringify(id->name().package) + "' '" + stringify(id->version()) + "'");
+ cmd.with_stderr_prefix(stringify(*id) + "> ");
cmd.with_setenv("GEMCACHE", stringify(_imp->params.location / "yaml"));
if (0 != run_command(cmd))
- throw PackageInstallActionError("Install of '" + stringify(PackageDatabaseEntry(q, v, name())) + "' failed");
+ throw PackageInstallActionError("Install of '" + stringify(*id) + "' failed");
}
diff --git a/paludis/repositories/gems/gems_repository.hh b/paludis/repositories/gems/gems_repository.hh
index 403cb49..da2dfce 100644
--- a/paludis/repositories/gems/gems_repository.hh
+++ b/paludis/repositories/gems/gems_repository.hh
@@ -23,6 +23,7 @@
#include <paludis/repository.hh>
#include <paludis/repositories/gems/params-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/tr1_memory.hh>
namespace paludis
{
@@ -35,37 +36,36 @@ namespace paludis
class PALUDIS_VISIBLE GemsRepository :
public Repository,
public RepositoryInstallableInterface,
- private PrivateImplementationPattern<GemsRepository>
+ private PrivateImplementationPattern<GemsRepository>,
+ public tr1::enable_shared_from_this<GemsRepository>
{
private:
void need_category_names() const;
- void need_entries() const;
+ void need_ids() const;
protected:
- /* core */
+ /* RepositoryInstallableInterface */
- virtual bool do_has_category_named(const CategoryNamePart &) const;
+ virtual void do_install(const tr1::shared_ptr<const PackageID> &, const InstallOptions &) const;
- virtual bool do_has_package_named(const QualifiedPackageName &) const;
+ /* Repository */
- virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const;
+ virtual tr1::shared_ptr<const PackageIDSequence> do_package_ids(
+ const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
- const CategoryNamePart &) const;
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const VersionSpecCollection> do_version_specs(
- const QualifiedPackageName &) const;
+ virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_has_version(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual bool do_has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const VersionMetadata> do_version_metadata(
- const QualifiedPackageName &,
- const VersionSpec &) const;
-
- /* installable */
-
- virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &) const;
+ virtual bool do_has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
/**
diff --git a/paludis/repositories/gems/gems_repository_TEST.cc b/paludis/repositories/gems/gems_repository_TEST.cc
index bdff0fe..bbbe315 100644
--- a/paludis/repositories/gems/gems_repository_TEST.cc
+++ b/paludis/repositories/gems/gems_repository_TEST.cc
@@ -40,6 +40,7 @@ namespace test_cases
env.package_database()->add_repository(1, make_shared_ptr(new GemsRepository(
gems::RepositoryParams::create()
.location(FSEntry("gems_repository_TEST_dir/repo"))
+ .install_dir(FSEntry("gems_repository_TEST_dir/install"))
.sync("")
.sync_options("")
.environment(&env)
diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index 51b3703..7b8642d 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -19,9 +19,9 @@
#include <paludis/repositories/gems/installed_gems_repository.hh>
#include <paludis/repositories/gems/params.hh>
-#include <paludis/repositories/gems/metadata.hh>
#include <paludis/repositories/gems/gem_specification.hh>
#include <paludis/repositories/gems/yaml.hh>
+#include <paludis/repository_info.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/util/stringify.hh>
@@ -42,8 +42,7 @@
using namespace paludis;
-typedef MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>, tr1::shared_ptr<const gems::InstalledGemMetadata> >::Type MetadataMap;
-typedef MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<VersionSpecCollection> >::Type VersionsMap;
+typedef MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> >::Type IDMap;
namespace paludis
{
@@ -54,16 +53,15 @@ namespace paludis
mutable tr1::shared_ptr<const CategoryNamePartCollection> category_names;
mutable MakeHashedMap<CategoryNamePart, tr1::shared_ptr<const QualifiedPackageNameCollection> >::Type package_names;
- mutable VersionsMap versions;
- mutable MetadataMap metadata;
+ mutable IDMap ids;
mutable bool has_category_names;
- mutable bool has_entries;
+ mutable bool has_ids;
Implementation(const gems::InstalledRepositoryParams p) :
params(p),
has_category_names(false),
- has_entries(false)
+ has_ids(false)
{
}
};
@@ -89,6 +87,7 @@ InstalledGemsRepository::InstalledGemsRepository(const gems::InstalledRepository
.destination_interface(this)
.licenses_interface(0)
.portage_interface(0)
+ .make_virtuals_interface(0)
.pretend_interface(0)
.hook_interface(0),
"installed_gems"),
@@ -96,7 +95,7 @@ InstalledGemsRepository::InstalledGemsRepository(const gems::InstalledRepository
{
tr1::shared_ptr<RepositoryInfoSection> config_info(new RepositoryInfoSection("Configuration information"));
- config_info->add_kv("location", stringify(_imp->params.location));
+ config_info->add_kv("install_dir", stringify(_imp->params.install_dir));
config_info->add_kv("buildroot", stringify(_imp->params.buildroot));
_info->add_section(config_info);
@@ -125,7 +124,7 @@ InstalledGemsRepository::do_has_package_named(const QualifiedPackageName & q) co
if (! do_has_category_named(q.category))
return false;
- need_entries();
+ need_ids();
return _imp->package_names.find(q.category)->second->end() != _imp->package_names.find(q.category)->second->find(q);
}
@@ -142,7 +141,7 @@ InstalledGemsRepository::do_package_names(const CategoryNamePart & c) const
if (! has_category_named(c))
return make_shared_ptr(new QualifiedPackageNameCollection::Concrete);
- need_entries();
+ need_ids();
MakeHashedMap<CategoryNamePart, tr1::shared_ptr<const QualifiedPackageNameCollection> >::Type::const_iterator i(
_imp->package_names.find(c));
@@ -151,43 +150,21 @@ InstalledGemsRepository::do_package_names(const CategoryNamePart & c) const
return i->second;
}
-tr1::shared_ptr<const VersionSpecCollection>
-InstalledGemsRepository::do_version_specs(const QualifiedPackageName & q) const
+tr1::shared_ptr<const PackageIDSequence>
+InstalledGemsRepository::do_package_ids(const QualifiedPackageName & q) const
{
if (! has_package_named(q))
- return make_shared_ptr(new VersionSpecCollection::Concrete);
+ return make_shared_ptr(new PackageIDSequence::Concrete);
- need_entries();
+ need_ids();
- VersionsMap::const_iterator i(_imp->versions.find(q));
- if (i == _imp->versions.end())
- return make_shared_ptr(new VersionSpecCollection::Concrete);
+ IDMap::const_iterator i(_imp->ids.find(q));
+ if (i == _imp->ids.end())
+ return make_shared_ptr(new PackageIDSequence::Concrete);
return i->second;
}
-bool
-InstalledGemsRepository::do_has_version(const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (! has_package_named(q))
- return false;
-
- need_entries();
-
- VersionsMap::const_iterator i(_imp->versions.find(q));
- return i->second->end() != i->second->find(v);
-}
-
-tr1::shared_ptr<const VersionMetadata>
-InstalledGemsRepository::do_version_metadata(const QualifiedPackageName & q, const VersionSpec & v) const
-{
- if (! has_version(q, v))
- throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
-
- need_version_metadata(q, v);
- return _imp->metadata.find(std::make_pair(q, v))->second;
-}
-
void
InstalledGemsRepository::need_category_names() const
{
@@ -202,9 +179,9 @@ InstalledGemsRepository::need_category_names() const
}
void
-InstalledGemsRepository::need_entries() const
+InstalledGemsRepository::need_ids() const
{
- if (_imp->has_entries)
+ if (_imp->has_ids)
return;
static CategoryNamePart gems("gems");
@@ -216,7 +193,7 @@ InstalledGemsRepository::need_entries() const
tr1::shared_ptr<QualifiedPackageNameCollection::Concrete> pkgs(new QualifiedPackageNameCollection::Concrete);
_imp->package_names.insert(std::make_pair(gems, pkgs));
- for (DirIterator d(_imp->params.location / "specifications"), d_end ; d != d_end ; ++d)
+ for (DirIterator d(_imp->params.install_dir / "specifications"), d_end ; d != d_end ; ++d)
{
if (! is_file_with_extension(*d, ".gemspec", IsFileWithOptions()))
continue;
@@ -234,49 +211,16 @@ InstalledGemsRepository::need_entries() const
PackageNamePart p(s.substr(0, h));
pkgs->insert(gems + p);
- if (_imp->versions.end() == _imp->versions.find(gems + p))
- _imp->versions.insert(std::make_pair(gems + p, make_shared_ptr(new VersionSpecCollection::Concrete)));
- _imp->versions.find(gems + p)->second->insert(v);
+ if (_imp->ids.end() == _imp->ids.find(gems + p))
+ _imp->ids.insert(std::make_pair(gems + p, make_shared_ptr(new PackageIDSequence::Concrete)));
+ _imp->ids.find(gems + p)->second->push_back(make_shared_ptr(new gems::GemSpecification(shared_from_this(), p, v, *d)));
}
}
-void
-InstalledGemsRepository::need_version_metadata(const QualifiedPackageName & q, const VersionSpec & v) const
-{
- MetadataMap::const_iterator i(_imp->metadata.find(std::make_pair(q, v)));
- if (i != _imp->metadata.end())
- return;
-
- Context c("When loading version metadata for '" + stringify(PackageDatabaseEntry(q, v, name())) + "':");
-
- tr1::shared_ptr<gems::InstalledGemMetadata> m(new gems::InstalledGemMetadata(v));
- _imp->metadata.insert(std::make_pair(std::make_pair(q, v), m));
-
- Command cmd(getenv_with_default("PALUDIS_GEMS_DIR", LIBEXECDIR "/paludis") +
- "/gems/gems.bash specification '" + stringify(q.package) + "' '" + stringify(v) + "'");
- cmd.with_stderr_prefix(stringify(q) + "-" + stringify(v) + "::" + stringify(name()) + "> ");
- cmd.with_sandbox();
- cmd.with_uid_gid(_imp->params.environment->reduced_uid(), _imp->params.environment->reduced_gid());
-
- PStream p(cmd);
- std::string output((std::istreambuf_iterator<char>(p)), std::istreambuf_iterator<char>());
-
- if (0 != p.exit_status())
- {
- Log::get_instance()->message(ll_warning, lc_context) << "Version metadata extraction returned non-zero";
- return;
- }
-
- yaml::Document spec_doc(output);
- gems::GemSpecification spec(*spec_doc.top());
- m->populate_from_specification(spec);
- m->eapi = EAPIData::get_instance()->eapi_from_string("gems-1");
-}
-
bool
-InstalledGemsRepository::is_suitable_destination_for(const PackageDatabaseEntry & e) const
+InstalledGemsRepository::is_suitable_destination_for(const PackageID & e) const
{
- std::string f(_imp->params.environment->package_database()->fetch_repository(e.repository)->format());
+ std::string f(e.repository()->format());
return f == "gems";
}
@@ -305,18 +249,21 @@ InstalledGemsRepository::root() const
}
void
-InstalledGemsRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v,
+InstalledGemsRepository::do_uninstall(const tr1::shared_ptr<const PackageID> & id,
const UninstallOptions &) const
{
- if (! has_version(q, v))
- throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
-
Command cmd(getenv_with_default("PALUDIS_GEMS_DIR", LIBEXECDIR "/paludis") +
- "/gems/gems.bash uninstall '" + stringify(q.package) + "' '" + stringify(v) + "'");
- cmd.with_stderr_prefix(stringify(q) + "-" + stringify(v) + "::" + stringify(name()) + "> ");
- cmd.with_setenv("GEMCACHE", stringify(_imp->params.location / "yaml"));
+ "/gems/gems.bash uninstall '" + stringify(id->name().package) + "' '" + stringify(id->version()) + "'");
+ cmd.with_stderr_prefix(stringify(*id) + "> ");
+ cmd.with_setenv("GEM_HOME", stringify(_imp->params.install_dir));
if (0 != run_command(cmd))
- throw PackageInstallActionError("Uninstall of '" + stringify(PackageDatabaseEntry(q, v, name())) + "' failed");
+ throw PackageInstallActionError("Uninstall of '" + stringify(*id) + "' failed");
+}
+
+time_t
+InstalledGemsRepository::do_installed_time(const PackageID &) const
+{
+ return 0;
}
diff --git a/paludis/repositories/gems/installed_gems_repository.hh b/paludis/repositories/gems/installed_gems_repository.hh
index 5ba7670..c5d4831 100644
--- a/paludis/repositories/gems/installed_gems_repository.hh
+++ b/paludis/repositories/gems/installed_gems_repository.hh
@@ -23,6 +23,7 @@
#include <paludis/repository.hh>
#include <paludis/repositories/gems/params-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/tr1_memory.hh>
namespace paludis
{
@@ -37,38 +38,42 @@ namespace paludis
public RepositoryDestinationInterface,
public RepositoryInstalledInterface,
public RepositoryUninstallableInterface,
+ public tr1::enable_shared_from_this<InstalledGemsRepository>,
private PrivateImplementationPattern<InstalledGemsRepository>
{
private:
void need_category_names() const;
- void need_entries() const;
- void need_version_metadata(const QualifiedPackageName &, const VersionSpec &) const;
+ void need_ids() const;
protected:
- /* core */
+ /* RepositoryInstalledInterface */
- virtual bool do_has_category_named(const CategoryNamePart &) const;
+ virtual time_t do_installed_time(const PackageID &) const;
- virtual bool do_has_package_named(const QualifiedPackageName &) const;
+ virtual FSEntry root() const PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const;
+ /* RepositoryUninstallableInterface */
- virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
- const CategoryNamePart &) const;
+ virtual void do_uninstall(const tr1::shared_ptr<const PackageID> &, const UninstallOptions &) const;
+
+ /* Repository */
- virtual tr1::shared_ptr<const VersionSpecCollection> do_version_specs(
- const QualifiedPackageName &) const;
+ virtual tr1::shared_ptr<const PackageIDSequence> do_package_ids(
+ const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual bool do_has_version(const QualifiedPackageName &, const VersionSpec &) const;
+ virtual tr1::shared_ptr<const QualifiedPackageNameCollection> do_package_names(
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual tr1::shared_ptr<const VersionMetadata> do_version_metadata(
- const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual tr1::shared_ptr<const CategoryNamePartCollection> do_category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- /* uninstallable */
+ virtual bool do_has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
- const UninstallOptions &) const;
+ virtual bool do_has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
public:
/**
@@ -83,16 +88,18 @@ namespace paludis
virtual void invalidate();
- /* destination */
+ /* RepositoryDestinationInterface */
- virtual bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
- virtual bool is_default_destination() const;
- virtual bool want_pre_post_phases() const;
- virtual void merge(const MergeOptions &) PALUDIS_ATTRIBUTE((noreturn));
+ virtual bool is_suitable_destination_for(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool is_default_destination() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- /* installed */
- virtual FSEntry root() const;
+ virtual bool want_pre_post_phases() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void merge(const MergeOptions &) PALUDIS_ATTRIBUTE((noreturn));
};
}
diff --git a/paludis/repositories/gems/installed_gems_repository_TEST.cc b/paludis/repositories/gems/installed_gems_repository_TEST.cc
index 54be5f4..80c4369 100644
--- a/paludis/repositories/gems/installed_gems_repository_TEST.cc
+++ b/paludis/repositories/gems/installed_gems_repository_TEST.cc
@@ -42,6 +42,7 @@ namespace test_cases
.location(FSEntry("gems_repository_TEST_dir/installed-repo"))
.environment(&env)
.buildroot(FSEntry("gems_repository_TEST_dir/build"))
+ .install_dir(FSEntry("gems_repository_TEST_dir/install_dir"))
)));
}
} test_creation;
diff --git a/paludis/repositories/gems/installed_gems_repository_TEST_setup.sh b/paludis/repositories/gems/installed_gems_repository_TEST_setup.sh
index 36e4acf..4edf8ac 100755
--- a/paludis/repositories/gems/installed_gems_repository_TEST_setup.sh
+++ b/paludis/repositories/gems/installed_gems_repository_TEST_setup.sh
@@ -4,3 +4,7 @@
mkdir installed_gems_repository_TEST_dir || exit 1
cd installed_gems_repository_TEST_dir || exit 1
+mkdir -p installed-repo/installed_dir/specifications
+cat <<END > installed-repo/yaml
+END
+
diff --git a/paludis/repositories/gems/metadata.cc b/paludis/repositories/gems/metadata.cc
deleted file mode 100644
index 46c5a40..0000000
--- a/paludis/repositories/gems/metadata.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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/gems/metadata.hh>
-#include <paludis/repositories/gems/gem_specification.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/eapi.hh>
-
-using namespace paludis;
-using namespace paludis::gems;
-
-InstalledGemMetadata::InstalledGemMetadata(const VersionSpec & v) :
- VersionMetadata(
- VersionMetadataBase::create()
- .slot(SlotName(stringify(v)))
- .homepage("")
- .description("")
- .eapi(EAPIData::get_instance()->unknown_eapi())
- .interactive(false),
- VersionMetadataCapabilities::create()
- .ebuild_interface(0)
- .cran_interface(0)
- .deps_interface(0)
- .license_interface(0)
- .virtual_interface(0)
- .origins_interface(0)
- .ebin_interface(0))
-{
-}
-
-InstalledGemMetadata::~InstalledGemMetadata()
-{
-}
-
-void
-InstalledGemMetadata::populate_from_specification(const GemSpecification & spec)
-{
- description = spec.summary();
- set_homepage(spec.homepage());
-}
-
-GemMetadata::GemMetadata(const VersionSpec & v) :
- VersionMetadata(
- VersionMetadataBase::create()
- .slot(SlotName(stringify(v)))
- .homepage("")
- .description("")
- .eapi(EAPIData::get_instance()->unknown_eapi())
- .interactive(false),
- VersionMetadataCapabilities::create()
- .ebuild_interface(0)
- .cran_interface(0)
- .deps_interface(0)
- .license_interface(0)
- .virtual_interface(0)
- .origins_interface(0)
- .ebin_interface(0))
-{
-}
-
-GemMetadata::~GemMetadata()
-{
-}
-
-void
-GemMetadata::populate_from_specification(const GemSpecification & spec)
-{
- description = spec.summary();
- set_homepage(spec.homepage());
-}
-
diff --git a/paludis/repositories/gems/metadata.hh b/paludis/repositories/gems/metadata.hh
deleted file mode 100644
index b4c1dba..0000000
--- a/paludis/repositories/gems/metadata.hh
+++ /dev/null
@@ -1,88 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * 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_GEMS_METADATA_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_METADATA_HH 1
-
-#include <paludis/version_metadata.hh>
-#include <paludis/version_spec-fwd.hh>
-#include <paludis/repositories/gems/gem_specification-fwd.hh>
-
-namespace paludis
-{
- namespace gems
- {
- /**
- * Version metadata for a Gem.
- *
- * \ingroup grpgemsrepository
- * \nosubgrouping
- */
- class GemMetadata :
- public VersionMetadata,
- public virtual VersionMetadataHasInterfaces
- {
- public:
- ///\name Basic operations
- ///\{
-
- GemMetadata(const VersionSpec &);
- virtual ~GemMetadata();
-
- ///\}
-
- virtual const VersionMetadata * version_metadata() const
- {
- return this;
- }
-
- void populate_from_specification(const GemSpecification &);
- };
-
- /**
- * Version metadata for an installed Gem.
- *
- * \ingroup grpgemsrepository
- * \nosubgrouping
- */
- class InstalledGemMetadata :
- public VersionMetadata,
- public VersionMetadataOriginsInterface,
- public virtual VersionMetadataHasInterfaces
- {
- public:
- ///\name Basic operations
- ///\{
-
- InstalledGemMetadata(const VersionSpec &);
- virtual ~InstalledGemMetadata();
-
- ///\}
-
- virtual const VersionMetadata * version_metadata() const
- {
- return this;
- }
-
- void populate_from_specification(const GemSpecification &);
- };
- }
-}
-
-#endif
diff --git a/paludis/repositories/gems/params.sr b/paludis/repositories/gems/params.sr
index 47f7eeb..d919021 100644
--- a/paludis/repositories/gems/params.sr
+++ b/paludis/repositories/gems/params.sr
@@ -7,6 +7,7 @@ make_class_RepositoryParams()
key environment "Environment *"
key location FSEntry
+ key install_dir FSEntry
key sync std::string
key sync_options std::string
key buildroot FSEntry
@@ -19,8 +20,8 @@ make_class_InstalledRepositoryParams()
visible
key environment "Environment *"
- key location FSEntry
key buildroot FSEntry
+ key install_dir FSEntry
allow_named_args
}
diff --git a/paludis/repositories/gems/registration.cc b/paludis/repositories/gems/registration.cc
index 0073759..433397b 100644
--- a/paludis/repositories/gems/registration.cc
+++ b/paludis/repositories/gems/registration.cc
@@ -41,6 +41,10 @@ namespace
if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
throw gems::RepositoryConfigurationError("Key 'location' not specified or empty");
+ std::string install_dir;
+ if (m->end() == m->find("install_dir") || ((install_dir = m->find("install_dir")->second)).empty())
+ throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty");
+
std::string sync;
if (m->end() != m->find("sync"))
sync = m->find("sync")->second;
@@ -58,6 +62,7 @@ namespace
.sync(sync)
.sync_options(sync_options)
.environment(env)
+ .install_dir(install_dir)
.buildroot(buildroot)));
}
@@ -66,17 +71,17 @@ namespace
Environment * const env,
tr1::shared_ptr<const AssociativeCollection<std::string, std::string> > m)
{
- std::string location;
- if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
- throw gems::RepositoryConfigurationError("Key 'location' not specified or empty");
+ std::string install_dir;
+ if (m->end() == m->find("install_dir") || ((install_dir = m->find("install_dir")->second)).empty())
+ throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty");
std::string buildroot;
if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
buildroot = DistributionData::get_instance()->distribution_from_string(env->default_distribution())->default_ebuild_build_root;
return make_shared_ptr(new InstalledGemsRepository(gems::InstalledRepositoryParams::create()
- .location(location)
.environment(env)
+ .install_dir(install_dir)
.buildroot(buildroot)));
}
}
diff --git a/paludis/repositories/gentoo/Makefile.am b/paludis/repositories/gentoo/Makefile.am
index 02f34fd..59b07bc 100644
--- a/paludis/repositories/gentoo/Makefile.am
+++ b/paludis/repositories/gentoo/Makefile.am
@@ -55,9 +55,7 @@ paludis_repositories_gentoo_include_HEADERS = \
make_ebuild_repository.hh \
make_ebin_repository.hh \
use_desc.hh \
- portage_virtual_version_metadata.hh \
vdb_repository.hh \
- vdb_version_metadata.hh \
vdb_repository-sr.hh \
vdb_merger-sr.hh \
vdb_merger.hh \
@@ -66,7 +64,10 @@ paludis_repositories_gentoo_include_HEADERS = \
layout.hh \
traditional_layout.hh \
exheres_layout.hh \
- eapi_phase.hh
+ eapi_phase.hh \
+ ebuild_id.hh \
+ vdb_id.hh \
+ e_key.hh
libpaludisgentoorepository_la_SOURCES = \
ebuild.cc \
@@ -87,16 +88,17 @@ libpaludisgentoorepository_la_SOURCES = \
make_ebuild_repository.cc \
make_ebin_repository.cc \
use_desc.cc \
- portage_virtual_version_metadata.cc \
registration.cc \
vdb_repository.cc \
- vdb_version_metadata.cc \
vdb_merger.cc \
vdb_unmerger.cc \
layout.cc \
traditional_layout.cc \
exheres_layout.cc \
eapi_phase.cc \
+ ebuild_id.cc \
+ vdb_id.cc \
+ e_key.cc \
$(paludis_repositories_gentoo_include_HEADERS)
libpaludisgentoorepository_la_LIBADD = \
diff --git a/paludis/repositories/gentoo/e_key.cc b/paludis/repositories/gentoo/e_key.cc
new file mode 100644
index 0000000..afca908
--- /dev/null
+++ b/paludis/repositories/gentoo/e_key.cc
@@ -0,0 +1,430 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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/gentoo/e_key.hh>
+#include <paludis/repositories/gentoo/ebuild_id.hh>
+
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/iterator.hh>
+
+#include <paludis/portage_dep_parser.hh>
+#include <paludis/eapi.hh>
+
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+#include <libwrapiter/libwrapiter_output_iterator.hh>
+
+#include <list>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+EStringKey::EStringKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataStringKey(r, h),
+ _value(v)
+{
+}
+
+EStringKey::~EStringKey()
+{
+}
+
+const std::string
+EStringKey::value() const
+{
+ return _value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EDependenciesKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<const DependencySpecTree::ConstItem> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+EDependenciesKey::EDependenciesKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataSpecTreeKey<DependencySpecTree>(r, h),
+ PrivateImplementationPattern<EDependenciesKey>(new Implementation<EDependenciesKey>(id, v)),
+ _imp(PrivateImplementationPattern<EDependenciesKey>::_imp.get())
+{
+}
+
+EDependenciesKey::~EDependenciesKey()
+{
+}
+
+const tr1::shared_ptr<const DependencySpecTree::ConstItem>
+EDependenciesKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ _imp->value = PortageDepParser::parse_depend(_imp->string_value, *_imp->id->eapi());
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ELicenseKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<const LicenseSpecTree::ConstItem> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+ELicenseKey::ELicenseKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataSpecTreeKey<LicenseSpecTree>(r, h),
+ PrivateImplementationPattern<ELicenseKey>(new Implementation<ELicenseKey>(id, v)),
+ _imp(PrivateImplementationPattern<ELicenseKey>::_imp.get())
+{
+}
+
+ELicenseKey::~ELicenseKey()
+{
+}
+
+const tr1::shared_ptr<const LicenseSpecTree::ConstItem>
+ELicenseKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ _imp->value = PortageDepParser::parse_license(_imp->string_value, *_imp->id->eapi());
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EURIKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<const URISpecTree::ConstItem> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+EURIKey::EURIKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataSpecTreeKey<URISpecTree>(r, h),
+ PrivateImplementationPattern<EURIKey>(new Implementation<EURIKey>(id, v)),
+ _imp(PrivateImplementationPattern<EURIKey>::_imp.get())
+{
+}
+
+EURIKey::~EURIKey()
+{
+}
+
+const tr1::shared_ptr<const URISpecTree::ConstItem>
+EURIKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ _imp->value = PortageDepParser::parse_uri(_imp->string_value, *_imp->id->eapi());
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ERestrictKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<const RestrictSpecTree::ConstItem> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+ERestrictKey::ERestrictKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataSpecTreeKey<RestrictSpecTree>(r, h),
+ PrivateImplementationPattern<ERestrictKey>(new Implementation<ERestrictKey>(id, v)),
+ _imp(PrivateImplementationPattern<ERestrictKey>::_imp.get())
+{
+}
+
+ERestrictKey::~ERestrictKey()
+{
+}
+
+const tr1::shared_ptr<const RestrictSpecTree::ConstItem>
+ERestrictKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ _imp->value = PortageDepParser::parse_restrict(_imp->string_value, *_imp->id->eapi());
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EProvideKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<const ProvideSpecTree::ConstItem> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+EProvideKey::EProvideKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataSpecTreeKey<ProvideSpecTree>(r, h),
+ PrivateImplementationPattern<EProvideKey>(new Implementation<EProvideKey>(id, v)),
+ _imp(PrivateImplementationPattern<EProvideKey>::_imp.get())
+{
+}
+
+EProvideKey::~EProvideKey()
+{
+}
+
+const tr1::shared_ptr<const ProvideSpecTree::ConstItem>
+EProvideKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ _imp->value = PortageDepParser::parse_provide(_imp->string_value, *_imp->id->eapi());
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EIUseKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<IUseFlagCollection> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+EIUseKey::EIUseKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataCollectionKey<IUseFlagCollection>(r, h),
+ PrivateImplementationPattern<EIUseKey>(new Implementation<EIUseKey>(id, v)),
+ _imp(PrivateImplementationPattern<EIUseKey>::_imp.get())
+{
+}
+
+EIUseKey::~EIUseKey()
+{
+}
+
+const tr1::shared_ptr<const IUseFlagCollection>
+EIUseKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ _imp->value.reset(new IUseFlagCollection::Concrete);
+ std::list<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(_imp->string_value, std::back_inserter(tokens));
+ for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ _imp->value->insert(IUseFlag(*t, _imp->id->eapi()->supported->iuse_flag_parse_mode));
+
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EKeywordsKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<KeywordNameCollection> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+EKeywordsKey::EKeywordsKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataCollectionKey<KeywordNameCollection>(r, h),
+ PrivateImplementationPattern<EKeywordsKey>(new Implementation<EKeywordsKey>(id, v)),
+ _imp(PrivateImplementationPattern<EKeywordsKey>::_imp.get())
+{
+}
+
+EKeywordsKey::~EKeywordsKey()
+{
+}
+
+const tr1::shared_ptr<const KeywordNameCollection>
+EKeywordsKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ _imp->value.reset(new KeywordNameCollection::Concrete);
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ WhitespaceTokeniser::get_instance()->tokenise(_imp->string_value, create_inserter<KeywordName>(_imp->value->inserter()));
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EUseKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<UseFlagNameCollection> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+EUseKey::EUseKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataCollectionKey<UseFlagNameCollection>(r, h),
+ PrivateImplementationPattern<EUseKey>(new Implementation<EUseKey>(id, v)),
+ _imp(PrivateImplementationPattern<EUseKey>::_imp.get())
+{
+}
+
+EUseKey::~EUseKey()
+{
+}
+
+const tr1::shared_ptr<const UseFlagNameCollection>
+EUseKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ _imp->value.reset(new UseFlagNameCollection::Concrete);
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ std::list<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(_imp->string_value, std::back_inserter(tokens));
+ for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ if ('-' != t->at(0))
+ _imp->value->insert(UseFlagName(*t));
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<EInheritedKey>
+ {
+ const tr1::shared_ptr<const PackageID> id;
+ const std::string string_value;
+ mutable tr1::shared_ptr<InheritedCollection> value;
+
+ Implementation(const tr1::shared_ptr<const PackageID> & i, const std::string & v) :
+ id(i),
+ string_value(v)
+ {
+ }
+ };
+}
+
+EInheritedKey::EInheritedKey(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & r, const std::string & h, const std::string & v) :
+ MetadataCollectionKey<InheritedCollection>(r, h),
+ PrivateImplementationPattern<EInheritedKey>(new Implementation<EInheritedKey>(id, v)),
+ _imp(PrivateImplementationPattern<EInheritedKey>::_imp.get())
+{
+}
+
+EInheritedKey::~EInheritedKey()
+{
+}
+
+const tr1::shared_ptr<const InheritedCollection>
+EInheritedKey::value() const
+{
+ if (_imp->value)
+ return _imp->value;
+
+ _imp->value.reset(new InheritedCollection::Concrete);
+ Context context("When parsing metadata key '" + raw_name() + "' from '" + stringify(*_imp->id) + "':");
+ WhitespaceTokeniser::get_instance()->tokenise(_imp->string_value, _imp->value->inserter());
+ return _imp->value;
+}
+
diff --git a/paludis/repositories/gentoo/e_key.hh b/paludis/repositories/gentoo/e_key.hh
new file mode 100644
index 0000000..1a50aff
--- /dev/null
+++ b/paludis/repositories/gentoo/e_key.hh
@@ -0,0 +1,192 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_GENTOO_E_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_E_KEY_HH 1
+
+#include <paludis/metadata_key.hh>
+
+namespace paludis
+{
+ class PackageID;
+
+ namespace erepository
+ {
+ class EStringKey :
+ public MetadataStringKey
+ {
+ private:
+ const std::string _value;
+
+ public:
+ EStringKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EStringKey();
+
+ virtual const std::string value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class EDependenciesKey :
+ public MetadataSpecTreeKey<DependencySpecTree>,
+ private PrivateImplementationPattern<EDependenciesKey>
+ {
+ private:
+ Implementation<EDependenciesKey> * const _imp;
+
+ public:
+ EDependenciesKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EDependenciesKey();
+
+ virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class EURIKey :
+ public MetadataSpecTreeKey<URISpecTree>,
+ private PrivateImplementationPattern<EURIKey>
+ {
+ private:
+ Implementation<EURIKey> * const _imp;
+
+ public:
+ EURIKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EURIKey();
+
+ virtual const tr1::shared_ptr<const URISpecTree::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class ERestrictKey :
+ public MetadataSpecTreeKey<RestrictSpecTree>,
+ private PrivateImplementationPattern<ERestrictKey>
+ {
+ private:
+ Implementation<ERestrictKey> * const _imp;
+
+ public:
+ ERestrictKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~ERestrictKey();
+
+ virtual const tr1::shared_ptr<const RestrictSpecTree::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class EProvideKey :
+ public MetadataSpecTreeKey<ProvideSpecTree>,
+ private PrivateImplementationPattern<EProvideKey>
+ {
+ private:
+ Implementation<EProvideKey> * const _imp;
+
+ public:
+ EProvideKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EProvideKey();
+
+ virtual const tr1::shared_ptr<const ProvideSpecTree::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class ELicenseKey :
+ public MetadataSpecTreeKey<LicenseSpecTree>,
+ private PrivateImplementationPattern<ELicenseKey>
+ {
+ private:
+ Implementation<ELicenseKey> * const _imp;
+
+ public:
+ ELicenseKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~ELicenseKey();
+
+ virtual const tr1::shared_ptr<const LicenseSpecTree::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class EIUseKey :
+ public MetadataCollectionKey<IUseFlagCollection>,
+ private PrivateImplementationPattern<EIUseKey>
+ {
+ private:
+ Implementation<EIUseKey> * const _imp;
+
+ public:
+ EIUseKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EIUseKey();
+
+ const tr1::shared_ptr<const IUseFlagCollection> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class EKeywordsKey :
+ public MetadataCollectionKey<KeywordNameCollection>,
+ private PrivateImplementationPattern<EKeywordsKey>
+ {
+ private:
+ Implementation<EKeywordsKey> * const _imp;
+
+ public:
+ EKeywordsKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EKeywordsKey();
+
+ const tr1::shared_ptr<const KeywordNameCollection> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class EUseKey :
+ public MetadataCollectionKey<UseFlagNameCollection>,
+ private PrivateImplementationPattern<EUseKey>
+ {
+ private:
+ Implementation<EUseKey> * const _imp;
+
+ public:
+ EUseKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EUseKey();
+
+ const tr1::shared_ptr<const UseFlagNameCollection> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ class EInheritedKey :
+ public MetadataCollectionKey<InheritedCollection>,
+ private PrivateImplementationPattern<EInheritedKey>
+ {
+ private:
+ Implementation<EInheritedKey> * const _imp;
+
+ public:
+ EInheritedKey(const tr1::shared_ptr<const PackageID> &,
+ const std::string &, const std::string &, const std::string &);
+ ~EInheritedKey();
+
+ const tr1::shared_ptr<const InheritedCollection> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/gentoo/ebin.cc b/paludis/repositories/gentoo/ebin.cc
index e5626bd..4ade151 100644
--- a/paludis/repositories/gentoo/ebin.cc
+++ b/paludis/repositories/gentoo/ebin.cc
@@ -25,6 +25,8 @@
#include <paludis/util/strip.hh>
#include <paludis/eapi.hh>
#include <paludis/about.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
#include <sys/resource.h>
#include <sys/time.h>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -36,32 +38,6 @@ using namespace paludis;
#include <paludis/repositories/gentoo/ebin-se.cc>
#include <paludis/repositories/gentoo/ebin-sr.cc>
-EbinVersionMetadata::EbinVersionMetadata(const SlotName & s) :
- VersionMetadata(
- VersionMetadataBase::create()
- .slot(s)
- .homepage("")
- .description("")
- .eapi(EAPIData::get_instance()->eapi_from_string("paludis-1"))
- .interactive(false),
- VersionMetadataCapabilities::create()
- .ebin_interface(this)
- .ebuild_interface(this)
- .deps_interface(this)
- .license_interface(this)
- .origins_interface(this)
- .cran_interface(0)
- .virtual_interface(0)
- ),
- VersionMetadataDepsInterface(&PortageDepParser::parse_depend),
- VersionMetadataLicenseInterface(&PortageDepParser::parse_license)
-{
-}
-
-EbinVersionMetadata::~EbinVersionMetadata()
-{
-}
-
EbinCommand::EbinCommand(const EbinCommandParams & p) :
params(p)
{
@@ -104,16 +80,16 @@ EbinCommand::operator() ()
tr1::shared_ptr<const FSEntryCollection> hook_dirs(params.environment->hook_dirs());
cmd = extend_command(cmd
- .with_setenv("P", stringify(params.db_entry->name.package) + "-" +
- stringify(params.db_entry->version.remove_revision()))
- .with_setenv("PV", stringify(params.db_entry->version.remove_revision()))
- .with_setenv("PR", stringify(params.db_entry->version.revision_only()))
- .with_setenv("PN", stringify(params.db_entry->name.package))
- .with_setenv("PVR", stringify(params.db_entry->version))
- .with_setenv("PF", stringify(params.db_entry->name.package) + "-" +
- stringify(params.db_entry->version))
- .with_setenv("CATEGORY", stringify(params.db_entry->name.category))
- .with_setenv("REPOSITORY", stringify(params.db_entry->repository))
+ .with_setenv("P", stringify(params.package_id->name().package) + "-" +
+ stringify(params.package_id->version().remove_revision()))
+ .with_setenv("PV", stringify(params.package_id->version().remove_revision()))
+ .with_setenv("PR", stringify(params.package_id->version().revision_only()))
+ .with_setenv("PN", stringify(params.package_id->name().package))
+ .with_setenv("PVR", stringify(params.package_id->version()))
+ .with_setenv("PF", stringify(params.package_id->name().package) + "-" +
+ stringify(params.package_id->version()))
+ .with_setenv("CATEGORY", stringify(params.package_id->name().category))
+ .with_setenv("REPOSITORY", stringify(params.package_id->repository()->name()))
.with_setenv("PORTDIR", stringify(params.portdir))
.with_setenv("DISTDIR", stringify(params.distdir))
.with_setenv("PKGMANAGER", PALUDIS_PACKAGE "-" + stringify(PALUDIS_VERSION_MAJOR) + "." +
@@ -146,9 +122,9 @@ EbinCommand::add_portage_vars(const Command & cmd) const
return Command(cmd)
.with_setenv("PORTAGE_BASHRC", "/dev/null")
.with_setenv("PORTAGE_BUILDDIR", stringify(params.buildroot) + "/" +
- stringify(params.db_entry->name.category) + "/" +
- stringify(params.db_entry->name.package) + "-" +
- stringify(params.db_entry->version))
+ stringify(params.package_id->name().category) + "/" +
+ stringify(params.package_id->name().package) + "-" +
+ stringify(params.package_id->version()))
.with_setenv("PORTAGE_CALLER", params.environment->paludis_command())
.with_setenv("PORTAGE_GID", "0")
.with_setenv("PORTAGE_INST_GID", "0")
@@ -169,8 +145,7 @@ EbinFetchCommand::commands() const
bool
EbinFetchCommand::failure()
{
- throw PackageFetchActionError("Fetch failed for '" + stringify(
- *params.db_entry) + "'");
+ throw PackageFetchActionError("Fetch failed for '" + stringify(*params.package_id) + "'");
}
Command
@@ -232,8 +207,7 @@ EbinInstallCommand::commands() const
bool
EbinInstallCommand::failure()
{
- throw PackageInstallActionError("Install failed for '" + stringify(
- *params.db_entry) + "'");
+ throw PackageInstallActionError("Install failed for '" + stringify(*params.package_id) + "'");
}
Command
diff --git a/paludis/repositories/gentoo/ebin.hh b/paludis/repositories/gentoo/ebin.hh
index 1455135..92415fc 100644
--- a/paludis/repositories/gentoo/ebin.hh
+++ b/paludis/repositories/gentoo/ebin.hh
@@ -35,36 +35,6 @@ namespace paludis
#include <paludis/repositories/gentoo/ebin-sr.hh>
/**
- * Version metadata for a .ebin file.
- *
- * \ingroup grpebininterface
- * \nosubgrouping
- */
- class EbinVersionMetadata :
- public VersionMetadata,
- public VersionMetadataEbuildInterface,
- public VersionMetadataEbinInterface,
- public VersionMetadataDepsInterface,
- public VersionMetadataLicenseInterface,
- public VersionMetadataOriginsInterface,
- public virtual VersionMetadataHasInterfaces
- {
- public:
- ///\name Basic operations
- ///\{
-
- EbinVersionMetadata(const SlotName &);
- virtual ~EbinVersionMetadata();
-
- ///\}
-
- virtual const VersionMetadata * version_metadata() const
- {
- return this;
- }
- };
-
- /**
* A command related to a .ebin file.
*
* \ingroup grpebininterface
diff --git a/paludis/repositories/gentoo/ebin.sr b/paludis/repositories/gentoo/ebin.sr
index 30097e1..20800ef 100644
--- a/paludis/repositories/gentoo/ebin.sr
+++ b/paludis/repositories/gentoo/ebin.sr
@@ -4,7 +4,7 @@
make_class_EbinCommandParams()
{
key environment "const Environment *"
- key db_entry "const PackageDatabaseEntry *"
+ key package_id "tr1::shared_ptr<const PackageID>"
key portdir FSEntry
key distdir FSEntry
key buildroot FSEntry
diff --git a/paludis/repositories/gentoo/ebin_entries.cc b/paludis/repositories/gentoo/ebin_entries.cc
index 030c664..95b64e7 100644
--- a/paludis/repositories/gentoo/ebin_entries.cc
+++ b/paludis/repositories/gentoo/ebin_entries.cc
@@ -24,6 +24,9 @@
#include <paludis/portage_dep_parser.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/environment.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/metadata_key_raw_printer.hh>
#include <paludis/eapi.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/log.hh>
@@ -40,6 +43,8 @@
using namespace paludis;
+#if 0
+
namespace paludis
{
template<>
@@ -124,23 +129,17 @@ namespace
}
void
-EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
+EbinEntries::install(const tr1::shared_ptr<const PackageID> & id,
const InstallOptions & o, tr1::shared_ptr<const PortageRepositoryProfile>) const
{
- if (! _imp->portage_repository->has_version(q, v))
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "' since has_version failed");
-
- tr1::shared_ptr<const VersionMetadata> metadata(_imp->portage_repository->version_metadata(q, v));
- PackageDatabaseEntry e(q, v, _imp->portage_repository->name());
-
std::string binaries, flat_bin_uri;
{
std::set<std::string> already_in_binaries;
/* make B and FLAT_BIN_URI */
- DepSpecFlattener f(_imp->params.environment, &e);
- metadata->ebin_interface->bin_uri()->accept(f);
+ DepSpecFlattener f(_imp->params.environment, id);
+ if (id->bin_uri_key())
+ id->bin_uri_key()->value()->accept(f);
for (DepSpecFlattener::Iterator ff(f.begin()), ff_end(f.end()) ; ff != ff_end ; ++ff)
{
@@ -174,14 +173,13 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
std::string::size_type spos(mirror.find('/'));
if (std::string::npos == spos)
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "' since BIN_URI is broken");
+ throw PackageInstallActionError("Can't install '" + stringify(*id) + "' since BIN_URI is broken");
tr1::shared_ptr<const MirrorsCollection> mirrors(_imp->params.environment->mirrors(mirror.substr(0, spos)));
if (! _imp->portage_repository->is_mirror(mirror.substr(0, spos)) &&
mirrors->empty())
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "' since BIN_URI references unknown mirror:// '" +
+ throw PackageInstallActionError("Can't install '" + stringify(*id)
+ + "' since BIN_URI references unknown mirror:// '" +
mirror.substr(0, spos) + "'");
for (MirrorsCollection::Iterator m(mirrors->begin()), m_end(mirrors->end()) ; m != m_end ; ++m)
@@ -216,7 +214,7 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
EbinCommandParams command_params(EbinCommandParams::create()
.environment(_imp->params.environment)
- .db_entry(&e)
+ .package_id(id)
.portdir(_imp->params.master_repository ? _imp->params.master_repository->params().location :
_imp->params.location)
.distdir(_imp->params.distdir)
@@ -250,8 +248,8 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
}
if (! o.destination)
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "' because no destination was provided");
+ throw PackageInstallActionError("Can't install '" + stringify(*id)
+ + "' because no destination was provided");
EbinFetchCommand fetch_cmd(command_params,
EbinFetchCommandParams::create()
@@ -275,9 +273,9 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
.disable_cfgpro(o.no_config_protect)
.config_protect(_imp->portage_repository->profile_variable("CONFIG_PROTECT"))
.config_protect_mask(_imp->portage_repository->profile_variable("CONFIG_PROTECT_MASK"))
- .loadsaveenv_dir(_imp->params.buildroot / stringify(q.category) / (
- stringify(q.package) + "-" + stringify(v)) / "temp")
- .slot(SlotName(metadata->slot)));
+ .loadsaveenv_dir(_imp->params.buildroot / stringify(id->name().category) / (
+ stringify(id->name().package) + "-" + stringify(id->version())) / "temp")
+ .slot(SlotName(id->slot())));
EbinInstallCommand prepare_cmd(command_params, install_params);
prepare_cmd();
@@ -295,8 +293,8 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
unpackbin_cmd();
if (! o.destination->destination_interface)
- throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
- + stringify(v) + "' to destination '" + stringify(o.destination->name())
+ throw PackageInstallActionError("Can't install '" + stringify(*id)
+ + "' to destination '" + stringify(o.destination->name())
+ "' because destination does not provide destination_interface");
if (o.destination->destination_interface->want_pre_post_phases())
@@ -310,11 +308,11 @@ EbinEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
o.destination->destination_interface->merge(
MergeOptions::create()
- .package(PackageDatabaseEntry(q, v, _imp->portage_repository->name()))
- .image_dir(command_params.buildroot / stringify(q.category) / (stringify(q.package) + "-"
- + stringify(v)) / "image")
- .environment_file(command_params.buildroot / stringify(q.category) / (stringify(q.package) + "-"
- + stringify(v)) / "temp" / "loadsaveenv")
+ .package_id(id)
+ .image_dir(_imp->params.buildroot / stringify(id->name().category) / (stringify(id->name().package) + "-"
+ + stringify(id->version())) / "image")
+ .environment_file(_imp->params.buildroot / stringify(id->name().category) / (stringify(id->name().package) + "-"
+ + stringify(id->version())) / "temp" / "loadsaveenv")
);
if (o.destination->destination_interface->want_pre_post_phases())
@@ -339,39 +337,42 @@ EbinEntries::make_ebin_entries(
}
std::string
-EbinEntries::get_environment_variable(const QualifiedPackageName & q,
- const VersionSpec & v, const std::string & var, tr1::shared_ptr<const PortageRepositoryProfile>) const
+EbinEntries::get_environment_variable(const tr1::shared_ptr<const PackageID> & id,
+ const std::string & var, tr1::shared_ptr<const PortageRepositoryProfile>) const
{
- PackageDatabaseEntry for_package(q, v, _imp->portage_repository->name());
+ PackageID::Iterator i(id->find(var));
+ if (id->end() != i)
+ {
+ MetadataKeyRawPrinter p;
+ i->accept(p);
+ return stringify(p);
+ }
throw EnvironmentVariableActionError("Couldn't get environment variable '" +
- stringify(var) + "' for package '" + stringify(for_package) + "'");
+ stringify(var) + "' for package '" + stringify(*id) + "'");
}
void
EbinEntries::merge(const MergeOptions & m)
{
- Context context("When merging '" + stringify(m.package) + "' at '" + stringify(m.image_dir)
+ Context context("When merging '" + stringify(*m.package_id) + "' at '" + stringify(m.image_dir)
+ "' to ebin repository '" + stringify(_imp->portage_repository->name()) + "':");
- if (! _imp->portage_repository->destination_interface->is_suitable_destination_for(m.package))
- throw PackageInstallActionError("Not a suitable destination for '" + stringify(m.package) + "'");
+ if (! _imp->portage_repository->destination_interface->is_suitable_destination_for(m.package()))
+ throw PackageInstallActionError("Not a suitable destination for '" + stringify(*m.package()) + "'");
FSEntry ebin_dir(_imp->params.location);
- ebin_dir /= stringify(m.package.name.category);
+ ebin_dir /= stringify(m.package_id->name().category);
ebin_dir.mkdir();
- ebin_dir /= stringify(m.package.name.package);
+ ebin_dir /= stringify(m.package_id->name().package);
ebin_dir.mkdir();
- FSEntry ebin_file_name(ebin_dir / (stringify(m.package.name.package) + "-" + stringify(m.package.version) + ".ebin.incomplete"));
+ FSEntry ebin_file_name(ebin_dir / (stringify(m.package_id->name.package()) + "-" +
+ stringify(m.package_id->version()) + ".ebin.incomplete"));
std::ofstream ebin_file(stringify(ebin_file_name).c_str());
if (! ebin_file)
throw PackageInstallActionError("Cannot write to '" + stringify(ebin_file_name) + "'");
- tr1::shared_ptr<const VersionMetadata> metadata(
- _imp->params.environment->package_database()->fetch_repository(m.package.repository)->
- version_metadata(m.package.name, m.package.version));
-
if (metadata->deps_interface)
{
DepSpecPrettyPrinter r(0, false), p(0, false), s(0, false);
@@ -416,9 +417,9 @@ EbinEntries::merge(const MergeOptions & m)
FSEntry pkg_file_name(_imp->params.distdir / (
stringify(_imp->portage_repository->name()) + "--" +
- stringify(m.package.name.category) + "--" +
- stringify(m.package.name.package) + "-" +
- stringify(m.package.version) + ".tar.bz2"));
+ stringify(m.package_id->name.category) + "--" +
+ stringify(m.package_id->name.package) + "-" +
+ stringify(m.package_id->version) + ".tar.bz2"));
ebin_file << "BIN_URI=" << _imp->params.write_bin_uri_prefix << pkg_file_name.basename() << std::endl;
@@ -442,7 +443,7 @@ EbinEntries::merge(const MergeOptions & m)
merge_cmd();
- FSEntry real_ebin_file_name(ebin_dir / (stringify(m.package.name.package) + "-" + stringify(m.package.version) + ".ebin"));
+ FSEntry real_ebin_file_name(ebin_dir / (stringify(m.package_id->name.package) + "-" + stringify(m.package_id->version) + ".ebin"));
if (real_ebin_file_name.exists())
real_ebin_file_name.unlink();
ebin_file_name.rename(real_ebin_file_name);
@@ -467,4 +468,5 @@ EbinEntries::pretend(const QualifiedPackageName &, const VersionSpec &,
{
return true;
}
+#endif
diff --git a/paludis/repositories/gentoo/ebin_entries.hh b/paludis/repositories/gentoo/ebin_entries.hh
index 93c1813..a74cd57 100644
--- a/paludis/repositories/gentoo/ebin_entries.hh
+++ b/paludis/repositories/gentoo/ebin_entries.hh
@@ -56,27 +56,26 @@ namespace paludis
///\}
- virtual tr1::shared_ptr<VersionMetadata> generate_version_metadata(const QualifiedPackageName &,
- const VersionSpec &) const;
+ virtual bool is_package_file(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string get_environment_variable(const QualifiedPackageName &,
- const VersionSpec &, const std::string & var,
- tr1::shared_ptr<const PortageRepositoryProfile>) const
- PALUDIS_ATTRIBUTE((noreturn));
+ virtual VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void install(const QualifiedPackageName &, const VersionSpec &,
- const InstallOptions &, tr1::shared_ptr<const PortageRepositoryProfile>) const;
+ virtual const tr1::shared_ptr<const PackageID> make_id(const QualifiedPackageName &, const VersionSpec &,
+ const FSEntry &, const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual void merge(const MergeOptions &);
+ virtual std::string get_environment_variable(const tr1::shared_ptr<const PackageID> &, const std::string & var,
+ tr1::shared_ptr<const PortageRepositoryProfile>) const;
- virtual bool pretend(const QualifiedPackageName &, const VersionSpec &,
+ virtual void install(const tr1::shared_ptr<const PackageID> &, const InstallOptions &,
tr1::shared_ptr<const PortageRepositoryProfile>) const;
- virtual bool is_package_file(const QualifiedPackageName &, const FSEntry &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual bool pretend(const tr1::shared_ptr<const PackageID> &,
+ tr1::shared_ptr<const PortageRepositoryProfile>) const;
- virtual VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSEntry &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual void merge(const MergeOptions &);
};
}
diff --git a/paludis/repositories/gentoo/ebuild.cc b/paludis/repositories/gentoo/ebuild.cc
index e779ba1..cb21c55 100644
--- a/paludis/repositories/gentoo/ebuild.cc
+++ b/paludis/repositories/gentoo/ebuild.cc
@@ -17,21 +17,31 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <paludis/about.hh>
#include <paludis/repositories/gentoo/ebuild.hh>
+#include <paludis/repositories/gentoo/ebuild_id.hh>
+#include <paludis/repositories/gentoo/portage_repository.hh>
+
#include <paludis/util/system.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/pstream.hh>
#include <paludis/util/log.hh>
+#include <paludis/util/collection_concrete.hh>
+
+#include <paludis/about.hh>
#include <paludis/environment.hh>
#include <paludis/config_file.hh>
#include <paludis/eapi.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
#include <paludis/portage_dep_parser.hh>
+
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>
+
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
+
#include "config.h"
/** \file
@@ -41,6 +51,7 @@
*/
using namespace paludis;
+using namespace paludis::erepository;
#include <paludis/repositories/gentoo/ebuild-sr.cc>
@@ -84,20 +95,20 @@ EbuildCommand::operator() ()
tr1::shared_ptr<const FSEntryCollection> hook_dirs(params.environment->hook_dirs());
cmd = extend_command(cmd
- .with_setenv("P", stringify(params.db_entry->name.package) + "-" +
- stringify(params.db_entry->version.remove_revision()))
- .with_setenv("PV", stringify(params.db_entry->version.remove_revision()))
- .with_setenv("PR", stringify(params.db_entry->version.revision_only()))
- .with_setenv("PN", stringify(params.db_entry->name.package))
- .with_setenv("PVR", stringify(params.db_entry->version))
- .with_setenv("PF", stringify(params.db_entry->name.package) + "-" +
- stringify(params.db_entry->version))
- .with_setenv("CATEGORY", stringify(params.db_entry->name.category))
- .with_setenv("REPOSITORY", stringify(params.db_entry->repository))
+ .with_setenv("P", stringify(params.package_id->name().package) + "-" +
+ stringify(params.package_id->version().remove_revision()))
+ .with_setenv("PV", stringify(params.package_id->version().remove_revision()))
+ .with_setenv("PR", stringify(params.package_id->version().revision_only()))
+ .with_setenv("PN", stringify(params.package_id->name().package))
+ .with_setenv("PVR", stringify(params.package_id->version()))
+ .with_setenv("PF", stringify(params.package_id->name().package) + "-" +
+ stringify(params.package_id->version()))
+ .with_setenv("CATEGORY", stringify(params.package_id->name().category))
+ .with_setenv("REPOSITORY", stringify(params.package_id->repository()->name()))
.with_setenv("FILESDIR", stringify(params.files_dir))
.with_setenv("PORTDIR", stringify(params.portdir))
.with_setenv("DISTDIR", stringify(params.distdir))
- .with_setenv("EAPI", stringify(params.eapi->name))
+ .with_setenv("EAPI", stringify(params.package_id->eapi()->name))
.with_setenv("SLOT", "")
.with_setenv("PKGMANAGER", PALUDIS_PACKAGE "-" + stringify(PALUDIS_VERSION_MAJOR) + "." +
stringify(PALUDIS_VERSION_MINOR) + "." +
@@ -115,32 +126,41 @@ EbuildCommand::operator() ()