]> granicus.if.org Git - postgis/commitdiff
Change from scripts-based script versions to repository based versions. Should also...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 8 Feb 2012 23:01:34 +0000 (23:01 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 8 Feb 2012 23:01:34 +0000 (23:01 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9123 b70326c6-7e19-0410-871a-916f4a2858ee

utils/read_scripts_version.pl

index e9dab74a94dd623e7a22df9e6ec11a99515d34d6..e7cb65167f979b3836f61e7a7e90a8e87231b7e5 100644 (file)
@@ -1,37 +1,39 @@
 #!/usr/bin/perl
 
-my $debug = 0;
-
-my @files = ( 
-       "postgis.sql.in.c",
-       "geography.sql.in.c",
-       "long_xact.sql.in.c" 
-       );
+$ENV{"LC_ALL"} = "C";
 
+use Cwd;
+my $cwd = &Cwd::cwd();
+my $svn_exe = `which svn`;
 my $rev = 0;
 
-foreach $f (@files)
-{
-       my $file = "./postgis/$f";
-       if( -f $file )
-       {
-               my $r = 0;
-               open(F, $file);
-               while(<F>)
-               {
-                       $r = $1 if /\$Id: \S+ (\d+) /;
-               }
-               print "$f got revision $r\n" if $debug && $r;
-               $rev = $r if $r > $rev; 
-       }
-       else 
-       {
-               die "Could not open input file $f\n";
-       }
+# We have a repo and can read from it
+if ( $svn_exe && -d ".svn" ) {
+  my $svn_info;
+  $svn_info  = `svn info`;
+
+  if ( $svn_info =~ /Last Changed Rev: (\d+)/ ) {
+    $rev = $1;
+    open(OUT,">$cwd/svnrevision.h");
+    print OUT "#define SVNREV $rev\n";
+    close(OUT);
+  } 
+  else {
+    die "Unable to find revision in svn info\n";
+  }
+}
+# No repo, but there's a version file in the tarball
+elsif ( -f "svnrevision.h" ) {
+  my $svn_revision_file = `cat svnrevision.h`;
+  if ( $svn_revision_file =~ /SVNREV (\d+)/ ) {
+    $rev = $1;
+  }
+  else {
+    die "svnrevision.h has an unexpected format\n";
+  }
+}
+else {
+  die "Unable read svnrevision.h or svn repository metadata\n";
 }
 
-print "\nMaximum scripts revision: $rev\n\n" if $debug;
-
-print $rev if ! $debug;
-
-
+print $rev;