-
Notifications
You must be signed in to change notification settings - Fork 1
/
makerpm.sh
executable file
·58 lines (48 loc) · 1.38 KB
/
makerpm.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# This script cares for the rpm crap.
# if [ `id -u` -ne 0 ]
# then
# echo This command must be run as root.
# exit 1
# fi
if [ $# -ne 5 ]
then
echo "Usage: $0 [path to rpm] [package] [package version] [awk] [prefix]"
echo 'Possible reason for failure: rpm not found?'
echo This script should preferentially be called from the Makefile only.
exit 1
fi
RPM=$1
PACKAGE=$2
VERSION=$3
AWK=$4
PREFIX=$5
HOMEDIR=`/bin/pwd`
# export RPM=/bin/rpm-2.5.5
RPMVERSION=`${RPM} --version | ${AWK} '{ if ($3 < 3 ) print("2"); else print("3"); }'`
if [ ${RPMVERSION} -eq 2 ]
then
echo rpm version 2.x recognized
RPMSRCDIR=`$RPM --showrc | grep ^sourcedir | ${AWK} '{ print($3); }'`
SPECDIR=`$RPM --showrc | grep ^specdir | $AWK '{ print($3); }'`
BUILDDIR=`$RPM --showrc | grep ^builddir | $AWK '{ print($3); }'`
else
echo rpm version 3.x recognized -- have to make educated guesses
RPMTOPDIR=/usr/src/packages/
RPMSRCDIR=${RPMTOPDIR}/SOURCES
SPECDIR=${RPMTOPDIR}/SPECS
BUILDDIR=${RPMTOPDIR}/BUILD
fi
SPECFILE=${SPECDIR}/${PACKAGE}.spec
if [ ! -x ${RPM} ]
then
echo rpm should be in $RPM but not found
exit 1
fi
cp ${HOMEDIR}/${PACKAGE}.spec ${SPECFILE}
cp ${HOMEDIR}/${PACKAGE}-${VERSION}.tar.gz ${RPMSRCDIR}/${PACKAGE}-${VERSION}.tar.gz
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
tar xzf ${HOMEDIR}/${PACKAGE}-${VERSION}.tar.gz
echo Building RPMs
${RPM} -ba ${SPECFILE}