r25570: move code of the locator child into its own file
[jpeach/samba.git] / packaging / RHEL4-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_DIR to the path to a release tarball docs dir in order to get docs
15 EXTRA_OPTIONS="$1"
16
17 SPECDIR=`rpm --eval %_specdir`
18 SRCDIR=`rpm --eval %_sourcedir`
19
20 # At this point the SPECDIR and SRCDIR vaiables must have a value!
21
22 USERID=`id -u`
23 GRPID=`id -g`
24 VERSION='3.0.25'
25 REVISION='ctdb'
26 SPECFILE="samba.spec"
27 RPMVER=`rpm --version | awk '{print $3}'`
28 RPM="rpmbuild"
29
30 ##
31 ## Check the RPM version (paranoid)
32 ##
33 case $RPMVER in
34     4*)
35        echo "Supported RPM version [$RPMVER]"
36        ;;
37     *)
38        echo "Unknown RPM version: `rpm --version`"
39        exit 1
40        ;;
41 esac
42
43 pushd .
44 cd ../../source
45 if [ -f Makefile ]; then 
46         make distclean
47 fi
48 popd
49
50 pushd .
51 cd ../../
52 SRCTREE=`basename $PWD`
53 if [ $DOCS_DIR ] && [ -d $DOCS_DIR ]; then
54     mv docs docs-orig
55     ln -s $DOCS_DIR docs
56 fi
57 cd ../
58 chown -R ${USERID}.${GRPID} $SRCTREE
59 if [ ! -d samba-${VERSION} ]; then
60         ln -s $SRCTREE samba-${VERSION} || exit 1
61 fi
62 echo -n "Creating samba-${VERSION}.tar.bz2 ... "
63 tar --exclude=.svn --exclude=.bzr --exclude=.bzrignore --exclude=docs-orig -chf - samba-${VERSION}/. | bzip2 > ${SRCDIR}/samba-${VERSION}.tar.bz2
64 echo "Done."
65 if [ $? -ne 0 ]; then
66         popd
67         cd ../../
68         # restore original structure if docs were specified
69         if [ ${DOCS_DIR} ] && [ -d docs-orig ] && [ -L docs ]; then
70             rm docs
71             mv docs-orig docs
72         fi
73         echo "Build failed!"
74         exit 1
75 fi
76
77 popd
78
79
80 ##
81 ## copy additional source files
82 ##
83 chmod 755 setup/filter-requires-samba.sh
84 tar --exclude=.svn -jcvf - setup > ${SRCDIR}/setup.tar.bz2
85 cp -p ${SPECFILE} ${SPECDIR}
86
87 ##
88 ## Build
89 ##
90 echo "$(basename $0): Getting Ready to build release package"
91 cd ${SPECDIR}
92 ${RPM} -ba --clean --rmsource $EXTRA_OPTIONS $SPECFILE
93
94 # restore original structure if docs were specified
95 cd ../../
96 if [ ${DOCS_DIR} ] && [ -d docs-orig ] && [ -L docs ]; then
97     rm docs
98     mv -f docs-orig docs
99 fi
100
101 echo "$(basename $0): Done."
102