The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / support / scripts / expunge-gconv-modules
1 #!/usr/bin/env bash
2
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.
9
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.
15 #
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.
21
22 gawk -v files="${1}" '
23 $1 == "alias" {
24     aliases[$3] = aliases[$3] " " $2;
25 }
26 $1 == "module" && $2 != "INTERNAL" && $3 == "INTERNAL" {
27     file2internals[$4] = file2internals[$4] " " $2;
28     mod2cost[$2] = $5;
29 }
30 $1 == "module" && $2 != "INTERNAL" && $3 != "INTERNAL" {
31     file2cset[$4] = file2cset[$4] " " $2 ":" $3;
32     mod2cost[$2] = $5;
33 }
34
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]);
45             }
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" );
49         }
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]]);
55         }
56         printf("%s", nb_csets != 0 ? "\n\n" : "");
57     }
58 }
59 '