v3-4-ctdb: Fix debuginfo builds
[obnox/samba-ctdb.git] / packaging / RHEL-CTDB / makerpms.sh
1 #!/bin/sh
2 # Copyright (C) John H Terpstra 1998-2002
3 # Copyright (C) Gerald (Jerry) Carter 2003
4 # Copyright (C) Michael Adam 2008
5
6 # Script to build RPMs for RHEL from inside a git checkout.
7
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
12 #
13 # Note: Under this directory rpm expects to find the same directories
14 # that are under the /usr/src/redhat directory.
15
16 # extra options passed to rpmbuild
17 EXTRA_OPTIONS="$1"
18
19 RPMSPECDIR=`rpm --eval %_specdir`
20 RPMSRCDIR=`rpm --eval %_sourcedir`
21
22 # At this point the RPMSPECDIR and RPMSRCDIR variables must have a value!
23
24 DIRNAME=$(dirname $0)
25 TOPDIR=${DIRNAME}/../..
26
27 SPECFILE="samba.spec"
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 ##
45 ## Delete the old debuginfo remnants
46 ##
47
48 echo "Deleting samba-debuginfo and /usr/src/redhat/BUILD/samba*"
49 echo "Press Control-C if you want to quit"
50 sleep 10
51 echo "That was your chance... :-)"
52 rpm -e samba-debuginfo
53 rm -rf /usr/src/redhat/BUILD/samba*
54
55 ##
56 ## determine the samba version and create the SPEC file
57 ##
58 ${DIRNAME}/makespec.sh
59 RC=$?
60 if [ $RC -ne 0 ]; then
61         exit ${RC}
62 fi
63
64 RELEASE=$(grep ^Release ${DIRNAME}/${SPECFILE} | sed -e 's/^Release:\ \+//')
65 VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//')
66
67 ##
68 ## create the tarball
69 ##
70 pushd ${TOPDIR}
71 echo -n "Creating samba-${VERSION}.tar.bz2 ... "
72 git archive --prefix=samba-${VERSION}/ HEAD | bzip2 > ${RPMSRCDIR}/samba-${VERSION}.tar.bz2
73 RC=$?
74 popd
75 echo "Done."
76 if [ $RC -ne 0 ]; then
77         echo "Build failed!"
78         exit 1
79 fi
80
81
82 ##
83 ## copy additional source files
84 ##
85 pushd ${DIRNAME}
86
87 chmod 755 setup/filter-requires-samba.sh
88 tar --exclude=.svn -jcvf - setup > ${RPMSRCDIR}/setup.tar.bz2
89
90 cp -p ${SPECFILE} ${RPMSPECDIR}
91
92 popd
93
94 ##
95 ## some symlink fixes for building 32bit compat libs
96 ##
97 if [ `arch` = "x86_64" ]; then
98     ln -sf /lib/libcom_err.so.2 /lib/libcom_err.so
99     ln -sf /lib/libuuid.so.1 /lib/libuuid.so
100 fi
101
102 ##
103 ## Build
104 ##
105 echo "$(basename $0): Getting Ready to build release package"
106
107 pushd ${RPMSPECDIR}
108 ${RPM} -ba $EXTRA_OPTIONS $SPECFILE
109 popd
110
111 echo "$(basename $0): Done."
112