From 5325a1c01dbe3a2b6d0eaeb9fc794ae8be2c88df Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 4 Oct 2009 15:57:33 +0200 Subject: [PATCH] Put the git version into all executables. This patch changes the -V output of all executables to print also the git version which was used to make the executable. The idea and the GIT-VERSION_GEN script was taken from git.git. It also adds a VERSION file to the generated tarball. If this file exists, its content is used as the version info rather than calling git to obtain this info. This way, even if paraslash is built from a tarball, the executables still contain the git version the tarball was generated from. --- GIT-VERSION-GEN | 45 +++++++++++++++++++++++++++++++++++++++++++++ Makefile.in | 10 +++++++++- NEWS | 2 ++ para.h | 5 +++-- 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100755 GIT-VERSION-GEN diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN new file mode 100755 index 00000000..a64d7961 --- /dev/null +++ b/GIT-VERSION-GEN @@ -0,0 +1,45 @@ +#!/bin/sh + +if test $# -ne 1; then + echo >&2 "usage: $0 " + exit 1 +fi + +GVF="$1" +DEF_VER="unnamed_version" + +LF=' +' + +# First see if there is a version file (included in release tarballs), +# then try git-describe, then default. +if test -f VERSION +then + VN=$(cat VERSION) || VN="$DEF_VER" +elif test -d .git -o -f .git && + VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && + case "$VN" in + *$LF*) (exit 1) ;; + v[0-9]*) + git update-index -q --refresh + test -z "$(git diff-index --name-only HEAD --)" || + VN="$VN-dirty" ;; + esac +then + VN=$(echo "$VN" | sed -e 's/-/./g'); +else + VN="$DEF_VER" +fi + +VN=$(expr "$VN" : v*'\(.*\)') + +if test -r $GVF +then + VC=$(sed -e 's/^GIT_VERSION = //' <$GVF) +else + VC=unset +fi +test "$VN" = "$VC" || { + echo >&2 "GIT_VERSION = $VN" + echo "GIT_VERSION = $VN" >$GVF +} diff --git a/Makefile.in b/Makefile.in index d71c0c9a..f184546b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,6 +59,7 @@ CPPFLAGS += @arch_cppflags@ CPPFLAGS += -I/usr/local/include CPPFLAGS += -I$(cmdline_dir) CPPFLAGS += @osl_cppflags@ +CPPFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"' BINARIES = para_server para_client para_audioc para_recv \ para_filter para_write para_afh @extra_binaries@ @@ -84,11 +85,17 @@ tarball_delete := $(addprefix $(tarball_pfx)/,\ $(ggo_dir) skencil) tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2 -.PHONY: all clean distclean maintainer-clean install man tarball +.PHONY: all clean distclean maintainer-clean install man tarball\ + .FORCE-GIT-VERSION-FILE all: $(BINARIES) $(man_pages) man: $(man_pages) tarball: $(tarball) +GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE + @./GIT-VERSION-GEN GIT-VERSION-FILE +-include GIT-VERSION-FILE +$(BINARIES): GIT-VERSION-FILE + -include $(ggo_dir)/makefile %_command_list.c: %.cmd @@ -230,6 +237,7 @@ $(tarball): $(cmdline_generated) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \ | tar --delete $(tarball_delete) > $(tarball_pfx).tar mkdir -p $(tarball_pfx)/$(cmdline_dir) + echo $(GIT_VERSION) > $(tarball_pfx)/VERSION cp -r $(autocrap) $(tarball_pfx) cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir) tar rf $(tarball_pfx).tar $(tarball_pfx)/* diff --git a/NEWS b/NEWS index cf24914c..c5b1f678 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ provided for conversion of the 0.3 database to the new 0.4 format. - stronger crypto for client authentication - the database code has been moved to a library - improved status item handling + - cleanup of the build system + - The "-V" option now also prints the git version - the new parser-friendly listing mode for the ls and stat commands - mandatory rc4 encryption - major audio format handler cleanups diff --git a/para.h b/para.h index c4c73a3f..454d736a 100644 --- a/para.h +++ b/para.h @@ -131,8 +131,9 @@ va_end(argp); \ } -/** version text used by various commands if -V switch was given */ -#define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION " (" CODENAME ")" "\n" \ +/** Version text used by various commands if -V switch was given. */ +#define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION \ + " (" GIT_VERSION ": " CODENAME ")" "\n" \ "Copyright (C) 2009 Andre Noll\n" \ "This is free software with ABSOLUTELY NO WARRANTY." \ " See COPYING for details.\n" \ -- 2.30.2