summaryrefslogtreecommitdiff
path: root/make_version_h.pl
blob: 06c7841c18a9b28ec1d7d4168364c7779def5ae3 (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
#!/usr/bin/perl

use warnings;
use strict;
use autodie;

my $changelog = $ARGV[0] or die "Usage: $0 debian/changelog\n";

open(my $fh, '<', $changelog);
my $line = <$fh>;
close($fh);

my ($ver) = $line =~ /^whois \s+ \( ( [^\)]+ ) \) \s+ \S+/x;
die "Version number not found in $changelog!\n" if not $ver;

$ver =~ s/ ( ~bpo\d+\+\d+ | \+b\d+ | ~deb\d+.* | ubuntu\d+ | \+dyson\d+ ) $//x;

# The version number must not deviate from this format or the -V option
# to RIPE-like servers will break. If needed, update the previous regexp.
die "Invalid version number in $changelog!\n"
	unless $ver =~ /^ \d+\.\d+ ( \.\d+ )? $/x;

print qq|#define VERSION "$ver"\n|;