python-cryptography: bump to version 1.7.2
[buildroot-gz.git] / support / scripts / expunge-gconv-modules
blob03012c1ce310e4b1ce3ff4cd880adcc3a371b439
1 #!/usr/bin/env bash
3 # This script is used to generate a gconv-modules file that takes into
4 # account only the gconv modules installed by Buildroot. It receives
5 # on its standard input the original complete gconv-modules file from
6 # the toolchain, and as arguments the list of gconv modules that were
7 # actually installed, and writes on its standard output the new
8 # gconv-modules file.
10 # The format of gconv-modules is precisely documented in the
11 # file itself. It consists of two different directives:
12 # module FROMSET TOSET FILENAME COST
13 # alias ALIAS REALNAME
14 # and that's what this script parses and generates.
16 # There are two kinds of 'module' directives:
17 # - the first defines conversion of a charset to/from INTERNAL representation
18 # - the second defines conversion of a charset to/from another charset
19 # we handle each with slightly different code, since the second never has
20 # associated aliases.
22 gawk -v files="${1}" '
23 $1 == "alias" {
24 aliases[$3] = aliases[$3] " " $2;
26 $1 == "module" && $2 != "INTERNAL" && $3 == "INTERNAL" {
27 file2internals[$4] = file2internals[$4] " " $2;
28 mod2cost[$2] = $5;
30 $1 == "module" && $2 != "INTERNAL" && $3 != "INTERNAL" {
31 file2cset[$4] = file2cset[$4] " " $2 ":" $3;
32 mod2cost[$2] = $5;
35 END {
36 nb_files = split(files, all_files);
37 for(f = 1; f <= nb_files; f++) {
38 file = all_files[f];
39 printf("# Modules and aliases for: %s\n", file);
40 nb_mods = split(file2internals[file], mods);
41 for(i = 1; i <= nb_mods; i++) {
42 nb_aliases = split(aliases[mods[i]], mod_aliases);
43 for(j = 1; j <= nb_aliases; j++) {
44 printf("alias\t%s\t%s\n", mod_aliases[j], mods[i]);
46 printf("module\t%s\t%s\t%s\t%d\n", mods[i], "INTERNAL", file, mod2cost[mods[i]]);
47 printf("module\t%s\t%s\t%s\t%d\n", "INTERNAL", mods[i], file, mod2cost[mods[i]]);
48 printf("\n" );
50 printf("%s", nb_mods != 0 ? "\n" : "");
51 nb_csets = split(file2cset[file], csets);
52 for(i = 1; i <= nb_csets; i++) {
53 split(csets[i], cs, ":");
54 printf("module\t%s\t%s\t%s\t%d\n", cs[1], cs[2], file, mod2cost[cs[1]]);
56 printf("%s", nb_csets != 0 ? "\n\n" : "");