]> granicus.if.org Git - postgis/commitdiff
Report SVN revision in PostGIS_Full_Version (#1518)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Sat, 11 Feb 2012 05:14:39 +0000 (05:14 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Sat, 11 Feb 2012 05:14:39 +0000 (05:14 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9155 b70326c6-7e19-0410-871a-916f4a2858ee

GNUmakefile.in
postgis/lwgeom_functions_basic.c
postgis/postgis.sql.in.c
postgis_config.h.in
utils/svn_repo_revision.pl

index 2fdf77bd4524028b5c3e63edd94686ee2efd80d2..2e133d56e315c55475be932cbe129d04b56ddc6b 100644 (file)
@@ -19,7 +19,7 @@ all install uninstall noop clean distclean check:
                echo "PostGIS was built successfully. Ready to install."; \
        fi
 
-all: 
+all: postgis_svn_revision.h
 
 install: all
 
@@ -178,6 +178,9 @@ authors.git: authors.svn
 svnrebase: authors.git
        git svn rebase --authors-file authors.git
 
+postgis_svn_revision.h: .FORCE
+       $(PERL) utils/svn_repo_revision.pl
+
 .PHONY: utils liblwgeom ChangeLog.svn raster
 
 .FORCE:
index 4883cb7d63d1cb16c29669ca4da9eb687304dd7f..75d16ccdc7e69540cfde0fbd09d0d672fc22653c 100644 (file)
@@ -36,6 +36,7 @@ Datum postgis_autocache_bbox(PG_FUNCTION_ARGS);
 Datum postgis_scripts_released(PG_FUNCTION_ARGS);
 Datum postgis_version(PG_FUNCTION_ARGS);
 Datum postgis_lib_version(PG_FUNCTION_ARGS);
+Datum postgis_svn_version(PG_FUNCTION_ARGS);
 Datum postgis_libxml_version(PG_FUNCTION_ARGS);
 Datum postgis_lib_build_date(PG_FUNCTION_ARGS);
 Datum LWGEOM_length2d_linestring(PG_FUNCTION_ARGS);
@@ -145,6 +146,20 @@ Datum postgis_lib_version(PG_FUNCTION_ARGS)
        PG_RETURN_TEXT_P(result);
 }
 
+PG_FUNCTION_INFO_V1(postgis_svn_version);
+Datum postgis_svn_version(PG_FUNCTION_ARGS)
+{
+       static int rev = POSTGIS_SVN_REVISION;
+       char ver[32];
+       if ( rev > 0 )
+       {
+               snprintf(ver, 32, "%d", rev);   
+               PG_RETURN_TEXT_P(cstring2text(ver));
+       }
+       else
+               PG_RETURN_NULL();
+}
+
 PG_FUNCTION_INFO_V1(postgis_lib_build_date);
 Datum postgis_lib_build_date(PG_FUNCTION_ARGS)
 {
index 5f80804ba265ca61853eeabb0ef007f8bde6c490..502041406621c2541da8f71f56381cd2fb93f167 100644 (file)
@@ -2315,6 +2315,10 @@ CREATE OR REPLACE FUNCTION postgis_geos_version() RETURNS text
        AS 'MODULE_PATHNAME'\r
        LANGUAGE 'C' IMMUTABLE;\r
 \r
+CREATE OR REPLACE FUNCTION postgis_svn_version() RETURNS text\r
+       AS 'MODULE_PATHNAME'\r
+       LANGUAGE 'C' IMMUTABLE;\r
+\r
 CREATE OR REPLACE FUNCTION postgis_libxml_version() RETURNS text\r
        AS 'MODULE_PATHNAME'\r
        LANGUAGE 'C' IMMUTABLE;\r
@@ -2355,6 +2359,7 @@ BEGIN
        SELECT postgis_uses_stats() INTO usestats;\r
        SELECT postgis_scripts_installed() INTO dbproc;\r
        SELECT postgis_scripts_released() INTO relproc;\r
+       select postgis_svn_version() INTO svnver;\r
 \r
        fullver = 'POSTGIS="' || libver || '"';\r
 \r
@@ -2373,6 +2378,10 @@ BEGIN
        IF  libxmlver IS NOT NULL THEN\r
                fullver = fullver || ' LIBXML="' || libxmlver || '"';\r
        END IF;\r
+\r
+       IF  svnver IS NOT NULL THEN\r
+               fullver = fullver || ' SVN_REVISION=' || svnver;\r
+       END IF;\r
        \r
        IF usestats THEN\r
                fullver = fullver || ' USE_STATS';\r
index 59193191da4c6e7e5d8849abe93d579e87c29090..edf1d08d1d9e9907d4603b99beba573b94aa21f7 100644 (file)
@@ -1,5 +1,7 @@
 /* postgis_config.h.in.  Generated from configure.ac by autoheader.  */
 
+#include "postgis_svn_revision.h"
+
 /* Define to 1 if translation of program messages to the user's native
    language is requested. */
 #undef ENABLE_NLS
index 3c2cfdc0c12f115dd6579f8994e0c8780594e3ea..46f84332a0a875d14959add63c621784e2505b1d 100644 (file)
@@ -5,26 +5,30 @@ $ENV{"LC_ALL"} = "C";
 use Cwd;
 my $cwd = &Cwd::cwd();
 
-my $svn_exe = `which svn`;
+my $svn_exe = `which svnn`;
 
-my $target = "local";
+my $svn_revision = 0;
+my $defn_string = $defn_string_start . $svn_revision;
+my $rev_file = "postgis_svn_revision.h";
 
 $target = $ARGV[0] if $ARGV[0];
 
 # Don't muck with things if you can't find svn
 if ( ! $svn_exe ) {
-  if ( ! -f "svnrevision.h" ) {
-    die "Couldn't find svn exectable or svnrevision.h, cannot continue.\n";
+  if ( ! -f $rev_file ) {
+    &write_defn(0);
+    exit(0);
   }
   else {
     exit(0);
   }
 };
 
-# Don't muck with thinks if you aren't in an svn repository
+# Don't muck with things if you aren't in an svn repository
 if ( $target eq "local" && ! -d ".svn" ) {
-  if ( ! -f "svnrevision.h" ) {
-    die "Couldn't find or generate svnrevision.h, cannot continue.\n";
+  if ( ! -f $rev_file ) {
+    &write_defn(0);
+    exit(0);
   }
   else {
     exit(0);
@@ -40,11 +44,22 @@ if ( $target eq "local" ) {
 }
 
 if ( $svn_info =~ /Last Changed Rev: (\d+)/ ) {
-  my $rev = $1;
-  open(OUT,">$cwd/svnrevision.h");
-  print OUT "#define SVNREV $rev\n";
-  close(OUT);
+  &write_defn($1);
 }
 else {
-  die "Unable to find revision in svn info\n";
+  if ( ! -f $rev_file ) {
+    &write_defn(0);
+    exit(0);
+  }
+  else {
+    exit(0);
+  }
+}
+
+sub write_defn {
+  my $rev = shift;
+  my $string = "#define POSTGIS_SVN_REVISION $rev\n";
+  open(OUT,">$rev_file");
+  print OUT $string;
+  close(OUT);
 }