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

base_dir=$(
  readlink -f "${0%/*}/.."
)

# TODO: search i486, too

search="$*"

pkgfile -wC "${base_dir}/misc/pacman-i686.conf" -s "${search##*/}" | \
  xargs -rn1 pkgfile -wC "${base_dir}/misc/pacman-i686.conf" -l | \
  if printf '%s\n' "${search}" | \
    grep -q '^/'; then
    grep -w "${search}"
  else
    grep "/${search}\\(/\\|\$\\)"
  fi | \
  sort -k2,2 | \
  sed '
    s,^\([^/[:space:]]\+\)/\([^/[:space:]]\+\)\s\(\S.*\)$,\2 [\1]: \3,
  ' | \
  sed '
    :a
    $!N
    s#^\(\([^/:[:space:]]\+ [^/:[:space:]]\+, \)*[^/:[:space:]]\+ [^/:[:space:]]\+\): \([^\n]\+\)\n\([^/:[:space:]]\+ [^/:[:space:]]\+\): \3$#\1, \4: \3#
    ta
    P
    D
  '