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

tmp_file=$(mktemp 'tmp.check-bugtracker.XXXXXXXX' --tmpdir)
trap 'rm "${tmp_file}"' EXIT

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

# shellcheck disable=SC2016
{
  printf 'CREATE TEMPORARY TABLE `bugs`('
    printf '`bugtracker_category` VARCHAR(32),'
    printf '`pkgname` VARCHAR(64)'
  printf ');\n';
  printf 'LOAD DATA LOCAL INFILE "%s" INTO TABLE `bugs`;\n' \
    "${tmp_file}"
  printf 'UPDATE `binary_packages`'
  mysql_join_binary_packages_binary_packages_in_repositories
  mysql_join_binary_packages_in_repositories_repositories
  mysql_join_repositories_repository_stabilities
  printf ' LEFT JOIN `bugs`'
  printf ' ON `bugs`.`pkgname`=`binary_packages`.`pkgname`'
  printf ' AND `bugs`.`bugtracker_category`=`repository_stabilities`.`bugtracker_category`'
  printf ' SET `binary_packages`.`has_issues`=(`bugs`.`pkgname` IS NOT NULL);\n'
} | \
  mysql_run_query 'unimportant'