aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-01 01:41:07 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-01 01:41:07 +0000
commitb36c3570357421a8999b96fae6ce42c0a8f6fbf6 (patch)
treed2b694be6bf5f12565c3f06b49eec3f5c351cdff
parent23cdbd1fbf26f2844172d642876bbb72c26c6cb4 (diff)
downloadpaludis-b36c3570357421a8999b96fae6ce42c0a8f6fbf6.tar.gz
paludis-b36c3570357421a8999b96fae6ce42c0a8f6fbf6.tar.xz
Allow -lines in profile package.mask. Be more tolerant of malformed profile files.
-rw-r--r--paludis/repositories/portage/portage_repository_TEST.cc34
-rwxr-xr-xpaludis/repositories/portage/portage_repository_TEST_setup.sh23
-rw-r--r--paludis/repositories/portage/portage_repository_profile.cc38
3 files changed, 93 insertions, 2 deletions
diff --git a/paludis/repositories/portage/portage_repository_TEST.cc b/paludis/repositories/portage/portage_repository_TEST.cc
index 0b002a4..401535b 100644
--- a/paludis/repositories/portage/portage_repository_TEST.cc
+++ b/paludis/repositories/portage/portage_repository_TEST.cc
@@ -628,5 +628,39 @@ namespace test_cases
}
}
} test_portage_repository_query_use;
+
+ /**
+ * \test Test PortageRepository query_profile_masks functions.
+ *
+ * \ingroup grptestcases
+ */
+ struct PortageRepositoryQueryProfileMasksTest : TestCase
+ {
+ PortageRepositoryQueryProfileMasksTest() : TestCase("profiles package.mask") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo10");
+ keys->insert("profiles", "portage_repository_TEST_dir/repo10/profiles/profile/subprofile");
+ PortageRepository::Pointer repo(make_ebuild_repository(
+ &env, env.package_database().raw_pointer(), keys));
+
+ for (int pass = 1 ; pass <= 2 ; ++pass)
+ {
+ TestMessageSuffix pass_suffix(stringify(pass), true);
+
+ TEST_CHECK(repo->query_profile_masks(QualifiedPackageName("cat/masked"),
+ VersionSpec("0")));
+ TEST_CHECK(! repo->query_profile_masks(QualifiedPackageName("cat/not_masked"),
+ VersionSpec("0")));
+ TEST_CHECK(! repo->query_profile_masks(QualifiedPackageName("cat/was_masked"),
+ VersionSpec("0")));
+ }
+ }
+ } test_portage_repository_query_profile_masks;
}
diff --git a/paludis/repositories/portage/portage_repository_TEST_setup.sh b/paludis/repositories/portage/portage_repository_TEST_setup.sh
index b0f4306..5fc9373 100755
--- a/paludis/repositories/portage/portage_repository_TEST_setup.sh
+++ b/paludis/repositories/portage/portage_repository_TEST_setup.sh
@@ -200,4 +200,27 @@ END
cat <<END > cat-one/pkg-one/pkg-one-2.ebuild || exit 1
cat <<END > cat-two/pkg-two/pkg-two-1.ebuild || exit 1
END
+cd ..
+
+mkdir -p repo10/{eclass,distfiles,profiles/profile/subprofile} || exit 1
+cd repo10 || exit 1
+echo "test-repo-10" > profiles/repo_name || exit 1
+cat <<END >profiles/profile/make.defaults || exit 1
+ARCH=test
+USE="flag1 flag2 flag3 -flag4 -flag5"
+END
+cat <<END >profiles/categories || exit 1
+cat
+END
+cat <<END >profiles/profile/package.mask
+cat/masked
+cat/was_masked
+END
+cat <<END >profiles/profile/subprofile/package.mask
+-cat/was_masked
+END
+cat <<END >profiles/profile/subprofile/parent
+..
+END
+cd ..
diff --git a/paludis/repositories/portage/portage_repository_profile.cc b/paludis/repositories/portage/portage_repository_profile.cc
index f6d89a8..a770d28 100644
--- a/paludis/repositories/portage/portage_repository_profile.cc
+++ b/paludis/repositories/portage/portage_repository_profile.cc
@@ -79,9 +79,11 @@ namespace paludis
void add_use_expand_to_use();
void load_system_packages();
+ void load_package_mask();
void handle_profile_arch_var();
std::set<std::string> system_lines;
+ std::set<std::string> package_mask_lines;
public:
///\name General variables
@@ -155,6 +157,7 @@ namespace paludis
load_profile_directory_recursively(*d);
add_use_expand_to_use();
+ load_package_mask();
load_system_packages();
handle_profile_arch_var();
}
@@ -415,8 +418,39 @@ Implementation<PortageRepositoryProfile>::load_profile_package_mask(const FSEntr
for (LineConfigFile::Iterator line(file.begin()), line_end(file.end()) ;
line != line_end ; ++line)
{
- PackageDepAtom::ConstPointer a(new PackageDepAtom(*line));
- package_mask[a->package()].push_back(a);
+ if (line->empty())
+ continue;
+
+ if ('-' == line->at(0))
+ {
+ if (0 == package_mask_lines.erase(line->substr(1)))
+ Log::get_instance()->message(ll_qa, lc_context,
+ "Trying to remove package.mask line '" + line->substr(1) +
+ "' that doesn't exist");
+ }
+ else
+ package_mask_lines.insert(*line);
+ }
+}
+
+void
+Implementation<PortageRepositoryProfile>::load_package_mask()
+{
+ Context context("When building package.mask set:");
+
+ for (std::set<std::string>::const_iterator i(package_mask_lines.begin()),
+ i_end(package_mask_lines.end()) ; i != i_end ; ++i)
+ {
+ try
+ {
+ PackageDepAtom::ConstPointer a(new PackageDepAtom(*i));
+ package_mask[a->package()].push_back(a);
+ }
+ catch (const NameError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping package.mask entry '"
+ + *i + "' due to exception '" + e.message() + "' (" + e.what() + ")");
+ }
}
}