summaryrefslogtreecommitdiff
path: root/bin/check-bugtracker
blob: 53d8ffb0f22f76e44d98dda6fe829d03b3085dce (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
#!/bin/sh

# check the bug tracker for packages in testing and community-testing
# with issues and mark these packages as "has_issues" if they are faulty
# and vice versa

# shellcheck disable=SC2039,SC2119,SC2120

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

bug_list=$(
  curl -LSs 'https://bugs.archlinux32.org/index.php?export_list=Export%20Tasklist' | \
    sed -n '
      1d
      s/^[^,]\+,"//
      T
      s/^\([^"]\+\)"\(,[^,]\+\)\{2\},"\([^"]\+\)".*$/"\1" "\3"/
      T
      p
    '
)

# shellcheck disable=SC2016
{
  printf 'SELECT `repository_stabilities`.`id`,`repository_stabilities`.`bugtracker_category`'
  printf ' FROM `repository_stabilities`'
  printf ' WHERE NOT `repository_stabilities`.`bugtracker_category` IS NULL'
} | \
  mysql_run_query | \
  while read -r stability_id category; do
    for has_issues in '1:' '0:NOT '; do
      printf 'UPDATE `binary_packages`'
      mysql_join_binary_packages_repositories
      printf ' SET `has_issues`=%s' \
        "${has_issues%:*}"
      printf ' WHERE `repositories`.`stability`=%s' \
        "${stability_id}"
      printf ' AND `binary_packages`.`pkgname` %sIN (' \
        "${has_issues#*:}"
      printf '%s\n' "${bug_list}" | \
        sed -n '
          s/^"'"$(str_to_regex "${category}")"'" //
          T
          :a
            /\[.*]/ {
              s/^[^[]*\[//
              T
              h
              s/].*$//
              p
              x
              ba
            }
        ' | \
        base64_encode_each | \
        sed '
          s/^/from_base64("/
          s/$/")/
        ' | \
        tr '\n' ','
      printf '"");\n'
    done
  done | \
  mysql_run_query