1#!/bin/sh 2 3set -u 4set -e 5trap onexit INT 6trap onexit TERM 7trap onexit EXIT 8 9TMPDIR= 10 11onexit() 12{ 13 if [ ! "$TMPDIR" = "" ]; then 14 rm -rf $TMPDIR 15 fi 16} 17 18PKGNAME=@PKGNAME@ 19PROJECT=@CMAKE_PROJECT_NAME@ 20VERSION=@VERSION@ 21BUILD=@BUILD@ 22 23if [ -f $PKGNAME-$VERSION.src.rpm ]; then 24 rm -f $PKGNAME-$VERSION.src.rpm 25fi 26 27umask 022 28TMPDIR=`mktemp -d /tmp/$PKGNAME-build.XXXXXX` 29 30mkdir -p $TMPDIR/RPMS 31mkdir -p $TMPDIR/SRPMS 32mkdir -p $TMPDIR/BUILD 33mkdir -p $TMPDIR/SOURCES 34mkdir -p $TMPDIR/SPECS 35 36if [ ! -f $PROJECT-$VERSION.tar.gz ]; then 37 echo "ERROR: $PROJECT-$VERSION.tar.gz does not exist." 38fi 39 40cp $PROJECT-$VERSION.tar.gz $TMPDIR/SOURCES/$PROJECT-$VERSION.tar.gz 41 42cat pkgscripts/rpm.spec | sed s/%{_blddir}/%{_tmppath}/g \ 43 | sed s/#--\>//g > $TMPDIR/SPECS/$PKGNAME.spec 44 45rpmbuild -bs --define "_topdir $TMPDIR" $TMPDIR/SPECS/$PKGNAME.spec 46mv $TMPDIR/SRPMS/$PKGNAME-$VERSION-$BUILD.src.rpm $PKGNAME-$VERSION.src.rpm 47 48exit 49