]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Put the git version into all executables.
authorAndre Noll <maan@systemlinux.org>
Sun, 4 Oct 2009 13:57:33 +0000 (15:57 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 4 Oct 2009 13:57:33 +0000 (15:57 +0200)
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 [new file with mode: 0755]
Makefile.in
NEWS
para.h

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
new file mode 100755 (executable)
index 0000000..a64d796
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+if test $# -ne 1; then
+       echo >&2 "usage: $0 <version file>"
+       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
+}
index d71c0c9a2c8b34cd7cb4750b1d6f213970ce8789..f184546b8ea22776a91f502a1c49f321b1fecbf7 100644 (file)
@@ -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 cf24914c8461bd0ad176d74c70e4dc8f34fd266b..c5b1f6782c33a084b0724744f6582ee001330719 100644 (file)
--- 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 c4c73a3f37661565037fc72ffbf03dc9bef8f20b..454d736a1d565e4ef84fc0226f748ca41fa4a256 100644 (file)
--- a/para.h
+++ b/para.h
                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" \