-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_rpm
executable file
·181 lines (171 loc) · 4 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
180
181
#!/bin/sh
#
# $Log: create_rpm,v $
# Revision 1.5 2022-05-10 21:30:47+05:30 Cprogrammer
# added --clean option
#
# Revision 1.4 2020-08-10 12:03:41+05:30 Cprogrammer
# fixed cwd
#
# Revision 1.3 2020-08-10 11:54:17+05:30 Cprogrammer
# added comments to indicate cwd
#
# Revision 1.2 2020-07-28 12:40:27+05:30 Cprogrammer
# remove misc from source archive
#
# Revision 1.1 2020-07-19 18:17:22+05:30 Cprogrammer
# Initial revision
#
#
# $Id: create_rpm,v 1.5 2022-05-10 21:30:47+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 mpdev.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 mpdev-"$version""
/bin/cp -rp mpdev stage/mpdev-"$version"
# /usr/local/src/stage/mpdev-$version
cd stage/mpdev-$version
echo "Cleaning mpdev-"$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 mpdev-"$version".tar.gz in `pwd`"
tar \
--exclude="mpdev-$version/.git" \
--exclude="mpdev-$version/debian" \
--exclude="mpdev-$version/misc" \
--exclude="mpdev-$version/RCS" \
-cf - mpdev-"$version" \
| gzip -c > $rpmbuild/SOURCES/mpdev-"$version".tar.gz
/bin/rm -rf mpdev-"$version"
fi
dist=`uname -r |cut -d . -f4`
if [ -z "$release" ] ; then
if [ -f /usr/bin/mpdev ] ; then
mdist=$(rpm -qf /usr/bin/mpdev|cut -d- -f3|cut -d. -f3)
if [ " $dist" = " $mdist" ] ; then
mversion=$(rpm -qf /usr/bin/mpdev|cut -d- -f2)
if [ "$mversion" = "$version" ] ; then
release=$(rpm -qf /usr/bin/mpdev | 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 mpdev-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
tmprel=`cat mpdev/conf-release 2>/dev/null`
if [ ! " $tmprel" = " 1.$release" ] ; then
cd mpdev
echo 1.$release > conf-release
make -s mpdev.spec
cp mpdev.spec /tmp
make -C debian -s
cd ../..
else
cp mpdev/mpdev.spec /tmp
fi
build_arch=`rpmbuild --showrc|grep "^build arch" | awk '{print $4}'`
if [ $verbose -eq 0 ] ; then
echo "rpmbuild -ba $clean --quiet /tmp/mpdev.spec"
rpmbuild -ba $clean --quiet /tmp/mpdev.spec
else
echo "rpmbuild -ba $clean --quiet /tmp/mpdev.spec"
rpmbuild -ba $clean /tmp/mpdev.spec
fi
if [ $? -eq 0 ] ; then
/bin/rm /tmp/mpdev.spec
rpm --addsign $rpmbuild/RPMS/$build_arch/mpdev-"$version"-"1.$release".$dist.$build_arch.rpm
echo -n "RPM lint for mpdev-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
(
echo mpdev
rpmlint $rpmbuild/RPMS/$build_arch/mpdev-"$version"-"1.$release".$dist.$build_arch.rpm
echo ------------------------
echo mpdev-"$version"-"1.$release".$dist.src.rpm
rpmlint $rpmbuild/SRPMS/mpdev-"$version"-"1.$release".$dist.src.rpm
echo ------------------------
) 2>&1 | less
fi
else
/bin/rm /tmp/mpdev.spec
fi
else
/bin/rm -rf /tmp/mpdev-"$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/mpdev-"$version".tar.gz
fi
fi