-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_rpm
executable file
·167 lines (157 loc) · 3.75 KB
/
create_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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/sh
#
# $Id: create_rpm,v 1.3 2023-06-23 00:24:27+05:30 Cprogrammer Exp mbhangui $
#
version=$(cat conf-version)
verbose=0
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
;;
*) optarg=
;;
esac
case "$1" in
--verbose)
verbose=1
;;
--clean)
clean="--clean"
;;
--release=*)
release=$optarg
;;
*)
echo "invalid option [$1]"
read key
usage 1
;;
esac
shift
done
if test -f $HOME/.rpmmacros
then
topdir=`grep ^%_topdir $HOME/.rpmmacros | awk '{print $2}'`
if test -n "$topdir"
then
rpmbuild=$topdir
else
rpmbuild=$HOME/rpmbuild
fi
else
rpmbuild=$HOME/rpmbuild
fi
copy_src=0
echo -n "Copy Source Files - "
read key
if [ " $key" = " y" -o " $key" = " Y" ] ; then
copy_src=1
fi
make -s lcd-daemon.spec
if [ $? -ne 0 ] ; then
echo "make failed" 1>&2
exit 0
fi
if [ $copy_src -eq 1 ] ; then
if [ ! -d ../stage ] ; then
mkdir ../stage
fi
if [ $? -ne 0 ] ; then
exit 1
fi
# /usr/local/src
cd ..
echo "Preparing lcd-daemon-"$version""
/bin/cp -rp lcd-daemon stage/lcd-daemon-"$version"
# /usr/local/src/stage/lcd-daemon-$version
cd stage/lcd-daemon-$version
echo "Cleaning lcd-daemon-"$version""
make -s clean >/dev/null 2>&1
make -s distclean >/dev/null 2>&1
/bin/rm -rf autom4te.cache .deps src/config.log
# /usr/local/src/stage/
cd ..
echo "Archiving lcd-daemon-"$version".tar.gz in `pwd`"
tar \
--exclude="lcd-daemon-$version/.git" \
--exclude="lcd-daemon-$version/debian" \
--exclude="lcd-daemon-$version/RCS" \
-cf - lcd-daemon-"$version" \
| gzip -c > $rpmbuild/SOURCES/lcd-daemon-"$version".tar.gz
/bin/rm -rf lcd-daemon-"$version"
fi
dist=`uname -r |cut -d . -f4`
if [ -z "$release" ] ; then
if [ -f /usr/bin/gpio ] ; then
mdist=$(rpm -qf /usr/bin/gpio|cut -d- -f3|cut -d. -f3)
if [ " $dist" = " $mdist" ] ; then
mversion=$(rpm -qf /usr/bin/gpio|cut -d- -f2)
if [ "$mversion" = "$version" ] ; then
release=$(rpm -qf /usr/bin/gpio | cut -d- -f3 | cut -d. -f2)
release=$(expr $release + 1)
else
release=1
fi
else
release=1
fi
else
release=1
fi
fi
# /usr/local/src/
cd ..
echo -n "Build RPM for lcd-daemon-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
tmprel=`cat lcd-daemon-"$version"/conf-release 2>/dev/null`
if [ ! " $tmprel" = " 1.$release" ] ; then
cd lcd-daemon
echo 1.$release > conf-release
make -s lcd-daemon.spec
cp lcd-daemon.spec /tmp
make -C debian -s
cd ../..
else
cp lcd-daemon/lcd-daemon.spec /tmp
fi
build_arch=`rpmbuild --showrc|grep "^build arch" | awk '{print $4}'`
if [ $verbose -eq 0 ] ; then
echo "rpmbuild -ba $clean --quiet /tmp/lcd-daemon.spec"
rpmbuild -ba $clean --quiet /tmp/lcd-daemon.spec
else
echo "rpmbuild -ba $clean --quiet /tmp/lcd-daemon.spec"
rpmbuild -ba $clean /tmp/lcd-daemon.spec
fi
if [ $? -eq 0 ] ; then
/bin/rm /tmp/lcd-daemon.spec
rpm --addsign \
$rpmbuild/RPMS/$build_arch/lcd-daemon-"$version"-1."$release".$dist.$build_arch.rpm
echo -n "RPM lint for lcd-daemon-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
(
for i in lcd-daemon
do
echo $i
rpmlint $rpmbuild/RPMS/$build_arch/$i-"$version"-"1.$release".$dist.$build_arch.rpm
echo ------------------------
done
echo lcd-daemon-"$version"-"1.$release".$dist.src.rpm
rpmlint $rpmbuild/SRPMS/lcd-daemon-"$version"-"1.$release".$dist.src.rpm
echo ------------------------
) 2>&1 | less
fi
else
/bin/rm /tmp/lcd-daemon.spec
fi
else
/bin/rm -rf /tmp/lcd-daemon-"$version"
fi
if [ $copy_src -eq 1 ] ; then
echo -n "Remove Source (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
/bin/rm -f $rpmbuild/SOURCES/lcd-daemon-"$version".tar.gz
fi
fi