1 eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
2 & eval 'exec perl -wS "$0" $argv:q'
4 # Generate a release announcement message.
6 my $VERSION = '2012-06-08 06:53'; # UTC
7 # The definition above must lie within the first 8 lines in order
8 # for the Emacs time-stamp write hook (at end) to update it.
9 # If you change this file with Emacs, please let the write hook
10 # do its job. Otherwise, update this string manually.
12 # Copyright (C) 2002-2013 Free Software Foundation, Inc.
14 # This program is free software: you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation, either version 3 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # Written by Jim Meyering
33 eval { require Digest::SHA; }
34 or eval 'use Digest::SHA1';
35 use POSIX qw(strftime);
37 (my $ME = $0) =~ s|.*/||;
39 my %valid_release_types = map {$_ => 1} qw (alpha beta stable);
40 my @archive_suffixes = ('tar.gz', 'tar.bz2', 'tar.lzma', 'tar.xz');
46 my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
49 print $STREAM "Try '$ME --help' for more information.\n";
53 my @types = sort keys %valid_release_types;
56 Generate an announcement message. Run this from builddir.
60 These options must be specified:
62 --release-type=TYPE TYPE must be one of @types
63 --package-name=PACKAGE_NAME
64 --previous-version=VER
66 --gpg-key-id=ID The GnuPG ID of the key used to sign the tarballs
67 --url-directory=URL_DIR
69 The following are optional:
71 --news=NEWS_FILE include the NEWS section about this release
72 from this NEWS_FILE; accumulates.
73 --srcdir=DIR where to find the NEWS_FILEs (default: $srcdir)
74 --bootstrap-tools=TOOL_LIST a comma-separated list of tools, e.g.,
75 autoconf,automake,bison,gnulib
76 --gnulib-version=VERSION report VERSION as the gnulib version, where
77 VERSION is the result of running git describe
78 in the gnulib source directory.
79 required if gnulib is in TOOL_LIST.
80 --no-print-checksums do not emit MD5 or SHA1 checksums
81 --archive-suffix=SUF add SUF to the list of archive suffixes
82 --mail-headers=HEADERS a space-separated list of mail headers, e.g.,
83 To: x\@example.com Cc: y-announce\@example.com,...
85 --help display this help and exit
86 --version output version information and exit
94 =item C<%size> = C<sizes (@file)>
96 Compute the sizes of the C<@file> and return them as a hash. Return
97 C<undef> if one of the computation failed.
107 foreach my $f (@file)
109 my $cmd = "du -h $f";
111 # FIXME-someday: give a better diagnostic, a la $PROCESS_STATUS
113 and (warn "command failed: '$cmd'\n"), $fail = 1;
115 $t =~ s/^\s*([\d.]+[MkK]).*/${1}B/;
118 return $fail ? undef : %res;
121 =item C<print_locations ($title, \@url, \%size, @file)
123 Print a section C<$title> dedicated to the list of <@file>, which
124 sizes are stored in C<%size>, and which are available from the C<@url>.
128 sub print_locations ($\@\%@)
130 my ($title, $url, $size, @file) = @_;
131 print "Here are the $title:\n";
132 foreach my $url (@{$url})
137 print " (", $$size{$file}, ")"
138 if exists $$size{$file};
145 =item C<print_checksums (@file)
147 Print the MD5 and SHA1 signature section for each C<@file>.
151 sub print_checksums (@)
155 print "Here are the MD5 and SHA1 checksums:\n";
158 foreach my $meth (qw (md5 sha1))
160 foreach my $f (@file)
163 or die "$ME: $f: cannot open for reading: $!\n";
167 ? Digest::MD5->new->addfile(*IN)->hexdigest
168 : Digest::SHA1->new->addfile(*IN)->hexdigest);
176 =item C<print_news_deltas ($news_file, $prev_version, $curr_version)
178 Print the section of the NEWS file C<$news_file> addressing changes
179 between versions C<$prev_version> and C<$curr_version>.
183 sub print_news_deltas ($$$)
185 my ($news_file, $prev_version, $curr_version) = @_;
187 my $news_name = $news_file;
188 $news_name =~ s|^\Q$srcdir\E/||;
190 print "\n$news_name\n\n";
192 # Print all lines from $news_file, starting with the first one
193 # that mentions $curr_version up to but not including
194 # the first occurrence of $prev_version.
197 my $re_prefix = qr/(?:\* )?(?:Noteworthy c|Major c|C)(?i:hanges)/;
200 open NEWS, '<', $news_file
201 or die "$ME: $news_file: cannot open for reading: $!\n";
202 while (defined (my $line = <NEWS>))
206 # Match lines like these:
207 # * Major changes in release 5.0.1:
208 # * Noteworthy changes in release 6.6 (2006-11-22) [stable]
209 $line =~ /^$re_prefix.*(?:[^\d.]|$)\Q$curr_version\E(?:[^\d.]|$)/o
216 # This regexp must not match version numbers in NEWS items.
217 # For example, they might well say "introduced in 4.5.5",
218 # and we don't want that to match.
219 $line =~ /^$re_prefix.*(?:[^\d.]|$)\Q$prev_version\E(?:[^\d.]|$)/o
229 or die "$ME: $news_file: no matching lines for '$curr_version'\n";
231 or die "$ME: $news_file: no news item found for '$curr_version'\n";
234 sub print_changelog_deltas ($$)
236 my ($package_name, $prev_version) = @_;
238 # Print new ChangeLog entries.
240 # First find all CVS-controlled ChangeLog files.
243 find ({wanted => sub {$_ eq 'ChangeLog' && -d 'CVS'
244 and push @changelog, $File::Find::name}},
247 # If there are no ChangeLog files, we're done.
250 my %changelog = map {$_ => 1} @changelog;
252 # Reorder the list of files so that if there are ChangeLog
253 # files in the specified directories, they're listed first,
255 my @dir = qw ( . src lib m4 config doc );
257 # A typical @changelog array might look like this:
267 my $dot_slash = $d eq '.' ? $d : "./$d";
268 my $target = "$dot_slash/ChangeLog";
269 delete $changelog{$target}
270 and push @reordered, $target;
273 # Append any remaining ChangeLog files.
274 push @reordered, sort keys %changelog;
276 # Remove leading './'.
277 @reordered = map { s!^\./!!; $_ } @reordered;
279 print "\nChangeLog entries:\n\n";
280 # print join ("\n", @reordered), "\n";
282 $prev_version =~ s/\./_/g;
283 my $prev_cvs_tag = "\U$package_name\E-$prev_version";
285 my $cmd = "cvs -n diff -u -r$prev_cvs_tag -rHEAD @reordered";
286 open DIFF, '-|', $cmd
287 or die "$ME: cannot run '$cmd': $!\n";
288 # Print two types of lines, making minor changes:
289 # Lines starting with '+++ ', e.g.,
290 # +++ ChangeLog 22 Feb 2003 16:52:51 -0000 1.247
291 # and those starting with '+'.
292 # Don't print the others.
293 my $prev_printed_line_empty = 1;
294 while (defined (my $line = <DIFF>))
296 if ($line =~ /^\+\+\+ /)
298 my $separator = "*"x70 ."\n";
301 $prev_printed_line_empty
303 print $separator, $line, $separator;
305 elsif ($line =~ /^\+/)
309 $prev_printed_line_empty = ($line =~ /^$/);
314 # The exit code should be 1.
315 # Allow in case there are no modified ChangeLog entries.
316 $? == 256 || $? == 128
317 or warn "warning: '$cmd' had unexpected exit code or signal ($?)\n";
320 sub get_tool_versions ($$)
322 my ($tool_list, $gnulib_version) = @_;
327 my @tool_version_pair;
328 foreach my $t (@$tool_list)
332 push @tool_version_pair, ucfirst $t . ' ' . $gnulib_version;
335 # Assume that the last "word" on the first line of
336 # 'tool --version' output is the version string.
337 my ($first_line, undef) = split ("\n", `$t --version`);
338 if ($first_line =~ /.* (\d[\w.-]+)$/)
341 push @tool_version_pair, "$t $1";
346 and $first_line = '';
347 warn "$t: unexpected --version output\n:$first_line";
355 return @tool_version_pair;
359 # Neutralize the locale, so that, for instance, "du" does not
360 # issue "1,2" instead of "1.2", what confuses our regexps.
373 my $print_checksums_p = 1;
375 # Reformat the warnings before displaying them.
376 local $SIG{__WARN__} = sub
379 # Warnings from GetOptions.
380 $msg =~ s/Option (\w)/option --$1/;
386 'mail-headers=s' => \$mail_headers,
387 'release-type=s' => \$release_type,
388 'package-name=s' => \$package_name,
389 'previous-version=s' => \$prev_version,
390 'current-version=s' => \$curr_version,
391 'gpg-key-id=s' => \$gpg_key_id,
392 'url-directory=s' => \@url_dir_list,
393 'news=s' => \@news_file,
394 'srcdir=s' => \$srcdir,
395 'bootstrap-tools=s' => \$bootstrap_tools,
396 'gnulib-version=s' => \$gnulib_version,
397 'print-checksums!' => \$print_checksums_p,
398 'archive-suffix=s' => \@archive_suffixes,
400 help => sub { usage 0 },
401 version => sub { print "$ME version $VERSION\n"; exit },
405 # Ensure that each required option is specified.
407 or (warn "release type not specified\n"), $fail = 1;
409 or (warn "package name not specified\n"), $fail = 1;
411 or (warn "previous version string not specified\n"), $fail = 1;
413 or (warn "current version string not specified\n"), $fail = 1;
415 or (warn "GnuPG key ID not specified\n"), $fail = 1;
417 or (warn "URL directory name(s) not specified\n"), $fail = 1;
419 my @tool_list = split ',', $bootstrap_tools;
421 grep (/^gnulib$/, @tool_list) ^ defined $gnulib_version
422 and (warn "when specifying gnulib as a tool, you must also specify\n"
423 . "--gnulib-version=V, where V is the result of running git describe\n"
424 . "in the gnulib source directory.\n"), $fail = 1;
426 exists $valid_release_types{$release_type}
427 or (warn "'$release_type': invalid release type\n"), $fail = 1;
430 and (warn "too many arguments:\n", join ("\n", @ARGV), "\n"),
435 my $my_distdir = "$package_name-$curr_version";
437 my $xd = "$package_name-$prev_version-$curr_version.xdelta";
439 my @candidates = map { "$my_distdir.$_" } @archive_suffixes;
440 my @tarballs = grep {-f $_} @candidates;
443 or die "$ME: none of " . join(', ', @candidates) . " were found\n";
444 my @sizable = @tarballs;
446 and push @sizable, $xd;
447 my %size = sizes (@sizable);
452 if (defined $mail_headers)
454 ($headers = $mail_headers) =~ s/\s+(\S+:)/\n$1/g;
458 # The markup is escaped as <\# so that when this script is sent by
459 # mail (or part of a diff), Gnus is not triggered.
462 ${headers}Subject: $my_distdir released [$release_type]
464 <\#secure method=pgpmime mode=sign>
466 FIXME: put comments here
470 if (@url_dir_list == 1 && @tarballs == 1)
472 # When there's only one tarball and one URL, use a more concise form.
473 my $m = "$url_dir_list[0]/$tarballs[0]";
474 print "Here are the compressed sources and a GPG detached signature[*]:\n"
480 print_locations ("compressed sources", @url_dir_list, %size, @tarballs);
482 and print_locations ("xdelta diffs (useful? if so, "
483 . "please tell bug-gnulib\@gnu.org)",
484 @url_dir_list, %size, $xd);
485 my @sig_files = map { "$_.sig" } @tarballs;
486 print_locations ("GPG detached signatures[*]", @url_dir_list, %size,
490 if ($url_dir_list[0] =~ "gnu\.org")
492 print "Use a mirror for higher download bandwidth:\n";
493 if (@tarballs == 1 && $url_dir_list[0] =~ m!http://ftp\.gnu\.org/gnu/!)
495 (my $m = "$url_dir_list[0]/$tarballs[0]")
496 =~ s!http://ftp\.gnu\.org/gnu/!http://ftpmirror\.gnu\.org/!;
503 print " http://www.gnu.org/order/ftp.html\n\n";
508 and print_checksums (@sizable);
511 [*] Use a .sig file to verify that the corresponding file (without the
512 .sig suffix) is intact. First, be sure to download both the .sig file
513 and the corresponding tarball. Then, run a command like this:
515 gpg --verify $tarballs[0].sig
517 If that command fails because you don't have the required public key,
518 then run this command to import it:
520 gpg --keyserver keys.gnupg.net --recv-keys $gpg_key_id
522 and rerun the 'gpg --verify' command.
525 my @tool_versions = get_tool_versions (\@tool_list, $gnulib_version);
527 and print "\nThis release was bootstrapped with the following tools:",
528 join ('', map {"\n $_"} @tool_versions), "\n";
530 print_news_deltas ($_, $prev_version, $curr_version)
533 $release_type eq 'stable'
534 or print_changelog_deltas ($package_name, $prev_version);
539 ### Setup "GNU" style for perl-mode and cperl-mode.
542 ## perl-indent-level: 2
543 ## perl-continued-statement-offset: 2
544 ## perl-continued-brace-offset: 0
545 ## perl-brace-offset: 0
546 ## perl-brace-imaginary-offset: 0
547 ## perl-label-offset: -2
548 ## perl-extra-newline-before-brace: t
549 ## perl-merge-trailing-else: nil
550 ## eval: (add-hook 'write-file-hooks 'time-stamp)
551 ## time-stamp-start: "my $VERSION = '"
552 ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
553 ## time-stamp-time-zone: "UTC"
554 ## time-stamp-end: "'; # UTC"