Home | History | Annotate | Line # | Download | only in tools
      1      1.1  mrg #!/usr/bin/env perl
      2      1.1  mrg 
      3      1.1  mrg # Note: this script must not be used to build MPFR due to the
      4      1.1  mrg # dependency on perl, but this is OK for "make dist".
      5      1.1  mrg 
      6  1.1.1.4  mrg # Copyright 2016-2023 Free Software Foundation, Inc.
      7      1.1  mrg # This script is free software; the Free Software Foundation
      8      1.1  mrg # gives unlimited permission to copy and/or distribute it,
      9      1.1  mrg # with or without modifications, as long as this notice is preserved.
     10      1.1  mrg 
     11      1.1  mrg # This program is distributed in the hope that it will be useful,
     12      1.1  mrg # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
     13      1.1  mrg # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
     14      1.1  mrg # PARTICULAR PURPOSE.
     15      1.1  mrg 
     16      1.1  mrg use strict;
     17      1.1  mrg use Cwd;
     18      1.1  mrg 
     19      1.1  mrg if (! -d 'src')
     20      1.1  mrg   {
     21      1.1  mrg     getcwd() =~ m,/tools$,
     22      1.1  mrg       or die "Execute $0 from the MPFR source directory\n";
     23      1.1  mrg     chdir '..' or die "$!\n$0: can't change cwd\n";
     24      1.1  mrg   }
     25      1.1  mrg 
     26      1.1  mrg open VERSION, '<', 'VERSION'
     27      1.1  mrg   or die "$!\n$0: can't open VERSION file\n";
     28      1.1  mrg my $version = do { local $/; <VERSION> };
     29      1.1  mrg close VERSION or die "$!\n$0: can't close VERSION file\n";
     30      1.1  mrg 
     31      1.1  mrg my ($base,$mv,$pl,$suf) = $version =~ /^((\d+\.\d+)\.(\d+))(-\S+)?/
     32      1.1  mrg   or die "$0: bad VERSION format\n";
     33      1.1  mrg 
     34      1.1  mrg my $r1 = qr/^Changes from version/;
     35      1.1  mrg my $r2 = qr/ to version \Q$base\E:/;
     36      1.1  mrg my $rx = $pl ? qr/$r1 \Q$mv\E\.@{[$pl-1]}$r2/ : qr/${r1}s? \S+\.[0*]$r2/;
     37      1.1  mrg 
     38      1.1  mrg open NEWS, '<', 'NEWS'
     39      1.1  mrg   or die "$!\n$0: can't open NEWS file\n";
     40      1.1  mrg my $ok;
     41      1.1  mrg while (<NEWS>)
     42      1.1  mrg   {
     43      1.1  mrg     /$rx/ and $ok = 1;
     44  1.1.1.3  mrg     # If this is a release or a release candidate, check that
     45  1.1.1.3  mrg     # the NEWS file does not contain FIXME or TODO.
     46  1.1.1.3  mrg     $suf =~ /^(-rc.*)?$/ && /FIXME|TODO/
     47  1.1.1.3  mrg       and $! = 2, die "$0: $& in NEWS file";
     48      1.1  mrg   }
     49      1.1  mrg close NEWS or die "$!\n$0: can't close NEWS file\n";
     50      1.1  mrg 
     51      1.1  mrg $ok or $! = 1, die "$0: missing or bad change log in NEWS file\n";
     52