-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrailsbuild-build
executable file
·136 lines (118 loc) · 3.63 KB
/
railsbuild-build
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
#!/usr/bin/bash
# Run Rails build of new packages. For every package run scratch-build
# first and if that succeeds, push changes and run the final build.
#
# Done builds are marked by .build in the repository, so running
# this script after it failed will pick up the work from the last run.
#
# Usage:
# ./railsbuild-build FEDORA_VERSION VERSION
. $(dirname $(readlink -f "$0"))/railsbuild-common
FEDORA_VERSION=$1
VERSION=$2
for gem in "${GEMS[@]}"
do
pushd ~/.railsbuild/f$FEDORA_VERSION/rubygem-$gem
# Skip already done builds
if [ -f .built ]; then
echo "$gem: build for $gem already done"
continue
fi
# Check changelog in spec file for same EVR
if [ -n "$(
sed -n '/^%changelog/,$p' rubygem-$gem.spec \
| grep -E " [0-9]+\:[0-9]+\.[0-9]+\.[0-9]+\-[0-9]+$" \
| head -n 2 | rev | cut -d' ' -f1 \
| sort | uniq -c | grep -vE "^[ ]*1 "
)" ]; then
echo "= FAIL ======"
echo "$gem: same EVR in changelog already exists"
exit 1
fi
rm *.src.rpm
fedpkg scratch-build --srpm
if [ "$?" = "0" ]; then
touch .scratch-built
git stash
echo "= SUCCESS ======"
echo "$gem: scratch build of rubygem-$gem succeeded"
fedpkg import rubygem-$gem-*.src.rpm > /dev/null
if [ ! "$?" = "0" ]; then
echo "= FAIL ======"
echo "$gem: fedpkg import failed"
exit 1
fi
git commit -am "Update to $gem $VERSION"
git push
fedpkg build
if [ "$?" = "0" ]; then
echo "= SUCCESS ======"
echo "$gem: build of rubygem-$gem succeeded"
echo "$gem: waiting until the build becomes available..."
koji wait-repo f$FEDORA_VERSION-build --build=rubygem-$gem-$VERSION-1.fc$FEDORA_VERSION
touch .built
else
echo "= FAIL ======"
echo "$gem: build of rubygem-$gem failed"
exit 1
fi
else
echo "= FAIL ======"
echo "$gem: scratch-build of rubygem-$gem failed"
exit 1
fi
popd
done
# Update bootsrapped gems
$(dirname $(readlink -f "$0"))/railsbuild-update-bootstrapped $FEDORA_VERSION $VERSION
# Build bootsrapped gems again
for gem in "${BOOTSTRAPPED_GEMS[@]}"
do
pushd ~/.railsbuild/f$FEDORA_VERSION/rubygem-$gem
# Skip already done builds
if [ ! -f .bootstrapped ]; then
echo "$gem: final build for bootsrapped $gem already done"
continue
fi
rm .scratch-built
rm *.src.rpm
fedpkg scratch-build --srpm
if [ "$?" = "0" ]; then
touch .scratch-built
git stash
echo "= SUCCESS ======"
echo "$gem: scratch build of rubygem-$gem succeeded"
fedpkg import rubygem-$gem-*.src.rpm > /dev/null
if [ ! "$?" = "0" ]; then
echo "= FAIL ======"
echo "$gem: fedpkg import failed"
exit 1
fi
git commit -am "Enable tests"
git push
fedpkg build
if [ "$?" = "0" ]; then
echo "= SUCCESS ======"
echo "$gem: build of rubygem-$gem succeeded"
echo "$gem: waiting until the build becomes available..."
koji wait-repo f$FEDORA_VERSION-build --build=rubygem-$gem-$VERSION-1.fc$FEDORA_VERSION
rm .bootsrapped
else
echo "= FAIL ======"
echo "$gem: build of rubygem-$gem failed"
exit 1
fi
else
echo "= FAIL ======"
echo "$gem: scratch-build of rubygem-$gem failed"
exit 1
fi
popd
done
echo
echo
echo "= SUCCESSFULLY DONE ====="
echo "Build of Ruby on Rails $VERSION for Fedora release $FEDORA_VERSION done."
echo
echo "Run the following to delete the build metadata:"
echo " rm ~/.railsbuild/f$FEDORA_VERSION/rubygem-*/.*built"