[parted-devel] [PATCH] Make inter-release --version output more useful.

Jim Meyering jim at meyering.net
Tue Dec 18 11:25:11 UTC 2007


This is the same approach to version-numbering that started
with git.git.  Most of the infrastructure comes verbatim from
coreutils, and is now also used in the upstream autoconf repo.

The idea is to get the version string directly from git.
This eliminates the pre/post-release requirement to manually
sync configure.ac with the latest tag.

One detail: it'd be relatively expensive to regenerate a new
version string after every commit, since doing that now requires
to run autoconf (see the new GNUmakefile rules).  I've compromised
in making it so when you run e.g., "make dist" or "make beta",
that triggers an autoconf run to regenerated the version string.

I'll push this later today if no one objects.

---------------------
Make inter-release --version output more useful.

Now, each unofficial build has a version "number" like 1.8.8.1.19-58dd,
which indicates that it is built using the 19th change set
(in _some_ repository) following the "v1.8.8.1" tag, and that 58dd
is a prefix of the commit SHA1.
* configure.ac: Run it to set the version.
(PED_MAJOR_VERSION): Derive from $PACKAGE_VERSION.
(PED_MINOR_VERSION): Likewise.
(PED_MICRO_VERSION): Likewise.
Remove the test that would ensure $PACKAGE_VERSION != $PED_VERSION,
now that the latter is derived from the former.
* Makefile.am (dist-hook): Arrange so that .version appears only
in distribution tarballs, never in a checked-out repository.
* .gitignore: Add .version here, too.  Just in case.
* lib/.gitignore: Remove now-generated (by bootstrap) file.
* build-aux/.gitignore: Likewise.

Ensure that $(VERSION) is up to date for dist-related targets.
* GNUmakefile: Arrange to rerun autoconf, if the version reported by
git-version-gen doesn't match $(VERSION), but only for dist targets.

Signed-off-by: Jim Meyering <meyering at redhat.com>
---
 .gitignore           |    1 +
 GNUmakefile          |   28 +++++++++++----
 Makefile.am          |    5 +++
 bootstrap.conf       |    1 +
 build-aux/.gitignore |   14 -------
 configure.ac         |   29 ++++++++++-----
 lib/.gitignore       |   94 --------------------------------------------------
 7 files changed, 47 insertions(+), 125 deletions(-)
 delete mode 100644 build-aux/.gitignore
 delete mode 100644 lib/.gitignore

diff --git a/.gitignore b/.gitignore
index 1bcbf96..bb569c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 *~
 .deps
 .libs
+.version
 ABOUT-NLS
 ChangeLog
 INSTALL
diff --git a/GNUmakefile b/GNUmakefile
index 454fce8..3dc6f15 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -4,20 +4,20 @@
 # It is necessary if you want to build targets usually of interest
 # only to the maintainer.

-# Copyright (C) 2001, 2003, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2006-2007 Free Software Foundation, Inc.
 #
-# This program is free software; you can redistribute it and/or modify
+# 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 3 of the License, or
+# the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.

 # Systems where /bin/sh is not the default shell need this.  The $(shell)
 # command below won't work with e.g. stock DOS/Windows shells.
@@ -39,6 +39,20 @@ ifeq ($(have-Makefile),yes)
 export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner

 include Makefile
+
+# Ensure that $(VERSION) is up to date for dist-related targets, but not
+# for others: running autoreconf and recompiling everything isn't cheap.
+ifeq (0,$(MAKELEVEL))
+  _is-dist-target = $(filter dist% alpha beta major,$(MAKECMDGOALS))
+  ifneq (,$(_is-dist-target))
+    _curr-ver := $(shell build-aux/git-version-gen .version)
+    ifneq ($(_curr-ver),$(VERSION))
+      $(info INFO: running autoreconf for new version string: $(_curr-ver))
+      dummy := $(shell rm -rf autom4te.cache; autoreconf)
+    endif
+  endif
+endif
+
 include $(srcdir)/Makefile.cfg
 include $(srcdir)/Makefile.maint

diff --git a/Makefile.am b/Makefile.am
index 1aba177..d5b722a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -72,3 +72,8 @@ MAINTAINERCLEANFILES += \
   INSTALL       \
   aclocal.m4    \
   configure
+
+# Arrange so that .version appears only in distribution tarballs,
+# never in a checked-out repository.
+dist-hook:
+	echo $(VERSION) > $(distdir)/.version
diff --git a/bootstrap.conf b/bootstrap.conf
index 8c2fce4..6d23209 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -41,6 +41,7 @@ gnulib_modules="
 	closeout
 	fdl
 	gettext
+	git-version-gen
 	gnupload
 	inttypes
 	lib-ignore
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
deleted file mode 100644
index a11d351..0000000
--- a/build-aux/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-announce-gen
-compile
-config.guess
-config.rpath
-config.sub
-depcomp
-gnupload
-install-sh
-link-warning.h
-ltmain.sh
-mdate-sh
-missing
-mkinstalldirs
-texinfo.tex
diff --git a/configure.ac b/configure.ac
index d156a56..693b979 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,11 @@ dnl
 dnl This file may be modified and/or distributed without restriction.

 AC_PREREQ(2.61)
-AC_INIT([GNU parted],[1.9.0],[bug-parted at gnu.org])
+AC_INIT([GNU parted], m4_esyscmd([build-aux/git-version-gen .version]),
+        [bug-parted at gnu.org])
+
+# When the most recent signed tag is v1.8.8.1,
+# the above might set e.g., PACKAGE_VERSION='1.8.8.1.1-0bfc'

 AC_CONFIG_SRCDIR(include/parted/parted.h)

@@ -22,9 +26,19 @@ dnl if any functions have been added, set PED_INTERFACE_AGE to 0.
 dnl if backwards compatibility has been broken (eg. functions removed,
 dnl function signatures changed),
 dnl set PED_BINARY_AGE _and_ PED_INTERFACE_AGE to 0.
-PED_MAJOR_VERSION=1
-PED_MINOR_VERSION=9
-PED_MICRO_VERSION=0
+
+# Derive these numbers from $PACKAGE_VERSION, which is set
+# when autoconf creates configure (see AC_INIT, above).
+PED_MAJOR_VERSION=`echo "$PACKAGE_VERSION"|sed 's/\..*//'`
+PED_MINOR_VERSION=`echo "$PACKAGE_VERSION"|sed 's/^[0-9][0-9]*\.//;s/\..*//'`
+case $PACKAGE_VERSION in
+  *.*.*.*.*)
+    PED_MICRO_VERSION=`echo "$PACKAGE_VERSION" \
+      | sed 's/^[^.]*\.[^.]*\.//;s/\..*//'`
+    ;;
+  *) PED_MICRO_VERSION=0;;
+esac
+
 PED_INTERFACE_AGE=0
 PED_BINARY_AGE=0
 PED_VERSION_SUFFIX=
@@ -39,11 +53,6 @@ AC_SUBST(LT_CURRENT)
 AC_SUBST(LT_REVISION)
 AC_SUBST(LT_AGE)

-# Ensure that the PED_*-specified version is the same as the literal
-# in the AC_INIT line, above.
-test $PACKAGE_VERSION = $PED_VERSION ||
-  AC_MSG_ERROR(configure.ac: version mismatch: $PACKAGE_VERSION != $PED_VERSION)
-
 AM_INIT_AUTOMAKE([1.10 dist-bzip2])

 AC_CANONICAL_HOST
@@ -501,7 +510,7 @@ AC_CHECK_FUNCS(getuid)

 dnl NOTE: We need to remove the gl_cv_ignore_unused_libraries flag if we
 dnl detected one earlier.  libreadline on some platforms (e.g., RHEL and
-dnl Fedora) is left with 
+dnl Fedora) is left with
 if test "$with_readline" = yes; then
 	OLD_LIBS="$LIBS"
 	LIBS="$LIBS $PARTED_LIBS -lreadline"
diff --git a/lib/.gitignore b/lib/.gitignore
deleted file mode 100644
index 25bd935..0000000
--- a/lib/.gitignore
+++ /dev/null
@@ -1,94 +0,0 @@
-*.la
-*.lo
-__fpending.c
-__fpending.h
-alloca.c
-alloca.h
-alloca_.h
-atexit.c
-basename.c
-calloc.c
-charset.alias
-close-stream.c
-close-stream.h
-closeout.c
-closeout.h
-config.charset
-config.h.in
-configmake.h
-dirname.c
-dirname.h
-error.c
-error.h
-exitfail.c
-exitfail.h
-free.c
-full-write.c
-full-write.h
-getopt.c
-getopt.h
-getopt1.c
-getopt_.h
-getopt_int.h
-gettext.h
-gnulib.mk
-inttypes.h
-inttypes_.h
-localcharset.c
-localcharset.h
-long-options.c
-long-options.h
-malloc.c
-memchr.c
-memcmp.c
-memcpy.c
-memmove.c
-memset.c
-quotearg.c
-quotearg.h
-realloc.c
-ref-add.sed
-ref-add.sin
-ref-del.sed
-ref-del.sin
-regcomp.c
-regex.c
-regex.h
-regex_internal.c
-regex_internal.h
-regexec.c
-rename.c
-rpmatch.c
-safe-read.c
-safe-read.h
-safe-write.c
-safe-write.h
-stdbool.h
-stdbool_.h
-stdint.h
-stdint_.h
-stdlib.h
-stdlib_.h
-strcspn.c
-string.h
-string_.h
-stripslash.c
-strndup.c
-strnlen.c
-strtod.c
-strtol.c
-unistd.h
-unistd_.h
-utime.c
-version-etc-fsf.c
-version-etc.c
-version-etc.h
-wchar.h
-wchar_.h
-wctype.h
-wctype_.h
-xalloc-die.c
-xalloc.h
-xmalloc.c
-xstrndup.c
-xstrndup.h
-- 
1.5.4.rc0.69.g454b




More information about the parted-devel mailing list