From 636610432a8dc633812d323d3e85b639aabb3302 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 31 May 2008 11:53:51 -0500 Subject: Allow GIT version to be used in pacman builds Add a new configure flag, --enable-git-version, that allows the output of 'git describe' to be used in the version string associated with this package. This could aid in debugging for users that are using a development version of pacman and we should be able to figure out which cut of code they are using. Sample output: $ pacman --version Pacman v3.1.4-190-g4cfa-dirty - libalpm v2.3.1 $ makepkg --version makepkg (pacman) 3.1.4-190-g5861-dirty Signed-off-by: Dan McGee --- configure.ac | 47 ++++++++++++++++++++++++++++++++--------------- scripts/Makefile.am | 9 ++++++++- src/pacman/Makefile.am | 5 +++++ src/pacman/pacman.c | 6 ++++++ 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 27efd170..ab5a3744 100644 --- a/configure.ac +++ b/configure.ac @@ -40,28 +40,19 @@ AC_PREREQ(2.60) # # Bugfix releases: # pacman_version_micro += 1 -# -# pacman_version_suffix should be similar to one of the following: -# For beta releases: [beta2] -# For code under development: [devel] -# For production releases: [] m4_define([lib_current], [5]) m4_define([lib_revision], [1]) m4_define([lib_age], [3]) m4_define([pacman_version_major], [3]) -m4_define([pacman_version_minor], [2]) -m4_define([pacman_version_micro], [0]) -m4_define([pacman_version_suffix], [devel]) +m4_define([pacman_version_minor], [1]) +m4_define([pacman_version_micro], [4]) m4_define([pacman_version], [pacman_version_major.pacman_version_minor.pacman_version_micro]) -m4_define([pacman_display_version], - pacman_version[]m4_ifdef([pacman_version_suffix],[pacman_version_suffix])) # Autoconf initialization -AC_INIT([Pacman Package Manager], [pacman_display_version], - [pacman-dev@archlinux.org], [pacman]) +AC_INIT([pacman], [pacman_version], [pacman-dev@archlinux.org]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) @@ -122,6 +113,12 @@ AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [enable debugging support]), [debug=$enableval], [debug=no]) +# Help line for using git version in pacman version string +AC_ARG_ENABLE(git-version, + AS_HELP_STRING([--enable-git-version], + [enable use of git version in version string if available]), + [wantgitver=$enableval], [wantgitver=no]) + # Help line for pacman.static AC_ARG_ENABLE(pacman-static, AS_HELP_STRING([--disable-pacman-static], [do not build static version of pacman]), @@ -259,9 +256,9 @@ fi AM_CONDITIONAL(WANT_DOC, test "x$wantdoc" = "xyes") # Check for doxygen support and status +AC_CHECK_PROGS([DOXYGEN], [doxygen]) AC_MSG_CHECKING([for doxygen]) if test "x$wantdoxygen" = "xyes" ; then - AC_CHECK_PROGS([DOXYGEN], [doxygen]) if test $DOXYGEN ; then AC_MSG_RESULT([yes]) usedoxygen=yes @@ -276,9 +273,9 @@ fi AM_CONDITIONAL(USE_DOXYGEN, test "x$usedoxygen" = "xyes") # Check for asciidoc support and status +AC_CHECK_PROGS([ASCIIDOC], [asciidoc]) AC_MSG_CHECKING([for asciidoc]) if test "x$wantasciidoc" = "xyes" ; then - AC_CHECK_PROGS([ASCIIDOC], [asciidoc]) if test $ASCIIDOC ; then AC_MSG_RESULT([yes]) useasciidoc=yes @@ -308,6 +305,25 @@ else CFLAGS="$CFLAGS -Wall" fi +# Enable or disable use of git version in pacman version string +AC_CHECK_PROGS([GIT], [git]) +AC_CHECK_FILE([.git/], hasgitdir=yes) +AC_MSG_CHECKING(whether to use git version if available) +if test "x$wantgitver" = "xyes" ; then + if test $GIT -a "x$hasgitdir" = "xyes"; then + AC_MSG_RESULT([yes]) + usegitver=yes + AC_DEFINE([USE_GIT_VERSION], , [Use GIT version in version string]) + else + AC_MSG_RESULT([no, git or .git dir missing]) + usegitver=no + fi +else + AC_MSG_RESULT([no, disabled by configure]) + usegitver=no +fi +AM_CONDITIONAL(USE_GIT_VERSION, test "x$usegitver" = "xyes") + # Enable or disable inclusion of pacman.static AC_MSG_CHECKING(whether to build pacman.static) if test "x$pacmanstatic" = "xyes" ; then @@ -347,7 +363,7 @@ Makefile AC_OUTPUT echo " -pacman_display_version: +${PACKAGE_NAME}: Build information: source code location : ${srcdir} @@ -368,6 +384,7 @@ pacman_display_version: libalpm version : ${LIB_VERSION} libalpm version info : ${LIB_VERSION_INFO} pacman version : ${PACKAGE_VERSION} + using git version : ${usegitver} Directory and file information: root working directory : ${ROOTDIR} diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 3185a476..e6c051b0 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -18,13 +18,20 @@ EXTRA_DIST = \ # Files that should be removed, but which Automake does not know. MOSTLYCLEANFILES = $(bin_SCRIPTS) *.tmp +if USE_GIT_VERSION +GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 | sed s/^v//')-dirty +REAL_PACKAGE_VERSION = $(GIT_VERSION) +else +REAL_PACKAGE_VERSION = $(PACKAGE_VERSION) +endif + #### Taken from the autoconf scripts Makefile.am #### edit = sed \ -e 's|@localedir[@]|$(localedir)|g' \ -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ -e 's|@localstatedir[@]|$(localstatedir)|g' \ -e 's|@prefix[@]|$(prefix)|g' \ - -e 's|@PACKAGE_VERSION[@]|$(PACKAGE_VERSION)|g' \ + -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \ -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \ -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ -e 's|@DBEXT[@]|$(DBEXT)|g' \ diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am index 5d6fef3c..e5f8cb36 100644 --- a/src/pacman/Makefile.am +++ b/src/pacman/Makefile.am @@ -21,6 +21,11 @@ INCLUDES = -I$(top_srcdir)/lib/libalpm AM_CFLAGS = -pedantic -D_GNU_SOURCE +if USE_GIT_VERSION +GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 | sed s/^v//')-dirty +DEFS += -DGIT_VERSION=\"$(GIT_VERSION)\" +endif + pacman_SOURCES = \ conf.h conf.c \ deptest.c \ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 66fafa10..0ce9c1e8 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -19,6 +19,12 @@ #include "config.h" +/* special handling of package version for GIT */ +#if defined(GIT_VERSION) +#undef PACKAGE_VERSION +#define PACKAGE_VERSION GIT_VERSION +#endif + #include /* atoi */ #include #include -- cgit v1.2.3-24-g4f1b