~ubuntu-branches/ubuntu/raring/lurker/raring

« back to all changes in this revision

Viewing changes to debian/mailman2lurker.pl

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Meurer
  • Date: 2006-12-20 05:05:31 UTC
  • mfrom: (3.1.6 feisty)
  • Revision ID: james.westby@ubuntu.com-20061220050531-79inzy7o6uu95qx7
Tags: 2.1-7
* updated vi debconf translations, thanks to Clytie Siddall
  <clytie@riverland.net.au>
* fixed typo in one template (that you would like, not that
  would you like), thanks as well to Clytie Siddall
  - unfuzzied all translations

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
 
use sort 'stable';
7
 
 
8
 
my $lurkerconf_fn = "/etc/lurker/lurker.conf";
9
 
#my $lurkerconfmm_fn = "/etc/lurker/lurker.conf.mm";
10
 
my $lurkerconfmm_fn = "$lurkerconf_fn.mm";
11
 
#my $list_lists_fn = "list_lists";
12
 
my $list_lists_fn = "/usr/lib/mailman/bin/list_lists |";
13
 
 
14
 
open LURKERCONF, $lurkerconf_fn or die "Could not open $lurkerconf_fn: $!";
15
 
 
16
 
my (%lists, %grouphead);
17
 
$grouphead{undef} = "undef";
18
 
 
19
 
my $listhost = "listhost";
20
 
my $listurl = "listurl";
21
 
 
22
 
my @list_props = qw/title address link description/;
23
 
 
24
 
my ($group, $list);
25
 
my (@lconfout);
26
 
 
27
 
# Parse lurker.conf
28
 
while (<LURKERCONF>)
29
 
{
30
 
    chomp;
31
 
    my ($prop,$val);
32
 
 
33
 
    if (not (($prop,$val) = /^\s*(\w+)\s*=\s*(.*?)\s*$/))
34
 
    {
35
 
        push @lconfout, $_;
36
 
    }
37
 
    elsif ($prop eq 'group')
38
 
    {
39
 
        $group = $val;
40
 
    }
41
 
    elsif ($prop eq 'heading')
42
 
    {
43
 
        $grouphead{$group} = $val;
44
 
    }
45
 
    elsif ($prop eq 'list')
46
 
    {
47
 
        $list = $val;
48
 
        $lists{$list} = {};
49
 
        $lists{$list}{group} = $group;
50
 
    }
51
 
    elsif (defined $list and grep($prop eq $_, @list_props))
52
 
    {
53
 
        $lists{$list}{$prop} = $val;
54
 
    }
55
 
    else
56
 
    {
57
 
        push @lconfout, $_;
58
 
    }
59
 
}
60
 
 
61
 
close LURKERCONF;
62
 
 
63
 
# parse lurkermm.conf
64
 
 
65
 
open LURKERMMCONF, $lurkerconfmm_fn or die "Could not open $lurkerconfmm_fn: $!";
66
 
 
67
 
while (<LURKERMMCONF>)
68
 
{
69
 
    if (/\#\s*listhost\s*=\s*(.*?)\s*$/)
70
 
    {
71
 
        $listhost = $1;
72
 
    }
73
 
    if (/\#\s*listurl\s*=\s*(.*?)\s*$/)
74
 
    {
75
 
        $listurl = $1;
76
 
    }
77
 
}
78
 
 
79
 
close LURKERMMCONF;
80
 
 
81
 
# parse list_lists
82
 
 
83
 
open LIST_LISTS, $list_lists_fn or die "Could not open $list_lists_fn: $!";
84
 
 
85
 
while (<LIST_LISTS>)
86
 
{
87
 
    chomp;
88
 
    my ($name, $desc);
89
 
 
90
 
    next unless (($name, $desc) = /(\w+) - (.*)$/);
91
 
 
92
 
    if ($desc eq "[no description available]")
93
 
    {
94
 
        $desc = "";
95
 
    }
96
 
 
97
 
    if (defined $lists{$name})
98
 
    {
99
 
        if ($desc)
100
 
        {
101
 
            $lists{$name}{description} = $desc;
102
 
        }
103
 
    }
104
 
    else
105
 
    {
106
 
        $lists{$name} = { title => $name,
107
 
                          address => $name . '@' . $listhost,
108
 
                          link => $listurl . '/' . $name, # todo
109
 
                          description => $desc,
110
 
                          group => "undef"
111
 
                       };
112
 
    }
113
 
}
114
 
 
115
 
close LIST_LISTS;
116
 
 
117
 
 
118
 
print join "\n", @lconfout;
119
 
print "\n";
120
 
 
121
 
# dump groups
122
 
$group = "";
123
 
for $_ (sort { $lists{$a}{group} cmp $lists{$b}{group} } keys %lists)
124
 
{
125
 
    unless ($lists{$_}{group} eq $group)
126
 
    {
127
 
        $group = $lists{$_}{group};
128
 
        print "\n";
129
 
        print "group = $group\n";
130
 
        print "   heading = ", ($grouphead{$group} ? $grouphead{$group} : "undef"), "\n";
131
 
        print "\n";
132
 
    }
133
 
 
134
 
    print "   list = $list\n";
135
 
    foreach my $t (@list_props)
136
 
    {
137
 
        printf "      %-14s = %s\n", $t, ${lists{$_}{$t}};
138
 
    }
139
 
}