aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-11 15:46:18 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-07-11 15:46:18 +0100
commita7acb0d794e335f22460ece651f542dd9917faed (patch)
tree1940d7340eb292bb41775feb257f435c1b867793
parent63c6d33d3c7ba9347eff1dcba5ce5badc275c9e4 (diff)
downloadpaludis-a7acb0d794e335f22460ece651f542dd9917faed.tar.gz
paludis-a7acb0d794e335f22460ece651f542dd9917faed.tar.xz
~* support for Portage env
Fixes: ticket:770
-rw-r--r--paludis/environments/portage/portage_environment.cc21
-rw-r--r--paludis/environments/portage/portage_environment_TEST.cc8
-rwxr-xr-xpaludis/environments/portage/portage_environment_TEST_setup.sh4
3 files changed, 30 insertions, 3 deletions
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index 53e2243..8293d6c 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -593,6 +593,15 @@ PortageEnvironment::set_paludis_command(const std::string & s)
_imp->paludis_command = s;
}
+namespace
+{
+ bool is_tilde_keyword(const KeywordName & k)
+ {
+ std::string k_s(stringify(k));
+ return 0 == k_s.compare(0, 1, "~");
+ }
+}
+
bool
PortageEnvironment::accept_keywords(const std::tr1::shared_ptr <const KeywordNameSet> & keywords,
const PackageID & d) const
@@ -601,6 +610,8 @@ PortageEnvironment::accept_keywords(const std::tr1::shared_ptr <const KeywordNam
return true;
std::set<std::string> accepted;
+ bool accept_star_star(false), accept_tilde_star(false);
+
std::copy(_imp->accept_keywords.begin(), _imp->accept_keywords.end(), std::inserter(accepted, accepted.begin()));
for (PackageKeywords::const_iterator it(_imp->package_keywords.begin()),
it_end(_imp->package_keywords.end()); it_end != it; ++it)
@@ -612,13 +623,21 @@ PortageEnvironment::accept_keywords(const std::tr1::shared_ptr <const KeywordNam
accepted.clear();
else if ('-' == it->second.at(0))
accepted.erase(it->second.substr(1));
+ else if ("**" == it->second)
+ accept_star_star = true;
+ else if ("~*" == it->second)
+ accept_tilde_star = true;
else
accepted.insert(it->second);
}
- if (accepted.end() != accepted.find("**"))
+ if (accept_star_star)
return true;
+ if (accept_tilde_star)
+ if (keywords->end() != std::find_if(keywords->begin(), keywords->end(), is_tilde_keyword))
+ return true;
+
for (KeywordNameSet::ConstIterator it(keywords->begin()),
it_end(keywords->end()); it_end != it; ++it)
if (accepted.end() != accepted.find(stringify(*it)))
diff --git a/paludis/environments/portage/portage_environment_TEST.cc b/paludis/environments/portage/portage_environment_TEST.cc
index 15b9934..6dd1ac6 100644
--- a/paludis/environments/portage/portage_environment_TEST.cc
+++ b/paludis/environments/portage/portage_environment_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -177,6 +177,12 @@ namespace test_cases
TEST_CHECK(accept_keyword(env, KeywordName("fred"), *id4));
std::tr1::shared_ptr<const KeywordNameSet> empty(new KeywordNameSet);
TEST_CHECK(env.accept_keywords(empty, *id4));
+
+ const std::tr1::shared_ptr<const PackageID> id5(*env[selection::RequireExactlyOne(
+ generator::Matches(PackageDepSpec(parse_user_package_dep_spec("=cat-one/pkg-five-1",
+ &env, UserPackageDepSpecOptions())), MatchPackageOptions()))]->begin());
+ TEST_CHECK(accept_keyword(env, KeywordName("~foo"), *id5));
+ TEST_CHECK(! accept_keyword(env, KeywordName("foo"), *id5));
}
} test_accept_keywords;
}
diff --git a/paludis/environments/portage/portage_environment_TEST_setup.sh b/paludis/environments/portage/portage_environment_TEST_setup.sh
index 2381596..957d1ca 100755
--- a/paludis/environments/portage/portage_environment_TEST_setup.sh
+++ b/paludis/environments/portage/portage_environment_TEST_setup.sh
@@ -17,7 +17,7 @@ END
mkdir -p var/db/pkg
-mkdir -p repo/{profiles,cat-one/pkg-{one,two,three,four,x}}
+mkdir -p repo/{profiles,cat-one/pkg-{one,two,three,four,five,x}}
cat <<"END" > repo/profiles/repo_name
repo
END
@@ -26,6 +26,7 @@ echo -e "IUSE='one two three four five six'\nSLOT='0'\n" > repo/cat-one/pkg-one/
echo -e "IUSE='one two three four five six'\nSLOT='0'\n" > repo/cat-one/pkg-two/pkg-two-1.ebuild || exit 4
echo -e "IUSE='one two three four five six'\nSLOT='0'\n" > repo/cat-one/pkg-three/pkg-three-1.ebuild || exit 4
echo -e "IUSE='one two three four five six'\nSLOT='0'\n" > repo/cat-one/pkg-four/pkg-four-1.ebuild || exit 4
+echo -e "IUSE='one two three four five six'\nSLOT='0'\n" > repo/cat-one/pkg-five/pkg-five-1.ebuild || exit 4
echo -e "IUSE='one two three four five six'\nSLOT='0'\n" > repo/cat-one/pkg-x/pkg-x-1.ebuild || exit 4
mkdir -p query_use/${SYSCONFDIR}/portage
@@ -51,6 +52,7 @@ cat-one/pkg-one ~arch
cat-one/pkg-two
cat-one/pkg-three -*
cat-one/pkg-four **
+cat-one/pkg-five ~*
END
mkdir -p known_use_expand_names/${SYSCONFDIR}/portage