summaryrefslogtreecommitdiffstats
path: root/sssd-nightly.sh
blob: 616630cb342677091783cb5e172c07b658bc7c3f (plain)
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#!/bin/bash

function finish { #(exit code)
    rm -f /local/sgallagh/.sssd-build.lock

    if [ x$scratch_build != x ]; then
        exit $1
    fi

    recipients="sgallagh@redhat.com jgalipea@redhat.com"

    if [ $1 -eq 0 ]; then
        successful="successfully"
    else
        successful="unsuccessfully"
    fi

    echo "Build completed $successful" | /bin/mailx -a $LOGFILE -s "SSSD automated build report for $datestamp" $recipients
    exit $1
}

if [ -e "/local/sgallagh/.sssd-build.lock" ]; then
    exit -1
fi

touch /local/sgallagh/.sssd-build.lock

mkdir -p /local/sgallagh/logs
cd /local/sgallagh
nextversion=$1
if [ x$nextversion == x ]; then
    nextversion=0.0.1
fi
datestamp=`date +%Y%m%d%H`
today=`date +%Y%m%d`
git_repo=$2
if [ x$git_repo == x ]; then
    git_repo=git://git.fedorahosted.org/sssd.git
    repodir=/local/sgallagh/repos
else
    scratch_build=1
    repodir=/local/sgallagh/repos/scratch
fi
gitbranch=$3

LOGFILE=/local/sgallagh/logs/nightly-$datestamp.log

echo "===== BUILD STARTED AT `date` =====" > $LOGFILE

echo "===== Cleaning old logs =====" > $LOGFILE
find /local/sgallagh/logs -type f -daystart -ctime +6 -name "nightly-*.log" -exec rm -f {} \; || finish 96

echo "===== Cleaning old RPMS =====" > $LOGFILE
find /local/sgallagh/repos/f11 -type f -daystart -ctime +6 -name "sssd-*" -exec rm -f {} \; || finish 98
find /local/sgallagh/repos/rhel5 -type f -daystart -ctime +6 -name "sssd-*" -exec rm -f {} \; || finish 99

echo "===== CHECKING OUT CODE =====" >> $LOGFILE
rm -Rf sssd-$datestamp #Remove an incomplete previous run
git clone $git_repo sssd-$datestamp >> $LOGFILE 2>&1
cd sssd-$datestamp
if [ x$gitbranch != x ]; then
    git branch $gitbranch origin/$gitbranch >> $LOGFILE 2>&1 || finish 96
    git checkout $gitbranch >> $LOGFILE 2>&1 || finish 97
fi
commit_id=`git log -1 --pretty=format:%h`

# If this is a scratch build, always run it
if [ x$scratch_build == x ]; then
    # See if the commit_id is different from the last run
    old_commit_id=`cat /local/sgallagh/.commit`
    if [ x$commit_id == x$old_commit_id ]; then
        cd /local/sgallagh && rm -Rf sssd-$datestamp
        rm -f $LOGFILE
        rm -f /local/sgallagh/.sssd-build.lock
        exit 0
    fi
fi

cd /local/sgallagh/sssd-$datestamp
prereleaseversion=".${datestamp}git${commit_id}"
echo $nextversion > VERSION
echo $prereleaseversion >> VERSION
rpmversion=$nextversion-0$prereleaseversion

mv contrib/sssd.spec.in contrib/sssd.spec.in.orig && \
sed -e "s/make %/make CFLAGS=\"-ggdb3 -O0\" %/" < contrib/sssd.spec.in.orig > contrib/sssd.spec.in

echo "===== CONFIGURING CODE =====" >> $LOGFILE
autoreconf -i -f >> $LOGFILE 2>&1  || finish 1
./configure >> $LOGFILE 2>&1 || finish 2
make srpms >> $LOGFILE 2>&1 || finish 3
cd rpmbuild/SRPMS

echo "===== BUILDING Fedora 12 i586 =====" >> $LOGFILE
mock -r fedora-12-i386 sssd-$rpmversion.fc11.src.rpm >> $LOGFILE 2>&1 || failed=1
if [ $failed ]; then
    cat /var/lib/mock/fedora-12-i386/result/build.log >> $LOGFILE
    finish 4
fi

echo "===== BUILDING Fedora 12 x86_64 =====" >> $LOGFILE
mock -r fedora-12-x86_64 sssd-$rpmversion.fc11.src.rpm >> $LOGFILE 2>&1 || failed=1
if [ $failed ]; then
    cat /var/lib/mock/fedora-12-x86_64/result/build.log >> $LOGFILE
    finish 5
fi

echo "===== CREATING Fedora 12 i586 YUM REPOSITORY ====" >> $LOGFILE
mkdir -p $repodir/f12/SRPMS
mkdir -p $repodir/f12/i386/DEBUGINFO
mkdir -p $repodir/f12/i386/RPMS
cp /var/lib/mock/fedora-12-i386/result/sssd-$rpmversion.fc11.src.rpm $repodir/f12/SRPMS
cp /var/lib/mock/fedora-12-i386/result/sssd-debuginfo-$rpmversion.fc11.i586.rpm $repodir/f12/i386/DEBUGINFO
cp /var/lib/mock/fedora-12-i386/result/sssd-$rpmversion.fc11.i586.rpm $repodir/f12/i386/RPMS
cp /var/lib/mock/fedora-12-i386/result/sssd-client-$rpmversion.fc11.i586.rpm $repodir/f12/i386/RPMS

createrepo $repodir/f12/SRPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 12 SRPM Repo updated" >> $LOGFILE
else
    echo "Fedora 12 SRPM Repo not updated" >> $LOGFILE
fi


createrepo $repodir/f12/i386/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 12 i386 DEBUGINFO Repo updated" >> $LOGFILE
else
    echo "Fedora 12 i386 DEBUGINFO Repo not updated" >> $LOGFILE
fi

createrepo $repodir/f12/i386/RPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 12 i386 RPM Repo updated" >> $LOGFILE
else
    echo "Fedora 12 i386 RPM Repo not updated" >> $LOGFILE
fi

echo "===== CREATING Fedora 12 x86_64 YUM REPOSITORY ====" >> $LOGFILE
mkdir -p $repodir/f12/x86_64/DEBUGINFO
mkdir -p $repodir/f12/x86_64/RPMS
cp /var/lib/mock/fedora-12-x86_64/result/sssd-debuginfo-$rpmversion.fc11.x86_64.rpm $repodir/f12/x86_64/DEBUGINFO
cp /var/lib/mock/fedora-12-i386/result/sssd-debuginfo-$rpmversion.fc11.i586.rpm $repodir/f12/x86_64/DEBUGINFO
cp /var/lib/mock/fedora-12-x86_64/result/sssd-$rpmversion.fc11.x86_64.rpm $repodir/f12/x86_64/RPMS
cp /var/lib/mock/fedora-12-x86_64/result/sssd-client-$rpmversion.fc11.x86_64.rpm $repodir/f12/x86_64/RPMS
cp /var/lib/mock/fedora-12-i386/result/sssd-client-$rpmversion.fc11.i586.rpm $repodir/f12/x86_64/RPMS

createrepo $repodir/f12/x86_64/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 12 x86_64 DEBUGINFO Repo updated" >> $LOGFILE
else
    echo "Fedora 12 x86_64 DEBUGINFO Repo not updated" >> $LOGFILE
fi

createrepo $repodir/f12/x86_64/RPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 12 x86_64 RPM Repo updated" >> $LOGFILE
else
    echo "Fedora 12 x86_64 RPM Repo not updated" >> $LOGFILE
fi

echo "===== BUILDING FEDORA 11 i586 =====" >> $LOGFILE
mock -r fedora-11-i386 sssd-$rpmversion.fc11.src.rpm >> $LOGFILE 2>&1 || failed=1
if [ $failed ]; then
    cat /var/lib/mock/fedora-11-i386/result/build.log >> $LOGFILE
    finish 4
fi

echo "===== BUILDING FEDORA 11 x86_64 =====" >> $LOGFILE
mock -r fedora-11-x86_64 sssd-$rpmversion.fc11.src.rpm >> $LOGFILE 2>&1 || failed=1
if [ $failed ]; then
    cat /var/lib/mock/fedora-11-x86_64/result/build.log >> $LOGFILE
    finish 5
fi

echo "===== CREATING FEDORA 11 i586 YUM REPOSITORY ====" >> $LOGFILE
mkdir -p $repodir/f11/SRPMS
mkdir -p $repodir/f11/i386/DEBUGINFO
mkdir -p $repodir/f11/i386/RPMS
cp /var/lib/mock/fedora-11-i386/result/sssd-$rpmversion.fc11.src.rpm $repodir/f11/SRPMS
cp /var/lib/mock/fedora-11-i386/result/sssd-debuginfo-$rpmversion.fc11.i586.rpm $repodir/f11/i386/DEBUGINFO
cp /var/lib/mock/fedora-11-i386/result/sssd-$rpmversion.fc11.i586.rpm $repodir/f11/i386/RPMS
cp /var/lib/mock/fedora-11-i386/result/sssd-client-$rpmversion.fc11.i586.rpm $repodir/f11/i386/RPMS

createrepo $repodir/f11/SRPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 11 SRPM Repo updated" >> $LOGFILE
else
    echo "Fedora 11 SRPM Repo not updated" >> $LOGFILE
fi


createrepo $repodir/f11/i386/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 11 i386 DEBUGINFO Repo updated" >> $LOGFILE
else
    echo "Fedora 11 i386 DEBUGINFO Repo not updated" >> $LOGFILE
fi

createrepo $repodir/f11/i386/RPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 11 i386 RPM Repo updated" >> $LOGFILE
else
    echo "Fedora 11 i386 RPM Repo not updated" >> $LOGFILE
fi

echo "===== CREATING FEDORA 11 x86_64 YUM REPOSITORY ====" >> $LOGFILE
mkdir -p $repodir/f11/x86_64/DEBUGINFO
mkdir -p $repodir/f11/x86_64/RPMS
cp /var/lib/mock/fedora-11-x86_64/result/sssd-debuginfo-$rpmversion.fc11.x86_64.rpm $repodir/f11/x86_64/DEBUGINFO
cp /var/lib/mock/fedora-11-i386/result/sssd-debuginfo-$rpmversion.fc11.i586.rpm $repodir/f11/x86_64/DEBUGINFO
cp /var/lib/mock/fedora-11-x86_64/result/sssd-$rpmversion.fc11.x86_64.rpm $repodir/f11/x86_64/RPMS
cp /var/lib/mock/fedora-11-x86_64/result/sssd-client-$rpmversion.fc11.x86_64.rpm $repodir/f11/x86_64/RPMS
cp /var/lib/mock/fedora-11-i386/result/sssd-client-$rpmversion.fc11.i586.rpm $repodir/f11/x86_64/RPMS

createrepo $repodir/f11/x86_64/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 11 x86_64 DEBUGINFO Repo updated" >> $LOGFILE
else
    echo "Fedora 11 x86_64 DEBUGINFO Repo not updated" >> $LOGFILE
fi

createrepo $repodir/f11/x86_64/RPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "Fedora 11 x86_64 RPM Repo updated" >> $LOGFILE
else
    echo "Fedora 11 x86_64 RPM Repo not updated" >> $LOGFILE
fi

echo "===== BUILDING RHEL 5 i386 =====" >> $LOGFILE
cd /local/sgallagh/sssd-$datestamp/rpmbuild/SRPMS
mv sssd-$rpmversion.fc11.src.rpm \
   sssd-$rpmversion.el5.src.rpm
mock -r epel-5-i386 sssd-$rpmversion.el5.src.rpm >> $LOGFILE 2>&1 || failed=1
if [ $failed ]; then
    cat /var/lib/mock/epel-5-i386/result/build.log >> $LOGFILE
    finish 6
fi

echo "===== BUILDING RHEL 5 x86_64 =====" >> $LOGFILE
mock -r epel-5-x86_64 sssd-$rpmversion.el5.src.rpm >> $LOGFILE 2>&1 || failed=1
if [ $failed ]; then
    cat /var/lib/mock/epel-5-x86_64/result/build.log >> $LOGFILE
    finish 7
fi

echo "===== CREATING RHEL 5 i586 YUM REPOSITORY ====" >> $LOGFILE
mkdir -p $repodir/rhel5/SRPMS
mkdir -p $repodir/rhel5/i386/DEBUGINFO
mkdir -p $repodir/rhel5/i386/RPMS
cp /var/lib/mock/epel-5-i386/result/sssd-$rpmversion.el5.src.rpm $repodir/rhel5/SRPMS
cp /var/lib/mock/epel-5-i386/result/sssd-debuginfo-$rpmversion.el5.i386.rpm $repodir/rhel5/i386/DEBUGINFO
cp /var/lib/mock/epel-5-i386/result/sssd-$rpmversion.el5.i386.rpm $repodir/rhel5/i386/RPMS
cp /var/lib/mock/epel-5-i386/result/sssd-client-$rpmversion.el5.i386.rpm $repodir/rhel5/i386/RPMS

createrepo -s sha1 $repodir/rhel5/SRPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "RHEL5 SRPM Repo updated" >> $LOGFILE
else
    echo "RHEL5 SRPM Repo not updated" >> $LOGFILE
fi

createrepo -s sha1 $repodir/rhel5/i386/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
    echo "RHEL5 i386 DEBUGINFO Repo updated" >> $LOGFILE
else
    echo "RHEL5 i386 DEBUGINFO Repo not updated" >> $LOGFILE
fi

createrepo -s sha1 $repodir/rhel5/i386/RPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "RHEL5 i386 RPM Repo updated" >> $LOGFILE
else
    echo "RHEL5 i386 RPM Repo not updated" >> $LOGFILE
fi

echo "===== CREATING RHEL 5 x86_86 YUM REPOSITORY ====" >> $LOGFILE
mkdir -p $repodir/rhel5/x86_64/DEBUGINFO
mkdir -p $repodir/rhel5/x86_64/RPMS
cp /var/lib/mock/epel-5-x86_64/result/sssd-debuginfo-$rpmversion.el5.x86_64.rpm $repodir/rhel5/x86_64/DEBUGINFO
cp /var/lib/mock/epel-5-i386/result/sssd-debuginfo-$rpmversion.el5.i386.rpm $repodir/rhel5/x86_64/DEBUGINFO
cp /var/lib/mock/epel-5-x86_64/result/sssd-$rpmversion.el5.x86_64.rpm $repodir/rhel5/x86_64/RPMS
cp /var/lib/mock/epel-5-x86_64/result/sssd-client-$rpmversion.el5.x86_64.rpm $repodir/rhel5/x86_64/RPMS
cp /var/lib/mock/epel-5-i386/result/sssd-client-$rpmversion.el5.i386.rpm $repodir/rhel5/x86_64/RPMS

createrepo -s sha1 $repodir/rhel5/x86_64/DEBUGINFO > /dev/null
if [ $? -eq 0 ]; then
    echo "RHEL5 x86_64 DEBUGINFO Repo updated" >> $LOGFILE
else
    echo "RHEL5 x86_64 DEBUGINFO Repo not updated" >> $LOGFILE
fi

createrepo -s sha1 $repodir/rhel5/x86_64/RPMS > /dev/null
if [ $? -eq 0 ]; then
    echo "RHEL5 x86_64 RPM Repo updated" >> $LOGFILE
else
    echo "RHEL5 x86_64 RPM Repo not updated" >> $LOGFILE
fi

echo "===== Removing Source Tree =====" >> $LOGFILE
cd /local/sgallagh && rm -Rf sssd-$datestamp

#Save the commit id for the next time
if [ x$scratch_build == x ]; then
    echo $commit_id > /local/sgallagh/.commit
fi

echo "===== BUILD CONCLUDED AT `date` =====" >> $LOGFILE

finish 0