Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/wtf
blob: 1963cff57a7323356d7ef9c5e927e13d6430bb87 (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
#!/bin/sh

# shellcheck disable=SC2119,SC2120

search="$*"

wget -qO- 'https://pkgapi.arch32.tyzoid.com/esearch/'"${search##*/}"'.xml' | \
  awk '
    BEGIN {
      package="";
      version="";
      repo="";
      filelen=0;
    }
    {
      if ($1 == "</package>") {
        printf "[" repo "] " package " (" version "):";
        for (i=1; i <= filelen; i++) {
          printf " " file[i];
        }
        print "";
        package="";
        version="";
        repo="";
        filelen=0;
      }
      if ($1 ~ /^<name>/) {
        package = gensub(/<[^>]+>/, " ", "g", $1);
      }
      if ($1 ~ /^<version>/) {
        version = gensub(/<[^>]+>/, "", "g", $1);
      }
      if ($1 ~ /^<repo>/) {
        repo = gensub(/<[^>]+>/, "", "g", $1);
      }
      if ($1 ~ /^<file>/) {
        file[++filelen] = gensub(/<[^>]+>/, "", "g", $1);
      }
    }
  ' | \
  if printf '%s\n' "${search}" | \
    grep -q '/'; then
    grep -w "${search}" || true
  else
    cat
  fi