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

# shellcheck disable=SC2119,SC2120

wget -qO- 'https://pkgapi.arch32.tyzoid.com/esearch/'"$*"'.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);
      }
    }
  '