diff options
author | 2010-01-05 15:41:49 +0000 | |
---|---|---|
committer | 2010-01-05 18:42:59 +0000 | |
commit | 6ac3d1601e04ba246aec693780ba998dbf314213 (patch) | |
tree | e2730d0d653abbd05df9d5c0905a1540a0244926 /paludis | |
parent | 218ea600dff25eee3cc6c0a97b12dc9aea3d7e4b (diff) | |
download | paludis-6ac3d1601e04ba246aec693780ba998dbf314213.tar.gz paludis-6ac3d1601e04ba246aec693780ba998dbf314213.tar.xz |
Don't hardcode PALUDIS_PIPE_COMMAND env name
Diffstat (limited to 'paludis')
-rw-r--r-- | paludis/repositories/e/ebuild.cc | 8 | ||||
-rw-r--r-- | paludis/util/system.cc | 29 | ||||
-rw-r--r-- | paludis/util/system.hh | 16 | ||||
-rw-r--r-- | paludis/util/system_TEST.cc | 8 |
4 files changed, 45 insertions, 16 deletions
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc index fe191da92..47444a3d0 100644 --- a/paludis/repositories/e/ebuild.cc +++ b/paludis/repositories/e/ebuild.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh + * Copyright (c) 2006, 2007, 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 @@ -147,7 +147,7 @@ EbuildCommand::operator() () using namespace std::tr1::placeholders; - cmd.with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(), + cmd.with_pipe_command_handler("PALUDIS_PIPE_COMMAND", std::tr1::bind(&pipe_command_handler, params.environment(), params.package_id(), _1, params.maybe_output_manager())); std::tr1::shared_ptr<const FSEntrySequence> syncers_dirs(params.environment()->syncers_dirs()); @@ -993,7 +993,7 @@ WriteVDBEntryCommand::operator() () params.package_id()->eapi()->supported()->ebuild_options()->ebuild_module_suffixes()) .with_setenv("PALUDIS_EBUILD_PHASE_VAR", params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_ebuild_phase()) - .with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(), + .with_pipe_command_handler("PALUDIS_PIPE_COMMAND", std::tr1::bind(&pipe_command_handler, params.environment(), params.package_id(), _1, params.maybe_output_manager())) ); @@ -1223,7 +1223,7 @@ WriteBinaryEbuildCommand::operator() () params.package_id()->eapi()->supported()->ebuild_options()->ebuild_module_suffixes()) .with_setenv("PALUDIS_EBUILD_PHASE_VAR", params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_ebuild_phase()) - .with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(), + .with_pipe_command_handler("PALUDIS_PIPE_COMMAND", std::tr1::bind(&pipe_command_handler, params.environment(), params.package_id(), _1, params.maybe_output_manager())) ); diff --git a/paludis/util/system.cc b/paludis/util/system.cc index e918fd20c..e17fd93fa 100644 --- a/paludis/util/system.cc +++ b/paludis/util/system.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh + * Copyright (c) 2006, 2007, 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 @@ -172,6 +172,7 @@ namespace paludis std::string stderr_prefix; bool prefix_discard_blank_output; bool prefix_blank_lines; + std::string pipe_command_env_var_prefix; std::tr1::function<std::string (const std::string &)> pipe_command_handler; std::ostream * captured_stdout_stream; std::ostream * captured_stderr_stream; @@ -187,6 +188,7 @@ namespace paludis std::tr1::shared_ptr<gid_t> g = std::tr1::shared_ptr<gid_t>(), const std::string & p = "", const std::string & q = "", const bool b = false, const bool bb = false, + const std::string & ep = "", const std::tr1::function<std::string (const std::string &)> & h = std::tr1::function<std::string (const std::string &)>(), std::ostream * cs = 0, std::ostream * ds = 0, @@ -205,6 +207,7 @@ namespace paludis stderr_prefix(q), prefix_discard_blank_output(b), prefix_blank_lines(bb), + pipe_command_env_var_prefix(ep), pipe_command_handler(h), captured_stdout_stream(cs), captured_stderr_stream(ds), @@ -232,7 +235,8 @@ Command::Command(const Command & other) : other._imp->clearenv, other._imp->setenv_values, other._imp->chdir, other._imp->echo_to_stderr, other._imp->uid, other._imp->gid, other._imp->stdout_prefix, other._imp->stderr_prefix, other._imp->prefix_discard_blank_output, - other._imp->prefix_blank_lines, other._imp->pipe_command_handler, other._imp->captured_stdout_stream, + other._imp->prefix_blank_lines, other._imp->pipe_command_env_var_prefix, + other._imp->pipe_command_handler, other._imp->captured_stdout_stream, other._imp->captured_stderr_stream, other._imp->input_stream, other._imp->input_fd, other._imp->input_fd_env_var, other._imp->ptys)) { @@ -251,7 +255,9 @@ Command::operator= (const Command & other) other._imp->stderr_prefix, other._imp->prefix_discard_blank_output, other._imp->prefix_blank_lines, - other._imp->pipe_command_handler, other._imp->captured_stdout_stream, + other._imp->pipe_command_env_var_prefix, + other._imp->pipe_command_handler, + other._imp->captured_stdout_stream, other._imp->captured_stderr_stream, other._imp->input_stream, other._imp->input_fd, @@ -595,8 +601,10 @@ paludis::run_command(const Command & cmd) if (cmd.pipe_command_handler()) { - setenv("PALUDIS_PIPE_COMMAND_WRITE_FD", stringify(pipe_command_reader->write_fd()).c_str(), 1); - setenv("PALUDIS_PIPE_COMMAND_READ_FD", stringify(pipe_command_response->read_fd()).c_str(), 1); + setenv((cmd.pipe_command_env_var_prefix() + "_WRITE_FD").c_str(), + stringify(pipe_command_reader->write_fd()).c_str(), 1); + setenv((cmd.pipe_command_env_var_prefix() + "_READ_FD").c_str(), + stringify(pipe_command_response->read_fd()).c_str(), 1); } if (cmd.captured_stdout_stream()) @@ -1229,8 +1237,11 @@ Command::with_stderr_prefix(const std::string & s) } Command & -Command::with_pipe_command_handler(const std::tr1::function<std::string (const std::string &)> & f) +Command::with_pipe_command_handler( + const std::string & p, + const std::tr1::function<std::string (const std::string &)> & f) { + _imp->pipe_command_env_var_prefix = p; _imp->pipe_command_handler = f; return *this; } @@ -1259,6 +1270,12 @@ Command::prefix_blank_lines() const return _imp->prefix_blank_lines; } +const std::string +Command::pipe_command_env_var_prefix() const +{ + return _imp->pipe_command_env_var_prefix; +} + const std::tr1::function<std::string (const std::string &)> & Command::pipe_command_handler() const { diff --git a/paludis/util/system.hh b/paludis/util/system.hh index 1ab5745e0..6114834f5 100644 --- a/paludis/util/system.hh +++ b/paludis/util/system.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh + * Copyright (c) 2006, 2007, 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 @@ -188,8 +188,13 @@ namespace paludis /** * Specify a pipe command handler. + * + * \param env_var_prefix has _READ_FD and _WRITE_FD appended to it. + * \since 0.44, previously was always PALUDIS_PIPE_COMMAND. */ - Command & with_pipe_command_handler(const std::tr1::function<std::string (const std::string &)> &); + Command & with_pipe_command_handler( + const std::string & env_var_prefix, + const std::tr1::function<std::string (const std::string &)> &); /** * Specify a stream to which stdout is captured and written. @@ -282,6 +287,13 @@ namespace paludis const std::tr1::function<std::string (const std::string &)> & pipe_command_handler() const; /** + * The pipe command env var prefix. + * + * \since 0.44 + */ + const std::string pipe_command_env_var_prefix() const; + + /** * The captured stdout stream, or null. */ std::ostream * captured_stdout_stream() const; diff --git a/paludis/util/system_TEST.cc b/paludis/util/system_TEST.cc index 16f7e8a7c..e027ea18a 100644 --- a/paludis/util/system_TEST.cc +++ b/paludis/util/system_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh + * Copyright (c) 2006, 2007, 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 @@ -202,9 +202,9 @@ namespace test_cases void run() { TEST_CHECK_EQUAL(run_command(Command("bash system_TEST_dir/pipe_test.bash ONE TWO") - .with_pipe_command_handler(&response_handler)), 12); + .with_pipe_command_handler("PALUDIS_PIPE_COMMAND", &response_handler)), 12); TEST_CHECK_EQUAL(run_command(Command("bash system_TEST_dir/pipe_test.bash THREE FOUR") - .with_pipe_command_handler(&response_handler)), 34); + .with_pipe_command_handler("PALUDIS_PIPE_COMMAND", &response_handler)), 34); } } test_pipe_command; @@ -287,7 +287,7 @@ namespace test_cases { std::stringstream s; TEST_CHECK_EQUAL(run_command(Command("bash system_TEST_dir/captured_pipe_test.bash ONE TWO THREE") - .with_pipe_command_handler(&response_handler) + .with_pipe_command_handler("PALUDIS_PIPE_COMMAND", &response_handler) .with_captured_stdout_stream(&s)), 13); std::string line; |