-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqt-build-noarch
executable file
·185 lines (149 loc) · 4.23 KB
/
qt-build-noarch
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
#!/bin/bash
# Copyright (C) 2013 Eric Shubert <[email protected]>
#
# Build QMailToaster nodist/noarch rpm file
######################################################################
# Change Log
# 12/08/13 shubes - created
######################################################################
# change my* variables appropriately. Nothing else should be changed.
mygithub=~/github
mygpgpass="use your gpg key pass"
myrepouser=shubes-stage
myidfile=~/.ssh/id_rsa-noarch
######################################################################
# set temp name for the git clone
#
a1_setup_temp_stuff(){
tempgit=$(tempfile 2>/dev/null) || tempgit=/tmp/$me.$$
# make sure the temp stuff is deleted when we're done
trap "rm -rf $tempgit" 0 1 2 5 15
}
######################################################################
# clone the git repo to a temporary directory,
#
a2_clone_git_to_temp(){
mkdir $tempgit
# git 1.8.5 will have a -C option. 'til then, we need to cd to the target
savepwd=$PWD
cd $tempgit
git clone https://github.com/QMailToaster/$pkg
cd $savepwd
gspecdir=$tempgit/$pkg
specfile=$gspecdir/$pkg.spec
if [ ! -f "$specfile" ]; then
echo "$me - unable to clone git repo, no spec file - terminating"
exit 1
fi
}
######################################################################
# check to see if the package is a noarch package
#
a3_check_pkg_type(){
grep --max-count=1 ^BuildArch $gspecdir/$pkg.spec | grep --quiet noarch
if [ $? -ne 0 ]; then
echo "$me - \"BuildArch: noarch\" tag not found in $pkg.spec file"
exit 1
fi
}
######################################################################
# get the src.rpm file from the mirrors
#
a4_get_src_rpm(){
read vertag version anythingleft <<!EOF!
$(grep --max-count=1 "^Version:" $specfile)
!EOF!
read reltag relstring anythingleft <<!EOF!
$(grep --max-count=1 "^Release:" $specfile)
!EOF!
release=$(echo $relstring | sed -e "s|%{?dist}|$repotag|")
pkgverrel=$pkg-$version-$release
srcname=$pkgverrel.src.rpm
echo "$me - processing $srcname"
srpmfile=$srcrpmdir/$srcname
wget -O $srpmfile $webmirror/$status/SRPMS/$srcname
rpm --checksig $srpmfile
if [ "$?" != "0" ]; then
echo "$me -- $srcname in $status failed signature check"
exit 1
fi
}
######################################################################
# invoke expect build and sign rpm with no prompt
#
a6_build_signed_rpm(){
logfile=$logdir/$pkgverrel.$dist.$arch.buildlog.txt
rm -f $logfile
expect -c "
set timeout -1
log_file $logfile
spawn rpmbuild --rebuild --define \"dist $repotag.$dist\" --sign $srpmfile
expect {
phrase: { send \"$mygpgpass\r\"; exp_continue }
}
"
}
######################################################################
# upload the binary rpm(s) to staging
#
a8_upload_resulting_rpms(){
repostage=/stage/$status/$dist
while read wrotestring; do
# for some reason this loop executes once when there's nothing read
if [ -z "$wrotestring" ]; then
echo "$me - build appears to have failed - exiting"
exit 1
fi
rpmfile=${wrotestring#Wrote: }
# there's a \r at the end of this string that we need to get rid of
rpmfile=${rpmfile%.rpm*}
rpmfile=${rpmfile}.rpm
if [ ! -z "$rpmfile" ]; then
scp -p -P 17132 -i $myidfile $rpmfile $myrepouser@$repohost:$repostage/.
rm $rpmfile
fi
done << !EOF!
$(grep ^Wrote $logfile)
!EOF!
}
######################################################################
# main routine begins here
#
me=${0##*/}
myver=v1.0
# find the package .spec file
if [ -z "$1" ]; then
if [ "$(find . -maxdepth 1 -name "*.spec" | wc -w)" == "0" ]; then
echo "$me what? (no .spec file here)"
exit 1
else
pkg=${PWD##*/}
fi
elif [ -f "$mygithub/$1/$1.spec" ]; then
pkg=$1
else
echo "$me - $1 not found"
exit 1
fi
echo "$me - processing $pkg ..."
# define constants
status=testing
dist=nodist
arch=noarch
repotag=".qt"
repohost=masterepo.qmailtoaster.com
webmirror=http://mirror1.qmailtoaster.com
srcrpmdir="$(rpm --eval='%{_srcrpmdir}')"
logdir="$(rpm --eval='%{_topdir}')/BUILDLOGS"
mkdir -p $logdir
a1_setup_temp_stuff
a2_clone_git_to_temp
a3_check_pkg_type
a4_get_src_rpm
a6_build_signed_rpm
a8_upload_resulting_rpms
if [ -f $logfile ]; then
scp -p -P 17132 -i $myidfile $logfile $myrepouser@$repohost:$repostage/.
rm $logfile
fi
echo "$me - done"