X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fpublish-decision;h=455e8f1e8795cc9dd505eed4c48ba1533be432dd;hb=7df2099171d7be75d869a230291bbf8161f20a03;hp=82e39c82de2e1b57fc38c17ed2b346c6808e4b01;hpb=a0cce61fe8fae14d79cd1445b0afd4ad3765b234;p=debian-ctte.git diff --git a/scripts/publish-decision b/scripts/publish-decision index 82e39c8..455e8f1 100755 --- a/scripts/publish-decision +++ b/scripts/publish-decision @@ -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,$&); +die "bad usage" unless @ARGV==1 && $ARGV[0] =~ m#^((\d+)_[\w-]+)/.*$#; +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} < +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} <$date + Bug #$d_bits->{bug}:$d_bits->{web_summary} +EOF -sub process_template () { - open T, $templ, '<' or die "$0: $templ: $!\n"; - while () { - +}