diff options
author | Olivier Blin <blino@mageia.org> | 2011-03-15 13:58:31 +0000 |
---|---|---|
committer | Olivier Blin <blino@mageia.org> | 2011-03-15 13:58:31 +0000 |
commit | 4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5 (patch) | |
tree | f6d8d18d835eb7a25088d351663a29c5058532d5 /files/compute-ooo-dicts.pl | |
download | draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar.gz draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar.bz2 draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.tar.xz draklive-config-4c4328833cb84e7e5e4eccbb385c9d4851bfd7b5.zip |
import initial live config
Diffstat (limited to 'files/compute-ooo-dicts.pl')
-rwxr-xr-x | files/compute-ooo-dicts.pl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/files/compute-ooo-dicts.pl b/files/compute-ooo-dicts.pl new file mode 100755 index 0000000..d9968c5 --- /dev/null +++ b/files/compute-ooo-dicts.pl @@ -0,0 +1,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); |