summaryrefslogtreecommitdiff
path: root/tools/ck-news
blob: 3bcf055abc414a9bd691e83448b7ff18a1eaa6fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env perl

# Note: this script must not be used to build MPFR due to the
# dependency on perl, but this is OK for "make dist".

# Copyright 2016-2021 Free Software Foundation, Inc.
# This script is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

use strict;
use Cwd;

if (! -d 'src')
  {
    getcwd() =~ m,/tools$,
      or die "Execute $0 from the MPFR source directory\n";
    chdir '..' or die "$!\n$0: can't change cwd\n";
  }

open VERSION, '<', 'VERSION'
  or die "$!\n$0: can't open VERSION file\n";
my $version = do { local $/; <VERSION> };
close VERSION or die "$!\n$0: can't close VERSION file\n";

my ($base,$mv,$pl,$suf) = $version =~ /^((\d+\.\d+)\.(\d+))(-\S+)?/
  or die "$0: bad VERSION format\n";

my $r1 = qr/^Changes from version/;
my $r2 = qr/ to version \Q$base\E:/;
my $rx = $pl ? qr/$r1 \Q$mv\E\.@{[$pl-1]}$r2/ : qr/${r1}s? \S+\.[0*]$r2/;

open NEWS, '<', 'NEWS'
  or die "$!\n$0: can't open NEWS file\n";
my $ok;
while (<NEWS>)
  {
    /$rx/ and $ok = 1;
    # If this is a release or a release candidate, check that
    # the NEWS file does not contain FIXME or TODO.
    $suf =~ /^(-rc.*)?$/ && /FIXME|TODO/
      and $! = 2, die "$0: $& in NEWS file";
  }
close NEWS or die "$!\n$0: can't close NEWS file\n";

$ok or $! = 1, die "$0: missing or bad change log in NEWS file\n";