-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_rpm
executable file
·187 lines (181 loc) · 4.77 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
182
183
184
185
186
187
#!/bin/sh
# $Log: create_rpm,v $
# Revision 1.15 2024-05-23 17:13:30+05:30 Cprogrammer
# updated create_rpm
#
# Revision 1.14 2023-02-08 11:21:49+05:30 Cprogrammer
# updated libqmail.spec before rpm generation
#
# Revision 1.13 2022-03-29 21:03:30+05:30 Cprogrammer
# added --clean option
#
# Revision 1.12 2020-10-13 22:26:44+05:30 Cprogrammer
# sign rpm package
#
# Revision 1.11 2020-10-04 14:05:40+05:30 Cprogrammer
# exclude base/RCS from tar source archive
#
# Revision 1.10 2020-09-13 01:35:40+05:30 Cprogrammer
# added --release option to specify release on command line
#
# Revision 1.9 2020-07-05 14:13:48+05:30 Cprogrammer
# added command line option to set verbose rpmbuild
#
# Revision 1.8 2020-07-04 23:43:07+05:30 Cprogrammer
# do rpmbuild silently
#
# Revision 1.7 2020-06-15 00:56:33+05:30 Cprogrammer
# refactored create_rpm script
#
# Revision 1.6 2020-05-25 23:14:02+05:30 Cprogrammer
# updated release numbers for build
#
# Revision 1.5 2020-05-24 12:06:39+05:30 Cprogrammer
# rpm creation script for libqmail
#
#
# $Id: create_rpm,v 1.15 2024-05-23 17:13:30+05:30 Cprogrammer Exp mbhangui $
#
curdir=`pwd`
version=$(cat conf-version)
if [ -f /etc/debian_version ] ; then
echo "you can't do rpmbuild on an insane system" 1>&2
exit 1
fi
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
--release=*)
release=$optarg
;;
--verbose)
verbose=1
;;
--clean)
clean="--clean"
;;
*)
echo "invalid option [$1]"
read key
;;
esac
shift
done
copy_src=0
echo -n "Copy Source Files - "
read key
if [ " $key" = " y" -o " $key" = " Y" ] ; then
copy_src=1
fi
make libqmail.spec
cd ..
/bin/rm -rf /tmp/libqmail-"$version"
cp -rp libqmail /tmp/libqmail-"$version"
cd /tmp/libqmail-"$version"
make -s clean
make -s distclean
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
/bin/rm -rf autom4te.cache .deps
cd ..
if [ $copy_src -eq 1 ] ; then
echo "Archiving libqmail-"$version".tar.gz in `pwd`"
tar \
--exclude="libqmail-$version/.git" \
--exclude="libqmail-$version/debian" \
--exclude="libqmail-$version/RCS" \
--exclude="libqmail-$version/base/RCS" \
-cf - libqmail-"$version" \
| gzip -c > $rpmbuild/SOURCES/libqmail-"$version".tar.gz
fi
dist=`uname -r |cut -d . -f4`
if [ -z "$release" ] ; then
if [ -d /usr/include/qmail ] ; then
qversion=$(rpm -qf /usr/include/qmail|cut -d- -f3)
if [ "$qversion" = "$version" ] ; then
t1=$(rpm -qf /usr/include/qmail | cut -d- -f4 | cut -d. -f1)
t2=$(rpm -qf /usr/include/qmail | cut -d- -f4 | cut -d. -f2)
t2=$(expr $t2 + 1)
release="$t1.$t2"
else
release=0.1
fi
else
release=0.1
fi
fi
echo -n "Build RPM for libqmail-"$version"-"$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
cp /tmp/libqmail-"$version"/libqmail.spec /tmp
sed -i -e "s|^Release: .*|Release: $release%{?dist}|g" /tmp/libqmail.spec
/bin/rm -rf /tmp/libqmail-"$version"
cd $curdir
if [ $? -eq 0 ] ; then
tmprel=`cat conf-release 2>/dev/null`
if [ ! " $tmprel" = " $release" ] ; then
echo $release > conf-release
make -s libqmail.spec
cp libqmail.spec /tmp
cd debian
make -s
cd ..
fi
fi
if [ $verbose -eq 0 ] ; then
echo "rpmbuild -ba $clean --quiet /tmp/libqmail.spec"
rpmbuild -ba $clean --quiet /tmp/libqmail.spec
else
echo "rpmbuild -ba $clean /tmp/libqmail.spec"
rpmbuild -ba $clean /tmp/libqmail.spec
fi
if [ $? -eq 0 ] ; then
/bin/rm /tmp/libqmail.spec
build_arch=`rpmbuild --showrc|grep "^build arch" | awk '{print $4}'`
rpm --addsign $rpmbuild/RPMS/$build_arch/libqmail-"$version"-"$release".$dist.$build_arch.rpm
rpm --addsign $rpmbuild/RPMS/$build_arch/libqmail-devel-"$version"-"$release".$dist.$build_arch.rpm
echo -n "RPM lint for libqmail-"$version"-"$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
(
echo libqmail
rpmlint $rpmbuild/RPMS/$build_arch/libqmail-"$version"-"$release".$dist.$build_arch.rpm
echo ------------------------
echo libqmail-devel
rpmlint $rpmbuild/RPMS/$build_arch/libqmail-devel-"$version"-"$release".$dist.$build_arch.rpm
echo ------------------------
echo libqmail-"$version"-"$release".$dist.src.rpm
rpmlint $rpmbuild/SRPMS/libqmail-"$version"-"$release".$dist.src.rpm
echo ------------------------
) 2>&1 | less
fi
else
/bin/rm /tmp/libqmail.spec
fi
else
/bin/rm -rf /tmp/libqmail-"$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/libqmail-"$version".tar.gz
fi
fi