Skip to content

Commit

Permalink
toolchain: support gconv modules from glibc >= 2.34
Browse files Browse the repository at this point in the history
Startig with glibc 2.34, the gconv modules description has been split in
two:
  - a common definition in the old location, /usr/lib/gconv/gconv-modules
  - specific definitions in a subdirectory, /usr/lib/gconv/gconv-modules.d/

This is done so as to simplify the handling of glibc gconv modules, and
eventually to segregate those outside of glibc, and so that third-parties
may also provide their own gconv converters and their definitions.

And starting with that same glibc version, most of the gconv modules
definitions are moved to an extra configuration file in that
sub-directory.

It is thus no longer possible to use special code pages, like cp850,
which are very useful to access FAT-formatted devices.

Add support for this new gconv layout, while keeping support for older
glibc versions. Note that the modules themselves are not moved or
renamed, just the definition files have changed.

Instead of passing the one old gonv modules definitions file on stdin,
we pass the base directory to that file, and move into the script the
responsibility to find all the gconv definition files.

Signed-off-by: Yann E. MORIN <[email protected]>
Cc: Thomas Petazzoni <[email protected]>
Cc: Romain Naour <[email protected]>
Cc: Thomas De Schampheleire <[email protected]>
Cc: Giulio Benetti <[email protected]>
Signed-off-by: Yann E. MORIN <[email protected]>
  • Loading branch information
ymorin-orange authored and yann-morin-1998 committed Oct 21, 2022
1 parent 822cc1e commit 9d948e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
22 changes: 16 additions & 6 deletions support/scripts/expunge-gconv-modules
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/env bash

# This script is used to generate a gconv-modules file that takes into
# account only the gconv modules installed by Buildroot. It receives
# on its standard input the original complete gconv-modules file from
# the toolchain, and as arguments the list of gconv modules that were
# actually installed, and writes on its standard output the new
# gconv-modules file.
# account only the gconv modules installed by Buildroot, and generates
# a stripped-down gconv-moduels file on its stdout.
# It takes two arguments:
# $1: the directory where to look for gconv modules definitions
# $2: a space-separated list of gconv modules that were actually
# installed

# Starting with glibc-2.34, modules definitions are located in multiple
# files:
# ${1}/gconv-modules
# ${1}/gconv-modules.d/*.conf

# The format of gconv-modules is precisely documented in the
# file itself. It consists of two different directives:
Expand All @@ -19,7 +25,11 @@
# we handle each with slightly different code, since the second never has
# associated aliases.

awk -v files="${2}" '
for f in ${1}/gconv-modules ${1}/gconv-modules.d/*.conf; do
[ -e "${f}" ] || continue
cat "${f}"
done \
|awk -v files="${2}" '
$1 == "alias" {
aliases[$3] = aliases[$3] " " $2;
}
Expand Down
9 changes: 7 additions & 2 deletions toolchain/toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ define TOOLCHAIN_GLIBC_COPY_GCONV_LIBS
$(INSTALL) -m 0644 $(STAGING_DIR)/usr/lib/$${d}/gconv/*.so \
$(TARGET_DIR)/usr/lib/gconv \
|| exit 1; \
if [ -d $(STAGING_DIR)/usr/lib/$${d}/gconv/gconv-modules.d ]; then \
cp -a $(STAGING_DIR)/usr/lib/$${d}/gconv/gconv-modules.d \
$(TARGET_DIR)/usr/lib/gconv/ || exit 1; \
fi; \
else \
for l in $(TOOLCHAIN_GLIBC_GCONV_LIBS); do \
$(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/$${d}/gconv/$${l}.so \
Expand All @@ -41,8 +45,9 @@ define TOOLCHAIN_GLIBC_COPY_GCONV_LIBS
|| exit 1; \
done; \
done; \
./support/scripts/expunge-gconv-modules "$(TOOLCHAIN_GLIBC_GCONV_LIBS)" \
<$(STAGING_DIR)/usr/lib/$${d}/gconv/gconv-modules \
./support/scripts/expunge-gconv-modules \
$(STAGING_DIR)/usr/lib/$${d}/gconv \
"$(TOOLCHAIN_GLIBC_GCONV_LIBS)" \
>$(TARGET_DIR)/usr/lib/gconv/gconv-modules; \
fi
endef
Expand Down

0 comments on commit 9d948e1

Please sign in to comment.