-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_rpm
executable file
·45 lines (36 loc) · 986 Bytes
/
build_rpm
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
# Helper script to build an rpm
#
# Version
CONFIGURE_TEMPLATE=configure.ac
VERSION=$(for _VERSION_FRAGMENT in MAJOR MINOR MICRO; do
_LINE_FRAGMENT='^\s*m4_define\s*(\s*PROJECT_'${_VERSION_FRAGMENT}'\s*,\s*'
sed -n 's/'${_LINE_FRAGMENT}'\(\S\+\)).*$/\1/p' $CONFIGURE_TEMPLATE
done | tr '\n' '.' | sed 's/\.$//')
# Variables
#
TMPDIR=$(mktemp -d /tmp/chos_rpmbuild.XXXXXXXXXX)
SDIR=$TMPDIR/chos-${VERSION}
TARFILE=chos-${VERSION}.tgz
mkdir $TMPDIR
mkdir $SDIR
cp -av . $SDIR
cd $TMPDIR
# Hack to work around template issue
touch $SDIR/config.h.top
tar czf $TMPDIR/${TARFILE} chos-${VERSION}
# Make RPM build space
#
mkdir $TMPDIR/rpmbuild
mkdir $TMPDIR/rpmbuild/SPECS
mkdir $TMPDIR/rpmbuild/SOURCES
mkdir $TMPDIR/rpmbuild/BUILD
mkdir $TMPDIR/rpmbuild/RPMS
mkdir $TMPDIR/rpmbuild/SRPMS
# Build RPM
rpmbuild --define "_topdir $TMPDIR/rpmbuild" -ta $TARFILE
# Move RPM to /tmp
mv $TMPDIR/rpmbuild/RPMS/`uname -i`/*rpm /tmp
# remove scratch space
#
rm -rf $TMPDIR