-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathosc-info.sh
executable file
·538 lines (440 loc) · 18.8 KB
/
osc-info.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
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
#!/bin/bash
mkdir -p osc-cache/
rm -f osc-info.stop
refresh=0
while [ $# -gt 0 ]; do
case $1 in
--refresh)
refresh=1
shift
;;
*)
package_refresh=$1
shift
;;
esac
done
echo -n "Gathering projects ..."
# List the projects and cache them locally.
if [ ! -f "osc_cache/obs_projects.list" -o ${refresh} -eq 1 ]; then
osc ls | grep -vE "^(home|deleted)" > osc-cache/obs_projects.list
# Legacy Kolab releases do not need to be updated
sed -r -i \
-e '/^cyrus-imapd/d' \
-e '/^Infrastructure/d' \
-e '/^Kolab:3\.0/d' \
-e '/^Kolab:3\.1/d' \
-e '/^Kolab:3\.2/d' \
-e '/^Kolab:3\.3/d' \
-e '/^Kolab:3\.4/d' \
-e '/^Kolab:Development/d' \
-e '/^Kube/d' \
-e '/^Tools/d' \
osc-cache/obs_projects.list
# Legacy target platforms do not need to be updated
sed -r -i \
-e '/^Debian:6\.0/d' \
-e '/^Debian:7\.0/d' \
-e '/^Fedora:17/d' \
-e '/^Fedora:18/d' \
-e '/^Fedora:19/d' \
-e '/^Fedora:20/d' \
-e '/^Fedora:21/d' \
-e '/^openSUSE:12\.1/d' \
-e '/^openSUSE:12\.2/d' \
-e '/^openSUSE:12\.3/d' \
-e '/^openSUSE:13\.1/d' \
-e '/^UCS:3\.0/d' \
-e '/^UCS:3\.1/d' \
-e '/^UCS:3\.2/d' \
-e '/^UCS:4\.0/d' \
-e '/^Kontact/d' \
osc-cache/obs_projects.list
fi
echo " DONE"
obs_projects=$(cat osc-cache/obs_projects.list | sort --version-sort -r)
# Placeholder for Kolab projects
declare -a kolab_projects
# Placeholder for target platform repositories
declare -a target_repositories
# First, attempt to discover the maximum width of:
#
# - Either the table column header or any project names, and
# - Either the table column header or any target platform name.
package_column_width=0
project_column_width=0
target_column_width=0
version_column_width=36
for project in ${obs_projects}; do
if [ -z "$(echo ${project} | grep ^Kolab)" ]; then
target_repositories[${#target_repositories[@]}]=$(echo ${project} | sed -e 's/:/_/g')
# Determine if the name of this project is longer than any other project
# name we've seen before
if [ $(echo -n "$(echo ${project} | sed -e 's/:/_/g')" | wc -c) -gt ${target_column_width} ]; then
target_column_width=$(echo -n "$(echo ${project} | sed -e 's/:/_/g')" | wc -c)
fi
else
kolab_projects[${#kolab_projects[@]}]="${project}"
# Determine if the name of this project is longer than any other project
# name we've seen before
if [ $(echo -n "${project}" | wc -c) -gt ${project_column_width} ]; then
project_column_width=$(echo -n "${project}" | wc -c)
fi
fi
done
# Capture all names being shorter than the header.
if [ $(echo -n "Kolab Version(s)" | wc -c) -gt ${project_column_width} ]; then
project_column_width=$(echo -n "Kolab Version(s)" | wc -c)
fi
if [ $(echo -n "Platform(s)" | wc -c) -gt ${target_column_width} ]; then
target_column_width=$(echo -n "Platform(s)" | wc -c)
fi
# List all packages in all projects
current=0
cur_percentage=0
total=${#kolab_projects[@]}
while [ ${current} -lt ${#kolab_projects[@]} ]; do
project=${kolab_projects[${current}]}
if [ ! -f "osc-cache/${project}_packages.list" -o ${refresh} -eq 1 ]; then
osc ls ${project} > osc-cache/${project}_packages.list
fi
if [ $(( ${current} * 100 / ${total} )) -ne ${cur_percentage} ]; then
echo -en "Listing packages for projects: $(printf %3d $(( ${current} * 100 / ${total} )))%\r"
export cur_percentage=$(( ${current} * 100 / ${total} ))
fi
export cur_percentage=$(( ${current} * 100 / ${total} ))
let current++
done
echo -en "Listing packages for projects: $(printf %3d $(( ${current} * 100 / ${total} )))%\r"
# Remove the exceptions to the rule
sed -r -i \
-e '/^roundcubemail-skin-contargo$/d' \
-e '/^roundcubemail-skin-ssd$/d' \
osc-cache/*_packages.list
cat osc-cache/*_packages.list | sort -u > osc-cache/packages.list
for package in $(cat osc-cache/packages.list); do
if [ $(echo -n "${package}" | wc -c) -gt ${package_column_width} ]; then
package_column_width=$(echo -n "${package}" | wc -c)
fi
done
package_column_width=$(( ${package_column_width} * 2 + $(echo -n ":ref:\`about-\'" | wc -c) ))
if [ $(echo -n "Package Name(s)" | wc -c) -gt ${package_column_width} ]; then
package_column_width=$(echo -n "Package Name(s)" | wc -c)
fi
echo ""
# To initialize the tables, first iterate over all unique packages (across all
# projects).
if [ ! -z "${package_refresh}" ]; then
packages=${package_refresh}
else
packages=$(cat osc-cache/*_packages.list | sort -u)
fi
total=$(cat osc-cache/*_packages.list | sort -u | wc -l)
current=1
cur_percentage=0
# Temp
#if [ 0 -eq 1 ]; then
for package in ${packages}; do
if [ -f "osc-info.stop" ]; then
echo "Stop issued."
exit 1
fi
target="source/about/${package}/version-matrix.rst"
if [ ! -d "$(dirname ${target})" ]; then
cp -a source/about/.template/ $(dirname ${target})
sed -i -e "s/template/${package}/g" $(find source/about/${package}/ -type f)
fi
sed -i -r -e "s/^[=]+$/$(echo ${package} | sed -e 's/./=/g')/g" source/about/${package}/index.rst
sed -i -r -e '0,/^[=]+$/{/^[=]+$/d}' $(find source/about/${package}/ -type f ! -name "index.rst")
if [ -f "${target}" ]; then
rm -rf ${target}
fi
x=0
while [ ${x} -lt ${#kolab_projects[@]} ]; do
project=${kolab_projects[${x}]}
if [ ! -f "osc-cache/${project}_${package}.meta" -o ${refresh} -eq 1 ]; then
osc meta pkg ${project} ${package} > osc-cache/${project}_${package}.meta 2>/dev/null
fi
let x++
done
echo ".. _about-$(echo ${package} | tr '[:upper:]' '[:lower:]')-version-matrix:" >> ${target}
echo "" >> ${target}
echo "Version Matrix" >> ${target}
echo "==============" >> ${target}
echo "" >> ${target}
if [ -f "source/about/${package}/notes.txt" ]; then
cat "source/about/${package}/notex.txt" >> ${target}
echo "" >> ${target}
fi
echo ".. table:: Version Table for ${package}" >> ${target}
echo "" >> ${target}
printf "%s" " +-" >> ${target}
printf "%*.*s" 0 ${project_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${target_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${version_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+" >> ${target}
echo "" >> ${target}
printf "%s" " | " >> ${target}
printf "%-${project_column_width}s" "Kolab Version(s)" >> ${target}
printf "%s" " | " >> ${target}
printf "%-${target_column_width}s" "Platform(s)" >> ${target}
printf "%s" " | " >> ${target}
printf "%-${version_column_width}s" "Version" >> ${target}
printf "%s" " |" >> ${target}
echo "" >> ${target}
printf "%s" " +=" >> ${target}
printf "%*.*s" 0 ${project_column_width} $(printf '%0.1s' "="{1..60}) >> ${target}
printf "%s" "=+=" >> ${target}
printf "%*.*s" 0 ${target_column_width} $(printf '%0.1s' "="{1..60}) >> ${target}
printf "%s" "=+=" >> ${target}
printf "%*.*s" 0 ${version_column_width} $(printf '%0.1s' "="{1..60}) >> ${target}
printf "%s" "=+" >> ${target}
echo "" >> ${target}
if [ $(( ${current} * 100 / ${total} )) -ne ${cur_percentage} ]; then
echo -en "Initialize package tables: $(printf %3d $(( ${current} * 100 / ${total} )))%\r"
export cur_percentage=$(( ${current} * 100 / ${total} ))
fi
export cur_percentage=$(( ${current} * 100 / ${total} ))
let current++
done
echo ""
# Loop through our projects,
# then through the packages for that project,
# then see what the packages are configured to build for,
# then see where the package originates from and what version is included, or
# we include.
x=0
while [ ${x} -lt ${#kolab_projects[@]} ]; do
project=${kolab_projects[${x}]}
if [ ! -z "${package_refresh}" ]; then
packages=${package_refresh}
else
packages=$(cat osc-cache/*_packages.list | sort -u)
fi
current=1
cur_percentage=0
total=$(cat osc-cache/*_packages.list | sort -u | wc -l)
for package in ${packages}; do
if [ -f "osc-info.stop" ]; then
echo "Stop issued."
exit 1
fi
enabled_repositories=""
target="source/about/${package}/version-matrix.rst"
if [ -s "osc-cache/${project}_${package}.meta" ]; then
disabled_default=$(awk '/<build>/,/<\/build>/' osc-cache/${project}_${package}.meta | grep -E "^\s*<disable/>$")
else
disabled_default="yes"
fi
if [ -z "${disabled_default}" ]; then
disabled_repositories=$(
awk '/<build>/,/<\/build>/' osc-cache/${project}_${package}.meta | \
grep -E "^\s*<disable repository.*" | \
sed -r -e 's/\s*<disable repository="(.*)"\/>/\1/g' | \
sort -u
)
y=$(( ${#target_repositories[@]} - 1 ))
while [ ${y} -ge 0 ]; do
repo_disabled=0
for disabled_repository in ${disabled_repositories}; do
if [ "${target_repositories[${y}]}" == "${disabled_repository}" ]; then
repo_disabled=1
fi
done
if [ ${repo_disabled} -eq 0 ]; then
enabled_repositories="${enabled_repositories} ${target_repositories[${y}]}"
fi
let y--
done
elif [ "${disabled_default}" == "yes" ]; then
enabled_repositories=""
else
enabled_repositories=$(
awk '/<build>/,/<\/build>/' osc-cache/${project}_${package}.meta | \
grep -E "^\s*<enable repository.*" | \
sed -r -e 's/\s*<enable repository="(.*)"\/>/\1/g' | \
sort -u
)
fi
if [ ! -z "${enabled_repositories}" ]; then
have_had_first=0
for enabled_repository in ${enabled_repositories}; do
# Here be version magic.
# osc buildinfo Kolab:3.1 389-admin Debian_7.0 x86_64 | awk '/<versrel>/,/<\/versrel>/' | sed -e 's/\s*<versrel>//g' -e 's/<\/versrel>//g'
if [ ! -s "osc-cache/${project}_${enabled_repository}_${package}.version" -o ${refresh} -eq 1 ]; then
osc buildinfo ${project} ${package} ${enabled_repository} x86_64 2>/dev/null | awk '/<versrel>/,/<\/versrel>/' | sed -e 's/\s*<versrel>//g' -e 's/<\/versrel>//g' > osc-cache/${project}_${enabled_repository}_${package}.version
fi
version=$(cat osc-cache/${project}_${enabled_repository}_${package}.version)
if [ -z "${version}" ]; then
continue
fi
if [ ${have_had_first} -eq 0 ]; then
printf " | %-${project_column_width}s |" ${project} >> ${target}
printf " %-${target_column_width}s | %-${version_column_width}s |" ${enabled_repository} ${version} >> ${target}
echo "" >> ${target}
printf "%s" " +-" >> ${target}
printf "%*.*s" 0 ${project_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${target_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${version_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+" >> ${target}
echo "" >> ${target}
have_had_first=1
else
printf " | %-${project_column_width}s |" >> ${target}
printf " %-${target_column_width}s | %-${version_column_width}s |" ${enabled_repository} ${version} >> ${target}
echo "" >> ${target}
printf "%s" " +-" >> ${target}
printf "%*.*s" 0 ${project_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${target_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${version_column_width} $(printf '%0.1s' "-"{1..60}) >> ${target}
printf "%s" "-+" >> ${target}
echo "" >> ${target}
fi
done
fi
if [ $(( ${current} * 100 / ${total} )) -ne ${cur_percentage} ]; then
echo -en "${project}: $(printf %3d $(( ${current} * 100 / ${total} )))%\r"
export cur_percentage=$(( ${current} * 100 / ${total} ))
fi
export cur_percentage=$(( ${current} * 100 / ${total} ))
let current++
done
echo ""
let x++
done
# Temp
#fi
# Projects page
current=0
cur_percentage=0
total=${#kolab_projects[@]}
while [ ${current} -lt ${#kolab_projects[@]} ]; do
project=${kolab_projects[${current}]}
project_lc=$(echo ${project} | sed -e 's/:/-/g' | tr '[:upper:]' '[:lower:]')
target="source/about/${project_lc}.rst"
enabled_repositories=""
if [ -f "${target}" ]; then
rm -rf ${target}
fi
echo ".. _product-${project_lc}:" >> ${target}
echo "" >> ${target}
echo "${project}" >> ${target}
echo "${project}" | sed -r -e 's/./=/g' >> ${target}
echo "" >> ${target}
if [ ! -f "osc-cache/${project}.meta" -o ${refresh} -eq 1 ]; then
osc meta prj ${project} > osc-cache/${project}.meta 2>/dev/null
fi
if [ -s "osc-cache/${project}.meta" ]; then
disabled_default=$(awk '/<build>/,/<\/build>/' osc-cache/${project}.meta | grep -E "^\s*<disable/>$")
else
disabled_default="yes"
fi
if [ -z "${disabled_default}" ]; then
disabled_repositories=$(
awk '/<build>/,/<\/build>/' osc-cache/${project}.meta | \
grep -E "^\s*<disable repository.*" | \
sed -r -e 's/\s*<disable repository="(.*)"\/>/\1/g' | \
sort -u
)
y=$(( ${#target_repositories[@]} - 1 ))
while [ ${y} -ge 0 ]; do
repo_disabled=0
for disabled_repository in ${disabled_repositories}; do
if [ "${target_repositories[${y}]}" == "${disabled_repository}" ]; then
repo_disabled=1
fi
done
if [ ${repo_disabled} -eq 0 ]; then
enabled_repositories="${enabled_repositories} ${target_repositories[${y}]}"
fi
let y--
done
elif [ "${disabled_default}" == "yes" ]; then
enabled_repositories=""
else
enabled_repositories=$(
awk '/<build>/,/<\/build>/' osc-cache/${project}.meta | \
grep -E "^\s*<enable repository.*" | \
sed -r -e 's/\s*<enable repository="(.*)"\/>/\1/g' | \
sort -u
)
fi
packages=$(cat osc-cache/${project}_packages.list)
if [ ! -z "${enabled_repositories}" ]; then
echo "Version Matrices per Target Platform" >> ${target}
echo "------------------------------------" >> ${target}
echo "" >> ${target}
for enabled_repository in ${enabled_repositories}; do
num_packages=0
for package in ${packages}; do
if [ -s "osc-cache/${project}_${enabled_repository}_${package}.version" ]; then
num_packages=$(( ${num_packages} + 1 ))
fi
done
if [ ${num_packages} -lt 1 ]; then
continue
fi
echo "* :ref:\`about-${project_lc}-$(echo ${enabled_repository} | sed -e 's/_/-/g' -e 's/:/-/g' | tr '[:upper:]' '[:lower:]')\`" >> ${target}
done
echo "" >> ${target}
fi
for enabled_repository in ${enabled_repositories}; do
num_packages=0
for package in ${packages}; do
if [ -s "osc-cache/${project}_${enabled_repository}_${package}.version" ]; then
num_packages=$(( ${num_packages} + 1 ))
fi
done
if [ ${num_packages} -lt 1 ]; then
continue
fi
echo ".. _about-${project_lc}-$(echo ${enabled_repository} | sed -e 's/_/-/g' -e 's/:/-/g' | tr '[:upper:]' '[:lower:]'):" >> ${target}
echo "" >> ${target}
echo "${enabled_repository}" >> ${target}
echo "${enabled_repository}" | sed -r -e 's/./^/g' >> ${target}
echo "" >> ${target}
echo ".. table:: Version Matrix for ${enabled_repository}" >> ${target}
echo "" >> ${target}
printf "%s" " +-" >> ${target}
printf "%*.*s" 0 ${package_column_width} $(printf '%0.1s' "-"{1..120}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${version_column_width} $(printf '%0.1s' "-"{1..120}) >> ${target}
printf "%s" "-+" >> ${target}
echo "" >> ${target}
printf "%s" " | " >> ${target}
printf "%-${package_column_width}s" "Package Name(s)" >> ${target}
printf "%s" " | " >> ${target}
printf "%-${version_column_width}s" "Version" >> ${target}
printf "%s" " |" >> ${target}
echo "" >> ${target}
printf "%s" " +=" >> ${target}
printf "%*.*s" 0 ${package_column_width} $(printf '%0.1s' "="{1..120}) >> ${target}
printf "%s" "=+=" >> ${target}
printf "%*.*s" 0 ${version_column_width} $(printf '%0.1s' "="{1..120}) >> ${target}
printf "%s" "=+" >> ${target}
echo "" >> ${target}
for package in ${packages}; do
if [ -s "osc-cache/${project}_${enabled_repository}_${package}.version" ]; then
package_version=$(cat "osc-cache/${project}_${enabled_repository}_${package}.version")
printf "%s" " | " >> ${target}
printf "%-${package_column_width}s | %-${version_column_width}s |" ":ref:\`about-$(echo ${package} | tr '[:upper:]' '[:lower:]')\`" ${package_version} >> ${target}
echo "" >> ${target}
printf "%s" " +-" >> ${target}
printf "%*.*s" 0 ${package_column_width} $(printf '%0.1s' "-"{1..120}) >> ${target}
printf "%s" "-+-" >> ${target}
printf "%*.*s" 0 ${version_column_width} $(printf '%0.1s' "-"{1..120}) >> ${target}
printf "%s" "-+" >> ${target}
echo "" >> ${target}
fi
done
echo "" >> ${target}
done
let current++
done
echo ""