#793368 Updating /etc/default/locale doesn't update debconf selections during dpkg-reconfigure

#793368#5
Date:
2015-07-23 10:41:32 UTC
From:
To:
When performing the following steps /etc/default/locale ends up changed
back to the previous value and debconf-get-selections is not updated:

1. Update /etc/default/locale
2. Run dpkg-reconfigure -fnoninteractive locales

I think this is a minor logic error in locales.config
(/var/lib/info/dpkg/locales.config):

"""
if ! echo "$SUPPORTED_LOCALES" | grep -q -e "\b$DEFAULT_ENVIRONMENT\b" ;
then
     db_set locales/default_environment_locale "$DEFAULT_ENVIRONMENT"
fi

"""

Which if I'm reading that correctly says "If the locale is not supported
then update default_environment_locale", I'd suggest removal of the
negating '!'.

Example transcripts:

"""
# cat /etc/default/locale
#  File generated by update-locale
LANG=en_US
# echo 'LANG=en_GB.UTF-8' > /etc/default/locale
# dpkg-reconfigure -fnoninteractive locales
Generating locales (this might take a while)...
   en_GB.ISO-8859-1... done
   en_GB.ISO-8859-15... done
   en_GB.UTF-8... done
   en_US.ISO-8859-1... done
   en_US.UTF-8... done
Generation complete.
# cat /etc/default/locale
LANG=en_US
"""

Inverting the logic condition as suggested by editing
/var/lib/dpkg/info/locales.config:

"""
# cat /etc/default/locale
LANG=en_US
# echo 'LANG=en_GB.UTF-8' > /etc/default/locale
# dpkg-reconfigure -fnoninteractive locales
Generating locales (this might take a while)...
   en_GB.ISO-8859-1... done
   en_GB.ISO-8859-15... done
   en_GB.UTF-8... done
   en_US.ISO-8859-1... done
   en_US.UTF-8... done
Generation complete.
# cat /etc/default/locale
LANG=en_GB.UTF-8
"""

#793368#10
Date:
2024-03-14 23:18:59 UTC
From:
To:
This bug still exits in Debian 12 "Bookworm"

File: /var/lib/dpkg/info/locales.config
Line: 371

The logic has to be inverted to work as intended.

Please fix
Matthias Bücher

#793368#15
Date:
2024-03-16 12:23:46 UTC
From:
To:
Here's a working and POSIX compatible patch for locales.config.

Kind regards
Matthias