updateVersions.pl.in 1.4 KB

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