From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C56CF15827B for ; Sun, 17 Aug 2025 02:01:10 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id AAD2C340B7E for ; Sun, 17 Aug 2025 02:01:10 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 6E805110280; Sun, 17 Aug 2025 02:01:09 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 663B1110280 for ; Sun, 17 Aug 2025 02:01:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 157B5340B7E for ; Sun, 17 Aug 2025 02:01:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 797DD3343 for ; Sun, 17 Aug 2025 02:01:07 +0000 (UTC) From: "Kerin Millar" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Kerin Millar" Message-ID: <1755395761.f5371db11967838deb85ce0d11ea76f3676ccadd.kfm@gentoo> Subject: [gentoo-commits] proj/locale-gen:master commit in: / X-VCS-Repository: proj/locale-gen X-VCS-Files: locale-gen X-VCS-Directories: / X-VCS-Committer: kfm X-VCS-Committer-Name: Kerin Millar X-VCS-Revision: f5371db11967838deb85ce0d11ea76f3676ccadd X-VCS-Branch: master Date: Sun, 17 Aug 2025 02:01:07 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: a2e23e12-105e-488e-98fb-24d29138d304 X-Archives-Hash: 3f111f5a30da8974f015b87c2d0c6545 commit: f5371db11967838deb85ce0d11ea76f3676ccadd Author: Kerin Millar plushkava net> AuthorDate: Sun Aug 17 01:38:04 2025 +0000 Commit: Kerin Millar plushkava net> CommitDate: Sun Aug 17 01:56:01 2025 +0000 URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=f5371db1 Ensure that locales/charmaps are opened relative to the prefix Consider a scenario in which an arbitrary prefix is specified. # mkdir /var/tmp/rootfs # cd / # cp -a --parents usr/share/i18n /var/tmp/rootfs # locale-gen -c - --prefix /var/tmp/rootfs <<<"C.UTF-8 UTF-8" Compiling 1 locale definition file with 1 worker ... [1/1] Compiling locale: C.UTF-8 The location of the archive shall be "/var/tmp/rootfs/usr/lib/locale/locale-archive". Adding 1 locale to the locale archive ... Successfully installed an archive containing 1 locale, of 0.46 MiB in size. At first glance, it would appear that all has gone well. However, through the use of the strace(1) utility, it can be seen that the localedef(1) utility is unable to honour the specified prefix in the course of opening the locale and charmap files. openat(AT_FDCWD, "/usr/share/i18n/charmaps/UTF-8.gz", O_RDONLY) = 3 openat(AT_FDCWD, "/usr/share/i18n/locales/C", O_RDONLY) = 3 Address this issue by setting the I18NPATH environment variable in accordance with the specified prefix. With that, it can be seen that the appropriate files are now opened. openat(AT_FDCWD, "/var/tmp/rootfs/usr/share/i18n/charmaps/UTF-8.gz", O_RDONLY) = 3 openat(AT_FDCWD, "/var/tmp/rootfs/usr/share/i18n/locales/C", O_RDONLY) = 3 It should be noted that this bug would have been rather difficult to reproduce in a Gentoo Prefix environment, since its localedef(1) binary hard-codes the appropriate prefix. Bug: https://bugs.gentoo.org/785406 Reported-by: Joakim Tjernlund nokia.com> Signed-off-by: Kerin Millar plushkava.net> locale-gen | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/locale-gen b/locale-gen index f0b85fe..b3052ed 100755 --- a/locale-gen +++ b/locale-gen @@ -60,6 +60,10 @@ umask 0022; my %opt = parse_opts($gentoo_prefix, @ARGV); my $prefix = $opt{'prefix'} // $gentoo_prefix; + # Ensure that locale/charmap files are opened relative to the prefix. + # This is important in situations where the --prefix option is given. + $ENV{'I18NPATH'} = catdir($prefix, '/usr/share/i18n'); + # For the directory to be unknown strongly implies the absence of glibc. if (! defined $locale_dir) { die "$PROGRAM: Aborting because the OS does not appear to use GNU libc\n";