9d948e1b34
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 <yann.morin@orange.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Cc: Romain Naour <romain.naour@gmail.com> Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> Cc: Giulio Benetti <giulio.benetti@benettiengineering.com> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
70 lines
2.5 KiB
Bash
Executable File
70 lines
2.5 KiB
Bash
Executable File
#!/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, 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:
|
|
# module FROMSET TOSET FILENAME COST
|
|
# alias ALIAS REALNAME
|
|
# and that's what this script parses and generates.
|
|
#
|
|
# There are two kinds of 'module' directives:
|
|
# - the first defines conversion of a charset to/from INTERNAL representation
|
|
# - the second defines conversion of a charset to/from another charset
|
|
# we handle each with slightly different code, since the second never has
|
|
# associated aliases.
|
|
|
|
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;
|
|
}
|
|
$1 == "module" && $2 != "INTERNAL" && $3 == "INTERNAL" {
|
|
file2internals[$4] = file2internals[$4] " " $2;
|
|
mod2cost[$2] = $5;
|
|
}
|
|
$1 == "module" && $2 != "INTERNAL" && $3 != "INTERNAL" {
|
|
file2cset[$4] = file2cset[$4] " " $2 ":" $3;
|
|
mod2cost[$2] = $5;
|
|
}
|
|
|
|
END {
|
|
nb_files = split(files, all_files);
|
|
for(f = 1; f <= nb_files; f++) {
|
|
file = all_files[f];
|
|
printf("# Modules and aliases for: %s\n", file);
|
|
nb_mods = split(file2internals[file], mods);
|
|
for(i = 1; i <= nb_mods; i++) {
|
|
nb_aliases = split(aliases[mods[i]], mod_aliases);
|
|
for(j = 1; j <= nb_aliases; j++) {
|
|
printf("alias\t%s\t%s\n", mod_aliases[j], mods[i]);
|
|
}
|
|
printf("module\t%s\t%s\t%s\t%d\n", mods[i], "INTERNAL", file, mod2cost[mods[i]]);
|
|
printf("module\t%s\t%s\t%s\t%d\n", "INTERNAL", mods[i], file, mod2cost[mods[i]]);
|
|
printf("\n" );
|
|
}
|
|
printf("%s", nb_mods != 0 ? "\n" : "");
|
|
nb_csets = split(file2cset[file], csets);
|
|
for(i = 1; i <= nb_csets; i++) {
|
|
split(csets[i], cs, ":");
|
|
printf("module\t%s\t%s\t%s\t%d\n", cs[1], cs[2], file, mod2cost[cs[1]]);
|
|
}
|
|
printf("%s", nb_csets != 0 ? "\n\n" : "");
|
|
}
|
|
}
|
|
'
|