packaging(RHEL-CTDB): refactor creation of spec file from template out
[abartlet/samba.git/.git] / packaging / RHEL-CTDB / makerpms.sh
index 5e1c7d52c8a5c9b2ecbae886444614acc5bf31e2..c85b865f790092e9b0d11f7d00a633e8e4e7acc9 100755 (executable)
@@ -3,16 +3,17 @@
 # Copyright (C) Gerald (Jerry) Carter 2003
 # Copyright (C) Michael Adam 2008
 
+# Script to build RPMs for RHEL from inside a git checkout.
+
 # The following allows environment variables to override the target directories
 #   the alternative is to have a file in your home directory calles .rpmmacros
 #   containing the following:
 #   %_topdir  /home/mylogin/redhat
 #
-# Note: Under this directory rpm expects to find the same directories that are under the
-#   /usr/src/redhat directory
-#
+# Note: Under this directory rpm expects to find the same directories
+# that are under the /usr/src/redhat directory.
 
-# set DOCS_TARBALL to the path to a docs release tarball in .tar.bz2 format
+# Set DOCS_TARBALL to the path to a docs release tarball in .tar.bz2 format.
 
 # extra options passed to rpmbuild
 EXTRA_OPTIONS="$1"
@@ -24,8 +25,6 @@ RPMSRCDIR=`rpm --eval %_sourcedir`
 
 DIRNAME=$(dirname $0)
 TOPDIR=${DIRNAME}/../..
-SRCDIR=${TOPDIR}/source
-VERSION_H=${SRCDIR}/include/version.h
 
 SPECFILE="samba.spec"
 DOCS="docs.tar.bz2"
@@ -48,24 +47,14 @@ esac
 ##
 ## determine the samba version and create the SPEC file
 ##
-pushd ${SRCDIR}
-./script/mkversion.sh
-popd
-if [ ! -f ${VERSION_H} ] ; then
-       echo "Error creating version.h"
-       exit 1
+${DIRNAME}/makespec.sh
+RC=$?
+if [ $RC -ne 0 ]; then
+       exit ${RC}
 fi
 
-VERSION=`grep SAMBA_VERSION_OFFICIAL_STRING ${VERSION_H} | awk '{print $3}'`
-vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX ${VERSION_H} | awk '{print $3}'`
-if test "x${vendor_version}"  != "x" ; then
-       VERSION="${VERSION}-${vendor_version}"
-fi
-VERSION=`echo ${VERSION} | sed 's/\"//g'`
-echo "VERSION: ${VERSION}"
-sed -e s/PVERSION/${VERSION}/g \
-       < ${DIRNAME}/${SPECFILE}.tmpl \
-       > ${DIRNAME}/${SPECFILE}
+RELEASE=$(grep ^Release ${DIRNAME}${SPECFILE} | sed -e 's/^Release:\ \+//')
+VERSION=$(grep ^Version ${DIRNAME}${SPECFILE} | sed -e 's/^Version:\ \+//')
 
 ##
 ## create the tarball