From: Simon Wilkinson Date: Tue, 12 Jul 2011 16:58:16 +0000 (+0100) Subject: rpms: Use git version information X-Git-Tag: openafs-devel-1_7_1~302 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=6a27e228bac196abada96f34ca9cd57f32e31f5c rpms: Use git version information Use the git version information when building RPMS, rather than hard coding it into configure.ac. Change-Id: I477629b4102f48a9669ff67aae429c08862a5afc Reviewed-on: http://gerrit.openafs.org/4983 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/configure-libafs.ac b/configure-libafs.ac index 6e11ba8..7e1429c 100644 --- a/configure-libafs.ac +++ b/configure-libafs.ac @@ -6,13 +6,8 @@ AM_INIT_AUTOMAKE AC_CONFIG_HEADER(src/config/afsconfig.h) MACOS_VERSION=1.5.76 -LINUX_PKGVER=1.5.76 -#LINUX_PKGREL=0.pre3 -LINUX_PKGREL=1.1 AC_SUBST(MACOS_VERSION) -AC_SUBST(LINUX_PKGVER) -AC_SUBST(LINUX_PKGREL) dnl If the user hasn't specified CFLAGS don't let configure pick -g -O2 AS_IF([test -z "$CFLAGS"], [CFLAGS=" "], []) diff --git a/configure.ac b/configure.ac index 764165e..0675a99 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,6 @@ AM_INIT_AUTOMAKE AC_CONFIG_HEADER(src/config/afsconfig.h) MACOS_VERSION=1.5.76 -LINUX_PKGVER=1.5.76 #LINUX_PKGREL=0.pre3 LINUX_PKGREL=1.1 @@ -18,8 +17,6 @@ if echo "$LINUX_PKGREL" | grep pre >/dev/null 2>/dev/null ; then fi AC_SUBST(MACOS_VERSION) -AC_SUBST(LINUX_PKGVER) -AC_SUBST(LINUX_PKGREL) AC_SUBST(DEB_PKGVER) dnl If the user hasn't specified CFLAGS don't let configure pick -g -O2 @@ -194,7 +191,6 @@ src/packaging/MacOS/OpenAFS.Description.plist \ src/packaging/MacOS/OpenAFS.Info.plist \ src/packaging/MacOS/OpenAFS.info \ src/packaging/MacOS/buildpkg.sh \ -src/packaging/RedHat/openafs.spec \ src/pam/Makefile \ src/platform/Makefile \ src/platform/${MKAFS_OSTYPE}/Makefile \ diff --git a/src/packaging/RedHat/makesrpm.pl b/src/packaging/RedHat/makesrpm.pl index 9da2de2..52bd88e 100755 --- a/src/packaging/RedHat/makesrpm.pl +++ b/src/packaging/RedHat/makesrpm.pl @@ -56,14 +56,6 @@ while(<$fh>) { $afsversion = $1; next; } - if (/LINUX_PKGVER=(.*)/) { - $linuxver = $1; - next; - } - if (/LINUX_PKGREL=(.*)/) { - $linuxrel = $1; - next; - } } undef $fh; @@ -71,9 +63,32 @@ if (not defined($afsversion)) { $afsversion = `"$srcdir/build-tools/git-version" "$srcdir"`; } +# Build the Linux version and release information from the package version +# We need to handle a number of varieties of package version - +# Normal: 1.7.0 +# Prereleases: 1.7.0pre1 +# Development trees: 1.7.0dev +# and RPMS which are built from trees midway between heads, such as +# 1.7.0-45-gabcdef or 1.7.0pre1-37-g12345 or 1.7.0dev-56-g98765 + +if ($afsversion=~m/(.*)(pre[0-9]+)/) { + $linuxver=$1; + $linuxrel="0.$2"; +} elsif ($afsversion=~m/(.*)dev/) { + $linuxver=$1; + $linuxrel="0.dev"; +} else { + $linuxver=$afsversion; + $linuxrel=1; +} + +if ($afsversion=~m/-([0-9]+)-(g[a-f0-9]+)$/) { + $linuxrel.=".$1.$2"; +} + # Figure out a major, minor and release so that we know which version we're # building, and therefore what the srpm is going to be called -$afsversion=~/([0-9]+)\.([0-9]+)\.([0-9]+)/; +$linuxver=~/([0-9]+)\.([0-9]+)\.([0-9]+)/; my $major = $1; my $minor = $2; my $patchlevel = $3; @@ -156,7 +171,7 @@ system("rpmbuild -bs --define \"dist %undefined\" ". or die "rpmbuild failed : $!\n"; # Copy it out to somewhere useful -if ($major > 1 || ($major == 1 && $minor >= 6)) { +if (!defined($major) || $major > 1 || ($major == 1 && $minor >= 6)) { File::Copy::copy("$tmpdir/rpmdir/SRPMS/openafs-$linuxver-$linuxrel.src.rpm", "openafs-$linuxver-$linuxrel.src.rpm") or die "Unable to copy output RPM : $!\n";