1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/usr/bin/perl
use MDK::Common;
use Getopt::Long;
use lib qw(/usr/lib/libDrakX);
use run_program;
my $prefix;
my $check_locale;
GetOptions(
"prefix=s" => \$prefix,
"check-locale" => \$check_locale,
);
my $dictd = $ARGV[0] or die "syntax: $0 [--check-locale] [--prefix <prefix>] <dictionary dir>";
my $dictf = "dictionary.lst";
my $dicts = "dictionary.src";
my $dictu = "dictionary.unused";
my @dictl;
my @unused;
my @available_langs = map {
/^locales-(\S+)/ ? $1 : ();
} chomp_(run_program::rooted_get_stdout($prefix, 'rpm', '-qa', '--provides', 'locales-*'));
sub add_dict {
my ($type, $name, $file, $add) = @_;
my ($lang, $country) = $name =~ /^([^_]+)_([^_]+)/;
my ($root_name) = $file =~ /^(.*)\.(.*?)$/;
if (!$check_locale || member($lang, @available_langs)) {
push @dictl, [ $type, $lang, $country, $root_name ] if $add;
} else {
push @unused, "$dictd/$file";
}
}
rename("$prefix$dictd/$dictf", "$prefix$dictd/$dicts") if ! -e "$prefix$dictd/$dicts";
foreach (all("$prefix/$dictd")) {
if (/^hyph_(.+)\.(.*?)$/) {
add_dict('HYPH', $1, $_, $2 eq 'dic');
} elsif (/^th_(.+)\.(.*?)$/) {
add_dict('THES', $1, $_, $2 eq 'idx');
} elsif (/^(.+_.+)\.(.*?)$/) {
add_dict('DICT', $1, $_, $2 eq 'dic');
}
}
output_p("$prefix$dictd/$dictf",
join('', grep { /^#/ } cat_("$prefix$dictd/$dicts")),
"\n",
map { join(' ', @$_) . "\n" } @dictl,
);
output_p("$prefix$dictd/$dictu", map { "$_\n" } @unused);
|