-
Notifications
You must be signed in to change notification settings - Fork 2
/
cmsfsrpm.sh
executable file
·86 lines (68 loc) · 1.77 KB
/
cmsfsrpm.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
#
#
# CMSFSRPM SH (shell script)
#
#
#
#
#
# run from the resident directory
cd `dirname "$0"`
D=`pwd`
# establish certain variables
APPLID=cmsfs
APPVRM=`grep '^#define' cmsfs.h | grep CMSFS_VERSION | awk '{print $3}' | sed 's#"##g'`
BUILDD=$D/$$
if [ ! -s .rpmseq ] ; then echo "0" > .rpmseq ; fi
RPMSEQ=`cat .rpmseq`
UNAMEM=`uname -m`
#UNAMEM=`uname -m | sed 's#^i.86$#i386#' | sed 's#^armv.l$#arm#'`
# create the "sed file"
rm -f cmsfsrpm.sed
echo "s#%APPLID%#$APPLID#g" >> cmsfsrpm.sed
echo "s#%APPVRM%#$APPVRM#g" >> cmsfsrpm.sed
echo "s#%BUILDD%#$BUILDD#g" >> cmsfsrpm.sed
echo "s#%RPMSEQ%#$RPMSEQ#g" >> cmsfsrpm.sed
echo "s#%UNAMEM%#$UNAMEM#g" >> cmsfsrpm.sed
# process the skeletal spec file into a usable spec file
sed -f cmsfsrpm.sed < cmsfs.spec > cmsfsrpm.spec
RC=$? ; if [ $RC -ne 0 ] ; then exit $RC ; fi
rm cmsfsrpm.sed
#
# clean up from any prior run
make clean 1> /dev/null 2> /dev/null
rm -rf $BUILDD
#find . -print | grep ';' | xargs -r rm
#
# configure for test
./configure --prefix=$BUILDD
RC=$? ; if [ $RC -ne 0 ] ; then exit $RC ; fi
#
# 'just make'
make
RC=$? ; if [ $RC -ne 0 ] ; then exit $RC ; fi
#
# now try an install
make install
RC=$? ; if [ $RC -ne 0 ] ; then exit $RC ; fi
#
# make it "properly rooted"
mkdir $BUILDD/usr
mv $BUILDD/bin $BUILDD/lib $BUILDD/man $BUILDD/usr/.
RC=$? ; if [ $RC -ne 0 ] ; then exit $RC ; fi
#
# build the RPM file (and keep a log of the process)
rm -f cmsfsrpm.log
rpmbuild -bb --nodeps cmsfsrpm.spec | tee cmsfsrpm.log
RC=$? ; if [ $RC -ne 0 ] ; then exit $RC ; fi
rm cmsfsrpm.spec
#
# recover the RPM file
cp -p $HOME/rpmbuild/RPMS/$UNAMEM/$APPLID-$APPVRM-$RPMSEQ.$UNAMEM.rpm .
#
# remove temporary build directory
rm -r $BUILDD
# increment the sequence number for the next build
expr $RPMSEQ + 1 > .rpmseq
exit