packaging(RHEL-CTDB): check for success of x86_64 build before building i386
[gd/samba-autobuild/.git] / packaging / RHEL-CTDB / makerpms.sh
1 #!/bin/sh
2 # Copyright (C) John H Terpstra 1998-2002
3 #               Gerald (Jerry) Carter 2003
4
5 # The following allows environment variables to override the target directories
6 #   the alternative is to have a file in your home directory calles .rpmmacros
7 #   containing the following:
8 #   %_topdir  /home/mylogin/redhat
9 #
10 # Note: Under this directory rpm expects to find the same directories that are under the
11 #   /usr/src/redhat directory
12 #
13
14 # set DOCS_TARBALL to the path to a docs release tarball in .tar.bz2 format
15
16 # extra options passed to rpmbuild
17 EXTRA_OPTIONS="$1"
18
19 SPECDIR=`rpm --eval %_specdir`
20 SRCDIR=`rpm --eval %_sourcedir`
21
22 # At this point the SPECDIR and SRCDIR variables must have a value!
23
24 VERSION='3.3.0'
25 REVISION='ctdb'
26 SPECFILE="samba.spec"
27 DOCS="docs.tar.bz2"
28 RPMVER=`rpm --version | awk '{print $3}'`
29 RPM="rpmbuild"
30
31 ##
32 ## Check the RPM version (paranoid)
33 ##
34 case $RPMVER in
35     4*)
36        echo "Supported RPM version [$RPMVER]"
37        ;;
38     *)
39        echo "Unknown RPM version: `rpm --version`"
40        exit 1
41        ;;
42 esac
43
44 DIRNAME=$(dirname $0)
45
46 pushd ${DIRNAME}/../..
47 echo -n "Creating samba-${VERSION}.tar.bz2 ... "
48 git archive --prefix=samba-${VERSION}/ HEAD | bzip2 > ${SRCDIR}/samba-${VERSION}.tar.bz2
49 RC=$?
50 popd
51 echo "Done."
52 if [ $RC -ne 0 ]; then
53         echo "Build failed!"
54         exit 1
55 fi
56
57
58 ##
59 ## copy additional source files
60 ##
61 if [ "x${DOCS_TARBALL}" != "x" ] && [ -f ${DOCS_TARBALL} ]; then
62     cp ${DOCS_TARBALL} ${SRCDIR}/${DOCS}
63 fi
64
65 pushd ${DIRNAME}
66
67 chmod 755 setup/filter-requires-samba.sh
68 tar --exclude=.svn -jcvf - setup > ${SRCDIR}/setup.tar.bz2
69
70 cp -p ${SPECFILE} ${SPECDIR}
71
72 popd
73
74 ##
75 ## Build
76 ##
77 echo "$(basename $0): Getting Ready to build release package"
78 pushd ${SPECDIR}
79 ${RPM} -ba $EXTRA_OPTIONS $SPECFILE
80 if [ "x$?" = "x0" ] && [ `arch` = "x86_64" ]; then
81     echo "Building 32 bit winbind libs"
82     # hi ho, a hacking we will go ...
83     ln -sf /lib/libcom_err.so.2 /lib/libcom_err.so
84     ln -sf /lib/libuuid.so.1 /lib/libuuid.so
85     ${RPM} -ba --rebuild --target=i386 $SPECFILE
86 fi
87
88 popd
89
90 echo "$(basename $0): Done."
91