From dad36d029bc3df8c764a1fe5a09fb7025a397f97 Mon Sep 17 00:00:00 2001 From: Stephen Tweedie Date: Thu, 10 Jan 2002 17:56:07 +0000 Subject: [PATCH] Fix build-rpm script to work a bit more safely. --- contrib/build-rpm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/contrib/build-rpm b/contrib/build-rpm index fcafce3..4e5da7d 100644 --- a/contrib/build-rpm +++ b/contrib/build-rpm @@ -9,23 +9,20 @@ pkgvers=`grep Version: e2fsprogs.spec | awk '{print $2;}'` builddir=${pkgname}-${pkgvers} cd .. +tmpdir=`mktemp -d rpmtmp.XXXXXX` # We need to build a tarball for the SRPM using $builddir as the # directory name (since that's what RPM will expect it to unpack # into). That may require a symlink. -if [ -L $builddir ] ; then - rm -f $builddir || exit 1 -elif [ -d $builddir ] ; then - rm -rf $builddir || exit 1 -fi - # Make a recursive-symlink copy of the source dir -cp -sR `pwd`/$currdir $builddir || exit 1 +cp -sR `pwd`/$currdir $tmpdir/$builddir || exit 1 # Remove any build files from the temporary tarball directory -[ -f $builddir/Makefile ] && make -C $builddir distclean +[ -f $tmpdir/$builddir/Makefile ] && make -C $tmpdir/$builddir distclean + +(cd $tmpdir && tar czfh ${builddir}.tar.gz $builddir) -tar czfh ${builddir}.tar.gz $builddir +rpm --define "_sourcedir `pwd`/$tmpdir" -ba $currdir/e2fsprogs.spec || exit $? +rm -rf $tmpdir -rpm --define "_sourcedir `pwd`" -ba $currdir/e2fsprogs.spec -- 1.8.3.1