summaryrefslogtreecommitdiff
path: root/bin/build-master-status
blob: 9330afefc508c0569efa93e32b63755029cead83 (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
#!/bin/sh

# report about status of build master

. "${0%/*}/../conf/default.conf"

if [ "x$1" = "x-o" ]; then
  output_file="$2"
  output() {
    cat >> "${output_file}"
  }
  : > "$2"
else
  output() {
    cat
  }
fi

stable="$(
  ${master_mirror_command} "${master_mirror_directory}/i686/" | \
    awk '{print $5}' | \
    grep -v 'testing$\|staging$\|^\.$' | \
    while read -r dir; do
      ${master_mirror_command} "${master_mirror_directory}/i686/${dir}/"
    done | \
    grep -c '\.pkg\.tar\.xz$'
  )"
tasks="$(
  wc -l < \
    "${work_dir}/build-list"
  )"
pending_packages="$(
  tr ' ' '.' < \
    "${work_dir}"/build-list | \
    while read -r package; do
      generate_package_metadata "${package}" &> /dev/null
      cat "${work_dir}/package-infos/${package%.*}.packages"
    done |
    wc -l
)"
staging="$(
  ${master_mirror_command} "${master_mirror_directory}/i686/" | \
    awk '{print $5}' | \
    grep 'staging$' | \
    while read -r dir; do
      ${master_mirror_command} "${master_mirror_directory}/i686/${dir}/"
    done | \
    grep -c '\.pkg\.tar\.xz$'
  )"
testing="$(
  ${master_mirror_command} "${master_mirror_directory}/i686/" | \
    awk '{print $5}' | \
    grep 'testing$' | \
    while read -r dir; do
      ${master_mirror_command} "${master_mirror_directory}/i686/${dir}/"
    done | \
    grep -c '\.pkg\.tar\.xz$'
  )"
broken="$(
  ls "${work_dir}/package-states/" | \
    grep -c '\.broken$'
  )" || true
loops="$(
  ls "${work_dir}/build-list.loops" | \
    grep -c '^loop_[0-9]\+$'
  )" || true
looped_packages="$(
  ls "${work_dir}/build-list.loops" | \
    grep '^loop_[0-9]\+$' | \
    sed "s|^|${work_dir}/build-list.loops/|" | \
    xargs -r cat | \
    sort -u | \
    wc -l
  )"

printf 'The mirror master contains %d stable packages (vs. ca. %d planned).\n' \
  "${stable}" \
  "$((${staging}+${testing}+${pending_packages}))" | \
  output
printf 'The build list contains %d tasks (incl. broken: %d, leading to %d packages).\n' \
  "$((${tasks}-${broken}))" \
  "${tasks}" \
  "${pending_packages}" | \
  output
printf 'There are %d testing and %d staging packages.\n' \
  "${testing}" \
  "${staging}" | \
  output
printf 'There are %d broken package builds.\n' \
  "${broken}" | \
  output
if [ "${loops}" -ne 0 ]; then
  printf 'There are %d loops containing %d package builds.\n' \
    "${loops}" \
    "${looped_packages}" | \
    output
fi
if [ $((${broken}+${testing}+${staging})) -ne 0 ]; then
  printf '%.1f%% of all packages are broken.\n' \
    "$(
      echo "scale=10; 100*${broken}/(${broken}+${testing}+${staging})" | \
        bc
    )" | \
    output
fi
if [ $((${testing}+${staging}+${pending_packages}-${broken})) -ne 0 ]; then
  printf '%.1f%% of the planned work has been done.\n' \
    "$(
      echo "scale=10; 100*(${testing}+${staging})/(${testing}+${staging}+${pending_packages}-${broken})" | \
        bc
    )" | \
    output
fi