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# Set DOCS_TARBALL to the path to a docs release tarball in .tar.bz2 format. 17 18# extra options passed to rpmbuild 19EXTRA_OPTIONS="$1" 20 21RPMSPECDIR=`rpm --eval %_specdir` 22RPMSRCDIR=`rpm --eval %_sourcedir` 23 24# At this point the RPMSPECDIR and RPMSRCDIR variables must have a value! 25 26DIRNAME=$(dirname $0) 27TOPDIR=${DIRNAME}/../.. 28 29SPECFILE="samba.spec" 30DOCS="docs.tar.bz2" 31RPMVER=`rpm --version | awk '{print $3}'` 32RPM="rpmbuild" 33 34## 35## Check the RPM version (paranoid) 36## 37case $RPMVER in 38 4*) 39 echo "Supported RPM version [$RPMVER]" 40 ;; 41 *) 42 echo "Unknown RPM version: `rpm --version`" 43 exit 1 44 ;; 45esac 46 47## 48## determine the samba version and create the SPEC file 49## 50${DIRNAME}/makespec.sh 51RC=$? 52if [ $RC -ne 0 ]; then 53 exit ${RC} 54fi 55 56RELEASE=$(grep ^Release ${DIRNAME}/${SPECFILE} | sed -e 's/^Release:\ \+//') 57VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//') 58 59## 60## create the tarball 61## 62pushd ${TOPDIR} 63echo -n "Creating samba-${VERSION}.tar.bz2 ... " 64git archive --prefix=samba-${VERSION}/ HEAD | bzip2 > ${RPMSRCDIR}/samba-${VERSION}.tar.bz2 65RC=$? 66popd 67echo "Done." 68if [ $RC -ne 0 ]; then 69 echo "Build failed!" 70 exit 1 71fi 72 73 74## 75## copy additional source files 76## 77if [ "x${DOCS_TARBALL}" != "x" ] && [ -f ${DOCS_TARBALL} ]; then 78 cp ${DOCS_TARBALL} ${RPMSRCDIR}/${DOCS} 79fi 80 81pushd ${DIRNAME} 82 83chmod 755 setup/filter-requires-samba.sh 84tar --exclude=.svn -jcvf - setup > ${RPMSRCDIR}/setup.tar.bz2 85 86cp -p ${SPECFILE} ${RPMSPECDIR} 87 88popd 89 90## 91## some symlink fixes for building 32bit compat libs 92## 93if [ `arch` = "x86_64" ]; then 94 ln -sf /lib/libcom_err.so.2 /lib/libcom_err.so 95 ln -sf /lib/libuuid.so.1 /lib/libuuid.so 96fi 97 98## 99## Build 100## 101echo "$(basename $0): Getting Ready to build release package" 102 103pushd ${RPMSPECDIR} 104${RPM} -ba $EXTRA_OPTIONS $SPECFILE 105popd 106 107echo "$(basename $0): Done." 108 109