Lines 136-142
useq() {
Link Here
|
136 |
# TODO: Add a registration interface for eclasses to register |
136 |
# TODO: Add a registration interface for eclasses to register |
137 |
# any number of phase hooks, so that global scope eclass |
137 |
# any number of phase hooks, so that global scope eclass |
138 |
# initialization can by migrated to phase hooks in new EAPIs. |
138 |
# initialization can by migrated to phase hooks in new EAPIs. |
139 |
# Example: add_phase_hook before pkg_setup $ECLASS_pre_pkg_setup |
139 |
# Example: register_phase_hook before pkg_setup $ECLASS_pre_pkg_setup |
140 |
#if [[ -n $EAPI ]] && ! hasq "$EAPI" 0 1 2 3 ; then |
140 |
#if [[ -n $EAPI ]] && ! hasq "$EAPI" 0 1 2 3 ; then |
141 |
# die "use() called during invalid phase: $EBUILD_PHASE" |
141 |
# die "use() called during invalid phase: $EBUILD_PHASE" |
142 |
#fi |
142 |
#fi |
Lines 283-288
register_success_hook() {
Link Here
|
283 |
done |
283 |
done |
284 |
} |
284 |
} |
285 |
|
285 |
|
|
|
286 |
register_phase_hook() { |
287 |
if [[ -z "$3" ]]; then |
288 |
echo "!!! register_phase_hook() called without enough parameters." >&2 |
289 |
echo "!!! register_phase_hook <before|after> <phase|all> <cmd>" >&2 |
290 |
return 1 |
291 |
fi |
292 |
local x when phase cmd cmdargs phase_hooks |
293 |
when="$(echo $1 | tr 'a-z' 'A-Z')"; shift # uppercase when |
294 |
phase="$(echo $1 | tr 'A-Z' 'a-z')"; shift # lowercase phase name (to match real phase names) |
295 |
|
296 |
case "${when}" in |
297 |
BEFORE|AFTER) |
298 |
: # allowed |
299 |
;; |
300 |
*) |
301 |
echo "!!! register_phase_hook() called with invalid when parameter: $when" >&2 |
302 |
return 1 |
303 |
;; |
304 |
esac |
305 |
|
306 |
phase_hooks="$(eval 'echo $EBUILD_PHASE_HOOKS_'"${when}"'_'"${phase}")" |
307 |
|
308 |
if [[ -z "${phase_hooks}" ]]; then |
309 |
phase_hooks="0 " |
310 |
elif ! _is_phase_hook_at_version "${phase_hooks}" 0; then |
311 |
echo "!!! Unsupported ebuild phase hook version" |
312 |
return $? |
313 |
fi |
314 |
|
315 |
for x in $* ; do |
316 |
hasq $x ${phase_hooks} || \ |
317 |
phase_hooks+="${x} " |
318 |
done |
319 |
|
320 |
export EBUILD_PHASE_HOOKS_"${when}"_"${phase}"="${phase_hooks}" |
321 |
} |
322 |
|
323 |
_is_phase_hook_at_version() { |
324 |
if [[ "${1:0:1}" == "$2" ]]; then |
325 |
return 0 |
326 |
else |
327 |
return 1 |
328 |
fi |
329 |
} |
330 |
|
286 |
# Ensure that $PWD is sane whenever possible, to protect against |
331 |
# Ensure that $PWD is sane whenever possible, to protect against |
287 |
# exploitation of insecure search path for python -c in ebuilds. |
332 |
# exploitation of insecure search path for python -c in ebuilds. |
288 |
# See bug #239560. |
333 |
# See bug #239560. |
Lines 655-671
_eapi4_src_install() {
Link Here
|
655 |
} |
700 |
} |
656 |
|
701 |
|
657 |
ebuild_phase() { |
702 |
ebuild_phase() { |
658 |
declare -F "$1" >/dev/null && qa_call $1 |
703 |
local x phase_name=${1} pre_phase_hooks post_phase_hooks |
|
|
704 |
|
705 |
# only run new-style hooks if this function isn't being used to |
706 |
# execute an old-style phase hook (which causes duplicate new-style |
707 |
# hook calls) |
708 |
if [[ "$(expr match $1 '^pre_\|^post_')" == "0" ]]; then |
709 |
# Loop through new-style ebuild phase hooks with version check |
710 |
for x in \ |
711 |
EBUILD_PHASE_HOOKS_BEFORE_"${phase_name}" \ |
712 |
EBUILD_PHASE_HOOKS_BEFORE_all \ |
713 |
EBUILD_PHASE_HOOKS_AFTER_"${phase_name}" \ |
714 |
EBUILD_PHASE_HOOKS_AFTER_all |
715 |
do |
716 |
x="$(eval 'echo $'${x})" |
717 |
if [[ "${x}" == "" ]]; then |
718 |
continue |
719 |
fi |
720 |
if ! _is_phase_hook_at_version "${x}" 0; then |
721 |
echo "!!! Unsupported ebuild phase hook version" |
722 |
return 1 |
723 |
fi |
724 |
done |
725 |
pre_phase_hooks="$(eval 'echo $EBUILD_PHASE_HOOKS_BEFORE_'"${phase_name}") $EBUILD_PHASE_HOOKS_BEFORE_all" |
726 |
post_phase_hooks="$(eval 'echo $EBUILD_PHASE_HOOKS_AFTER_'"${phase_name}") $EBUILD_PHASE_HOOKS_AFTER_all" |
727 |
fi |
728 |
|
729 |
for x in \ |
730 |
$pre_phase_hooks \ |
731 |
${phase_name} \ |
732 |
$post_phase_hooks |
733 |
do |
734 |
exec_ebuild_phase ${x} |
735 |
done |
659 |
} |
736 |
} |
660 |
|
737 |
|
|
|
738 |
# TODO: deprecate this function? Should be easy to provide backwards |
739 |
# compatibility: |
740 |
# register_phase_hook before <phase> pre_<phase> |
741 |
# register_phase_hook after <phase> post_<phase> |
661 |
ebuild_phase_with_hooks() { |
742 |
ebuild_phase_with_hooks() { |
662 |
local x phase_name=${1} |
743 |
local x phase_name=${1} |
663 |
[ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE" |
744 |
[ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE" |
664 |
for x in {pre_,,post_}${phase_name} ; do |
745 |
|
665 |
ebuild_phase ${x} |
746 |
# Loop through new-style ebuild phase hooks with version check |
|
|
747 |
for x in \ |
748 |
EBUILD_PHASE_HOOKS_BEFORE_"${phase_name}" \ |
749 |
EBUILD_PHASE_HOOKS_BEFORE_all \ |
750 |
EBUILD_PHASE_HOOKS_AFTER_"${phase_name}" \ |
751 |
EBUILD_PHASE_HOOKS_AFTER_all |
752 |
do |
753 |
x="$(eval 'echo $'${x})" |
754 |
if [[ "${x}" == "" ]]; then |
755 |
continue |
756 |
fi |
757 |
if ! _is_phase_hook_at_version "${x}" 0; then |
758 |
echo "!!! Unsupported ebuild phase hook version" |
759 |
return 1 |
760 |
fi |
761 |
done |
762 |
|
763 |
# Loop through all hooks and the actual phase |
764 |
for x in \ |
765 |
$(eval 'echo $EBUILD_PHASE_HOOKS_BEFORE_'"${phase_name}") \ |
766 |
$EBUILD_PHASE_HOOKS_BEFORE_all \ |
767 |
{pre_,,post_}${phase_name} \ |
768 |
$(eval 'echo $EBUILD_PHASE_HOOKS_AFTER_'"${phase_name}") \ |
769 |
$EBUILD_PHASE_HOOKS_AFTER_all |
770 |
do |
771 |
exec_ebuild_phase ${x} |
666 |
done |
772 |
done |
667 |
} |
773 |
} |
668 |
|
774 |
|
|
|
775 |
exec_ebuild_phase() { |
776 |
declare -F "$1" >/dev/null && qa_call $1 |
777 |
} |
778 |
|
669 |
dyn_pretend() { |
779 |
dyn_pretend() { |
670 |
ebuild_phase_with_hooks pkg_pretend |
780 |
ebuild_phase_with_hooks pkg_pretend |
671 |
} |
781 |
} |
Lines 1760-1765
preprocess_ebuild_env() {
Link Here
|
1760 |
return ${retval} |
1870 |
return ${retval} |
1761 |
} |
1871 |
} |
1762 |
|
1872 |
|
|
|
1873 |
# Portage hooks |
1874 |
portage_hooks_pre_ebuild() { |
1875 |
source "${HOOKS_SH_BINARY}" --do-pre-ebuild || return $? |
1876 |
} |
1877 |
portage_hooks_post_ebuild() { |
1878 |
source "${HOOKS_SH_BINARY}" --do-post-ebuild || return $? |
1879 |
} |
1880 |
register_phase_hook before all portage_hooks_pre_ebuild |
1881 |
register_phase_hook after all portage_hooks_post_ebuild |
1882 |
|
1763 |
# === === === === === === === === === === === === === === === === === === |
1883 |
# === === === === === === === === === === === === === === === === === === |
1764 |
# === === === === === functions end, main part begins === === === === === |
1884 |
# === === === === === functions end, main part begins === === === === === |
1765 |
# === === === === === functions end, main part begins === === === === === |
1885 |
# === === === === === functions end, main part begins === === === === === |