Wednesday, November 10, 2004

Save diskspace by recompiling glibc

The idea is to keep the number of installed locales to the bare minimum.

Ever since sys-libs/glibc-2.3.4.20040619-r2 has been in Portage, a USE-flag called userlocales was provided to make sure only those locales mentioned in /etc/locales.build are to be built and installed. As a side-effect, this also leads to a much faster emerge of glibc.
Code: Activate the userlocales USE flag especially for glibc
# echo 'sys-libs/glibc userlocales' >> /etc/portage/package.use



Now specify the locales you want to be able to use:
Code:
# nano -w /etc/locales.build



only add the locales you need, like this:

en_HK.UTF-8/UTF-8
en_HK/ISO-8859-1
zh_CN.GB18030/GB18030
zh_CN.GBK/GBK
zh_CN.UTF-8/UTF-8
zh_CN/GB2312
zh_HK.UTF-8/UTF-8
zh_HK/BIG5-HKSCS
zh_TW.EUC-TW/EUC-TW
zh_TW.UTF-8/UTF-8
zh_TW/BIG5

All those locales supported by glibc can be viewed by unpacking the source, the file is /var/tmp/portage/glibc-......../work/glibc-........../localedata/SUPPORTED.

(Note: If this is the first time you compile glibc, skip the following steps).
Now let's start compiling glibc:
Code:
# emerge -B glibc


Then use localepurge script to delete all the locale files (you need to emerge localepurge and configure /etc/locale.nopurge first):
Code:
# localepurge


Finally, install the newly compiled glibc:
Code:
# emerge -k glibc