How to preserve custom locales across glibc-* updates?
Environment
- Red Hat Enterprise Linux
- 5.x
- 6.x
- 7.x
- 8.x
- 9.x
- glibc
- glibc-common
Issue
-
How to preserve custom locales across
glibc-*updates? -
Why does customized locale info disappear after updating
glibc-*? -
How to preserve custom locales after
glibc-commonre-install? -
After updating
glibcand dependent packages, some locale info is missing from the output of# locale -a.# localedef -f WINDOWS-31J -i ja_JP ja_JP.SJIS # locale -a | grep ja ja_JP ja_JP.eucjp ja_JP.sjis <=== here it is. ja_JP.ujis ja_JP.utf8 japanese japanese.euc # yum update glibc -y (..SNIP..) # locale -a | grep ja ja_JP ja_JP.eucjp ja_JP.ujis ja_JP.utf8 japanese japanese.euc /* ja_JP.sjis is missing */Why does this happen? And should I define it again?
Resolution
-
Use the
--no-archiveoption to add custom locales. This would create a subdirectory under in/usr/lib/localefor the new locales instead of adding it to the locale-archive/usr/lib/locale/locale-archive.--no-archive Do not use the locale archive file, instead create outputpath as a subdirectory in the same directory as the locale archive file, and create separate output files for locale categories in it. -
Example : To add a new locale
tr_TR@SAP, below command should be used.# localedef --no-archive -f ISO-8859-9 -i tr_TR@SAP tr_TR@SAP # ls /usr/lib/locale/ locale-archive locale-archive.tmpl tr_TR@SAP <--==== # ls /usr/lib/locale/tr_TR\@SAP/ LC_ADDRESS LC_COLLATE LC_CTYPE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME # locale -a | grep -i SAP tr_TR@SAP -
How does this help?
- An update or reinstall of
glibc-commonwill not destroy the folder/usr/lib/locale/tr_TR@SAP. Therefore, the custom user locale will not be lost. - The
build-locale-archivecalled in the%postinstall of next update ofglibc-commonwill merge the folder into thelocale-archivebut will not delete the folder. - The locale-archive file will also contain the custom user locale
tr_TR@SAP.
# yum update glibc glibc-common Setting up Update Process (...) Complete! # locale -a | grep -i SAP tr_TR.iso88599@SAP tr_TR@SAP # ls /usr/lib/locale/ locale-archive locale-archive.tmpl tr_TR@SAP # localedef --list-archive | grep -i SAP tr_TR.iso88599@SAP tr_TR@SAP - An update or reinstall of
-
The locale folder needs to be kept on system to get it merged into
locale-archiveevery timeglibc-commonis updated or reinstalled.
Root Cause
- If installed without using
--no-archiveoption, then the new locale is added to the archive/usr/lib/locale/locale-archive. - The next update of
glibc-commonwill call/usr/sbin/build-locale-archivein the%postinstall script which will delete the existinglocale-archiveand create a new one from the/usr/lib/locale/locale-archive.tmplfile contained in theglibc-commonrpm. Therefore, the custom user locale is lost afterglibc-commonupdate.
Diagnostic Steps
-
Add the custom locales using
localedefcommand.# localedef -f ISO-8859-9 -i tr_TR@SAP tr_TR@SAP # locale -a | grep -i SAP tr_TR.iso88599@SAP tr_TR@SAP # localedef --list-archive | grep -i SAP tr_TR.iso88599@SAP tr_TR@SAP -
Update glibc packages on system.
# yum update glibc glibc-common nscd -
Check for the locales after after update.
# locale -a | grep -i SAP # # localedef --list-archive | grep -i SAP #
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.