1 |
By default, glibc generates around 500 locales with more added each |
2 |
year. |
3 |
|
4 |
With USE=-compile-locales, glibc generates the locale archive in |
5 |
pkg_postinst(). Since files generated in pkg_postinst() are not recorded |
6 |
in the vdb, this has the advantage of allowing users to freely change |
7 |
the set of enabled locales (by editing /etc/locale.gen and running |
8 |
locale-gen). |
9 |
|
10 |
Since it is so easy for the user to generate any locales they want with |
11 |
locale-gen (and they probably would have anyway to rid themselves of the |
12 |
499 locales they don't want!), just disable all locales except for |
13 |
C.UTF8 and save stage builders a lot of time. |
14 |
|
15 |
The patch works by |
16 |
(1) Writing /etc/locale.gen with "C.UTF8 UTF-8" |
17 |
(2) Setting CONFIG_PROTECT so glibc doesn't overwrite |
18 |
/etc/locale.gen |
19 |
(3) Running etc-update to reset /etc/locale.gen |
20 |
|
21 |
In order to do this I modified scripts/bootstrap.sh in commit |
22 |
0aa49828ae25 (scripts/bootstrap.sh: Allow CONFIG_PROTECT). |
23 |
|
24 |
Reducing the set of locales cuts the user time (as reported by time(1)) |
25 |
of the stage2 and stage3 builds as well as the file size of the |
26 |
resulting xz'd tarballs: |
27 |
|
28 |
stage 2 stage 3 |
29 |
size time size time |
30 |
before 89M 22m42s 206M 45m5s |
31 |
after 77M 4m29s 195M 26m8s |
32 |
|
33 |
An alternative solution would be to set USE=compiled-locales for glibc, |
34 |
but that has the downside of being non-default and likely causing users |
35 |
to unnecessarily rebuild glibc. (We'll do this for the ISOs where we |
36 |
want all the locales) |
37 |
|
38 |
Note that this patch does not change the contents of /etc/locale.gen in |
39 |
the stage3 tarball. |
40 |
|
41 |
Closes: https://bugs.gentoo.org/686862 |
42 |
Signed-off-by: Matt Turner <mattst88@g.o> |
43 |
--- |
44 |
In order to avoid shipping ISOs with a reduced set of locales, I'm going |
45 |
to delay committing this patch until glibc-2.30 is stablized, which has |
46 |
USE=compile-locales. I'll send a corresponding patch for releng.git that |
47 |
enables USE=compile-locales for the ISOs. |
48 |
|
49 |
targets/stage1/chroot.sh | 1 + |
50 |
targets/stage2/chroot.sh | 6 ++++++ |
51 |
targets/stage3/chroot.sh | 7 +++++++ |
52 |
targets/support/chroot-functions.sh | 6 +++++- |
53 |
4 files changed, 19 insertions(+), 1 deletion(-) |
54 |
|
55 |
diff --git a/targets/stage1/chroot.sh b/targets/stage1/chroot.sh |
56 |
index 88a36481..639feaa4 100755 |
57 |
--- a/targets/stage1/chroot.sh |
58 |
+++ b/targets/stage1/chroot.sh |
59 |
@@ -57,6 +57,7 @@ make_destpath /tmp/stage1root |
60 |
run_merge "--oneshot --nodeps sys-apps/baselayout" |
61 |
${clst_sed} -i "/USE=\"${USE} -build\"/d" ${clst_make_conf} |
62 |
|
63 |
+echo "$locales" > /etc/locale.gen |
64 |
for etc in /etc /tmp/stage1root/etc; do |
65 |
echo "LANG=C.UTF8" > ${etc}/env.d/02locale |
66 |
done |
67 |
diff --git a/targets/stage2/chroot.sh b/targets/stage2/chroot.sh |
68 |
index 5fac858f..bf98d328 100755 |
69 |
--- a/targets/stage2/chroot.sh |
70 |
+++ b/targets/stage2/chroot.sh |
71 |
@@ -4,6 +4,12 @@ source /tmp/chroot-functions.sh |
72 |
|
73 |
# Setup the environment |
74 |
export FEATURES="${clst_myfeatures} nodoc noman noinfo -news" |
75 |
+export CONFIG_PROTECT="-* /etc/locale.gen" |
76 |
+ |
77 |
+echo "$locales" > /etc/locale.gen |
78 |
|
79 |
## START BUILD |
80 |
${clst_repo_basedir}/${clst_repo_name}/scripts/bootstrap.sh ${bootstrap_opts} || exit 1 |
81 |
+ |
82 |
+# Replace modified /etc/locale.gen with default |
83 |
+etc-update --automode -5 |
84 |
diff --git a/targets/stage3/chroot.sh b/targets/stage3/chroot.sh |
85 |
index 4f8bb0ee..e6712015 100755 |
86 |
--- a/targets/stage3/chroot.sh |
87 |
+++ b/targets/stage3/chroot.sh |
88 |
@@ -5,4 +5,11 @@ source /tmp/chroot-functions.sh |
89 |
## START BUILD |
90 |
setup_pkgmgr |
91 |
|
92 |
+export CONFIG_PROTECT="-* /etc/locale.gen" |
93 |
+ |
94 |
+echo "$locales" > /etc/locale.gen |
95 |
+ |
96 |
run_merge "-e --update --deep --with-bdeps=y @system" |
97 |
+ |
98 |
+# Replace modified /etc/locale.gen with default |
99 |
+etc-update --automode -5 |
100 |
diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh |
101 |
index 2207e7b4..942fc116 100755 |
102 |
--- a/targets/support/chroot-functions.sh |
103 |
+++ b/targets/support/chroot-functions.sh |
104 |
@@ -286,7 +286,7 @@ run_merge() { |
105 |
export CLEAN_DELAY=0 |
106 |
export EBEEP_IGNORE=0 |
107 |
export EPAUSE_IGNORE=0 |
108 |
- export CONFIG_PROTECT="-*" |
109 |
+ [[ $CONFIG_PROTECT != "-*"* ]] && export CONFIG_PROTECT="-*" |
110 |
|
111 |
if [[ "${clst_VERBOSE}" == "true" ]] |
112 |
then |
113 |
@@ -433,5 +433,9 @@ Comment=This is a link to the local copy of the Gentoo Linux Handbook. |
114 |
Icon=text-editor" > /usr/share/applications/gentoo-handbook.desktop |
115 |
} |
116 |
|
117 |
+readonly locales=" |
118 |
+C.UTF8 UTF-8 |
119 |
+" |
120 |
+ |
121 |
# We do this everywhere, so why not put it in this script |
122 |
run_default_funcs |
123 |
-- |
124 |
2.24.1 |