aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Bo ├śrsted Andresen <bo.andresen@zlin.dk> 2010-08-12 15:11:43 +0000
committerAvatar Bo ├śrsted Andresen <bo.andresen@zlin.dk> 2010-08-13 21:38:26 +0000
commit52bc5b1f61040e15db3cd508007955e343b27f24 (patch)
treef4a8606c4bf7b8afcd0f1c9c3814d7b594b583b6
parenta645e704e18e1d7baa64fe2d7e3cdf91534c14bb (diff)
downloadpaludis-52bc5b1f61040e15db3cd508007955e343b27f24.tar.gz
paludis-52bc5b1f61040e15db3cd508007955e343b27f24.tar.xz
has_version/best_version --slash/--root
-rw-r--r--paludis/repositories/e/ebuild/0/portage_stubs.bash4
-rwxr-xr-xpaludis/repositories/e/ebuild/exheres-0/portage_stubs.bash24
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc28
3 files changed, 44 insertions, 12 deletions
diff --git a/paludis/repositories/e/ebuild/0/portage_stubs.bash b/paludis/repositories/e/ebuild/0/portage_stubs.bash
index 7c8745d..cb90e4c 100644
--- a/paludis/repositories/e/ebuild/0/portage_stubs.bash
+++ b/paludis/repositories/e/ebuild/0/portage_stubs.bash
@@ -61,7 +61,7 @@ portageq()
best_version()
{
[[ "${#@}" -ne 1 ]] && die "$0 should take exactly one arg"
- local r=$(paludis_pipe_command BEST_VERSION "$EAPI" "$1" )
+ local r=$(paludis_pipe_command BEST_VERSION "$EAPI" --root "$1" )
echo ${r#*;}
return ${r%%;*}
}
@@ -69,7 +69,7 @@ best_version()
has_version()
{
[[ "${#@}" -ne 1 ]] && die "$0 should take exactly one arg"
- local r=$(paludis_pipe_command HAS_VERSION "$EAPI" "$1" )
+ local r=$(paludis_pipe_command HAS_VERSION "$EAPI" --root "$1" )
return ${r%%;*}
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/portage_stubs.bash b/paludis/repositories/e/ebuild/exheres-0/portage_stubs.bash
index 2eff448..ef65090 100755
--- a/paludis/repositories/e/ebuild/exheres-0/portage_stubs.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/portage_stubs.bash
@@ -23,8 +23,16 @@
has_version()
{
illegal_in_global_scope
- [[ "${#@}" -ne 1 ]] && die "$0 should take exactly one arg"
- local r=$(paludis_pipe_command HAS_VERSION "$EAPI" "$1" )
+ local slash
+ if [[ "${#}" -eq 1 ]]; then
+ slash=--root
+ elif [[ "${#}" -eq 2 ]]; then
+ slash=${1}
+ shift
+ else
+ die "$0 should take one or two arguments"
+ fi
+ local r=$(paludis_pipe_command HAS_VERSION "$EAPI" "$slash" "$1" )
return ${r%%;*}
}
@@ -36,8 +44,16 @@ portageq()
best_version()
{
illegal_in_global_scope
- [[ "${#@}" -ne 1 ]] && die "$0 should take exactly one arg"
- local r=$(paludis_pipe_command BEST_VERSION "$EAPI" "$1" )
+ local slash
+ if [[ "${#}" -eq 1 ]]; then
+ slash=--root
+ elif [[ "${#}" -eq 2 ]]; then
+ slash=${1}
+ shift
+ else
+ die "$0 should take one or two arguments"
+ fi
+ local r=$(paludis_pipe_command BEST_VERSION "$EAPI" "$slash" "$1" )
echo ${r#*;}
return ${r%%;*}
}
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index 3ba78a5..b68d14d 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -249,7 +249,7 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
}
else if (tokens[0] == "BEST_VERSION")
{
- if (tokens.size() != 3)
+ if (tokens.size() != 4)
{
Log::get_instance()->message("e.pipe_commands.best_version.bad", ll_warning, lc_context) << "Got bad BEST_VERSION pipe command";
return "Ebad BEST_VERSION command";
@@ -260,11 +260,19 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
if (! eapi->supported())
return "EBEST_VERSION EAPI " + tokens[1] + " unsupported";
- PackageDepSpec spec(parse_elike_package_dep_spec(tokens[2],
+ Filter root((filter::All()));
+ if (tokens[2] == "--slash")
+ root = filter::InstalledAtSlash();
+ else if (tokens[2] == "--root")
+ root = filter::InstalledAtRoot(environment->preferred_root_key()->value());
+ else
+ return "Ebad BEST_VERSION " + tokens[2] + " argument";
+
+ PackageDepSpec spec(parse_elike_package_dep_spec(tokens[3],
eapi->supported()->package_dep_spec_parse_options(),
eapi->supported()->version_spec_options(), package_id));
std::shared_ptr<const PackageIDSequence> entries((*environment)[selection::AllVersionsSorted(
- generator::Matches(spec, { }) | filter::InstalledAtRoot(environment->preferred_root_key()->value()))]);
+ generator::Matches(spec, { }) | root)]);
if (eapi->supported()->pipe_commands()->rewrite_virtuals() && (! entries->empty()) &&
(*entries->last())->virtual_for_key())
{
@@ -290,7 +298,7 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
}
else if (tokens[0] == "HAS_VERSION")
{
- if (tokens.size() != 3)
+ if (tokens.size() != 4)
{
Log::get_instance()->message("e.pipe_commands.has_version.bad", ll_warning, lc_context) << "Got bad HAS_VERSION pipe command";
return "Ebad HAS_VERSION command";
@@ -301,11 +309,19 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
if (! eapi->supported())
return "EHAS_VERSION EAPI " + tokens[1] + " unsupported";
- PackageDepSpec spec(parse_elike_package_dep_spec(tokens[2],
+ Filter root((filter::All()));
+ if (tokens[2] == "--slash")
+ root = filter::InstalledAtSlash();
+ else if (tokens[2] == "--root")
+ root = filter::InstalledAtRoot(environment->preferred_root_key()->value());
+ else
+ return "Ebad HAS_VERSION " + tokens[2] + " argument";
+
+ PackageDepSpec spec(parse_elike_package_dep_spec(tokens[3],
eapi->supported()->package_dep_spec_parse_options(),
eapi->supported()->version_spec_options(), package_id));
std::shared_ptr<const PackageIDSequence> entries((*environment)[selection::SomeArbitraryVersion(
- generator::Matches(spec, { }) | filter::InstalledAtRoot(environment->preferred_root_key()->value()))]);
+ generator::Matches(spec, { }) | root)]);
if (entries->empty())
return "O1;";
else