forked from gofed/gofed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitPackageInRepo.sh
executable file
·227 lines (197 loc) · 5.25 KB
/
initPackageInRepo.sh
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
#!/bin/sh
# $1 pkg_name
# $2 review request bug id
script_dir=$(dirname $0)
if [ "$1" == "" ]; then
echo "Synopsis: PACKAGE REVIEWBUGID"
exit 1
fi
if [ "$2" == "" ]; then
echo "Synopsis: PACKAGE REVIEWBUGID"
exit 1
fi
pkg_name=$1
bug_id=$2
############# clone the repo and cd to its directory #############
# $1 ... pkg_name
function dirExists {
ls $1/fedora/$1 >/dev/null 2>/dev/null
echo $?
}
# $1 ... pkg_name
function cloneRepo {
mkdir -p $1
cd $1
mkdir -p fedora
cd fedora
fedpkg clone $1
}
############# download srpm #############
# $1 ... pkg_name
function downloadSrpm {
srpm=$(ssh [email protected] "ls public_html/reviews/$1/*.src.rpm")
srpm=$(basename $srpm)
wget -q https://jchaloup.fedorapeople.org/reviews/$1/$srpm >/dev/null 2>/dev/null
if [ "$?" -eq 0 ]; then
echo $srpm
else
echo ""
fi
}
############# import srpm to repo #############
# $1 ... srpm
function importSrpm {
fedpkg import $1
}
############# has resolves: #bug_id? #############
# $1 ... pkg_name
# $2 ... bug_id
function hasResolves {
has_resolves=$(cat *.spec | grep resolves | grep $2 | wc -l)
if [ "$has_resolves" -eq 0 ]; then
echo "Missing Resolves: #$2"
read -p "Open vim? [y/n]. n means quit: " input
if [ "$input" == "y" ]; then
echo " resolves: #$2" >> ${1}.spec
vi *.spec
read -p "Continue? [y/n]: " input
if [ "$input" == "n" ]; then
exit 1
fi
else
exit 1
fi
git add *.spec
git commit --verbose
fi
}
############# clone master to all other branches #############
function cloneMasterToBranches {
gofed tools --gcp
}
############# scratch build of all branches #############
function scratchBuildBranches {
gofed scratch-build
ret=$?
echo "Return value: $ret"
read -p "Continue? [y/n]: " input
if [ "$input" == "n" ]; then
exit 1
fi
}
############# push and build of all branches #############
function pushAndBuildBranches {
gofed parallel-push
gofed build
ret=$?
echo "Return value: $ret"
read -p "Continue? [y/n]: " input
if [ "$input" == "n" ]; then
exit 1
fi
}
############# update all branches except master and f22 #############
function updateBranches {
gofed update
}
# $1 ... srpm
function bboBuilds {
build=$(echo $1 | rev | sed 's/^[^.]*\.[^.]*\.[^.]*\.//' | rev)
read -p "$build detected. Continue? [y/n]: " input
if [ "$input" == "n" ]; then
exit 1
fi
gofed bbo $build
}
state_file=".initpkg.state"
#echo "#### cache of gofed initpkg ####" > $state_file
e=$(dirExists $pkg_name)
if [ "$e" -eq 0 ]; then
cd $pkg_name/fedora/$pkg_name
if [ ! -f $state_file ]; then
echo "# clone the repo and cd to its directory" >> $state_file
echo "1: $(pwd)" >> $state_file
fi
else
cloneRepo $pkg_name
cd $pkg_name
echo "# clone the repo and cd to its directory" >> $state_file
echo "1: $(pwd)" >> $state_file
fi
# get the last step executed
# this loop handles empty lines
for line in $(cat $state_file | grep -v "^#" | cut -d':' -f1); do
last_step=$line
done
STEP_CLONE_REPO=1
STEP_DOWNLOAD_SRPM=2
STEP_IMPORT_SRPM=3
STEP_HAS_RESOLVES=4
STEP_CLONE_TO_BRANCHES=5
STEP_SCRATCH_BUILD=6
STEP_PUSH_AND_BUILD=7
STEP_UPDATE_BRANCHES=8
STEP_OVERRIDE=9
srpm=""
if [ "$last_step" -lt $STEP_DOWNLOAD_SRPM ]; then
srpm=$(downloadSrpm $pkg_name)
if [ "$srpm" == "" ]; then
echo "Unable to wget SRPM"
exit 1
fi
echo "# download srpm" >> $state_file
echo "2: $srpm" >> $state_file
else
srpm=$(ssh [email protected] "ls public_html/reviews/$1/*.src.rpm")
srpm=$(basename $srpm)
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_DOWNLOAD_SRPM:")
fi
if [ "$last_step" -lt $STEP_IMPORT_SRPM ]; then
importSrpm $srpm
echo "# import srpm" >> $state_file
echo "3: srpm imported" >> $state_file
else
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_IMPORT_SRPM:")
fi
if [ "$last_step" -lt $STEP_HAS_RESOLVES ]; then
hasResolves $pkg_name $bug_id
echo "# has resolves" >> $state_file
echo "4: resolves: #$bug_id " >> $state_file
else
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_HAS_RESOLVES:")
fi
if [ "$last_step" -lt $STEP_CLONE_TO_BRANCHES ]; then
cloneMasterToBranches
echo "# clone master to other branches" >> $state_file
echo "5: cloned to other branches " >> $state_file
else
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_CLONE_TO_BRANCHES:")
fi
if [ "$last_step" -lt $STEP_SCRATCH_BUILD ]; then
scratchBuildBranches
echo "# scratch build branches" >> $state_file
echo "6: scratch build branches " >> $state_file
else
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_SCRATCH_BUILD:")
fi
if [ "$last_step" -lt $STEP_PUSH_AND_BUILD ]; then
pushAndBuildBranches
echo "# build branches" >> $state_file
echo "7: build branches " >> $state_file
else
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_PUSH_AND_BUILD:")
fi
if [ "$last_step" -lt $STEP_UPDATE_BRANCHES ]; then
updateBranches
echo "# update branches" >> $state_file
echo "8: update branches " >> $state_file
else
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_UPDATE_BRANCHES:")
fi
if [ "$last_step" -lt $STEP_OVERRIDE ]; then
bboBuilds $srpm
echo "# buildroot override branches" >> $state_file
echo "9: buildroot override branches " >> $state_file
else
echo "skipping:" $(cat $state_file | grep -v "^#" | grep "^$STEP_OVERRIDE:")
fi