]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Restrict package locales to en_US
authorReto Gantenbein <reto.gantenbein@linuxmonk.ch>
Thu, 5 Jan 2017 06:22:35 +0000 (07:22 +0100)
committerReto Gantenbein <reto.gantenbein@linuxmonk.ch>
Sat, 7 Jan 2017 01:51:27 +0000 (02:51 +0100)
Adjust locale setup to official Fedora cloud setup. This will
shrink the image size for e.g. Fedora 25 from around 350MB to
260MB.

Signed-off-by: Reto Gantenbein <reto.gantenbein@linuxmonk.ch>
templates/lxc-fedora.in

index ae9f8f03d78dbe058ad188c7ffc4c6d360e50b92..19d5808fe7d4292eb0b5ebb42790e081b967b948 100644 (file)
@@ -530,6 +530,7 @@ download_fedora()
 
     # suppress errors due to unknown locales
     LC_ALL=C
+    LANG=en_US
 
     echo "Downloading ${basearch} rootfs for Fedora ${release} ..."
 
@@ -614,6 +615,21 @@ download_fedora()
     rm -f "${setup_rootfs}"/var/lib/rpm/__db*
     chroot "${setup_rootfs}" rpm --rebuilddb
 
+    # Restrict locale for installed packages to en_US to shrink image size
+    # following: https://pagure.io/fedora-kickstarts/blob/master/f/fedora-cloud-base.ks
+    echo "Cleanup locales and language files ..."
+    find "${setup_rootfs}/usr/share/locale" -mindepth  1 -maxdepth 1 -type d \
+        -not -name "${LANG}" -exec rm -rf {} +
+
+    chroot "${setup_rootfs}" localedef --list-archive | grep -v ^"${LANG}" | xargs \
+        chroot "${setup_rootfs}" localedef --delete-from-archive
+
+    mv -f "${setup_rootfs}/usr/lib/locale/locale-archive" \
+        "${setup_rootfs}/usr/lib/locale/locale-archive.tmpl"
+    chroot "${setup_rootfs}" build-locale-archive
+
+    echo "%_install_langs C:en:${LANG}:${LANG}.UTF-8" > "${setup_rootfs}/etc/rpm/macros.image-language-conf"
+
     chroot_umounts "${setup_rootfs}"
 
     # reset traps