Title: [opsview-base] [161] Set opsview-base package version independently of top level Opsview package
Revision
161
Author
tvoon
Date
2012-12-19 16:45:01 +0000 (Wed, 19 Dec 2012)

Log Message

Set opsview-base package version independently of top level Opsview package

Modified Paths

Added Paths

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2012-12-19 16:33:30 UTC (rev 160)
+++ trunk/Makefile	2012-12-19 16:45:01 UTC (rev 161)
@@ -22,7 +22,11 @@
 # If you run "make install DESTDIR=/tmp/build", then will install files into /tmp/build for packaging
 # Check that /usr/local/nagios does not have any files in there
 
-# Expects VERSION to be set
+# This sets the version of the packages
+BASE_VERSION = 4.3.1
+BUILD_AND_DATE := $(shell ./get_version)
+REVISION := $(shell echo ${BUILD_AND_DATE} | awk '{print $$1}')
+VERSION = ${BASE_VERSION}.${REVISION}
 RELEASE = 1
 
 NAGIOS = nagios-4.0.20121205
@@ -217,6 +221,9 @@
 	${INSTALL} -d -o $(NAGIOS_USER) -g $(NAGIOS_GROUP) -m 0775 ${DESTDIR}/${SNMP_DIR}/load
 	${INSTALL} -d -o $(NAGIOS_USER) -g $(NAGIOS_GROUP) -m 0775 ${DESTDIR}/${LIB_DIR}
 
+echo-version:
+	echo ${VERSION}
+
 tar: opsview-base.spec
 	if [ x${VERSION} = "x" ] ; then echo "Need version" ; false; fi
 	$(MAKE) clean

Added: trunk/get_version
===================================================================
--- trunk/get_version	                        (rev 0)
+++ trunk/get_version	2012-12-19 16:45:01 UTC (rev 161)
@@ -0,0 +1,52 @@
+#!/usr/bin/env perl
+#
+# small script to get svn version number out of either svn or git local
+# repository, depending on how code has been checked out
+#
+use strict;
+use warnings;
+use Cwd;
+
+my $revision = 0;
+my $date     = "";
+
+# Shortcut here if testing
+# Shortcut should be in Makefile, but don't how to get
+# conditional variables assigned
+if ( $ENV{OPSVIEW_TEST_HUDSON} ) {
+    print "0 \n";
+    exit;
+}
+
+if ( -d cwd() . '/.svn' ) {
+    my $svnrevision = qx/ svnversion -c . /;
+    chomp($svnrevision);
+
+    if ( $svnrevision !~ m/exported/xsm ) {
+        $svnrevision =~ s/.*://;
+        $svnrevision =~ s/M//;
+        $revision = $svnrevision;
+
+        my @svnlog = qx/svn info/;
+        foreach $_ (@svnlog) {
+            if (/Last Changed Date: (20\d\d)\-(\d\d)\-(\d\d)/) {
+                $date = $1 . $2 . $3;
+                last;
+            }
+        }
+    }
+
+}
+elsif ( -d cwd() . '/.git' ) {
+
+    my @svnlog = qx/git svn log --limit=1/;
+    my ($gitrevision) = $svnlog[1] =~ m/^r(\d+)\s/xsm;
+
+    if ( !$gitrevision ) {
+        die 'Unable to parse revision number out of git', $/;
+    }
+    $revision = $gitrevision;
+
+}
+
+print "$revision $date", $/;


Property changes on: trunk/get_version
___________________________________________________________________
Added: svn:executable
   + *

_______________________________________________
Opsview-checkins mailing list
[email protected]
http://lists.opsview.org/lists/listinfo/opsview-checkins

Reply via email to