Extract the version number from the changelog

This commit is contained in:
Marco d'Itri 2014-02-06 01:35:10 +01:00
parent bc35c3c585
commit d2ee7af1d7
6 changed files with 29 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
*_del.h
tld_serv.h
servers_charset.h
version.h
Makefile.depend
*.o

View File

@ -69,6 +69,9 @@ mkpasswd: $(mkpasswd_OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(mkpasswd_LDADD) $(LIBS)
##############################################################################
version.h: debian/changelog make_version_h.pl
$(PERL) -w make_version_h.pl $< > $@
as_del.h: as_del_list make_as_del.pl
$(PERL) -w make_as_del.pl < $< > $@

View File

@ -1,6 +1,3 @@
/* Program version */
#define VERSION "5.1.1"
/* Configurable features */
/* Always hide legal disclaimers */

23
make_version_h.pl Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/perl
use warnings;
use strict;
my $changelog = $ARGV[0] or die "Usage: $0 debian/changelog\n";
open(my $fh, '<', $changelog) or die "open($changelog): $!";
my $line = <$fh>;
close($fh) or die "close($changelog): $!";
my ($ver) = $line =~ /^whois \s+ \( ( [^\)]+ ) \) \s+ \S+/x;
die "Version number not found in $changelog!\n" if not $ver;
$ver =~ s/ ( ~deb\d+.* | ubuntu\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|;

View File

@ -45,6 +45,7 @@
#endif
/* Application-specific */
#include "version.h"
#include "utils.h"
/* Global variables */

View File

@ -39,6 +39,7 @@
#endif
/* Application-specific */
#include "version.h"
#include "data.h"
#include "whois.h"
#include "utils.h"