b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/2] batctl: Add support for git revision string
@ 2010-06-21 16:18 Sven Eckelmann
  2010-06-21 16:18 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: " Sven Eckelmann
  2010-06-24 15:37 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: " Marek Lindner
  0 siblings, 2 replies; 3+ messages in thread
From: Sven Eckelmann @ 2010-06-21 16:18 UTC (permalink / raw)
  To: b.a.t.m.a.n

The Makefile tries to find a version number which describes the state of
the version somebody compiles. Currently this can only be a subversion
revision. This must also be done for git as it is used to prepare the
actual releases.

The revision string consists of 4 parts:
 1. last annotated tag name
 2. number of commits inbetween last tag name and this commit
 3. shortened sha1 sum of the commit
 4. indicator whether the files where modified

The first part is only shown when there was a tag before the commit or
the current commit was tagged. Part two and three is only shown when the
current commit is not tagged. The indicator is also only shown when the
files were modified.

This should make it quite easy understandable for humans and still makes
it possible to find the commit in the repository using standard git
tools (for that purpose the "-dirty" string  must be ommited).

A full example would be v2010.0.0-15-g154f68a-dirty

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batctl/Makefile |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/batctl/Makefile b/batctl/Makefile
index ab9c075..fde5486 100644
--- a/batctl/Makefile
+++ b/batctl/Makefile
@@ -47,23 +47,27 @@ PACKAGE_NAME = batctl
 BINARY_NAME = batctl
 SOURCE_VERSION_HEADER = main.h
 
-REVISION = $(shell if [ -d .svn ]; then \
-					if which svn > /dev/null; then \
-						svn info | grep "Rev:" | sed -e '1p' -n | awk '{print $$4}'; \
-					else \
-						echo "[unknown]"; \
-					fi ; \
+REVISION= $(shell	if [ -d .svn ]; then \
+				if which svn > /dev/null; then \
+					echo rv$$(svn info | grep "Rev:" | sed -e '1p' -n | awk '{print $$4}'); \
 				else \
-					if [ -d ~/.svk ]; then \
-						if which svk > /dev/null; then \
-							echo $$(svk info | grep "Mirrored From" | awk '{print $$5}'); \
-						else \
-							echo "[unknown]"; \
-						fi; \
-					fi; \
-				fi)
+					echo "[unknown]"; \
+				fi; \
+			elif [ -d .git ]; then \
+				if which git > /dev/null; then \
+					echo $$(git describe --always --dirty 2> /dev/null); \
+				else \
+					echo "[unknown]"; \
+				fi; \
+			elif [ -d ~/.svk ]; then \
+				if which svk > /dev/null; then \
+					echo rv$$(svk info | grep "Mirrored From" | awk '{print $$5}'); \
+				else \
+					echo "[unknown]"; \
+				fi; \
+			fi)
 
-REVISION_VERSION =\"\ rv$(REVISION)\"
+REVISION_VERSION =\"\ $(REVISION)\"
 
 BAT_VERSION = $(shell grep "^\#define SOURCE_VERSION " $(SOURCE_VERSION_HEADER) | sed -e '1p' -n | awk -F '"' '{print $$2}' | awk '{print $$1}')
 FILE_NAME = $(PACKAGE_NAME)_$(BAT_VERSION)-rv$(REVISION)_$@
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Add support for git revision string
  2010-06-21 16:18 [B.A.T.M.A.N.] [PATCH 1/2] batctl: Add support for git revision string Sven Eckelmann
@ 2010-06-21 16:18 ` Sven Eckelmann
  2010-06-24 15:37 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: " Marek Lindner
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2010-06-21 16:18 UTC (permalink / raw)
  To: b.a.t.m.a.n

The Makefile tries to find a version number which describes the state of
the version somebody compiles. Currently this can only be a subversion
revision. This must also be done for git as it is used to prepare the
actual releases.

The revision string consists of 4 parts:
 1. last annotated tag name
 2. number of commits inbetween last tag name and this commit
 3. shortened sha1 sum of the commit
 4. indicator whether the files where modified

The first part is only shown when there was a tag before the commit or
the current commit was tagged. Part two and three is only shown when the
current commit is not tagged. The indicator is also only shown when the
files were modified.

This should make it quite easy understandable for humans and still makes
it possible to find the commit in the repository using standard git
tools (for that purpose the "-dirty" string  must be ommited).

A full example would be v2010.0.0-25-gdc3f30c-dirty

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
 batman-adv/Makefile        |   30 +++++++++++++++++++-----------
 batman-adv/Makefile.kbuild |    2 +-
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/batman-adv/Makefile b/batman-adv/Makefile
index 4f6a460..e52a2d3 100644
--- a/batman-adv/Makefile
+++ b/batman-adv/Makefile
@@ -29,17 +29,25 @@ endif
 
 export KERNELPATH
 
-REVISION=	$(shell if [ -d .svn ]; then \
-						if which svn > /dev/null; then \
-							svn info | grep "Rev:" | sed -e '1p' -n | awk '{print $$4}'; \
-						fi; \
-					else \
-						if [ -d ~/.svk ]; then \
-							if which svk > /dev/null; then \
-								echo $$(svk info | grep "Mirrored From" | awk '{print $$5}'); \
-							fi; \
-						fi; \
-					fi)
+REVISION= $(shell	if [ -d .svn ]; then \
+				if which svn > /dev/null; then \
+					echo rv$$(svn info | grep "Rev:" | sed -e '1p' -n | awk '{print $$4}'); \
+				else \
+					echo "[unknown]"; \
+				fi; \
+			elif [ -d .git ]; then \
+				if which git > /dev/null; then \
+					echo $$(git describe --always --dirty 2> /dev/null); \
+				else \
+					echo "[unknown]"; \
+				fi; \
+			elif [ -d ~/.svk ]; then \
+				if which svk > /dev/null; then \
+					echo rv$$(svk info | grep "Mirrored From" | awk '{print $$5}'); \
+				else \
+					echo "[unknown]"; \
+				fi; \
+			fi)
 
 NUM_CPUS = $(shell NUM_CPUS=`cat /proc/cpuinfo | grep -v 'model name' | grep processor | tail -1 | awk -F' ' '{print $$3}'`;echo `expr $$NUM_CPUS + 1`)
 
diff --git a/batman-adv/Makefile.kbuild b/batman-adv/Makefile.kbuild
index d42f6a3..762ee4e 100644
--- a/batman-adv/Makefile.kbuild
+++ b/batman-adv/Makefile.kbuild
@@ -28,7 +28,7 @@ endif
 # EXTRA_CFLAGS += -DCONFIG_BATMAN_ADV_DEBUG
 
 ifneq ($(REVISION),)
-EXTRA_CFLAGS += -DREVISION_VERSION=\"r$(REVISION)\"
+EXTRA_CFLAGS += -DREVISION_VERSION=\"$(REVISION)\"
 endif
 
 obj-m += batman-adv.o
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 1/2] batctl: Add support for git revision string
  2010-06-21 16:18 [B.A.T.M.A.N.] [PATCH 1/2] batctl: Add support for git revision string Sven Eckelmann
  2010-06-21 16:18 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: " Sven Eckelmann
@ 2010-06-24 15:37 ` Marek Lindner
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2010-06-24 15:37 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Monday 21 June 2010 18:18:34 Sven Eckelmann wrote:
> The Makefile tries to find a version number which describes the state of
> the version somebody compiles. Currently this can only be a subversion
> revision. This must also be done for git as it is used to prepare the
> actual releases.

Applied in revision 1722 and 1723.

Thanks,
Marek

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-24 15:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-21 16:18 [B.A.T.M.A.N.] [PATCH 1/2] batctl: Add support for git revision string Sven Eckelmann
2010-06-21 16:18 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: " Sven Eckelmann
2010-06-24 15:37 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: " Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).