TOR: fix compilation
[tomato.git] / release / src / router / e2fsprogs / contrib / build-rpm
blob0b06071517b8e1ee0d4734eae9f4dbb2f32741f7
1 #!/bin/sh
3 # enable xtrace output if requested
4 if [ -n ${ENABLE_XTRACE:-''} ]; then
5 set -x
6 fi
8 # Build an e2fsprogs RPM from cvs
10 pwd=`pwd`
11 currdir=`basename $pwd`
12 pkgname=`grep Name: e2fsprogs.spec | awk '{print $2;}'`
13 pkgvers=`grep Version: e2fsprogs.spec | awk '{print $2;}'`
14 builddir=${pkgname}-${pkgvers}
16 # ensure that $TMP is set to something
17 TMP=${TMP:-'/tmp'}
19 cd ..
20 tmpdir=`mktemp -d ${RPM_TMPDIR:-$TMP}/rpmtmp.XXXXXX`
22 # We need to build a tarball for the SRPM using $builddir as the
23 # directory name (since that's what RPM will expect it to unpack
24 # into). That may require a symlink.
26 # Make a recursive-symlink copy of the source dir
27 cp -sR `pwd`/$currdir $tmpdir/$builddir || exit 1
29 # Remove any build files from the temporary tarball directory
30 [ -f $tmpdir/$builddir/Makefile ] && make -C $tmpdir/$builddir distclean
32 EXCLUDE="--exclude .hg* --exclude .pc*"
33 (cd $tmpdir && tar czfh ${builddir}.tar.gz $EXCLUDE $builddir)
35 [ "`rpmbuild --version 2> /dev/null`" ] && RPM=rpmbuild || RPM=rpm
37 $RPM --define "_sourcedir $tmpdir" \
38 --define "_topdir ${RPM_TOPDIR:-$(rpm -E %_topdir)}" \
39 --define "_tmpdir ${RPM_TMPDIR:-$TMP}" \
40 --define "extra_config_flags ${EXTRA_CONFIG_FLAGS:-''}" \
41 -ba $currdir/e2fsprogs.spec
43 rpm_exit=$?
44 rm -rf $tmpdir
45 exit $rpm_exit