]> git.donarmstrong.com Git - debian-ctte.git/commitdiff
update decision script to sort of work
authorDon Armstrong <don@donarmstrong.com>
Fri, 5 Oct 2012 20:53:54 +0000 (13:53 -0700)
committerDon Armstrong <don@donarmstrong.com>
Fri, 5 Oct 2012 20:53:54 +0000 (13:53 -0700)
scripts/publish-decision

index 82e39c82de2e1b57fc38c17ed2b346c6808e4b01..0a66463e6835d132ae03edf15b62dd3354f5dd2e 100755 (executable)
@@ -1,8 +1,12 @@
-wip wip wip do not use
-
 #!/usr/bin/perl -w
+
+use warnings;
 use strict;
 
+use IO::File;
+
+use POSIX qw(strftime);
+
 # USAGE:
 #
 # 0. See "configuration" below
@@ -17,13 +21,91 @@ use strict;
 #
 # 3. This will leave:
 #      - BUGNUMBER_blah_blah/decision.email    ready for sendmail -t
-#      - ../www-devel/tech-ctte.wml            ready for cvs commit
+#      - BUGNUMBER_blah_blah/decision.wml      ready to paste into webmml
 #    Inspect them and if appropriate send and commit.
 
 die "bad usage" unless @ARGV==1 && $ARGV[0] =~ m#^((\d+)_\w+)/.*$#;
-my ($bugn, $dir, $templ) = ($1,$2,$&);
+my ($dir, $bugn, $decision) = ($1,$2,$&);
+
+my %decision = process_decision($decision,$bugn);
+
+decision_email($decision,\%decision);
+decision_webml($decision,\%decision);
+
+sub process_decision{
+    my ($decision,$bugn) = @_;
+    my $dfh = IO::File->new($decision,'r') or
+       die "Unable to open $decision for reading: $!";
+    my %d_bits = (bug => $bugn,
+                 email_epilogue => '',
+                 email_intro => '',
+                 decision => '',
+                 web_summary => '',
+                );
+    my $current_bit;
+    while (<$dfh>) {
+       if (/^={4,}\s+(\S.+?)\s*\n?$/) {
+           $current_bit = $1;
+           $current_bit =~ s/[\s_]+/_/g;
+           $current_bit = lc($current_bit);
+           next;
+       } elsif (/^={4,}/) {
+           # this will unset the current bit
+           undef $current_bit;
+           next;
+       }
+       # silently skip wrong sections
+       if (not defined $current_bit) {
+           next;
+       }
+       $d_bits{$current_bit} .= $_;
+       next;
+    }
+    close($dfh);
+    # clean up %d_bits;
+    for my $key (keys %d_bits) {
+       # ditch leading and trailing blank lines
+       $d_bits{$key} =~ s/(?:^\n*|\n*$)//g;
+    }
+    $d_bits{bug} = $bugn;
+    return %d_bits;
+}
+
+sub decision_email {
+    my ($dfn,$d_bits) = @_;
+    my $efh = IO::File->new($dfn.".email",'w') or
+       die "Unable to open ${dfn}.email for writing: $!";
+    print {$efh} <<EOF;
+To: debian-devel-announce\@lists.debian.org
+From: $ENV{DEBFULLNAME} <$ENV{DEBEMAIL}>
+Subject: [CTTE #$d_bits->{bug}] $d_bits->{title}
+Mail-Followup-To: debian-ctte\@lists.debian.org
+
+$d_bits->{email_intro}
+
+==== RESOLUTION ====
+
+$d_bits->{decision}
+
+==== END OF RESOLUTION ====
+
+$d_bits->{email_epilogue}
+
+Please see http://bugs.debian.org/$d_bits->{bug} for discussion of
+this bug.
+
+EOF
+    close($efh);
+}
+
+sub decision_webml {
+    my ($dfn,$d_bits) = @_;
+    my $wfh = IO::File->new($dfn.".wml",'w') or
+       die "Unable to open ${dfn}.wml for writing: $!";
+    my $date = strftime('%Y-%m-%d',gmtime());
+    print {$wfh} <<EOF;
+<li>$date
+  <a href="http://bugs.debian.org/$d_bits->{bug}">Bug #$d_bits->{bug}:</a>$d_bits->{web_summary}</li>
+EOF
 
-sub process_template () {
-    open T, $templ, '<' or die "$0: $templ: $!\n";
-    while (<T>) {
-       
+}