]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Use git describe to determine build version
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Sat, 26 Jun 2010 18:35:18 +0000 (19:35 +0100)
committerRuss Allbery <rra@stanford.edu>
Mon, 28 Jun 2010 22:19:23 +0000 (15:19 -0700)
This patch makes the configure and build system use the output
from 'git describe' to determine the version of the software being
built. This means that all that is necessary to create a new release
is to tag the repository - removing the double sources of version
information.

There are a couple of fallbacks for systems which do not have git
available for builds. Firstly, if a file called '.version' exists
in the top level of the repository, then the version information is
pulled from this file. The intention is that those packaging up
git checkouts for onwards distribution will use
'git describe > .version' before producing their tarballs.

Secondly, if we cannot find any version information then the version
will default to 'UNKNOWN'

This all mirrors the way that many others have integrated git with
automake and friends - although the implementation is independent.

Change-Id: I7fa4605e52181d60657ad794ca8efdb5a9fb1449
Reviewed-on: http://gerrit.openafs.org/1824
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Russ Allbery <rra@stanford.edu>
.gitignore
build-tools/git-version [new file with mode: 0755]
build-tools/libafsdep [new file with mode: 0644]
configure-libafs.in
configure.in
src/config/Makefile.version-NOCML.in
src/config/make_libafs_tree.pl

index d261255c45fbcf222312957ff9b5c8dd76f14252..9ef0621bbf4a346b0784fc5cfc6ceec6cd9d0006 100644 (file)
@@ -52,6 +52,7 @@ rs_state.ini
 /TAGS
 /NTLang.bat
 /golast.bat
+/.version
 
 # Destination build directories
 /alpha_nbsd*
diff --git a/build-tools/git-version b/build-tools/git-version
new file mode 100755 (executable)
index 0000000..b8c6802
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+version_file=$1
+
+if [ -f $version_file ] ; then
+  git_version=`cat $version_file`
+else
+  if which git > /dev/null; then
+    git_version=`git describe --abbrev=4 HEAD 2>/dev/null`
+
+    # Is the working tree dirty?
+    if ! git diff-index --quiet --cached HEAD --ignore-submodules || \
+       ! git diff-files --quiet --ignore-submodules ; then
+      git_version="$git_version-dirty"
+    fi
+  else
+    git_version=UNKNOWN
+  fi
+fi
+
+echo "$git_version" | sed -e 's/openafs-[^-]*-//' -e 's/_/./g' | tr -d '\012'
diff --git a/build-tools/libafsdep b/build-tools/libafsdep
new file mode 100644 (file)
index 0000000..163773d
--- /dev/null
@@ -0,0 +1 @@
+git-version
index c8c476edf59a7dbf753b7f3e79e16a3f9e570dd6..77fb092a020dcf0c389b74f6ba6f7ff7df032345 100644 (file)
@@ -1,5 +1,5 @@
 AC_PRERQ([2.60])
-AC_INIT([OpenAFS], [1.5.74.1])
+AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .version]))
 AC_CONFIG_SRCDIR(src/libafs/Makefile.common.in)
 AM_INIT_AUTOMAKE
 
index b6269e0fb3822749e2b92776ff11e5a43f84bf2f..039d8c7fddb388039c0aeb07005ae36c6206e145 100644 (file)
@@ -1,5 +1,5 @@
 AC_PREREQ([2.60])
-AC_INIT([OpenAFS], [1.5.74.1])
+AC_INIT([OpenAFS], m4_esyscmd([build-tools/git-version .version]))
 AC_CONFIG_SRCDIR([src/config/stds.h])
 AM_INIT_AUTOMAKE
 
index 0d612ddfa21afd70f499825fa00f0794c091c78c..e5baf5a0368d59cdc59351bc5aa82153eb572070 100644 (file)
@@ -6,18 +6,19 @@
 # directory or online at http://www.openafs.org/dl/license10.html
 
 PACKAGE=@PACKAGE@
-VERSION=@VERSION@
 
 AFS_component_version_number.o: AFS_component_version_number.c
 
 AFS_component_version_number.c: @TOP_OBJDIR@/src/config/Makefile.version
-       echo 'char cml_version_number[]="@(#) OpenAFS ${VERSION} built ' `date +"%Y-%m-%d"` '";' >AFS_component_version_number.c
-       echo 'char* AFSVersion = "${PACKAGE} ${VERSION}"; ' >>AFS_component_version_number.c
+       VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@/.version` && \
+       echo 'char cml_version_number[]="@(#) OpenAFS '$$VERSION' built ' `date +"%Y-%m-%d"` '";' >AFS_component_version_number.c && \
+       echo 'char* AFSVersion = "${PACKAGE} '$$VERSION'";' >>AFS_component_version_number.c
 
 version.xml:
-       echo '<?xml version="1.0" encoding="UTF-8"?>' >version.xml
-       echo '<revision>' >>version.xml
-       echo '<revnumber>${VERSION}</revnumber>' >>version.xml
+       VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir/.version` && \
+       echo '<?xml version="1.0" encoding="UTF-8"?>' >version.xml && \
+       echo '<revision>' >>version.xml && \
+       echo '<revnumber>'$$VERSION'</revnumber>' >>version.xml && \
        echo '</revision>' >>version.xml
 
 version.txt:
index fb8295d755ee1603ed3410be7ba2a24f000ac9bf..05e1eb8b1044f82439b13f6c8d7446e5d106e297 100755 (executable)
@@ -76,6 +76,8 @@ finddepth(\&find_libafsdep, $projdir);
 &copyit("$projdir/src/libafs/MakefileProto.$ostype.in",
         "$treedir/src/libafs/MakefileProto.in");
 
+$showonly || system("$projdir/build-tools/git-version $projdir/.version > $treedir/.version");
+
 # We need to regenerate this to support building amd64 kernels from a
 # libafs_tree built on i386.
 unlink("$treedir/include/afs/param.h");