aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-03-05 18:31:47 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-03-05 18:31:47 +0000
commit5e5621d80222d644fb11f52da562a2796453d59a (patch)
tree0df6d8ba9070707afb1bef799e6fa50b0fc10a83
parent28cee80678bb3b69e0712d016b8413b5b3cbebb1 (diff)
downloadpaludis-5e5621d80222d644fb11f52da562a2796453d59a.tar.gz
paludis-5e5621d80222d644fb11f52da562a2796453d59a.tar.xz
Support "-spec" lines in repository package.mask.
-rw-r--r--paludis/repositories/e/e_repository.cc56
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc51
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_setup.sh57
3 files changed, 135 insertions, 29 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 44bb28f..9296d16 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -24,6 +24,7 @@
#include <paludis/repositories/e/e_key.hh>
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/e_repository_mask_file.hh>
+#include <paludis/repositories/e/e_repository_profile_file.hh>
#include <paludis/repositories/e/e_repository_profile.hh>
#include <paludis/repositories/e/e_repository_news.hh>
#include <paludis/repositories/e/e_repository_sets.hh>
@@ -555,38 +556,35 @@ ERepository::repository_masked(const PackageID & id) const
{
Context context("When querying repository mask for '" + stringify(id) + "':");
+ using namespace tr1::placeholders;
+
tr1::shared_ptr<const FSEntrySequence> repository_mask_files(_imp->layout->repository_mask_files());
- for (FSEntrySequence::ConstIterator p(repository_mask_files->begin()), p_end(repository_mask_files->end()) ;
- p != p_end ; ++p)
- {
- Context context_local("When reading '" + stringify(*p) + "':");
+ erepository::ProfileFile<erepository::MaskFile> repository_mask_file;
+ std::for_each(repository_mask_files->begin(), repository_mask_files->end(),
+ tr1::bind(&erepository::ProfileFile<erepository::MaskFile>::add_file, tr1::ref(repository_mask_file), _1));
- if (p->exists())
+ for (erepository::ProfileFile<erepository::MaskFile>::ConstIterator
+ line(repository_mask_file.begin()), line_end(repository_mask_file.end()) ;
+ line != line_end ; ++line)
+ {
+ try
{
- erepository::MaskFile ff(*p, LineConfigFileOptions());
- for (erepository::MaskFile::ConstIterator line(ff.begin()), line_end(ff.end()) ;
- line != line_end ; ++line)
- {
- try
- {
- tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(erepository::parse_e_package_dep_spec(
- line->first,
- *erepository::EAPIData::get_instance()->eapi_from_string(_imp->params.profile_eapi),
- tr1::shared_ptr<const PackageID>())));
- if (a->package_ptr())
- _imp->repo_mask[*a->package_ptr()].push_back(std::make_pair(a, line->second));
- else
- Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
- + stringify(line->first) + "' failed because specification does not restrict to a "
- "unique package");
- }
- catch (const Exception & e)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
- + stringify(line->first) + "' failed due to exception '" + e.message() + "' ("
- + e.what() + ")");
- }
- }
+ tr1::shared_ptr<const PackageDepSpec> a(new PackageDepSpec(erepository::parse_e_package_dep_spec(
+ line->first,
+ *erepository::EAPIData::get_instance()->eapi_from_string(_imp->params.profile_eapi),
+ tr1::shared_ptr<const PackageID>())));
+ if (a->package_ptr())
+ _imp->repo_mask[*a->package_ptr()].push_back(std::make_pair(a, line->second));
+ else
+ Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
+ + stringify(line->first) + "' failed because specification does not restrict to a "
+ "unique package");
+ }
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
+ + stringify(line->first) + "' failed due to exception '" + e.message() + "' ("
+ + e.what() + ")");
}
}
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 7313ccb..5cde664 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -724,6 +724,57 @@ namespace test_cases
} test_e_repository_query_use;
/**
+ * \test Test ERepository repository masks.
+ *
+ */
+ struct ERepositoryRepositoryMasksTest : TestCase
+ {
+ ERepositoryRepositoryMasksTest() : TestCase("repository masks") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ env.set_paludis_command("/bin/false");
+
+ tr1::shared_ptr<Map<std::string, std::string> > keys18(
+ new Map<std::string, std::string>);
+ keys18->insert("format", "ebuild");
+ keys18->insert("names_cache", "/var/empty");
+ keys18->insert("location", "e_repository_TEST_dir/repo18");
+ keys18->insert("profiles", "e_repository_TEST_dir/repo18/profiles/profile");
+ tr1::shared_ptr<ERepository> repo18(make_ebuild_repository(&env, keys18));
+ env.package_database()->add_repository(1, repo18);
+
+ tr1::shared_ptr<Map<std::string, std::string> > keys19(
+ new Map<std::string, std::string>);
+ keys19->insert("format", "ebuild");
+ keys19->insert("names_cache", "/var/empty");
+ keys19->insert("location", "e_repository_TEST_dir/repo19");
+ keys19->insert("master_repository", "test-repo-18");
+ tr1::shared_ptr<ERepository> repo19(make_ebuild_repository(&env, keys19));
+ env.package_database()->add_repository(1, repo19);
+
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-1::test-repo-18",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-2::test-repo-18",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-3::test-repo-18",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-4::test-repo-18",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-1::test-repo-19",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-2::test-repo-19",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK((*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-3::test-repo-19",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+ TEST_CHECK(! (*env.package_database()->query(query::Matches(PackageDepSpec(parse_user_package_dep_spec("=category/package-4::test-repo-19",
+ UserPackageDepSpecOptions()))), qo_require_exactly_one)->begin())->masked());
+ }
+ } test_e_repository_repository_masks;
+
+ /**
* \test Test ERepository query_profile_masks functions.
*
*/
diff --git a/paludis/repositories/e/e_repository_TEST_setup.sh b/paludis/repositories/e/e_repository_TEST_setup.sh
index e27259c..ffdbc1a 100755
--- a/paludis/repositories/e/e_repository_TEST_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_setup.sh
@@ -1055,5 +1055,62 @@ DEPENDENCIES="cat/pkg1 build: cat/pkg2 build,run: cat/pkg3 suggested: cat/pkg4 p
END
cd ..
+mkdir -p repo18/{eclass,distfiles,profiles/profile} || exit 1
+mkdir -p repo18/category/package || exit 1
+cd repo18 || exit 1
+echo test-repo-18 >> profiles/repo_name || exit 1
+echo category >> profiles/categories || exit 1
+cat <<END > profiles/profile/make.defaults || exit 1
+ARCH=test
+END
+cat <<END > profiles/package.mask || exit 1
+=category/package-1
+=category/package-2
+END
+cat <<END > category/package/package-1.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cat <<END > category/package/package-2.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cat <<END > category/package/package-3.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cat <<END > category/package/package-4.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cd ..
+
+mkdir -p repo19/profiles || exit 1
+mkdir -p repo19/category/package || exit 1
+cd repo19 || exit 1
+echo test-repo-19 >> profiles/repo_name || exit 1
+cat <<END > profiles/package.mask || exit 1
+-category/package
+-=category/package-2
+=category/package-3
+END
+cat <<END > category/package/package-1.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cat <<END > category/package/package-2.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cat <<END > category/package/package-3.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cat <<END > category/package/package-4.ebuild || exit 1
+SLOT="0"
+KEYWORDS="test"
+END
+cd ..
+
cd ..