forked from CDrummond/cantata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_rpm
executable file
·172 lines (163 loc) · 3.96 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
#!/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
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 cantata-"$version""
/bin/cp -rp cantata stage/cantata-"$version"
# /usr/local/src/stage/cantata-$version
cd stage/cantata-$version
echo "Cleaning cantata-"$version""
/bin/rm -rf build .git
# /usr/local/src/stage/
cd ..
echo "Archiving cantata-"$version".tar.bz2 in `pwd`"
#tar \
# --exclude="cantata-$version/.git" \
# --exclude="cantata-$version/debian" \
# -cf - cantata-"$version" \
# | bzip2 -c > $rpmbuild/SOURCES/cantata-"$version".tar.bz2
/bin/rm -rf cantata-"$version"
cd ../cantata
cp com.github.cdrummond.cantata.metainfo.xml cantata-unbundle-fontawesome.patch \
cantata-unbundle-qtiocompressor.patch $rpmbuild/SOURCES
fi
dist=`uname -r |cut -d . -f4`
if [ -z "$release" ] ; then
if [ -f /usr/bin/cantata ] ; then
mdist=$(rpm -qf /usr/bin/cantata|cut -d- -f3|cut -d. -f3)
if [ " $dist" = " $mdist" ] ; then
mversion=$(rpm -qf /usr/bin/cantata|cut -d- -f2)
if [ "$mversion" = "$version" ] ; then
release=$(rpm -qf /usr/bin/cantata | 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 cantata-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
tmprel=`cat cantata/conf-release 2>/dev/null`
if [ ! " $tmprel" = " 1.$release" ] ; then
cd cantata
echo 1.$release > conf-release
cp cantata.spec /tmp
cd ../..
else
cp cantata/cantata.spec /tmp
fi
build_arch=`rpmbuild --showrc|grep "^build arch" | awk '{print $4}'`
if [ $verbose -eq 0 ] ; then
echo "rpmbuild -ba $clean --quiet /tmp/cantata.spec"
rpmbuild -ba $clean --quiet /tmp/cantata.spec
else
echo "rpmbuild -ba $clean --quiet /tmp/cantata.spec"
rpmbuild -ba $clean /tmp/cantata.spec
fi
if [ $? -eq 0 ] ; then
/bin/rm /tmp/cantata.spec
rpm --addsign $rpmbuild/RPMS/$build_arch/cantata-"$version"-"1.$release".$dist.$build_arch.rpm
echo -n "RPM lint for cantata-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
(
echo cantata
rpmlint $rpmbuild/RPMS/$build_arch/cantata-"$version"-"1.$release".$dist.$build_arch.rpm
echo ------------------------
echo cantata-"$version"-"1.$release".$dist.src.rpm
rpmlint $rpmbuild/SRPMS/cantata-"$version"-"1.$release".$dist.src.rpm
echo ------------------------
) 2>&1 | less
fi
else
/bin/rm /tmp/cantata.spec
fi
else
/bin/rm -rf /tmp/cantata-"$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/cantata-"$version".tar.gz
fi
fi