| #!/bin/sh |
| |
| set -u |
| set -e |
| trap onexit INT |
| trap onexit TERM |
| trap onexit EXIT |
| |
| TMPDIR= |
| |
| onexit() |
| { |
| if [ ! "$TMPDIR" = "" ]; then |
| sudo rm -rf $TMPDIR |
| fi |
| } |
| |
| usage() |
| { |
| echo "$0 <package name> <version> <build> <RPM architecture> <source dir.>" |
| exit 1 |
| } |
| |
| if [ $# -lt 5 ]; then usage $0; fi |
| PACKAGE_NAME=$1 |
| VERSION=$2 |
| BUILD=$3 |
| RPMARCH=$4 |
| SRCDIR=$5 |
| |
| TMPDIR=`mktemp -d /tmp/$PACKAGE_NAME-build.XXXXXX` |
| mkdir -p $TMPDIR/RPMS |
| ln -fs `pwd` $TMPDIR/BUILD |
| rm -f $PACKAGE_NAME.$RPMARCH.rpm |
| rpmbuild -bb --define "_name $PACKAGE_NAME" \ |
| --define "_blddir $TMPDIR/buildroot" --define "_topdir $TMPDIR" \ |
| --define "_version $VERSION" --define "_build $BUILD" \ |
| --define "_srcdir $SRCDIR" --target $RPMARCH \ |
| $SRCDIR/release/libjpeg-turbo.spec |
| cp $TMPDIR/RPMS/$RPMARCH/$PACKAGE_NAME-$VERSION-$BUILD.$RPMARCH.rpm $PACKAGE_NAME.$RPMARCH.rpm |
| |
| exit |