updateVersions.pl 1.3 KB

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