packaging: add a comment explaining EXTRA_OPTIONS to the makerpms script
[ira/wip.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_DIR to the path to a release tarball docs dir in order to get docs
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 USERID=`id -u`
25 GRPID=`id -g`
26 VERSION='3.2.0'
27 REVISION='ctdb'
28 SPECFILE="samba.spec"
29 RPMVER=`rpm --version | awk '{print $3}'`
30 RPM="rpmbuild"
31
32 ##
33 ## Check the RPM version (paranoid)
34 ##
35 case $RPMVER in
36     4*)
37        echo "Supported RPM version [$RPMVER]"
38        ;;
39     *)
40        echo "Unknown RPM version: `rpm --version`"
41        exit 1
42        ;;
43 esac
44
45 pushd .
46 cd ../../source
47 if [ -f Makefile ]; then 
48         make distclean
49 fi
50 popd
51
52 pushd .
53 cd ../../
54 SRCTREE=`basename $PWD`
55 if [ $DOCS_DIR ] && [ -d $DOCS_DIR ]; then
56     mv docs docs-orig
57     ln -s $DOCS_DIR docs
58 fi
59 cd ../
60 chown -R ${USERID}.${GRPID} $SRCTREE
61 if [ ! -d samba-${VERSION} ]; then
62         ln -s $SRCTREE samba-${VERSION} || exit 1
63 fi
64 echo -n "Creating samba-${VERSION}.tar.bz2 ... "
65 tar --exclude=.svn --exclude=.bzr --exclude=.bzrignore --exclude=docs-orig -chf - samba-${VERSION}/. | bzip2 > ${SRCDIR}/samba-${VERSION}.tar.bz2
66 echo "Done."
67 if [ $? -ne 0 ]; then
68         popd
69         cd ../../
70         # restore original structure if docs were specified
71         if [ ${DOCS_DIR} ] && [ -d docs-orig ] && [ -L docs ]; then
72             rm docs
73             mv docs-orig docs
74         fi
75         echo "Build failed!"
76         exit 1
77 fi
78
79 popd
80
81
82 ##
83 ## copy additional source files
84 ##
85 chmod 755 setup/filter-requires-samba.sh
86 tar --exclude=.svn -jcvf - setup > ${SRCDIR}/setup.tar.bz2
87 cp -p ${SPECFILE} ${SPECDIR}
88
89 ##
90 ## Build
91 ##
92 echo "$(basename $0): Getting Ready to build release package"
93 cd ${SPECDIR}
94 ${RPM} -ba $EXTRA_OPTIONS $SPECFILE
95 [ `arch` = "x86_64" ] && {
96     echo "Building 32 bit winbind libs"
97     # hi ho, a hacking we will go ...
98     ln -sf /lib/libcom_err.so.2 /lib/libcom_err.so
99     ln -sf /lib/libuuid.so.1 /lib/libuuid.so
100     ${RPM} -ba --rebuild --target=i386 $SPECFILE
101 }
102
103
104
105
106 # restore original structure if docs were specified
107 cd ../../
108 if [ ${DOCS_DIR} ] && [ -d docs-orig ] && [ -L docs ]; then
109     rm docs
110     mv -f docs-orig docs
111 fi
112
113 echo "$(basename $0): Done."
114