From 83ff6a846e23fcde3d0ba82b9c0eec74be7d195d Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Nov 24 2016 14:57:39 +0000 Subject: treecompose-post.sh: keep all supported LANGs In https://bugzilla.redhat.com/show_bug.cgi?id=1186757, it was acknowledged that a just middle between deleting all the locales and keeping them all was to only keep "supported" locales. There doesn't seem to be such a list for Fedora, though RHEL does have one. So for now, we piggyback on the RHEL definition as to what "supported" means. As of right now, this increases the on-disk size of an F25 tree by 17M. Its compressed size should be even more insignificant. --- diff --git a/fedora-atomic-docker-host.json b/fedora-atomic-docker-host.json index 9d4abd4..d1ee296 100644 --- a/fedora-atomic-docker-host.json +++ b/fedora-atomic-docker-host.json @@ -12,7 +12,49 @@ "initramfs-args": ["--no-hostonly", "--add", "iscsi"], - "install-langs": ["en_US"], + "install-langs-comment": "Keep this in sync with treecompose-post.sh", + "install-langs": [ + "pt_BR", + "fr", + "fr_FR", + "de", + "de_DE", + "it", + "it_IT", + "ru", + "ru_RU", + "es", + "es_ES", + "en_US", + "zh_CN", + "ja", + "ja_JP", + "ko", + "ko_KR", + "zh_TW", + "as", + "as_IN", + "bn", + "bn_IN", + "gu", + "gu_IN", + "hi", + "hi_IN", + "kn", + "kn_IN", + "ml", + "ml_IN", + "mr", + "mr_IN", + "or", + "or_IN", + "pa", + "pa_IN", + "ta", + "ta_IN", + "te", + "te_IN" + ], "postprocess-script": "treecompose-post.sh", diff --git a/treecompose-post.sh b/treecompose-post.sh index b1221c2..b507aad 100755 --- a/treecompose-post.sh +++ b/treecompose-post.sh @@ -8,9 +8,48 @@ echo 'Storage=persistent' >> /etc/systemd/journald.conf # Work around https://github.com/systemd/systemd/issues/4082 find /usr/lib/systemd/system/ -type f -exec sed -i -e '/^PrivateTmp=/d' -e '/^Protect\(Home\|System\)=/d' {} \; +# The loop below is too spammy otherwise... +set +x + # See: https://bugzilla.redhat.com/show_bug.cgi?id=1051816 -KEEPLANG=en_US -find /usr/share/locale -mindepth 1 -maxdepth 1 -type d -not -name "${KEEPLANG}" -exec rm -rf {} + -localedef --list-archive | grep -a -v ^"${KEEPLANG}" | xargs localedef --delete-from-archive +# and: https://bugzilla.redhat.com/show_bug.cgi?id=1186757 +# Keep this in sync with the `install-langs` in the treefile JSON +KEEPLANGS=" +pt_BR +fr_FR +de_DE +it_IT +ru_RU +es_ES +en_US +zh_CN +ja_JP +ko_KR +zh_TW +as_IN +bn_IN +gu_IN +hi_IN +kn_IN +ml_IN +mr_IN +or_IN +pa_IN +ta_IN +te_IN +" + +# Filter out locales from glibc which aren't UTF-8 and in the above set. +# TODO: https://github.com/projectatomic/rpm-ostree/issues/526 +localedef --list-archive | while read locale; do + lang=${locale%%.*} + lang=${lang%%@*} + if [[ $locale != *.utf8 ]] || ! grep -q "$lang" <<< "$KEEPLANGS"; then + localedef --delete-from-archive "$locale" + fi +done + +set -x + cp -f /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl build-locale-archive