Changes file for 9866
[tor.git] / contrib / updateVersions.pl
blob9dae1ff95204fee72b350410dcbc3a5ce9ea041b
1 #!/usr/bin/perl -w
3 $CONFIGURE_IN = './configure.ac';
4 $ORCONFIG_H = './src/win32/orconfig.h';
5 $TOR_NSI = './contrib/tor-mingw.nsi.in';
7 $quiet = 1;
9 sub demand {
10 my $fn = shift;
11 die "Missing file $fn" unless (-f $fn);
14 demand($CONFIGURE_IN);
15 demand($ORCONFIG_H);
16 demand($TOR_NSI);
18 # extract version from configure.ac
20 open(F, $CONFIGURE_IN) or die "$!";
21 $version = undef;
22 while (<F>) {
23 if (/AC_INIT\(\[tor\],\s*\[([^\]]*)\]\)/) {
24 $version = $1;
25 last;
28 die "No version found" unless $version;
29 print "Tor version is $version\n" unless $quiet;
30 close F;
32 sub correctversion {
33 my ($fn, $defchar) = @_;
34 undef $/;
35 open(F, $fn) or die "$!";
36 my $s = <F>;
37 close F;
38 if ($s =~ /^$defchar(?:)define\s+VERSION\s+\"([^\"]+)\"/m) {
39 $oldver = $1;
40 if ($oldver ne $version) {
41 print "Version mismatch in $fn: It thinks that the version is $oldver. I think it's $version. Fixing.\n";
42 $line = $defchar . "define VERSION \"$version\"";
43 open(F, ">$fn.bak");
44 print F $s;
45 close F;
46 $s =~ s/^$defchar(?:)define\s+VERSION.*?$/$line/m;
47 open(F, ">$fn");
48 print F $s;
49 close F;
50 } else {
51 print "$fn has the correct version. Good.\n" unless $quiet;
53 } else {
54 print "Didn't find a version line in $fn -- uh oh.\n";
58 correctversion($TOR_NSI, "!");
59 correctversion($ORCONFIG_H, "#");