| 1 |
#!/bin/bash -x |
| 2 |
######################################################################### |
| 3 |
# $Id$ |
| 4 |
######################################################################### |
| 5 |
# build/redhat/make-rpm |
| 6 |
# |
| 7 |
# This script creates an RPM from the bochs directory. You must run |
| 8 |
# it as root from the top of the source directory (where the configure |
| 9 |
# scripts are). Then just run: |
| 10 |
# ./build/redhat/make-rpm |
| 11 |
# |
| 12 |
######################################################################### |
| 13 |
|
| 14 |
CAT=cat |
| 15 |
RM=rm |
| 16 |
CP=cp |
| 17 |
MV=mv |
| 18 |
MKDIR=mkdir |
| 19 |
GREP=grep |
| 20 |
ECHO=echo |
| 21 |
RPM=rpm |
| 22 |
RPMBUILD=/usr/bin/rpmbuild |
| 23 |
SED=sed |
| 24 |
TAR=tar |
| 25 |
RPMSRCPATH=_rpm_top |
| 26 |
SOURCES=${RPMSRCPATH}/SOURCES |
| 27 |
SPECS=${RPMSRCPATH}/SPECS |
| 28 |
RPMSPEC="build/redhat/bochs.rpmspec.template" |
| 29 |
TMPDIR=/tmp |
| 30 |
|
| 31 |
echo Reading version from configure.ac script. |
| 32 |
VERSION='unknown' |
| 33 |
eval `${GREP} '^VERSION="' configure.ac` |
| 34 |
if test $? != 0 -o "$VERSION" = unknown; then |
| 35 |
echo Could not get version number from configure.ac script. |
| 36 |
echo Exiting. |
| 37 |
exit 1 |
| 38 |
fi |
| 39 |
|
| 40 |
# clean up previous rpm builds |
| 41 |
${RM} -rf *.rpm ${RPMSRCPATH} |
| 42 |
if test -f Makefile; then |
| 43 |
make dist-clean |
| 44 |
fi |
| 45 |
|
| 46 |
# make a TAR.GZ of the entire source directory, exactly as it is. The |
| 47 |
# tar is placed in $SOURCES/bochs-$VERSION.tar.gz. Because the current |
| 48 |
# directory could be named nearly anything, I copy all the contents into |
| 49 |
# $SOURCES/bochs-$VERSION and then build a tar in $SOURCES. |
| 50 |
|
| 51 |
${RM} -rf ${TMPDIR}/bochs-${VERSION} |
| 52 |
test $? = 0 || exit 1 |
| 53 |
${MKDIR} ${TMPDIR}/bochs-${VERSION} |
| 54 |
test $? = 0 || exit 1 |
| 55 |
${TAR} cf - * .??* | (cd ${TMPDIR}/bochs-${VERSION} && tar xf -) |
| 56 |
test $? = 0 || exit 1 |
| 57 |
(cd ${TMPDIR}; tar czf bochs-${VERSION}.tar.gz --exclude=.svn bochs-${VERSION}) |
| 58 |
test $? = 0 || exit 1 |
| 59 |
${RM} -rf ${TMPDIR}/bochs-${VERSION} |
| 60 |
test $? = 0 || exit 1 |
| 61 |
|
| 62 |
# create RPM build area |
| 63 |
rm -rf ${RPMSRCPATH} |
| 64 |
mkdir ${RPMSRCPATH} ${RPMSRCPATH}/SOURCES ${RPMSRCPATH}/SPECS ${RPMSRCPATH}/BUILD ${RPMSRCPATH}/RPMS ${RPMSRCPATH}/SRPMS |
| 65 |
test $? = 0 || exit 1 # test that mkdir succeeded |
| 66 |
|
| 67 |
# copy source into sources |
| 68 |
${MV} ${TMPDIR}/bochs-${VERSION}.tar.gz ${SOURCES} |
| 69 |
test $? = 0 || exit 1 |
| 70 |
|
| 71 |
# copy the spec into SPECS. The template is in $RPMSPEC, and we use |
| 72 |
# SED to substitute in the version number. |
| 73 |
${RM} -f ${SPECS}/bochs.spec |
| 74 |
test $? = 0 || exit 1 |
| 75 |
${CAT} ${RPMSPEC} | ${SED} "s/@SEDVERSION@/${VERSION}/g" > ${SPECS}/bochs.spec |
| 76 |
test $? = 0 || exit 1 |
| 77 |
|
| 78 |
# finally, start the rpm build. |
| 79 |
if [ -x ${RPMBUILD} ] |
| 80 |
then |
| 81 |
${RPMBUILD} -ba --define "_topdir `pwd`/${RPMSRCPATH}" ${SPECS}/bochs.spec |
| 82 |
else |
| 83 |
${RPM} -ba --define "_topdir `pwd`/${RPMSRCPATH}" ${SPECS}/bochs.spec |
| 84 |
fi |
| 85 |
|
| 86 |
# test status |
| 87 |
if test $? = 0; then |
| 88 |
echo RPM build succeeded |
| 89 |
else |
| 90 |
echo RPM build failed. |
| 91 |
exit 1 |
| 92 |
fi |
| 93 |
|
| 94 |
# copy all rpms out into main directory |
| 95 |
ALLRPMS=`find ${RPMSRCPATH} -name '*.rpm'` |
| 96 |
if test "$ALLRPMS" != ""; then |
| 97 |
echo Moving .rpm files into the main directory. |
| 98 |
mv ${ALLRPMS} . |
| 99 |
ls -l *.rpm |
| 100 |
fi |