Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/check-upstream-bug-tracker
blob: 71754d0433e794a73e4467c216eb4f62259e9a09 (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
#!/bin/sh

# check archlinux' bug tracker for open bugs on packages that fail to build

# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"

tmp_dir=$(mktemp -d 'tmp.check-upstream-bug-tracker.XXXXXXXXXX' --tmpdir)
trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT

>&2 printf 'receiving upstream bugs of broken packages '

# shellcheck disable=SC2016
{
  printf 'SELECT DISTINCT'
  printf '`package_sources`.`%s`,' \
    'pkgbase' \
    'git_revision' \
    'mod_git_revision'
  printf '`upstream_repositories`.`name`'
  printf ' FROM `package_sources`'
  mysql_join_package_sources_upstream_repositories
  mysql_join_package_sources_build_assignments
  mysql_join_build_assignments_binary_packages
  mysql_join_binary_packages_binary_packages_in_repositories
  printf ' WHERE `binary_packages_in_repositories`.`repository`=%s' \
    "${repository_ids__any_build_list}"
  printf ' AND `build_assignments`.`is_broken`'
  printf ' AND `build_assignments`.`is_blocked` IS NULL;\n'
} | \
  mysql_run_query 'unimportant' | \
  while read -r pkgbase git_revision mod_git_revision repository; do
    >&2 printf '.'
    curl -Ssg 'https://bugs.archlinux.org/index.php?string=['"${pkgbase}"']&project=5&status[]=open' | \
      sed -n '
        s@^.*<td class='"'"'task_id'"'"'><a href="https://bugs\.archlinux\.org/task/\([0-9]\+\)?.*<td class='"'"'task_summary'"'"'><a href=[^>]\+>\(.*\)</a></td>.*$@\1\t\2@
        T
        s/^/'"${pkgbase}.${git_revision}.${mod_git_revision}.${repository}"'\t/
        p
      '
  done > \
  "${tmp_dir}/broken-packages"

>&2 printf ' done\n'

while [ -s "${tmp_dir}/broken-packages" ]; do
  identifier=$(
    head -n1 "${tmp_dir}/broken-packages" | \
      cut -f1
  )
  fs_ids=''
  OIFS="${IFS}"
  lines=$(
    grep "^$(str_to_regex "${identifier}")\\s" "${tmp_dir}/broken-packages" | \
      cut -f2,3 | \
      tr '\t\n' '\n\t'
  )
  IFS=$(printf '\t')
  # shellcheck disable=SC2013
  for line in ${lines}; do
    IFS="${OIFS}"
    printf '> '
    printf '%s' "${line}" | \
      tr '\t\n' '\n\t' | \
      cut -f2
    printf 'Should we wait (empty = "yes")? '
    read -r w
    if [ -z "${w}" ]; then
      fs_ids="${fs_ids},FS#$(
        printf '%s\n' "${line}" | \
          tr '\t\n' '\n\t' | \
          cut -f1
      )"
    fi
  done
  IFS="${OIFS}"
  if [ -n "${fs_ids}" ]; then
    printf '%s.any wait for %s\n' \
      "${identifier}" \
      "${fs_ids#,}" >> \
      "${tmp_dir}/block-list"
  fi
  sed -i '/^'"$(str_to_regex "${identifier}")"'\s/d' "${tmp_dir}/broken-packages"
done

if [ -s "${tmp_dir}/block-list" ]; then
  "${base_dir}/bin/modify-package-state" -w -b "${tmp_dir}/block-list"
fi