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

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);
      }
    }
  '