diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 591d2de07..4c4f11d7b 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -1190,7 +1190,7 @@ __ebuild_main() { # The ebuild is sourced by the time pkg_setup has run, so PATCHES # is visible here. Record when it is set: the default src_prepare # applies it, so the no-op src-phase skip must not fire. - if [[ $1 == setup ]] && _=${| __expand_patches; }; then + if [[ $1 == setup ]] && _=${| __expand_words "${PATCHES@a}" "${PATCHES[@]}"; }; then : > "${PORTAGE_BUILDDIR}/.src_patches" fi ;; diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 32522e78a..c12fe81aa 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -805,6 +805,9 @@ __eapi2_src_compile() { } __eapi4_src_install() { + local -a docs + local path + if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then emake DESTDIR="${D}" install fi @@ -813,36 +816,44 @@ __eapi4_src_install() { # whether it was set. Unfortunately, the language of EAPI 4 requires # that it be this way. # https://projects.gentoo.org/pms/4/pms.html#x1-10400010.1.9 - if ! declare -p DOCS &>/dev/null ; then - local d - for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \ - THANKS BUGS FAQ CREDITS CHANGELOG ; do - [[ -s "${d}" ]] && dodoc "${d}" + if ! declare -p DOCS &>/dev/null; then + docs=( + AUTHORS BUGS CHANGELOG CHANGES CREDITS ChangeLog FAQ + NEWS README* THANKS TODO + ) + for path in "${docs[@]}"; do + [[ -s "${path}" ]] && dodoc "${path}" done - elif [[ ${DOCS@a} == *a* ]] ; then - dodoc "${DOCS[@]}" - else - dodoc ${DOCS} + elif _=${| __expand_words "${DOCS@a}" "${DOCS[@]}" && docs=("${REPLY[@]}"); }; then + dodoc "${docs[@]}" fi } __eapi6_src_prepare() { local -a patches - if _=${| __expand_patches && patches=( "${REPLY[@]}" ); }; then + if _=${| __expand_words "${PATCHES@a}" "${PATCHES[@]}" && patches=("${REPLY[@]}"); }; then eapply "$@" "${patches[@]}" fi eapply_user } -__expand_patches() { +__expand_words() { + local attr=$1 local IFS + shift - if [[ ${PATCHES@a} == *a* ]]; then - REPLY=( "${PATCHES[@]}" ) - else - REPLY=( ${PATCHES} ) - fi + case ${attr} in + *a*) + REPLY=( "$@" ) + ;; + *A*) + REPLY=() + ;; + *) + # shellcheck disable=2206 + REPLY=( $* ) + esac (( ${#REPLY[@]} )) } @@ -983,32 +994,29 @@ fi if ___eapi_has_einstalldocs; then einstalldocs() ( - local f + local -a docs + local file # The implementation deviates from PMS, which purports to be # concerned with whether the "DOCS variable is unset". In fact, # the implementation checks whether the variable is undeclared. # However, it is PMS that is in the wrong. See bug #962934. if [[ ! ${DOCS@A} ]]; then - for f in README* ChangeLog AUTHORS NEWS TODO CHANGES \ - THANKS BUGS FAQ CREDITS CHANGELOG - do - if [[ -f ${f} && -s ${f} ]]; then - docinto / && dodoc "${f}" + docs=( + AUTHORS BUGS CHANGELOG CHANGES CREDITS + ChangeLog FAQ NEWS README* THANKS TODO + ) + for file in "${docs[@]}"; do + if [[ -f ${file} && -s ${file} ]]; then + docinto / && dodoc "${file}" fi done - elif [[ ${DOCS@a} == *a* ]] && (( ${#DOCS[@]} )); then - docinto / && dodoc -r "${DOCS[@]}" - elif [[ ${DOCS@a} != *[aA]* && ${DOCS} ]]; then - # shellcheck disable=2086 - docinto / && dodoc -r ${DOCS} + elif _=${| __expand_words "${DOCS@a}" "${DOCS[@]}" && docs=("${REPLY[@]}"); }; then + docinto / && dodoc -r "${docs[@]}" fi - if [[ ${HTML_DOCS@a} == *a* ]] && (( ${#HTML_DOCS[@]} )); then - docinto html && dodoc -r "${HTML_DOCS[@]}" - elif [[ ${HTML_DOCS@a} != *[aA]* && ${HTML_DOCS} ]]; then - # shellcheck disable=2086 - docinto html && dodoc -r ${HTML_DOCS} + if _=${| __expand_words "${HTML_DOCS@a}" "${HTML_DOCS[@]}" && docs=("${REPLY[@]}"); }; then + docinto html && dodoc -r "${docs[@]}" fi ) fi diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index f145de40d..f2654be64 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -202,7 +202,7 @@ __save_ebuild_env() ( __eprint __eqaquote __eqatag - __expand_patches + __expand_words __filter_readonly_variables __get_columns __has_phase_defined_up_to