diff options
author | 2010-12-04 15:19:22 +0000 | |
---|---|---|
committer | 2010-12-04 15:19:22 +0000 | |
commit | 6a25169fa25d76f8cc41f9bf01bb2227f4f25ee8 (patch) | |
tree | cf6a8c65bb3c65a4bbfd93190669418012f6a580 | |
parent | cc36e7cca2b441437ae16cb9f3096f42c75c69e7 (diff) | |
download | paludis-6a25169fa25d76f8cc41f9bf01bb2227f4f25ee8.tar.gz paludis-6a25169fa25d76f8cc41f9bf01bb2227f4f25ee8.tar.xz |
Ban optionq in global scope the explicit way
Fixes: ticket:1056
-rw-r--r-- | paludis/repositories/e/e_repository_TEST_exheres_0.cc | 9 | ||||
-rwxr-xr-x | paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh | 14 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild.cc | 18 | ||||
-rw-r--r-- | paludis/repositories/e/ebuild.hh | 7 | ||||
-rw-r--r-- | paludis/repositories/e/pipe_command_handler.cc | 7 | ||||
-rw-r--r-- | paludis/repositories/e/pipe_command_handler.hh | 3 |
6 files changed, 52 insertions, 6 deletions
diff --git a/paludis/repositories/e/e_repository_TEST_exheres_0.cc b/paludis/repositories/e/e_repository_TEST_exheres_0.cc index acaf8124d..449e318e8 100644 --- a/paludis/repositories/e/e_repository_TEST_exheres_0.cc +++ b/paludis/repositories/e/e_repository_TEST_exheres_0.cc @@ -640,6 +640,15 @@ namespace test_cases TEST_CHECK(bool(id)); TEST_CHECK_THROWS(id->perform_action(action), ActionFailedError); } + + { + TestMessageSuffix suffix("global optionq", true); + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/global-optionq-1", + &env, { })), { }))]->last()); + TEST_CHECK(bool(id)); + TEST_CHECK_THROWS(id->perform_action(action), ActionFailedError); + } } } test_e_repository_install_exheres_0; } diff --git a/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh b/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh index 2e6c78e2e..baf256942 100755 --- a/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh +++ b/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh @@ -1084,6 +1084,20 @@ src_install() { nonfatal doman bar.1 && die } END +mkdir -p "packages/cat/global-optionq" +cat <<'END' > packages/cat/global-optionq/global-optionq-1.ebuild || exit 1 +DESCRIPTION="The Long Description" +SUMMARY="The Short Description" +HOMEPAGE="http://example.com/" +DOWNLOADS="" +SLOT="0" +MYOPTIONS="spork" +LICENCES="GPL-2" +PLATFORMS="test" +WORK="${WORKBASE}" + +optionq spork +END cd .. cd .. diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc index e60bf6994..04b501551 100644 --- a/paludis/repositories/e/ebuild.cc +++ b/paludis/repositories/e/ebuild.cc @@ -147,7 +147,7 @@ EbuildCommand::operator() () using namespace std::placeholders; process.pipe_command_handler("PALUDIS_PIPE_COMMAND", std::bind(&pipe_command_handler, params.environment(), - params.package_id(), _1, params.maybe_output_manager())); + params.package_id(), in_metadata_generation(), _1, params.maybe_output_manager())); std::shared_ptr<const FSPathSequence> syncers_dirs(params.environment()->syncers_dirs()); std::shared_ptr<const FSPathSequence> bashrc_files(params.environment()->bashrc_files()); @@ -361,6 +361,12 @@ EbuildCommand::add_portage_vars(Process & process) const } bool +EbuildCommand::in_metadata_generation() const +{ + return false; +} + +bool EbuildCommand::do_run_command(Process & process) { return 0 == process.run().wait(); @@ -395,6 +401,12 @@ EbuildMetadataCommand::extend_command(Process & process) ; } +bool +EbuildMetadataCommand::in_metadata_generation() const +{ + return true; +} + namespace { std::string purdy(const std::string & s) @@ -1014,7 +1026,7 @@ WriteVDBEntryCommand::operator() () .setenv("PALUDIS_PIPE_COMMANDS_SUPPORTED", "yes") .setenv("PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED", "yes") .pipe_command_handler("PALUDIS_PIPE_COMMAND", std::bind(&pipe_command_handler, params.environment(), - params.package_id(), _1, params.maybe_output_manager())); + params.package_id(), false, _1, params.maybe_output_manager())); if (! params.package_id()->eapi()->supported()->ebuild_metadata_variables()->iuse_effective()->name().empty()) if (params.package_id()->raw_iuse_effective_key()) @@ -1261,7 +1273,7 @@ WriteBinaryEbuildCommand::operator() () .setenv("PALUDIS_PIPE_COMMANDS_SUPPORTED", "yes") .setenv("PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED", "yes") .pipe_command_handler("PALUDIS_PIPE_COMMAND", std::bind(&pipe_command_handler, params.environment(), - params.package_id(), _1, params.maybe_output_manager())); + params.package_id(), false, _1, params.maybe_output_manager())); if (0 != process.run().wait()) throw ActionFailedError("Write binary command failed"); diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh index b98fca204..8e1cc3b08 100644 --- a/paludis/repositories/e/ebuild.hh +++ b/paludis/repositories/e/ebuild.hh @@ -390,6 +390,11 @@ namespace paludis */ virtual void extend_command(Process &) = 0; + /** + * Are we generating metadata? + */ + virtual bool in_metadata_generation() const; + public: /** * Destructor. @@ -754,6 +759,8 @@ namespace paludis bool do_run_command(Process &); + virtual bool in_metadata_generation() const; + virtual void extend_command(Process &); void load(const std::shared_ptr<const EbuildID> &); diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc index cf3478284..72ba2d79d 100644 --- a/paludis/repositories/e/pipe_command_handler.cc +++ b/paludis/repositories/e/pipe_command_handler.cc @@ -162,8 +162,8 @@ namespace std::string paludis::erepository::pipe_command_handler(const Environment * const environment, - const std::shared_ptr<const PackageID> & package_id, const std::string & s, - const std::shared_ptr<OutputManager> & maybe_output_manager) + const std::shared_ptr<const PackageID> & package_id, bool in_metadata_generation, + const std::string & s, const std::shared_ptr<OutputManager> & maybe_output_manager) { Context context("In ebuild pipe command handler:"); @@ -419,6 +419,9 @@ paludis::erepository::pipe_command_handler(const Environment * const environment if (! eapi->supported()) return "EOPTIONQ EAPI " + tokens[1] + " unsupported"; + if (in_metadata_generation) + return "Ecannot query options during metadata generation"; + if (! package_id->choices_key()) return "EOPTIONQ ID " + stringify(*package_id) + " has no choices"; diff --git a/paludis/repositories/e/pipe_command_handler.hh b/paludis/repositories/e/pipe_command_handler.hh index ae0cc9971..64c5b047f 100644 --- a/paludis/repositories/e/pipe_command_handler.hh +++ b/paludis/repositories/e/pipe_command_handler.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010 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 @@ -32,6 +32,7 @@ namespace paludis { std::string pipe_command_handler(const Environment * const, const std::shared_ptr<const PackageID> &, + bool in_metadata_generation, const std::string & s, const std::shared_ptr<OutputManager> & maybe_output_manager); } |