-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_rpm
executable file
·179 lines (169 loc) · 3.95 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
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/sh
#
# $Log: create_rpm,v $
# Revision 1.4 2022-04-30 10:29:03+05:30 Cprogrammer
# added --clean argument
#
# Revision 1.3 2020-08-31 21:18:02+05:30 Cprogrammer
# fixed path for pistop
#
# Revision 1.2 2020-08-29 16:01:31+05:30 Cprogrammer
# fixed path for pistop
#
# Revision 1.1 2020-08-28 17:20:13+05:30 Cprogrammer
# Initial revision
#
#
# $Id: create_rpm,v 1.4 2022-04-30 10:29:03+05:30 Cprogrammer Exp mbhangui $
#
version=$(cat conf-version)
verbose=0
clean=""
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 pistop.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 pistop-"$version""
/bin/cp -rp pistop stage/pistop-"$version"
# /usr/local/src/stage/pistop-$version
cd stage/pistop-$version
echo "Cleaning pistop-"$version""
make -s clean
make -s distclean
/bin/rm -rf autom4te.cache .deps src/config.log
# /usr/local/src/stage/
cd ..
echo "Archiving pistop-"$version".tar.gz in `pwd`"
tar \
--exclude="pistop-$version/.git" \
--exclude="pistop-$version/debian" \
--exclude="pistop-$version/misc" \
--exclude="pistop-$version/RCS" \
-cf - pistop-"$version" \
| gzip -c > $rpmbuild/SOURCES/pistop-"$version".tar.gz
/bin/rm -rf pistop-"$version"
fi
dist=`uname -r |cut -d . -f4`
if [ -z "$release" ] ; then
if [ -d /usr/libexec/pistop ] ; then
mdist=$(rpm -qf /usr/libexec/pistop|cut -d- -f3|cut -d. -f3)
if [ " $dist" = " $mdist" ] ; then
mversion=$(rpm -qf /usr/libexec/pistop|cut -d- -f2)
if [ "$mversion" = "$version" ] ; then
release=$(rpm -qf /usr/libexec/pistop | 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 pistop-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
tmprel=`cat pistop/conf-release 2>/dev/null`
if [ ! " $tmprel" = " 1.$release" ] ; then
cd pistop
echo 1.$release > conf-release
make -s pistop.spec
cp pistop.spec /tmp
make -C debian -s
cd ../..
else
cp pistop/pistop.spec /tmp
fi
build_arch=`rpmbuild --showrc|grep "^build arch" | awk '{print $4}'`
if [ $verbose -eq 0 ] ; then
echo "rpmbuild -ba $clean --quiet /tmp/pistop.spec"
rpmbuild -ba $clean --quiet /tmp/pistop.spec
else
echo "rpmbuild -ba $clean --quiet /tmp/pistop.spec"
rpmbuild -ba $clean /tmp/pistop.spec
fi
if [ $? -eq 0 ] ; then
/bin/rm /tmp/pistop.spec
rpm --addsign $rpmbuild/RPMS/$build_arch/pistop-"$version"-"1.$release".$dist.$build_arch.rpm
echo -n "RPM lint for pistop-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
(
echo pistop
rpmlint $rpmbuild/RPMS/$build_arch/pistop-"$version"-"1.$release".$dist.$build_arch.rpm
echo ------------------------
echo pistop-"$version"-"1.$release".$dist.src.rpm
rpmlint $rpmbuild/SRPMS/pistop-"$version"-"1.$release".$dist.src.rpm
echo ------------------------
) 2>&1 | less
fi
else
/bin/rm /tmp/pistop.spec
fi
else
/bin/rm -rf /tmp/pistop-"$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/pistop-"$version".tar.gz
fi
fi