]> git.donarmstrong.com Git - debian-ctte.git/blob - scripts/publish-decision
Add my vote for august meeting
[debian-ctte.git] / scripts / publish-decision
1 #!/usr/bin/perl -w
2
3 use warnings;
4 use strict;
5
6 use IO::File;
7
8 use POSIX qw(strftime);
9
10 # USAGE:
11 #
12 # 0. See "configuration" below
13 #
14 # 1. Put the decision in
15 #      tech-ctte.git/<BUGNUMBER>_blah_blah/decision
16 #    in the special template format.  Commit it.
17 #
18 # 2. Run
19 #      cd tech-ctte.git
20 #      scripts/publish-decision BUGNUMBER_blah_blah/decision
21 #
22 # 3. This will leave:
23 #      - BUGNUMBER_blah_blah/decision.email    ready for sendmail -t
24 #      - BUGNUMBER_blah_blah/decision.wml      ready to paste into webmml
25 #    Inspect them and if appropriate send and commit.
26
27 die "bad usage" unless @ARGV==1 && $ARGV[0] =~ m#^((\d+)_[\w-]+)/.*$#;
28 my ($dir, $bugn, $decision) = ($1,$2,$&);
29
30 my %decision = process_decision($decision,$bugn);
31
32 decision_email($decision,\%decision);
33 decision_webml($decision,\%decision);
34
35 sub process_decision{
36     my ($decision,$bugn) = @_;
37     my $dfh = IO::File->new($decision,'r') or
38         die "Unable to open $decision for reading: $!";
39     my %d_bits = (bug => $bugn,
40                   email_epilogue => '',
41                   email_intro => '',
42                   decision => '',
43                   web_summary => '',
44                  );
45     my $current_bit;
46     while (<$dfh>) {
47         if (/^={4,}\s+(\S.+?)\s*\n?$/) {
48             $current_bit = $1;
49             $current_bit =~ s/[\s_]+/_/g;
50             $current_bit = lc($current_bit);
51             next;
52         } elsif (/^={4,}/) {
53             # this will unset the current bit
54             undef $current_bit;
55             next;
56         }
57         # silently skip wrong sections
58         if (not defined $current_bit) {
59             next;
60         }
61         $d_bits{$current_bit} .= $_;
62         next;
63     }
64     close($dfh);
65     # clean up %d_bits;
66     for my $key (keys %d_bits) {
67         # ditch leading and trailing blank lines
68         $d_bits{$key} =~ s/(?:^\n*|\n*$)//g;
69     }
70     $d_bits{bug} = $bugn;
71     return %d_bits;
72 }
73
74 sub decision_email {
75     my ($dfn,$d_bits) = @_;
76     my $efh = IO::File->new($dfn.".email",'w') or
77         die "Unable to open ${dfn}.email for writing: $!";
78     print {$efh} <<EOF;
79 To: debian-devel-announce\@lists.debian.org
80 From: $ENV{DEBFULLNAME} <$ENV{DEBEMAIL}>
81 Subject: [CTTE #$d_bits->{bug}] $d_bits->{title}
82 Mail-Followup-To: debian-ctte\@lists.debian.org
83
84 $d_bits->{email_intro}
85
86 ==== RESOLUTION ====
87
88 $d_bits->{decision}
89
90 ==== END OF RESOLUTION ====
91
92 $d_bits->{email_epilogue}
93
94 Please see http://bugs.debian.org/$d_bits->{bug} for discussion of
95 this bug.
96
97 EOF
98     close($efh);
99 }
100
101 sub decision_webml {
102     my ($dfn,$d_bits) = @_;
103     my $wfh = IO::File->new($dfn.".wml",'w') or
104         die "Unable to open ${dfn}.wml for writing: $!";
105     my $date = strftime('%Y-%m-%d',gmtime());
106     print {$wfh} <<EOF;
107 <li>$date
108   <a href="http://bugs.debian.org/$d_bits->{bug}">Bug #$d_bits->{bug}:</a>$d_bits->{web_summary}</li>
109 EOF
110
111 }