locale: symlink identical langpack LC_CTYPEs to the C.utf8 version

Almost half the LC_CTYPE files in langpacks are identical to the C.utf8
variant which is installed by default.  This commit converts these to
symbolic links instead, saving ~350K of installed size per langpack.

Rawhide commit: a0bdca4f3f

Also:

 * locale: make install-locale-files instead of install-locales
   - Drop glibc-fedora-localedef.patch
   - Rawhide commit: cf979ff812

 * localedef: Handle symbolic links when generating locale-archive
   - Add glibc-localedef-handle-symlinks.patch
   - Upstream commit: ea89d5bbd9e5e514b606045d909e6ab87d851c88
This commit is contained in:
Arjun Shankar 2022-03-02 14:04:03 +01:00
parent 5c209d3a56
commit 024178b5e0
3 changed files with 56 additions and 27 deletions

View File

@ -1,21 +0,0 @@
Short description: Fedora-specific glibc install locale changes.
Author(s): Fedora glibc team <glibc@lists.fedoraproject.org>
Origin: PATCH
Upstream status: not-needed
The Fedora glibc build and install does not need the normal install
behaviour which updates the locale archive. The Fedora install phase
in the spec file of the rpm will handle this manually.
diff --git a/localedata/Makefile b/localedata/Makefile
index 0eea396ad86da956..54caabda33728207 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -413,6 +413,7 @@ define build-one-locale
echo -n '...'; \
input=`echo $$locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; \
$(LOCALEDEF) $$flags --alias-file=../intl/locale.alias \
+ --no-archive \
-i locales/$$input -f charmaps/$$charset \
$(addprefix --prefix=,$(install_root)) $$locale \
&& echo ' done';

View File

@ -0,0 +1,27 @@
commit ea89d5bbd9e5e514b606045d909e6ab87d851c88
Author: Arjun Shankar <arjun@redhat.com>
Date: Thu Feb 24 21:43:09 2022 +0100
localedef: Handle symbolic links when generating locale-archive
Whenever locale data for any locale included symbolic links, localedef
would throw the error "incomplete set of locale files" and exclude it
from the generated locale archive. This commit fixes that.
Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
index 45408c26c169ff05..eeb2fa6ffecd1dba 100644
--- a/locale/programs/locarchive.c
+++ b/locale/programs/locarchive.c
@@ -1397,7 +1397,7 @@ add_locales_to_archive (size_t nlist, char *list[], bool replace)
{
char fullname[fnamelen + 2 * strlen (d->d_name) + 7];
- if (d_type == DT_UNKNOWN)
+ if (d_type == DT_UNKNOWN || d_type == DT_LNK)
{
strcpy (stpcpy (stpcpy (fullname, fname), "/"),
d->d_name);

View File

@ -152,7 +152,7 @@ end \
Summary: The GNU libc libraries
Name: glibc
Version: %{glibcversion}
Release: 3%{?dist}
Release: 4%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries.
@ -217,7 +217,6 @@ rpm.define("__debug_install_post bash " .. wrapper
# - For new patches follow template.patch format.
##############################################################################
Patch4: glibc-fedora-linux-tcsetattr.patch
Patch6: glibc-fedora-localedef.patch
Patch8: glibc-fedora-manual-dircategory.patch
Patch9: glibc-rh827510.patch
Patch13: glibc-fedora-localedata-rh61908.patch
@ -225,6 +224,7 @@ Patch15: glibc-rh1070416.patch
Patch17: glibc-cs-path.patch
Patch23: glibc-python3.patch
Patch30: glibc-deprecated-selinux-makedb.patch
Patch31: glibc-localedef-handle-symlinks.patch
# Temporary until gcc is patched to have -mlong-double-64 override
# -mabi=ibmlongdouble instead of conflict with it.
@ -1218,11 +1218,11 @@ done
pushd build-%{target}
%make_build install_root=%{glibc_sysroot} install
%make_build install_root=%{glibc_sysroot} \
install-locales -C ../localedata objdir=`pwd`
install-locale-files -C ../localedata objdir=`pwd`
popd
# Locale creation may produce different groups of hardlinks in an
# unpredictable manner. Re-grouping makes those differences go away.
hardlink %{glibc_sysroot}/usr/lib/locale
# Locale creation via install-locale-files does not group identical files
# via hardlinks, so we must group them ourselves.
hardlink -c %{glibc_sysroot}/usr/lib/locale
# install_different:
# Install all core libraries into DESTDIR/SUBDIR. Either the file is
@ -1344,6 +1344,22 @@ $olddir/build-%{target}/elf/ld.so \
# glibc-all-langpacks versions)
ln locale-archive locale-archive.real
# Almost half the LC_CTYPE files in langpacks are identical to the C.utf8
# variant which is installed by default. When we keep them as hardlinks,
# each langpack ends up retaining a copy. If we convert these to symbolic
# links instead, we save ~350K each when they get installed that way.
#
# LC_MEASUREMENT and LC_PAPER also have several duplicates but we don't
# bother with these because they are only ~30 bytes each.
#
# Note: This must be done AFTER locale-archive generation since the locale
# archive is incorrectly generated when symbolic links are present.
pushd %{glibc_sysroot}/usr/lib/locale
for f in $(find eo *_* -samefile C.utf8/LC_CTYPE); do
rm $f && ln -s '../C.utf8/LC_CTYPE' $f
done
popd
# Create the file lists for the language specific sub-packages:
for i in eo *_*
do
@ -2161,6 +2177,13 @@ update_gconv_modules_cache ()
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
%changelog
* Wed Mar 02 2022 Arjun Shankar <arjun@redhat.com> - 2.35-4
- Reduce installed size of some langpacks by de-duplicating LC_CTYPE.
- Add glibc-localedef-handle-symlinks.patch so localedef can handle symbolic
links when generating locale-archive.
- Drop glibc-fedora-localedef.patch and adjust locale installation
accordingly so that installed content remains unchanged.
* Mon Feb 28 2022 Florian Weimer <fweimer@redhat.com> - 2.35-3
- Auto-sync with upstream branch release/2.35/master,
commit 732dd3a63d39c7ca77e817b462285c14551c8b49: