commit:     390ba58c130c544f51729eac31bc8d8e66b01883
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Sep 19 01:53:25 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Sep 19 08:18:21 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=390ba58c

sys-libs/glibc: convey locale-gen(8) diagnostics with ewarn()

This commit modifies the behaviour of the run_locale_gen() function
present in the 2.41-r5, 2.41-r6, 2.42, 2.42-r1 and 9999 ebuilds. The
changes are as follows.

Firstly, the responsibility of checking the exit status of locale-gen(8)
and determining whether to die is now that of the function.

Secondly, the standard error stream of locale-gen(8) shall now be
captured. In the event that any lines are captured at all, each shall be
conveyed by the ewarn() function. The purpose of this is to ensure that
diagnostic messages produced by locale-gen(8) are shown not only once
but also a second time, upon emerge exiting. The probability of a user
being aware of any guidance issued by the utility should thus be
markedly increased. Indeed, those that make use of the --quiet-build
option would previously have been oblivious to any such guidance.

Link: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=cf37b8be25
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-libs/glibc/glibc-2.41-r5.ebuild | 33 +++++++++++++++++++++++++++------
 sys-libs/glibc/glibc-2.41-r6.ebuild | 33 +++++++++++++++++++++++++++------
 sys-libs/glibc/glibc-2.42-r1.ebuild | 33 +++++++++++++++++++++++++++------
 sys-libs/glibc/glibc-2.42.ebuild    | 33 +++++++++++++++++++++++++++------
 sys-libs/glibc/glibc-9999.ebuild    | 33 +++++++++++++++++++++++++++------
 5 files changed, 135 insertions(+), 30 deletions(-)

diff --git a/sys-libs/glibc/glibc-2.41-r5.ebuild 
b/sys-libs/glibc/glibc-2.41-r5.ebuild
index 4d6666a270ec..62e711bdcb15 100644
--- a/sys-libs/glibc/glibc-2.41-r5.ebuild
+++ b/sys-libs/glibc/glibc-2.41-r5.ebuild
@@ -1316,7 +1316,8 @@ src_test() {
 # src_install
 
 run_locale_gen() {
-       local prefix=$1 user_config config
+       local fatal=$1 prefix=$2
+       local user_config action config stderr noun ret
        local -a hasversion_opts localegen_args
 
        if [[ ${EBUILD_PHASE_FUNC} == src_install ]]; then
@@ -1345,7 +1346,27 @@ run_locale_gen() {
        fi
 
        printf 'Executing: locale-gen %s\n' "${localegen_args[*]@Q}" >&2
-       locale-gen "${localegen_args[@]}"
+       { stderr=$(locale-gen "${localegen_args[@]}" 2>&1 >&3); } 3>&1
+       ret=$?
+       action="ewarn"
+       if (( ret == 0 )); then
+               noun="warning"
+       else
+               noun="error"
+               if (( fatal )); then
+                       action="die"
+               fi
+       fi
+       # Convey warnings/errors so that they can be reseen upon emerge exiting.
+       if [[ ${stderr} ]]; then
+               ewarn "locale-gen(8) issued the following ${noun}s:"
+               while read -r; do
+                       ewarn "$REPLY"
+               done <<<"${stderr}"
+       fi
+       if (( ret != 0 )); then
+               "${action}" "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       fi
 }
 
 glibc_do_src_install() {
@@ -1560,8 +1581,8 @@ glibc_do_src_install() {
        rm -f "${ED}"/etc/localtime
 
        # Generate all locales if this is a native build as locale generation
-       if use compile-locales && ! is_crosscompile && ! run_locale_gen 
"${ED}"; then
-               die "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       if use compile-locales && ! is_crosscompile; then
+               run_locale_gen 1 "${ED}"
        fi
 }
 
@@ -1711,8 +1732,8 @@ pkg_postinst() {
                # window for the affected programs.
                use loong && glibc_refresh_ldconfig
 
-               if ! use compile-locales && ! run_locale_gen "${EROOT}"; then
-                       ewarn "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+               if ! use compile-locales; then
+                       run_locale_gen 0 "${EROOT}"
                fi
 
                # If fixincludes was/is active for a particular GCC slot, we

diff --git a/sys-libs/glibc/glibc-2.41-r6.ebuild 
b/sys-libs/glibc/glibc-2.41-r6.ebuild
index feb0c810468e..b10af22d16d5 100644
--- a/sys-libs/glibc/glibc-2.41-r6.ebuild
+++ b/sys-libs/glibc/glibc-2.41-r6.ebuild
@@ -1316,7 +1316,8 @@ src_test() {
 # src_install
 
 run_locale_gen() {
-       local prefix=$1 user_config config
+       local fatal=$1 prefix=$2
+       local user_config action config stderr noun ret
        local -a hasversion_opts localegen_args
 
        if [[ ${EBUILD_PHASE_FUNC} == src_install ]]; then
@@ -1345,7 +1346,27 @@ run_locale_gen() {
        fi
 
        printf 'Executing: locale-gen %s\n' "${localegen_args[*]@Q}" >&2
-       locale-gen "${localegen_args[@]}"
+       { stderr=$(locale-gen "${localegen_args[@]}" 2>&1 >&3); } 3>&1
+       ret=$?
+       action="ewarn"
+       if (( ret == 0 )); then
+               noun="warning"
+       else
+               noun="error"
+               if (( fatal )); then
+                       action="die"
+               fi
+       fi
+       # Convey warnings/errors so that they can be reseen upon emerge exiting.
+       if [[ ${stderr} ]]; then
+               ewarn "locale-gen(8) issued the following ${noun}s:"
+               while read -r; do
+                       ewarn "$REPLY"
+               done <<<"${stderr}"
+       fi
+       if (( ret != 0 )); then
+               "${action}" "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       fi
 }
 
 glibc_do_src_install() {
@@ -1560,8 +1581,8 @@ glibc_do_src_install() {
        rm -f "${ED}"/etc/localtime
 
        # Generate all locales if this is a native build as locale generation
-       if use compile-locales && ! is_crosscompile && ! run_locale_gen 
"${ED}"; then
-               die "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       if use compile-locales && ! is_crosscompile; then
+               run_locale_gen 1 "${ED}"
        fi
 }
 
@@ -1711,8 +1732,8 @@ pkg_postinst() {
                # window for the affected programs.
                use loong && glibc_refresh_ldconfig
 
-               if ! use compile-locales && ! run_locale_gen "${EROOT}"; then
-                       ewarn "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+               if ! use compile-locales; then
+                       run_locale_gen 0 "${EROOT}"
                fi
 
                # If fixincludes was/is active for a particular GCC slot, we

diff --git a/sys-libs/glibc/glibc-2.42-r1.ebuild 
b/sys-libs/glibc/glibc-2.42-r1.ebuild
index 60b0954a3c02..59381ce71802 100644
--- a/sys-libs/glibc/glibc-2.42-r1.ebuild
+++ b/sys-libs/glibc/glibc-2.42-r1.ebuild
@@ -1324,7 +1324,8 @@ src_test() {
 # src_install
 
 run_locale_gen() {
-       local prefix=$1 user_config config
+       local fatal=$1 prefix=$2
+       local user_config action config stderr noun ret
        local -a hasversion_opts localegen_args
 
        if [[ ${EBUILD_PHASE_FUNC} == src_install ]]; then
@@ -1353,7 +1354,27 @@ run_locale_gen() {
        fi
 
        printf 'Executing: locale-gen %s\n' "${localegen_args[*]@Q}" >&2
-       locale-gen "${localegen_args[@]}"
+       { stderr=$(locale-gen "${localegen_args[@]}" 2>&1 >&3); } 3>&1
+       ret=$?
+       action="ewarn"
+       if (( ret == 0 )); then
+               noun="warning"
+       else
+               noun="error"
+               if (( fatal )); then
+                       action="die"
+               fi
+       fi
+       # Convey warnings/errors so that they can be reseen upon emerge exiting.
+       if [[ ${stderr} ]]; then
+               ewarn "locale-gen(8) issued the following ${noun}s:"
+               while read -r; do
+                       ewarn "$REPLY"
+               done <<<"${stderr}"
+       fi
+       if (( ret != 0 )); then
+               "${action}" "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       fi
 }
 
 glibc_do_src_install() {
@@ -1568,8 +1589,8 @@ glibc_do_src_install() {
        rm -f "${ED}"/etc/localtime
 
        # Generate all locales if this is a native build as locale generation
-       if use compile-locales && ! is_crosscompile && ! run_locale_gen 
"${ED}"; then
-               die "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       if use compile-locales && ! is_crosscompile; then
+               run_locale_gen 1 "${ED}"
        fi
 }
 
@@ -1719,8 +1740,8 @@ pkg_postinst() {
                # window for the affected programs.
                use loong && glibc_refresh_ldconfig
 
-               if ! use compile-locales && ! run_locale_gen "${EROOT}"; then
-                       ewarn "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+               if ! use compile-locales; then
+                       run_locale_gen 0 "${EROOT}"
                fi
 
                # If fixincludes was/is active for a particular GCC slot, we

diff --git a/sys-libs/glibc/glibc-2.42.ebuild b/sys-libs/glibc/glibc-2.42.ebuild
index fe945b6630e2..93330136fc37 100644
--- a/sys-libs/glibc/glibc-2.42.ebuild
+++ b/sys-libs/glibc/glibc-2.42.ebuild
@@ -1324,7 +1324,8 @@ src_test() {
 # src_install
 
 run_locale_gen() {
-       local prefix=$1 user_config config
+       local fatal=$1 prefix=$2
+       local user_config action config stderr noun ret
        local -a hasversion_opts localegen_args
 
        if [[ ${EBUILD_PHASE_FUNC} == src_install ]]; then
@@ -1353,7 +1354,27 @@ run_locale_gen() {
        fi
 
        printf 'Executing: locale-gen %s\n' "${localegen_args[*]@Q}" >&2
-       locale-gen "${localegen_args[@]}"
+       { stderr=$(locale-gen "${localegen_args[@]}" 2>&1 >&3); } 3>&1
+       ret=$?
+       action="ewarn"
+       if (( ret == 0 )); then
+               noun="warning"
+       else
+               noun="error"
+               if (( fatal )); then
+                       action="die"
+               fi
+       fi
+       # Convey warnings/errors so that they can be reseen upon emerge exiting.
+       if [[ ${stderr} ]]; then
+               ewarn "locale-gen(8) issued the following ${noun}s:"
+               while read -r; do
+                       ewarn "$REPLY"
+               done <<<"${stderr}"
+       fi
+       if (( ret != 0 )); then
+               "${action}" "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       fi
 }
 
 glibc_do_src_install() {
@@ -1568,8 +1589,8 @@ glibc_do_src_install() {
        rm -f "${ED}"/etc/localtime
 
        # Generate all locales if this is a native build as locale generation
-       if use compile-locales && ! is_crosscompile && ! run_locale_gen 
"${ED}"; then
-               die "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       if use compile-locales && ! is_crosscompile; then
+               run_locale_gen 1 "${ED}"
        fi
 }
 
@@ -1719,8 +1740,8 @@ pkg_postinst() {
                # window for the affected programs.
                use loong && glibc_refresh_ldconfig
 
-               if ! use compile-locales && ! run_locale_gen "${EROOT}"; then
-                       ewarn "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+               if ! use compile-locales; then
+                       run_locale_gen 0 "${EROOT}"
                fi
 
                # If fixincludes was/is active for a particular GCC slot, we

diff --git a/sys-libs/glibc/glibc-9999.ebuild b/sys-libs/glibc/glibc-9999.ebuild
index 591810d05653..053c0a1a2470 100644
--- a/sys-libs/glibc/glibc-9999.ebuild
+++ b/sys-libs/glibc/glibc-9999.ebuild
@@ -1324,7 +1324,8 @@ src_test() {
 # src_install
 
 run_locale_gen() {
-       local prefix=$1 user_config config
+       local fatal=$1 prefix=$2
+       local user_config action config stderr noun ret
        local -a hasversion_opts localegen_args
 
        if [[ ${EBUILD_PHASE_FUNC} == src_install ]]; then
@@ -1353,7 +1354,27 @@ run_locale_gen() {
        fi
 
        printf 'Executing: locale-gen %s\n' "${localegen_args[*]@Q}" >&2
-       locale-gen "${localegen_args[@]}"
+       { stderr=$(locale-gen "${localegen_args[@]}" 2>&1 >&3); } 3>&1
+       ret=$?
+       action="ewarn"
+       if (( ret == 0 )); then
+               noun="warning"
+       else
+               noun="error"
+               if (( fatal )); then
+                       action="die"
+               fi
+       fi
+       # Convey warnings/errors so that they can be reseen upon emerge exiting.
+       if [[ ${stderr} ]]; then
+               ewarn "locale-gen(8) issued the following ${noun}s:"
+               while read -r; do
+                       ewarn "$REPLY"
+               done <<<"${stderr}"
+       fi
+       if (( ret != 0 )); then
+               "${action}" "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       fi
 }
 
 glibc_do_src_install() {
@@ -1568,8 +1589,8 @@ glibc_do_src_install() {
        rm -f "${ED}"/etc/localtime
 
        # Generate all locales if this is a native build as locale generation
-       if use compile-locales && ! is_crosscompile && ! run_locale_gen 
"${ED}"; then
-               die "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+       if use compile-locales && ! is_crosscompile; then
+               run_locale_gen 1 "${ED}"
        fi
 }
 
@@ -1719,8 +1740,8 @@ pkg_postinst() {
                # window for the affected programs.
                use loong && glibc_refresh_ldconfig
 
-               if ! use compile-locales && ! run_locale_gen "${EROOT}"; then
-                       ewarn "locale-gen(8) unexpectedly failed during the 
${EBUILD_PHASE_FUNC} phase"
+               if ! use compile-locales; then
+                       run_locale_gen 0 "${EROOT}"
                fi
 
                # If fixincludes was/is active for a particular GCC slot, we

Reply via email to