WHATSNEW: Add release notes for Samba 4.6.12.
[Samba.git] / packaging / RHEL-CTDB / makerpms.sh
blob163b4aed306c39983827f0fb05a7cad7d2d9698f
1 #!/bin/sh
2 # Copyright (C) John H Terpstra 1998-2002
3 # Copyright (C) Gerald (Jerry) Carter 2003
4 # Copyright (C) Michael Adam 2008
6 # Script to build RPMs for RHEL from inside a git checkout.
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
13 # Note: Under this directory rpm expects to find the same directories
14 # that are under the /usr/src/redhat directory.
16 # extra options passed to rpmbuild
17 EXTRA_OPTIONS="$1"
19 RPMSPECDIR=`rpm --eval %_specdir`
20 RPMSRCDIR=`rpm --eval %_sourcedir`
21 RPMBUILDDIR=`rpm --eval %_builddir`
23 # At this point the RPMSPECDIR and RPMSRCDIR variables must have a value!
25 DIRNAME=$(dirname $0)
26 TOPDIR=${DIRNAME}/../..
28 SPECFILE="samba.spec"
29 RPMVER=`rpm --version | awk '{print $3}'`
30 test -z "$RPMVER" && {
31 RPMVER=`rpm --version | awk '{print $2}'`
33 RPM="rpmbuild"
36 ## Check the RPM version (paranoid)
38 case $RPMVER in
39 4*)
40 echo "Supported RPM version [$RPMVER]"
43 echo "Unknown RPM version: `rpm --version`"
44 exit 1
46 esac
48 mkdir -p `rpm --eval %_specdir`
49 mkdir -p `rpm --eval %_sourcedir`
50 mkdir -p `rpm --eval %_builddir`
51 mkdir -p `rpm --eval %_srcrpmdir`
52 mkdir -p `rpm --eval %_rpmdir`/noarch
53 mkdir -p `rpm --eval %_rpmdir`/i386
54 mkdir -p `rpm --eval %_rpmdir`/x86_64
57 ## Delete the old debuginfo remnants:
59 ## At least on RHEL 5.5, we observed broken debuginfo packages
60 ## when either old build directories were still present or old
61 ## debuginfo packages (of samba) were installed.
63 ## Remove the debuginfo samba RPMs and old RPM build
64 ## directories, giving the user a 10 second chance to quit.
67 if rpm -qa | grep -q samba-debuginfo || test -n "$(echo ${RPMBUILDDIR}/samba* | grep -v \*)" ; then
68 echo "Removing debuginfo remnants to fix debuginfo build:"
69 if rpm -qa | grep -q samba-debuginfo ; then
70 echo "Uninstalling the samba-debuginfo RPM"
71 echo -n "Press Control-C if you want to quit (you have 10 seconds)"
72 for count in $(seq 1 10) ; do
73 echo -n "."
74 sleep 1
75 done
76 echo
77 echo "That was your chance... :-)"
78 rpm -e samba-debuginfo
80 if test -n "$(echo ${RPMBUILDDIR}/samba* | grep -v \*)" ; then
81 echo "Deleting ${RPMBUILDDIR}/samba*"
82 echo -n "Press Control-C if you want to quit (you have 10 seconds)"
83 for count in $(seq 1 10) ; do
84 echo -n "."
85 sleep 1
86 done
87 echo
88 echo "That was your chance... :-)"
89 rm -rf ${RPMBUILDDIR}/samba*
94 ## determine the samba version and create the SPEC file
96 ${DIRNAME}/makespec.sh
97 RC=$?
98 if [ $RC -ne 0 ]; then
99 exit ${RC}
102 RELEASE=$(grep ^Release ${DIRNAME}/${SPECFILE} | sed -e 's/^Release:\ \+//')
103 VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//')
106 ## create the tarball
108 pushd ${TOPDIR}
109 echo -n "Creating samba-${VERSION}.tar.bz2 ... "
110 git archive --prefix=samba-${VERSION}/ HEAD | bzip2 > ${RPMSRCDIR}/samba-${VERSION}.tar.bz2
111 RC=$?
112 popd
113 echo "Done."
114 if [ $RC -ne 0 ]; then
115 echo "Build failed!"
116 exit 1
121 ## copy additional source files
123 pushd ${DIRNAME}
125 chmod 755 setup/filter-requires-samba.sh
126 tar --exclude=.svn -jcvf - setup > ${RPMSRCDIR}/setup.tar.bz2
128 cp -p ${SPECFILE} ${RPMSPECDIR}
130 popd
133 ## some symlink fixes for building 32bit compat libs
135 if [ `arch` = "x86_64" ]; then
136 ln -sf /lib/libcom_err.so.2 /lib/libcom_err.so
137 ln -sf /lib/libuuid.so.1 /lib/libuuid.so
141 ## Build
143 echo "$(basename $0): Getting Ready to build release package"
145 case ${EXTRA_OPTIONS} in
146 *-b*)
147 BUILD_TARGET=""
150 BUILD_TARGET="-ba"
152 esac
154 pushd ${RPMSPECDIR}
155 ${RPM} ${BUILD_TARGET} ${EXTRA_OPTIONS} ${SPECFILE}
156 popd
158 echo "$(basename $0): Done."