8554a5990596f7f2b4395f946dedb77b76062b98
[sahlberg/ctdb.git] / packaging / RPM / makerpms.sh
1 #!/bin/sh
2 # Copyright (C) John H Terpstra 1998-2002
3 #               Gerald (Jerry) Carter 2003
4 #               Jim McDonough 2007
5 #               Andrew Tridgell 2007
6
7 # The following allows environment variables to override the target directories
8 #   the alternative is to have a file in your home directory calles .rpmmacros
9 #   containing the following:
10 #   %_topdir  /home/mylogin/redhat
11 #
12 # Note: Under this directory rpm expects to find the same directories that are under the
13 #   /usr/src/redhat directory
14 #
15
16 EXTRA_OPTIONS="$1"
17
18 [ -d packaging ] || {
19     echo "Must run this from the ctdb directory"
20     exit 1
21 }
22
23
24 SPECDIR=`rpm --eval %_specdir`
25 SRCDIR=`rpm --eval %_sourcedir`
26
27 # At this point the SPECDIR and SRCDIR vaiables must have a value!
28
29 VERSION='1.0'
30 REVISION=''
31 SPECFILE="ctdb.spec"
32 RPMBUILD="rpmbuild"
33
34 echo -n "Creating ctdb-${VERSION}.tar.gz ... "
35 git archive --prefix=ctdb-${VERSION} | gzip -9 --rsyncable > ${SRCDIR}/ctdb-${VERSION}.tar.gz
36 echo "Done."
37 if [ $? -ne 0 ]; then
38         echo "Build failed!"
39         exit 1
40 fi
41
42
43 ##
44 ## copy additional source files
45 ##
46 cp -p packaging/RPM/ctdb.spec ${SPECDIR}
47
48 ##
49 ## Build
50 ##
51 echo "$(basename $0): Getting Ready to build release package"
52 cd ${SPECDIR}
53 ${RPMBUILD} -ba --clean --rmsource $EXTRA_OPTIONS $SPECFILE || exit 1
54
55 echo "$(basename $0): Done."
56
57 exit 0