summaryrefslogtreecommitdiff
path: root/contrib/build-rpm
blob: 0b06071517b8e1ee0d4734eae9f4dbb2f32741f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh

# enable xtrace output if requested
if [ -n ${ENABLE_XTRACE:-''} ]; then
    set -x
fi

# Build an e2fsprogs RPM from cvs

pwd=`pwd`
currdir=`basename $pwd`
pkgname=`grep Name: e2fsprogs.spec | awk '{print $2;}'`
pkgvers=`grep Version: e2fsprogs.spec | awk '{print $2;}'`
builddir=${pkgname}-${pkgvers}

# ensure that $TMP is set to something
TMP=${TMP:-'/tmp'}

cd ..
tmpdir=`mktemp -d ${RPM_TMPDIR:-$TMP}/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.

# Make a recursive-symlink copy of the source dir
cp -sR `pwd`/$currdir $tmpdir/$builddir || exit 1

# Remove any build files from the temporary tarball directory
[ -f $tmpdir/$builddir/Makefile ] && make -C $tmpdir/$builddir distclean

EXCLUDE="--exclude .hg* --exclude .pc*"
(cd $tmpdir && tar czfh ${builddir}.tar.gz $EXCLUDE $builddir)

[ "`rpmbuild --version 2> /dev/null`" ] && RPM=rpmbuild || RPM=rpm

$RPM --define "_sourcedir $tmpdir" \
     --define "_topdir ${RPM_TOPDIR:-$(rpm -E %_topdir)}" \
     --define "_tmpdir ${RPM_TMPDIR:-$TMP}" \
     --define "extra_config_flags ${EXTRA_CONFIG_FLAGS:-''}" \
     -ba $currdir/e2fsprogs.spec

rpm_exit=$?
rm -rf $tmpdir
exit $rpm_exit