summaryrefslogtreecommitdiffstats
path: root/files/compute-i18n-list.pl
diff options
context:
space:
mode:
Diffstat (limited to 'files/compute-i18n-list.pl')
-rwxr-xr-xfiles/compute-i18n-list.pl88
1 files changed, 88 insertions, 0 deletions
diff --git a/files/compute-i18n-list.pl b/files/compute-i18n-list.pl
new file mode 100755
index 0000000..914585b
--- /dev/null
+++ b/files/compute-i18n-list.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+
+use MDK::Common;
+use Getopt::Long;
+use lib qw(/usr/lib/libDrakX);
+use run_program;
+
+# alleged i18n packages for french (useful to spot missing requires on locales-fr)
+# rpm -qa \*-fr\* --qf '%{name}\n' | perl -n -e '/^(.*)-fr(_.+)?$/ and print "$1\n"' | sort -u
+# my @packages = (
+# aspell
+# kde-i18n
+# locales
+# mozilla-firefox
+# myspell
+# myspell-hyph
+# openoffice.org-l10n
+# );
+
+my ($prefix, $ooo_version);
+GetOptions(
+ "prefix=s" => \$prefix,
+ "ooo=s" => \$ooo_version,
+);
+
+my @misowned_dirs = qw(
+/usr/lib/ooo-${ooo_version}
+/usr/lib/ooo-${ooo_version}/help
+/usr/share/apps
+/usr/share/apps/khangman
+/usr/share/apps/khangman/data
+/usr/share/apps/ktuberling
+/usr/share/apps/ktuberling/sounds
+/usr/share/doc/HTML
+/usr/share/locale
+);
+
+my @dirs = qw(
+/usr/share/man
+/usr/share/doc/HTML
+);
+
+my @files = qw(
+/usr/lib/ooo-${ooo_version}/share/dict/$L.*
+/usr/lib/ooo-${ooo_version}/share/dict/$L_comb.*
+/usr/lib/ooo-${ooo_version}/share/dict/hyph_$L.*
+/usr/lib/ooo-${ooo_version}/share/dict/th_$L.*
+/usr/lib/ooo-${ooo_version}/share/dict/th_$L_v2.*
+);
+
+my %per_locale_files = (
+ zh => [
+ #- disables anti-aliasing by default
+ '/etc/fonts/conf.d/99-ttf-arphic-uming-bitmaps.conf'
+ ],
+);
+
+my @locale_packages = run_program::rooted_get_stdout($prefix, 'rpm', '-qa', 'locales-*', '--qf', '%{name}\n');
+my @locales = sort(map { s/^locales-//; chomp; $_ } @locale_packages);
+
+sub expand_files {
+ my ($p, $o_lang) = @_;
+ $p =~ s/\$L/$o_lang/ if $o_lang;
+ map { s/^$prefix//; $_ } grep { -e $_ } glob($prefix . $p);
+}
+
+foreach my $l (@locales) {
+ my @list;
+ my $locale_pkg = "locales-$l";
+ #my $l_pattern = qr/^$l([_.@].+)?$/;
+ #my @l_packages = map { ("$_-$l", "$_-${l}_*") } @packages;
+ my @l_packages = chomp_(run_program::rooted_get_stdout($prefix, 'rpm', '-q', '--qf', '%{name}\n', '--whatrequires', $locale_pkg));
+ unshift @l_packages, $locale_pkg;
+ my @list = chomp_(run_program::rooted_get_stdout($prefix, 'rpm', '-ql', @l_packages));
+ my @all_locales = map { m!^/usr/share/locale/([^/]+)$! } chomp_(run_program::rooted_get_stdout($prefix, 'rpm', '-ql', $locale_pkg));
+ # skip misowned directories such as /usr/share/locale
+ @list = grep { ! -d $prefix . $_ || member(basename($_), @all_locales) } @list;
+ #@list = difference2(\@list, \@misowned_dirs);
+ foreach my $l2 (@all_locales) {
+ foreach my $d (@dirs) {
+ my $l_d = $d . '/' . $l2;
+ push @list, $l_d if -e $prefix . $l_d;
+ }
+ push @list, expand_files($_, $l2) foreach @files;
+ }
+ push @list, expand_files($_) foreach @{$per_locale_files{$l} || []};
+ output_p($prefix . "/root/drakx/i18n-$l.lst", map { "$_\n" } sort(@list));
+}