aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2012-04-09 22:09:17 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2012-04-09 22:09:17 +0100
commitdffb3c42eec74374dff3791f93d1f4517115f72d (patch)
tree8ecc099ca3c1118808e5cfedfc4f40686a276124
parentad2ae2ba3b6fc8f113638a86de0e7d8a6a046091 (diff)
downloadpaludis-dffb3c42eec74374dff3791f93d1f4517115f72d.tar.gz
paludis-dffb3c42eec74374dff3791f93d1f4517115f72d.tar.xz
Refactor ebuild_main a bit
-rw-r--r--paludis/repositories/e/ebuild.cc5
-rw-r--r--paludis/repositories/e/ebuild/0/output_functions.bash1
-rw-r--r--paludis/repositories/e/ebuild/1/output_functions.bash1
-rw-r--r--paludis/repositories/e/ebuild/2/output_functions.bash1
-rw-r--r--paludis/repositories/e/ebuild/3/output_functions.bash1
-rw-r--r--paludis/repositories/e/ebuild/4/output_functions.bash1
-rwxr-xr-xpaludis/repositories/e/ebuild/ebuild.bash67
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/output_functions.bash1
-rw-r--r--paludis/repositories/e/ebuild/output_functions.bash1
-rw-r--r--paludis/repositories/e/ebuild/paludis-1/output_functions.bash1
10 files changed, 42 insertions, 38 deletions
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 7246209..2ee9735 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -177,6 +177,7 @@ EbuildCommand::operator() ()
.setenv("PALUDIS_REDUCED_GID", stringify(params.environment()->reduced_gid()))
.setenv("PALUDIS_REDUCED_UID", stringify(params.environment()->reduced_uid()))
.setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
+ .setenv("PALUDIS_EBUILD_QUIET", "")
.setenv("PALUDIS_EBUILD_DIR", getenv_with_default(env_vars::ebuild_dir, LIBEXECDIR "/paludis"))
.setenv("PALUDIS_UTILITY_PATH_SUFFIXES",
params.package_id()->eapi()->supported()->ebuild_options()->utility_path_suffixes())
@@ -402,6 +403,7 @@ void
EbuildMetadataCommand::extend_command(Process & process)
{
process
+ .setenv("PALUDIS_EBUILD_QUIET", "yes")
.setuid_setgid(params.environment()->reduced_uid(), params.environment()->reduced_gid())
;
}
@@ -748,6 +750,7 @@ EbuildVariableCommand::extend_command(Process & process)
{
process
.setenv("PALUDIS_VARIABLE", _var)
+ .setenv("PALUDIS_EBUILD_QUIET", "yes")
.setuid_setgid(params.environment()->reduced_uid(), params.environment()->reduced_gid());
}
@@ -1124,6 +1127,7 @@ EbuildPretendCommand::extend_command(Process & process)
stringify(params.package_id()->version()) + "> ")
.prefix_stderr(stringify(params.package_id()->name().package()) + "-" +
stringify(params.package_id()->version()) + "> ")
+ .setenv("PALUDIS_EBUILD_QUIET", "yes")
.setenv("PALUDIS_PROFILE_DIR", stringify(*pretend_params.profiles()->begin()))
.setenv("PALUDIS_PROFILE_DIRS", join(pretend_params.profiles()->begin(),
pretend_params.profiles()->end(), " "))
@@ -1335,6 +1339,7 @@ void
EbuildBadOptionsCommand::extend_command(Process & process)
{
process
+ .setenv("PALUDIS_EBUILD_QUIET", "yes")
.setenv("PALUDIS_PROFILE_DIR", stringify(*bad_options_params.profiles()->begin()))
.setenv("PALUDIS_PROFILE_DIRS", join(bad_options_params.profiles()->begin(),
bad_options_params.profiles()->end(), " "))
diff --git a/paludis/repositories/e/ebuild/0/output_functions.bash b/paludis/repositories/e/ebuild/0/output_functions.bash
index 8fe8817..1a3ecd5 100644
--- a/paludis/repositories/e/ebuild/0/output_functions.bash
+++ b/paludis/repositories/e/ebuild/0/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_GREEN}>>>${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_GREEN}>>>${COLOUR_NORMAL} $@" >/dev/null
diff --git a/paludis/repositories/e/ebuild/1/output_functions.bash b/paludis/repositories/e/ebuild/1/output_functions.bash
index 701e6d6..e906e30 100644
--- a/paludis/repositories/e/ebuild/1/output_functions.bash
+++ b/paludis/repositories/e/ebuild/1/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_BLUE}>>>${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_BLUE}>>>${COLOUR_NORMAL} $@" >/dev/null
diff --git a/paludis/repositories/e/ebuild/2/output_functions.bash b/paludis/repositories/e/ebuild/2/output_functions.bash
index 29fde57..117c900 100644
--- a/paludis/repositories/e/ebuild/2/output_functions.bash
+++ b/paludis/repositories/e/ebuild/2/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_BROWN}>>>${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_BROWN}>>>${COLOUR_NORMAL} $@" >/dev/null
diff --git a/paludis/repositories/e/ebuild/3/output_functions.bash b/paludis/repositories/e/ebuild/3/output_functions.bash
index af13af1..7d0ae07 100644
--- a/paludis/repositories/e/ebuild/3/output_functions.bash
+++ b/paludis/repositories/e/ebuild/3/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_DARK_BLUE}>>>${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_DARK_BLUE}>>>${COLOUR_NORMAL} $@" >/dev/null
diff --git a/paludis/repositories/e/ebuild/4/output_functions.bash b/paludis/repositories/e/ebuild/4/output_functions.bash
index ea8ded8..f49533c 100644
--- a/paludis/repositories/e/ebuild/4/output_functions.bash
+++ b/paludis/repositories/e/ebuild/4/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_PURPLE}>>>${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_PURPLE}>>>${COLOUR_NORMAL} $@" >/dev/null
diff --git a/paludis/repositories/e/ebuild/ebuild.bash b/paludis/repositories/e/ebuild/ebuild.bash
index 546b043..8f40fb8 100755
--- a/paludis/repositories/e/ebuild/ebuild.bash
+++ b/paludis/repositories/e/ebuild/ebuild.bash
@@ -592,8 +592,7 @@ ebuild_main()
if [[ ${#@} -ge 2 ]] ; then
ebuild_section "Running ebuild phases $@ as $(id -un ):$(id -gn )..."
- elif [[ ${1} != variable ]] && [[ ${1} != metadata ]] && \
- [[ ${1} != pretend ]] && [[ ${1} != bad_options ]] ; then
+ else
ebuild_section "Running ebuild phase $@ as $(id -un ):$(id -gn )..."
fi
@@ -601,11 +600,11 @@ ebuild_main()
ebuild_load_module $(paludis_phase_to_function_name "${action}")
done
- if [[ $1 == metadata ]] || [[ $1 == variable ]] || [[ $1 == pretend ]] || \
- [[ $1 == bad_options ]] ; then
- export ${PALUDIS_EBUILD_PHASE_VAR}="${1}"
+ for action in $@ ; do
+ export ${PALUDIS_EBUILD_PHASE_VAR}="${action}"
perform_hook ebuild_${action}_pre
- if [[ $1 == metadata ]]; then
+
+ if [[ ${action} == metadata ]]; then
# Ban execve() calls if we're running under sandbox
if esandbox check 2>/dev/null; then
esandbox enable_exec || ebuild_notice "warning" "esandbox enable_exec returned failure"
@@ -625,46 +624,38 @@ ebuild_main()
if esandbox check 2>/dev/null; then
esandbox disable_exec || ebuild_notice "warning" "esandbox disable_exec returned failure"
fi
- else
+ fi
+
+ if [[ ${#@} -eq 1 ]] && [[ ${action} == variable || ${action} == pretend || ${action} == bad_options ]]; then
ebuild_load_em_up_dan
fi
- if ! ${PALUDIS_F_FUNCTION_PREFIX:-ebuild_f}_${1} ; then
+
+ # Restrict network access if running under sandbox
+ if [[ $action != unpack ]] && [[ $action != fetch_extra ]] ; then
+ if esandbox check 2>/dev/null; then
+ esandbox enable_net || ebuild_notice "warning" "esandbox enable_net returned failure"
+ fi
+ fi
+
+ ${PALUDIS_F_FUNCTION_PREFIX:-ebuild_f}_${action}
+ local paludis_ebuild_phase_status="${?}"
+
+ if [[ $action != unpack ]] && [[ $action != fetch_extra ]] ; then
+ if esandbox check 2>/dev/null; then
+ esandbox disable_net || ebuild_notice "warning" "esandbox disable_net returned failure"
+ fi
+ fi
+
+ if [[ ${paludis_ebuild_phase_status} -ne 0 ]]; then
perform_hook ebuild_${action}_fail
- die "${1} failed"
+ die "${action} failed"
fi
perform_hook ebuild_${action}_post
- else
- for action in $@ ; do
- export ${PALUDIS_EBUILD_PHASE_VAR}="${action}"
- perform_hook ebuild_${action}_pre
- # Restrict network access if running under sandbox
- if [[ $action != unpack ]] && [[ $action != fetch_extra ]] ; then
- if esandbox check 2>/dev/null; then
- esandbox enable_net || ebuild_notice "warning" "esandbox enable_net returned failure"
- fi
- fi
- if ! ${PALUDIS_F_FUNCTION_PREFIX:-ebuild_f}_${action} ; then
- if [[ $action != unpack ]] && [[ $action != fetch_extra ]] ; then
- if esandbox check 2>/dev/null; then
- esandbox disable_net || ebuild_notice "warning" "esandbox disable_net returned failure"
- fi
- fi
- perform_hook ebuild_${action}_fail
- die "${action} failed"
- fi
- if [[ $action != unpack ]] && [[ $action != fetch_extra ]] ; then
- if esandbox check 2>/dev/null; then
- esandbox disable_net || ebuild_notice "warning" "esandbox disable_net returned failure"
- fi
- fi
- perform_hook ebuild_${action}_post
- done
- fi
+ done
if [[ ${#@} -ge 2 ]] ; then
ebuild_section "Completed ebuild phases $@"
- elif [[ ${1} != variable ]] && [[ ${1} != metadata ]] && \
- [[ ${1} != pretend ]] && [[ ${1} != bad_options ]] ; then
+ else
ebuild_section "Completed ebuild phase $@"
fi
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/output_functions.bash b/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
index 9308508..e9dcc77 100644
--- a/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_PINK}===${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_PINK}===${COLOUR_NORMAL} $@" >/dev/null
diff --git a/paludis/repositories/e/ebuild/output_functions.bash b/paludis/repositories/e/ebuild/output_functions.bash
index 8fe8817..1a3ecd5 100644
--- a/paludis/repositories/e/ebuild/output_functions.bash
+++ b/paludis/repositories/e/ebuild/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_GREEN}>>>${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_GREEN}>>>${COLOUR_NORMAL} $@" >/dev/null
diff --git a/paludis/repositories/e/ebuild/paludis-1/output_functions.bash b/paludis/repositories/e/ebuild/paludis-1/output_functions.bash
index 968598f..71d8878 100644
--- a/paludis/repositories/e/ebuild/paludis-1/output_functions.bash
+++ b/paludis/repositories/e/ebuild/paludis-1/output_functions.bash
@@ -24,6 +24,7 @@ ebuild_notice()
ebuild_section()
{
+ [[ -n ${PALUDIS_EBUILD_QUIET} ]] && return
echo -ne "${COLOUR_YELLOW}===${COLOUR_NORMAL} "
[[ ${PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED} == "yes" ]] && \
paludis_pipe_command LOG "$EAPI" "status" "${COLOUR_YELLOW}===${COLOUR_NORMAL} $@" >/dev/null