1#!/bin/sh 2# 3# Copyright (C) Michael Adam 2008 4# 5# Script to determine the samba version and create the SPEC file from template 6 7DIRNAME=$(dirname $0) 8TOPDIR=${DIRNAME}/../.. 9SRCDIR=${TOPDIR}/source3 10VERSION_H=${SRCDIR}/include/version.h 11SPECFILE=${DIRNAME}/samba.spec 12 13## 14## determine the samba version and create the SPEC file 15## 16pushd ${SRCDIR} 17./script/mkversion.sh 18popd 19if [ ! -f ${VERSION_H} ] ; then 20 echo "Error creating version.h" 21 exit 1 22fi 23 24VERSION=`grep "^#define SAMBA_VERSION_OFFICIAL_STRING " ${VERSION_H} | awk '{print $3}'` 25vendor_version=`grep "^#define SAMBA_VERSION_VENDOR_SUFFIX " ${VERSION_H} | awk '{print $3}'` 26if test "x${vendor_version}" != "x" ; then 27 VERSION="${VERSION}-${vendor_version}" 28fi 29vendor_patch=`grep "^#define SAMBA_VERSION_VENDOR_PATCH " ${VERSION_H} | awk '{print $3}'` 30if test "x${vendor_patch}" != "x" ; then 31 VERSION="${VERSION}-${vendor_patch}" 32fi 33VERSION=`echo ${VERSION} | sed 's/-/_/g'` 34VERSION=`echo ${VERSION} | sed 's/\"//g'` 35echo "VERSION: ${VERSION}" 36 37# to build a release-rpm, set USE_GITHASH="no" 38# in the environmet 39# 40if test "x$USE_GITHASH" = "xno" ; then 41 GITHASH="" 42 echo "GITHASH: not used" 43else 44 GITHASH=".$(git log --pretty=format:%h -1)" 45 echo "GITHASH: ${GITHASH}" 46fi 47 48sed -e s/PVERSION/${VERSION}/g \ 49 -e s/GITHASH/${GITHASH}/g \ 50 < ${SPECFILE}.tmpl \ 51 > ${SPECFILE} 52 53