Refactor ebuild_main a bit
This commit is contained in:
parent
ad2ae2ba3b
commit
dffb3c42ee
@ -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(), " "))
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user