commit:     d0e6657d8f577b76fefa005e8081032e58381755
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Wed Nov  5 08:06:37 2025 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Wed Nov  5 08:11:22 2025 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=d0e6657d

mkconfig: Improve the diagnostics for missing locales

It would appear that some see fit to remove files belonging to glibc.
Improve the diagnostics and distinguish between the case where the file
is missing and the case where the file contains no language attribute.

I anticipate that someone might eventually request that they be allowed
to cull locale files by way of INSTALL_MASK. Time will tell.

Bug: https://bugs.gentoo.org/965533
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>

 mkconfig | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/mkconfig b/mkconfig
index b52beb5..e348497 100755
--- a/mkconfig
+++ b/mkconfig
@@ -20,8 +20,7 @@ use File::Slurper qw(read_lines read_text);
        my $prefix = @ARGV ? $ARGV[0] : '';
 
        # Read the file containing the supported locale/charmap combinations.
-       my $path = catfile($prefix, '/usr/share/i18n', 'SUPPORTED');
-       my @lines = read_lines($path);
+       my @lines = read_lines(catfile($prefix, '/usr/share/i18n', 
'SUPPORTED'));
 
        # Gather the language and territory attributes of the locale templates.
        my $attr_by = map_locale_attributes($prefix);
@@ -41,14 +40,16 @@ use File::Slurper qw(read_lines read_text);
 
                # Compose a commented entry which also has a trailing comment,
                # indicating the language and territory in plain English.
-               my ($comment, $territory) = $attr_by->{$locale}->@{'language', 
'territory'};
-               if (! length $comment) {
-                       die "Can't find a language attribute for 
'$read_locale'";
-               } else {
+               if (exists $attr_by->{$locale}) {
+                       my ($comment, $territory) = 
$attr_by->{$locale}->@{'language', 'territory'};
                        if (length $territory) {
                                $comment .= " ($territory)";
                        }
                        printf {$pipe} "# %s\037%s\037# %s\n", $read_locale, 
$charmap, $comment;
+               } elsif (-e (my $path = catfile($prefix, 
'/usr/share/i18n/locales', $locale))) {
+                       die "mkconfig: Aborting because no language attribute 
was found in '$path'\n";
+               } else {
+                       die "mkconfig: Aborting because the '$path' file is 
missing\n";
                }
        }
        close $pipe or exit 1;

Reply via email to