~ubuntu-mozilla-daily/firefox/firefox-aurora.head.daily

« back to all changes in this revision

Viewing changes to debian/build/dump-langpack-control-entries

  • Committer: Chris Coulson
  • Date: 2011-08-17 01:25:15 UTC
  • mfrom: (867.1.25 firefox-aurora)
  • Revision ID: chrisccoulson@ubuntu.com-20110817012515-o848fux9qnnr0787
* Merge with firefox-aurora.head #892

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
my $ip_dir;
 
7
my $template_dir;
 
8
 
 
9
my $lp_avail_desc;
 
10
my $lp_unavail_desc;
 
11
 
 
12
my %all;
 
13
my %shipped;
 
14
 
 
15
while (@ARGV) {
 
16
    my $arg = shift(@ARGV);
 
17
    if ($arg eq '-i') {
 
18
        $ip_dir = shift(@ARGV);
 
19
    } elsif ($arg eq '-t') {
 
20
        $template_dir = shift(@ARGV);
 
21
    }
 
22
}
 
23
 
 
24
if (not defined($ip_dir) || not defined($template_dir)) { die "Need to specify a location for input and template data\n"; }
 
25
 
 
26
{
 
27
    my $file;
 
28
    local $/=undef;
 
29
    open($file, "$template_dir/control.langpacks") or die "Couldn't find control.langpacks";
 
30
    $lp_avail_desc = <$file>;
 
31
 
 
32
    open($file, "$template_dir/control.langpacks.unavail") or die "Couldn't find control.langpacks.unavail";
 
33
    $lp_unavail_desc = <$file>;
 
34
}
 
35
 
 
36
my $all_file;
 
37
my $shipped_file;
 
38
 
 
39
open($all_file, "$ip_dir/locales.all") or die "Failed to open $ip_dir/locales.all";
 
40
open($shipped_file, "$ip_dir/locales.shipped") or die "Failed to open $ip_dir/locales.shipped";
 
41
while (<$all_file>) {
 
42
    if ((not $_ =~ /^$/) && (not $_ =~ /^#.*/)) {
 
43
        my $line = $_;
 
44
        chomp($line);
 
45
        my $pkgname = $line;
 
46
        my $desc = $line;
 
47
        $pkgname =~ s/([^:]*):*([^:]*)/$1/;
 
48
        $desc =~ s/([^:]*):*([^:]*)/$2/;
 
49
        if ($desc eq "") { die "Malformed locales.all"; }
 
50
        $all{$pkgname} = $desc;
 
51
    }
 
52
}
 
53
 
 
54
while (<$shipped_file>) {
 
55
    if ((not $_ =~ /^$/) && (not $_ =~ /^#.*/)) {
 
56
        my $line = $_;
 
57
        chomp($line);
 
58
        my $locale = $line;
 
59
        my $pkgname = $line;
 
60
        $locale =~ s/([^:]*):*([^:]*)/$1/;
 
61
        $pkgname =~ s/([^:]*):*([^:]*)/$2/;
 
62
        if ($pkgname eq "") { die "Malformed locales.shipped"; }
 
63
        $shipped{$pkgname} = 1;
 
64
    }
 
65
}
 
66
close($all_file);
 
67
close($shipped_file);
 
68
 
 
69
my @pkglist = keys(%all);
 
70
@pkglist = sort(@pkglist);
 
71
foreach my $pkg (@pkglist) {
 
72
    my $desc = $all{$pkg};
 
73
    my $entry;
 
74
    $entry = exists $shipped{$pkg} ? $lp_avail_desc : $lp_unavail_desc;
 
75
    $entry =~ s/\@LANGCODE\@/$pkg/g;
 
76
    $entry =~ s/\@LANG\@/$desc/g;
 
77
    print $entry;
 
78
}