Browse Source

Generate the autoconf version from git

Use a new script to retrieve the version from a file shipped in the
released tarballs, or from the git repository using “git describe”
which will give an appropriate string in case of a snapshot, and add
a possible “-dirty” suffix if the working dir has uncommitted changes.
Guillem Jover 14 years ago
parent
commit
971e675a18
4 changed files with 47 additions and 1 deletions
  1. 2 0
      Makefile.am
  2. 1 1
      configure.ac
  3. 2 0
      debian/changelog
  4. 42 0
      get-version

+ 2 - 0
Makefile.am

@@ -24,6 +24,7 @@ EXTRA_DIST = \
 	.mailmap \
 	ChangeLog.old \
 	README.translators \
+	get-version \
 	doc/README.api \
 	doc/README.feature-removal-schedule \
 	doc/coding-style.txt \
@@ -67,6 +68,7 @@ ChangeLog:
 # If we create the dist tarball from the git repository, make sure
 # that we're not forgetting some files...
 dist-hook:
+	echo $(VERSION) >$(distdir)/.dist-version
 	if [ -e .git ]; then \
 		for file in `git ls-files | grep -v .gitignore`; do \
 			if [ ! -e "$(distdir)/$$file" ]; then \

+ 1 - 1
configure.ac

@@ -1,7 +1,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.60)
-AC_INIT([dpkg], [1.15.5~], [debian-dpkg@lists.debian.org])
+AC_INIT([dpkg], m4_esyscmd([./get-version]), [debian-dpkg@lists.debian.org])
 AC_CONFIG_SRCDIR([lib/dpkg/dpkg.h])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])

+ 2 - 0
debian/changelog

@@ -29,6 +29,8 @@ dpkg (1.15.5) UNRELEASED; urgency=low
   * Rework varbuf api to avoid increasing buffers indefinitely when adding
     content to them, regardless of space being already available.
   * Fix build macros to allow start-stop-deaemon to use TIOCNOTTY.
+  * Generate the autoconf version from git to make it easier to see when a
+    snapshot version is being used.
 
   [ Raphaël Hertzog ]
   * Add versioned dependency on base-files (>= 5.0.0) to dpkg-dev to ensure

+ 42 - 0
get-version

@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# get-version
+#
+# Copyright © 2009 Guillem Jover <guillem@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+
+if [ -f .dist-version ]; then
+  # Get the version from the file distributed in the tarball.
+  version=$(cat .dist-version)
+elif [ -d .git ]; then
+  # Ger the version from the git repository.
+  version=$(git describe --abbrev=4 HEAD 2>/dev/null)
+
+  # Check if we are on a dirty checkout.
+  git update-index --refresh -q >/dev/null
+  dirty=$(git diff-index --name-only HEAD 2>/dev/null)
+  if [ -n "$dirty" ]; then
+    version="$version-dirty"
+  fi
+else
+  echo "error: cannot get project version." 1>&2
+  exit 1
+fi
+
+# Use printf to avoid the trailing new line that m4_esyscmd would not handle.
+printf "$version"
+