Whamcloud - gitweb
9596684935fd4849c520a1f3da890b9bdc8664ce
[tools/e2fsprogs.git] / contrib / build-rpm
1 #!/bin/sh
2
3 # Build an e2fsprogs RPM from cvs
4
5 pwd=`pwd`
6 currdir=`basename $pwd`
7 pkgname=`grep Name: e2fsprogs.spec | awk '{print $2;}'`
8 pkgvers=`grep Version: e2fsprogs.spec | awk '{print $2;}'`
9 builddir=${pkgname}-${pkgvers}
10
11 cd ..
12 tmpdir=`mktemp -d rpmtmp.XXXXXX`
13
14 # We need to build a tarball for the SRPM using $builddir as the 
15 # directory name (since that's what RPM will expect it to unpack
16 # into).  That may require a symlink.
17
18 # Make a recursive-symlink copy of the source dir
19 cp -sR `pwd`/$currdir $tmpdir/$builddir || exit 1
20
21 # Remove any build files from the temporary tarball directory
22 [ -f $tmpdir/$builddir/Makefile ] && make -C $tmpdir/$builddir distclean
23
24 EXCLUDE="--exclude .hg*"
25 (cd $tmpdir && tar czfh ${builddir}.tar.gz $EXCLUDE $builddir)
26
27 [ "`rpmbuild --version 2> /dev/null`" ] && RPM=rpmbuild || RPM=rpm
28 $RPM --define "_sourcedir `pwd`/$tmpdir" -ba $currdir/e2fsprogs.spec || exit $?