Linux Fedora Core 15: /usr/lib/locale/locale-archive still large after removing all but one locale

Forums: 

After running bleachbit 0.8.7-1 on Linux Fedora Core 15 as root to remove all but 'en' locales (that removed 400 meg of files!), I see that /usr/lib/locale/locale-archive is still 100 meg, and the command 'locale -a' lists 100 or so locales. Trying to run the command build-locale-archive fails because locale-archive-tmpl has been truncated to an empty file. If I delete locale-archive* and then do yum reinstall glibc-common, I end up with many locales reinstalled and the locale-archive is 100 Meg. Suggestions?

I found Red Hat Bugzilla 156477 that describes the process you are trying. On my system (Fedora 16) the file /usr/lib/locale/locale-archive.tmpl is also zero bytes, but I think I haven't run the BleachBit locale cleaner yet on this installation. Also BleachBit version 0.9.1 doesn't have any rules that clean /usr/lib/locale, so I think someone else truncated the file. What error message do you get when trying to rebuild? Is it "cannot read archive header"? Do you get this error right after reinstalling glibc-common?

---
Andrew, lead developer

The program
build-locale-archive
is the one that complains about the bad .../locale-archive.tmpl
That program is also the one that truncates that file to 0 bytes (I looked at the source code) after it uses it.

If I remove both files in /usr/lib/locale/* and do
yum reinstall glibc-common
many many locales get installed and two files end up in that directory [without any errors]

The 156477 bug report mentions tweaking RPM config files to override %_install_langs to limit what
locales are included into locale-archive. However, I do not understand what file needs to be tweaked.

In doing more searching via google, I found a post that mentioned these commands:

localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive
mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
/usr/sbin/build-locale-archive

[Of course, "^en" should be a grep regular expression of the locales you wish to keep]

I ran those and my locale-archive went from 100 meg to 3 meg.
But, a side effect was Firefox died (perhaps because it did not like locale-archive being
changed while it was running). I rebooted and things appear to be OK.

I notice that the contents of /usr/share/locale (after being cleaned by bleachbit) do not
match the output of
localedef -- list-archive
Both have the 'en' family of locales, but they are different.

My gut feeling is, if I were to reinstall glibc-common, I would get back a 100 meg locale-archive,
as I do not know how to control which locales it installs.

Yes, Firefox probably died because the file /usr/lib/locale/locale-archive is mmap'd which maps a file to memory in an efficient way and assumes the file will not be modified, so you violated the assumption. No big deal, though.

Yes, if you reinstall or even update glibc-common, you'll probably get the big file back. I suppose you could write a daily cron task to check the size and execute your script.

So in conclusion, BleachBit 0.9.1 does not interfere with nor enable this process. It would be a nice feature to add one day, but I wonder how fragile it would be across Linux distributions and across changes in glibc.

---
Andrew, lead developer