summaryrefslogtreecommitdiff
path: root/bin/wtp
blob: b1b682f87e95ce8e45a50052cd430dcc7b98b421 (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
#!/bin/sh

# search for a package in the database

# shellcheck disable=SC2119,SC2120

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

# shellcheck disable=SC2016
{
  printf 'SELECT'
  printf ' CONCAT('
    printf '`architectures`.`name`,"/",'
    printf '`binary_packages`.`pkgname`,": ",'
    printf 'GROUP_CONCAT('
      printf 'CONCAT('
      printf '`r_a`.`name`,"/",'
      printf '`repositories`.`name`," (",'
      printf 'IF('
        printf '`binary_packages`.`epoch`=0,'
        printf '"",'
        printf 'CONCAT(`binary_packages`.`epoch`,":")'
      printf '),'
      printf '`binary_packages`.`pkgver`,"-",'
      printf '`binary_packages`.`pkgrel`,'
      printf 'IF('
        printf 'NOT `binary_packages`.`sub_pkgrel_omitted`,'
        printf 'CONCAT(".",`binary_packages`.`sub_pkgrel`),'
        printf '""),'
      printf '")"'
      printf ')'
      printf ' ORDER BY `repositories`.`stability`'
      printf ' SEPARATOR ", "'
    printf ')'
  printf ')'
  printf ' FROM `binary_packages`'
  mysql_join_binary_packages_architectures
  mysql_join_binary_packages_binary_packages_in_repositories
  mysql_join_binary_packages_in_repositories_repositories
  mysql_join_repositories_architectures '' 'r_a'
  printf ' WHERE `binary_packages`.`pkgname` LIKE from_base64("'
  printf '%s' "$*" | \
    base64 -w0
  printf '") AND `repositories`.`is_on_master_mirror`'
  printf ' GROUP BY CONCAT(`binary_packages`.`pkgname`,"-",`architectures`.`name`)'
  printf ' ORDER BY `binary_packages`.`pkgname`,`architectures`.`name`'
  printf ';\n'
} | \
  mysql_run_query