From 7ce01e1dd1129553f291d6f3d1ebefe2142cc569 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Nov 09 2016 22:01: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/treecompose-post.sh b/treecompose-post.sh index b1221c2..99f652d 100755 --- a/treecompose-post.sh +++ b/treecompose-post.sh @@ -8,9 +8,52 @@ 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 loops below are 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 +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 +" + +find /usr/share/locale -mindepth 1 -maxdepth 1 -type d | while read locale; do + locale=$(basename $locale) + if ! grep -q "^$locale\$" <<< "$KEEPLANGS"; then + rm -rf "/usr/share/locale/$locale" + fi +done + +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