Rework yum-minimal locale cleanup
It turns out our manual locale cleanup is causing issues (see I54490b17a7f8b2f977369044fcc6bb49cc13768e). Upon further investigation, I think this is a better approach than manually deleting repos. glibc on Fedora obeys the %_install_langs macro for reducing the installed locales (as mentioned in the comments, F24 has moved to having different packages, but worry about that later). So our existing clear-out is really only required for CentOS, whose glibc does not have any way to indicate to build less locales. However, %_install_langs is still correct there, as it restricts some of the translation files and other things installed with the %lang macro in spec files. This is complicated by us having to set this at glibc-common install time, which happens with the "yum" from outside the chroot (i.e. on trusty). Since this is too old to have flags to pass this, we need to fiddle with rpmmacros. I've tested this with fedora-minimal builds and the locales file is about 2MiB, which is what it was after the cleanups, and the listed locales are only those we expect (i.e. it appears to be working). Change-Id: I528a68beeb7b2ceec25ccbec1900670501608158
This commit is contained in:
parent
5f4cac3303
commit
f5dff9c52a
@ -23,13 +23,9 @@ set -o pipefail
|
||||
|
||||
# effectively: febootstrap-minimize --keep-zoneinfo --keep-rpmdb --keep-services "$target"
|
||||
|
||||
# Fedora 24 has a much better way to handle just installing some
|
||||
# languages; see bug. We should support that at the right time.
|
||||
if [[ $DISTRO_NAME == "fedora" && $DIB_RELEASE -gt 23 ]]; then
|
||||
echo "Locale support for Fedora 24 is incomplete"
|
||||
echo " see: https://bugs.launchpad.net/diskimage-builder/+bug/1571488"
|
||||
die "Cannot cleanup locales on > Fedora 23"
|
||||
fi
|
||||
# This is only required on CentOS ... see notes in
|
||||
# root.d/08-yum-chroot about %_install_langs
|
||||
if [[ $DISTRO_NAME != "fedora" ]]; then
|
||||
|
||||
# Stripping *all* locales is a bad idea. For now, we take the
|
||||
# suggestion in [1] for reducing this
|
||||
@ -75,6 +71,8 @@ find . ! -name 'locale.alias' -delete
|
||||
popd
|
||||
rm -rf {lib.lib64}/gconv
|
||||
|
||||
fi
|
||||
|
||||
# docs
|
||||
rm -rf /usr/share/{doc,info,gnome/help}
|
||||
# cracklib
|
||||
|
@ -128,6 +128,29 @@ function _install_pkg_manager {
|
||||
flock -w 1200 9 || die "Can not lock .rpmmacros"
|
||||
echo "%_dbpath /var/lib/rpm" >> $HOME/.rpmmacros
|
||||
|
||||
# Fedora 24 has a much better way to handle just installing some
|
||||
# languages; see bug. We should support that at the right time.
|
||||
if [[ $DISTRO_NAME == "fedora" && $DIB_RELEASE -gt 23 ]]; then
|
||||
echo "Locale support for Fedora 24 is incomplete"
|
||||
echo " see: https://bugs.launchpad.net/diskimage-builder/+bug/1571488"
|
||||
die "Cannot cleanup locales on > Fedora 23"
|
||||
fi
|
||||
|
||||
# _install_langs is a rpm macro that limits the translation
|
||||
# files, etc installed by packages. For Fedora 23 [1], the
|
||||
# glibc-common package will obey this to only install the
|
||||
# listed locales, keeping things much smaller (we still have
|
||||
# to clean up locales manually on centos7). We install just
|
||||
# en_US because people often ssh in with that locale, but
|
||||
# leave out everything else. Note that yum has an option to
|
||||
# set this from the command-line [2], but the yum in trusty we
|
||||
# are using is too old to have it. So we set it directly in
|
||||
# the macros file
|
||||
#
|
||||
# [1] http://pkgs.fedoraproject.org/cgit/rpms/glibc.git/commit/glibc.spec?h=f23&id=91764bd9ec690d4b8a886c0a3a104aac12d340d2
|
||||
# [2] http://yum.baseurl.org/gitweb?p=yum.git;a=commit;h=26128173b362474456e8f0642073ecb0322ed031
|
||||
echo "%_install_langs C:en_US:en_US.UTF-8" >> $HOME/.rpmmacros
|
||||
|
||||
sudo -E yum -y \
|
||||
--setopt=cachedir=$YUM_CACHE/$ARCH/$DIB_RELEASE \
|
||||
--setopt=reposdir=$TARGET_ROOT/etc/yum.repos.d \
|
||||
@ -137,7 +160,8 @@ function _install_pkg_manager {
|
||||
|
||||
# We modified the base system - make sure we clean up always!
|
||||
rm $HOME/.rpmmacros.dib.lock
|
||||
sed -i '$ d' $HOME/.rpmmacros
|
||||
# sed makes it easy to remove last line, but not last n lines...
|
||||
sed -i '$ d' $HOME/.rpmmacros; sed -i '$ d' $HOME/.rpmmacros;
|
||||
if [ $rc != 0 ]; then
|
||||
die "Initial yum install to chroot failed! Can not continue."
|
||||
fi
|
||||
@ -193,6 +217,10 @@ else
|
||||
sudo -E chroot $TARGET_ROOT rpm --rebuilddb
|
||||
sudo -E chroot $TARGET_ROOT ${YUM} clean all
|
||||
|
||||
# populate the lang reduction macro in the chroot
|
||||
echo "%_install_langs C:en_US:en_US.UTF-8" | \
|
||||
sudo tee -a $TARGET_ROOT/etc/rpm/macros.langs > /dev/null
|
||||
|
||||
# bootstrap the environment within the chroot; bring in new
|
||||
# metadata with an update and install some base packages we need.
|
||||
sudo -E chroot $TARGET_ROOT ${YUM} -y update
|
||||
|
Loading…
Reference in New Issue
Block a user