sys-apps/locale-gen: Sync with Gentoo

It's from Gentoo commit ae7745b7dc0fe3ef421b2e67ceba8b779fd608ea.

Signed-off-by: Flatcar Buildbot <buildbot@flatcar-linux.org>
This commit is contained in:
Flatcar Buildbot 2025-11-03 07:12:34 +00:00 committed by Krzesimir Nowak
parent 51d5dc7f30
commit 19f8b23109
6 changed files with 193 additions and 4 deletions

View File

@ -1,2 +1,3 @@
DIST locale-gen-2.23.tar.bz2 7664 BLAKE2B a529b62fbb840c9352f06e8f5c80fc764425a2619dc69cc820f550a026d391788d5e2cfeeb46a8b5b9716da63340b4fce57a5b523edd4196ee1219c1200cb752 SHA512 c1245caadb04403c535a836f19bc410d0f04b5c0e297ea5be9852e6d71e08e528071ae769d63d31a677dda8fdd618b4c4d581ed525cf8786b82d8f37636db754
DIST locale-gen-3.8.tar.bz2 17593 BLAKE2B 0197096021286f47f4e289ee5c4cbf0220264b5784c101df567c0a5dc81a0a83999e8306e8ab72e47f4f35f92d0f7e7e40589ff3c74936e22c56e3b5a172fb15 SHA512 6e802283bce6a927ed020d3011a9bc4a81ef017d728a698fa6a8c74887895a87d225cdbe23cf18798a12f2e58beacfdd6ba5e3990d74ebafb4b2ba5986d35720
DIST locale-gen-3.9.tar.bz2 17793 BLAKE2B 982c6460a40ac29b9aa3f2bab42cfa7862510c715e13bb68b0b6c7f7910fd728862ed4cc2ce7a07bfe1888566a469c1264174a4f41306506d77edc7189957a7c SHA512 8bdb5e7cb19d62284291d092b03e04f2c40b52cac542192afe5e3c28776a88f4452efdd6dd76a6719fe7b73edf37b916322db4d048c08fd7d03d6d3474fdd6fe

View File

@ -0,0 +1,104 @@
From a4dbd5aa801fbe5510a7bc10af1027b6ce19061b Mon Sep 17 00:00:00 2001
From: Kerin Millar <kfm@plushkava.net>
Date: Fri, 31 Oct 2025 19:44:55 +0000
Subject: [PATCH] Suppress bash warnings regarding setlocale(3) failures
Presently, there are five instances in which sh(1) will be executed by
locale-gen(8). Consequently, irritating warnings will be raised where
both of the following conditions hold true.
- bash(1) is the effective /bin/sh implementation
- the LC_ALL environment variable is set as an unavailable locale
For example:
$ LC_ALL=unavailable bash -c ''
bash: warning: setlocale: LC_ALL: cannot change locale (unavailable): No
such file or directory
This occurs because bash chooses to report setlocale(3) failures. While
there is nothing wrong in doing so, to encounter such warnings while
executing locale-gen(8) is tantamount to noise. Address this annoyance
by having Perl ensure that the execve(2) call responsible for launching
sh(1) specifies LC_ALL as 'C'.
See-also: 04c08067b15933d195d8500eefdc363cb46c1b32
Signed-off-by: Kerin Millar <kfm@plushkava.net>
---
locale-gen | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/locale-gen b/locale-gen
index 3f825b4..a65b99a 100644
--- a/locale-gen
+++ b/locale-gen
@@ -138,7 +138,10 @@ umask 0022;
}
sub get_locale_dir () {
- my $stdout = qx{ LC_ALL=C localedef --help 2>/dev/null };
+ my $stdout = do {
+ local $ENV{'LC_ALL'} = 'C';
+ qx{ localedef --help 2>/dev/null };
+ };
if ($? == 0 && $stdout =~ m/\hlocale path\h*:\s+(\/[^:]+)/) {
return canonpath($1);
} elsif (($? & 0x7F) == 0) {
@@ -415,7 +418,10 @@ sub check_archive_dir ($prefix, $locale_dir) {
my $archive_dir = local $ENV{'DIR'} = catdir($prefix, $locale_dir);
# Quietly attempt to create the directory if it does not already exist.
- system q{ mkdir -p -- "$DIR" 2>/dev/null };
+ {
+ local $ENV{'LC_ALL'} = 'C';
+ system q{ mkdir -p -- "$DIR" 2>/dev/null };
+ }
# Check whether the directory exists and can be modified by the EUID.
if (! utime undef, undef, $archive_dir) {
@@ -609,8 +615,10 @@ sub check_effective_locale ($supported_by) {
}
sub copy_security_context ($src_path, $dst_path) {
- local @ENV{'SRC_PATH', 'DST_PATH'} = ($src_path, $dst_path);
- my $stderr = qx{ LC_ALL=C chcon --reference="\$SRC_PATH" -- "\$DST_PATH" 2>&1 >/dev/null };
+ my $stderr = do {
+ local @ENV{'LC_ALL', 'SRC_PATH', 'DST_PATH'} = ('C', $src_path, $dst_path);
+ qx{ chcon --reference="\$SRC_PATH" -- "\$DST_PATH" 2>&1 >/dev/null };
+ };
# Throw exceptions for any errors that are not a consequence of ENOTSUP.
if ($? != 0 && $stderr !~ m/: Operation not supported$/m) {
if (length $stderr) {
@@ -631,7 +639,11 @@ sub fopen ($path) {
}
sub get_nprocs () {
- chomp(my $nproc = qx{ { nproc || getconf _NPROCESSORS_CONF; } 2>/dev/null });
+ my $nproc = do {
+ local $ENV{'LC_ALL'} = 'C';
+ qx{ { nproc || getconf _NPROCESSORS_CONF; } 2>/dev/null };
+ };
+ chomp $nproc;
return $nproc;
}
@@ -693,10 +705,12 @@ sub dirname ($path) {
sub has_mount_option ($target, $option) {
# Per bug 962817, / may not necessarily exist as a mountpoint. Assuming
# it does not, ignore the case that findmnt(8) exits with a status of 1.
- local $ENV{'TARGET'} = $target;
- my $stdout = qx{
- findmnt -no options -T "\$TARGET"
- case \$? in 1) ! mountpoint -q / ;; *) exit "\$?" ;; esac
+ my $stdout = do {
+ local @ENV{'LC_ALL', 'TARGET'} = ('C', $target);
+ qx{
+ findmnt -no options -T "\$TARGET"
+ case \$? in 1) ! mountpoint -q / ;; *) exit "\$?" ;; esac
+ };
};
throw_child_error('findmnt');
chomp $stdout;
--
2.51.2

View File

@ -47,8 +47,12 @@ src_install() {
# See the locale.gen(5) and locale-gen(8) man pages for more details.
EOF
# Run the interpreter by name so as not to have to prefixify mkconfig.
perl mkconfig "${EROOT}"
if [[ -e ${EROOT}/usr/share/i18n/SUPPORTED ]]; then
# Run the interpreter by name so as not to have to prefixify.
perl mkconfig "${EROOT}"
else
ewarn "Skipping the incorporation of locale.gen examples because the SUPPORTED file is absent"
fi
} | newins - locale.gen
if (( PIPESTATUS[0] || PIPESTATUS[1] )); then
die "Failed to generate and/or install locale.gen"

View File

@ -0,0 +1,72 @@
# Copyright 2023-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DESCRIPTION="Generate locales based upon the config file /etc/locale.gen"
HOMEPAGE="https://gitweb.gentoo.org/proj/locale-gen.git/"
if [[ ${PV} == 9999 ]] ; then
EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/locale-gen.git"
inherit git-r3
else
SRC_URI="https://gitweb.gentoo.org/proj/locale-gen.git/snapshot/${P}.tar.bz2"
KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ~loong ~m68k ~mips ppc ~ppc64 ~riscv ~s390 ~sparc x86"
fi
LICENSE="GPL-2"
SLOT="0"
BDEPEND="
>=dev-lang/perl-5.36
dev-perl/File-Slurper
"
RDEPEND="
>=dev-lang/perl-5.36
!<sys-libs/glibc-2.37-r3
"
src_prepare() {
# EPREFIX is readonly.
local -x MY_EPREFIX=${EPREFIX}
eapply "${FILESDIR}/${PV}-suppress-bash-setlocale-warnings.patch"
eapply_user
perl -pi -e '$f //= ($. == 1 && s/^#!\h*\K/$ENV{MY_EPREFIX}/); END { exit !$f }' "${PN}" \
|| die "Failed to prefixify ${PN}"
}
src_install() {
dosbin locale-gen
doman *.[0-8]
insinto /etc
{
cat <<-'EOF' &&
# This file defines which locales to incorporate into the glibc locale archive.
# See the locale.gen(5) and locale-gen(8) man pages for more details.
EOF
if [[ -e ${EROOT}/usr/share/i18n/SUPPORTED ]]; then
# Run the interpreter by name so as not to have to prefixify.
perl mkconfig "${EROOT}"
else
ewarn "Skipping the incorporation of locale.gen examples because the SUPPORTED file is absent"
fi
} | newins - locale.gen
if (( PIPESTATUS[0] || PIPESTATUS[1] )); then
die "Failed to generate and/or install locale.gen"
fi
keepdir /usr/lib/locale
}
pkg_postinst() {
while read -r; do ewarn "${REPLY}"; done <<-'EOF'
As of version 3.9, locale-gen(8) only supports locale/charmap pairs that are
officially supported by glibc itself. For most users, there should be no
impact. Nevertheless, if running locale-gen(8) raises errors regarding
unsupported combinations, it will be necessary to modify its config file.
The locale.gen(5) man page explains how to determine which are supported.
EOF
}

View File

@ -47,8 +47,12 @@ src_install() {
# See the locale.gen(5) and locale-gen(8) man pages for more details.
EOF
# Run the interpreter by name so as not to have to prefixify mkconfig.
perl mkconfig "${EROOT}"
if [[ -e ${EROOT}/usr/share/i18n/SUPPORTED ]]; then
# Run the interpreter by name so as not to have to prefixify.
perl mkconfig "${EROOT}"
else
ewarn "Skipping the incorporation of locale.gen examples because the SUPPORTED file is absent"
fi
} | newins - locale.gen
if (( PIPESTATUS[0] || PIPESTATUS[1] )); then
die "Failed to generate and/or install locale.gen"

View File

@ -5,6 +5,10 @@
<email>toolchain@gentoo.org</email>
<name>Gentoo Toolchain Project</name>
</maintainer>
<maintainer type="person">
<email>kfm@plushkava.net</email>
<name>Kerin Millar</name>
</maintainer>
<upstream>
<remote-id type="gentoo">proj/locale-gen</remote-id>
<remote-id type="github">gentoo/locale-gen</remote-id>