Fixed a compiler warning.
[Samba/nivanova.git] / packaging / RHEL-CTDB / makerpms.sh
blob50fa96c2b11248827c7d496bfad556b8ed54abf8
1 #!/bin/sh
2 # Copyright (C) John H Terpstra 1998-2002
3 # Copyright (C) Gerald (Jerry) Carter 2003
4 # Copyright (C) Michael Adam 2008
6 # Script to build RPMs for RHEL from inside a git checkout.
8 # The following allows environment variables to override the target directories
9 # the alternative is to have a file in your home directory calles .rpmmacros
10 # containing the following:
11 # %_topdir /home/mylogin/redhat
13 # Note: Under this directory rpm expects to find the same directories
14 # that are under the /usr/src/redhat directory.
16 # Set DOCS_TARBALL to the path to a docs release tarball in .tar.bz2 format.
18 # extra options passed to rpmbuild
19 EXTRA_OPTIONS="$1"
21 RPMSPECDIR=`rpm --eval %_specdir`
22 RPMSRCDIR=`rpm --eval %_sourcedir`
24 # At this point the RPMSPECDIR and RPMSRCDIR variables must have a value!
26 DIRNAME=$(dirname $0)
27 TOPDIR=${DIRNAME}/../..
29 SPECFILE="samba.spec"
30 DOCS="docs.tar.bz2"
31 RPMVER=`rpm --version | awk '{print $3}'`
32 RPM="rpmbuild"
35 ## Check the RPM version (paranoid)
37 case $RPMVER in
38 4*)
39 echo "Supported RPM version [$RPMVER]"
42 echo "Unknown RPM version: `rpm --version`"
43 exit 1
45 esac
48 ## determine the samba version and create the SPEC file
50 ${DIRNAME}/makespec.sh
51 RC=$?
52 if [ $RC -ne 0 ]; then
53 exit ${RC}
56 RELEASE=$(grep ^Release ${DIRNAME}/${SPECFILE} | sed -e 's/^Release:\ \+//')
57 VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//')
60 ## create the tarball
62 pushd ${TOPDIR}
63 echo -n "Creating samba-${VERSION}.tar.bz2 ... "
64 git archive --prefix=samba-${VERSION}/ HEAD | bzip2 > ${RPMSRCDIR}/samba-${VERSION}.tar.bz2
65 RC=$?
66 popd
67 echo "Done."
68 if [ $RC -ne 0 ]; then
69 echo "Build failed!"
70 exit 1
75 ## copy additional source files
77 if [ "x${DOCS_TARBALL}" != "x" ] && [ -f ${DOCS_TARBALL} ]; then
78 cp ${DOCS_TARBALL} ${RPMSRCDIR}/${DOCS}
81 pushd ${DIRNAME}
83 chmod 755 setup/filter-requires-samba.sh
84 tar --exclude=.svn -jcvf - setup > ${RPMSRCDIR}/setup.tar.bz2
86 cp -p ${SPECFILE} ${RPMSPECDIR}
88 popd
91 ## Build
93 echo "$(basename $0): Getting Ready to build release package"
94 pushd ${RPMSPECDIR}
95 ${RPM} -ba $EXTRA_OPTIONS $SPECFILE
96 if [ "x$?" = "x0" ] && [ `arch` = "x86_64" ]; then
97 echo "Building 32 bit winbind libs"
98 # hi ho, a hacking we will go ...
99 ln -sf /lib/libcom_err.so.2 /lib/libcom_err.so
100 ln -sf /lib/libuuid.so.1 /lib/libuuid.so
101 ${RPM} -ba --rebuild --target=i386 $SPECFILE
104 popd
106 echo "$(basename $0): Done."