forked from WiringPi/WiringPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_rpm
executable file
·170 lines (160 loc) · 4.01 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
#!/bin/sh
#
# $Id: $
#
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 wiringpi.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 wiringpi-"$version""
/bin/cp -rp wiringPi stage/wiringpi-"$version"
# /usr/local/src/stage/wiringpi-$version
cd stage/wiringpi-$version
echo "Cleaning wiringpi-"$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 wiringpi-"$version".tar.gz in `pwd`"
tar \
--exclude="wiringpi-$version/.git" \
--exclude="wiringpi-$version/debian" \
-cf - wiringpi-"$version" \
| gzip -c > $rpmbuild/SOURCES/wiringpi-"$version".tar.gz
/bin/rm -rf wiringpi-"$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 wiringpi-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
tmprel=`cat wiringPi/conf-release 2>/dev/null`
if [ ! " $tmprel" = " 1.$release" ] ; then
cd wiringPi
echo 1.$release > conf-release
make -s wiringpi.spec
cp wiringpi.spec /tmp
make -C debian -s
cd ../..
else
cp wiringPi/wiringpi.spec /tmp
fi
build_arch=`rpmbuild --showrc|grep "^build arch" | awk '{print $4}'`
if [ $verbose -eq 0 ] ; then
echo "rpmbuild -ba $clean --quiet /tmp/wiringpi.spec"
rpmbuild -ba $clean --quiet /tmp/wiringpi.spec
else
echo "rpmbuild -ba $clean --quiet /tmp/wiringpi.spec"
rpmbuild -ba $clean /tmp/wiringpi.spec
fi
if [ $? -eq 0 ] ; then
/bin/rm /tmp/wiringpi.spec
rpm --addsign \
$rpmbuild/RPMS/$build_arch/wiringpi-"$version"-1."$release".$dist.$build_arch.rpm \
$rpmbuild/RPMS/$build_arch/libwiringpi-"$version"-1."$release".$dist.$build_arch.rpm \
$rpmbuild/RPMS/$build_arch/libwiringpi-devel-"$version"-1."$release".$dist.$build_arch.rpm \
$rpmbuild/RPMS/$build_arch/libwiringpidev-"$version"-1."$release".$dist.$build_arch.rpm \
$rpmbuild/RPMS/$build_arch/libwiringpidev-devel-"$version"-1."$release".$dist.$build_arch.rpm
echo -n "RPM lint for wiringpi-"$version"-1."$release" (Y/N) - "
read key
if [ " $key" = " Y" -o " $key" = " y" ] ; then
(
for i in wiringpi libwiringpi libwiringpi-devel libwiringpidev libwiringpidev-devel
do
echo $i
rpmlint $rpmbuild/RPMS/$build_arch/$i-"$version"-"1.$release".$dist.$build_arch.rpm
echo ------------------------
done
echo wiringpi-"$version"-"1.$release".$dist.src.rpm
rpmlint $rpmbuild/SRPMS/wiringpi-"$version"-"1.$release".$dist.src.rpm
echo ------------------------
) 2>&1 | less
fi
else
/bin/rm /tmp/wiringpi.spec
fi
else
/bin/rm -rf /tmp/wiringpi-"$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/wiringpi-"$version".tar.gz
fi
fi