summaryrefslogtreecommitdiff
path: root/liste-verfuegbare-Versionen
blob: 185329670c563900d11b4007c7661cfda5abaea2 (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
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash

provided=$(mktemp)

if grep -qxF 'ID=arch' /etc/os-release; then
  sources=(
    /var/lib/pacman/sync
    /mnt/archlinux/archlinux
    /mnt/archlinux
  )
  sudo pacman -Sy >/dev/null || exit $?
else
  sources=(
    http://pkgcache.eckner.net/arch/x86_64/core/core.db.tar.gz
    http://pkgcache.eckner.net/arch/x86_64/extra/extra.db.tar.gz
  )
fi

for i in "${!sources[@]}"; do
  source="${sources["${i}"]}"
  if [ -z "${source##*://*}" ]; then
    curl -Ss "${source}" \
    | bsdtar -Oxzf
  else
    find "${sources["${i}"]}" -name '*.db' \
      -exec bsdtar -Oxzf {} \; \
    2>/dev/null \
  fi \
  | sed -n '
    /^%\(NAME\|VERSION\)%$/ {
      N
      s/\n/ /
      p
    }
    /^%PROVIDES%$/,/^$/ {
      /^[^%]/ p
    }
  ' \
  | sed -n '
    s/^\(\S\+\)=\(\S\+\)-\(64\|32\)$/\2 \1/
    T no_provides
    p
    d
    :no_provides
    /^%NAME%/ {
      N
      s/^%NAME% \(\S\+\)\n%VERSION% \(\S\+\)-\S\+$/\2 \1/
      T
      p
    }
  ' \
  | sed '
    /^\(\S\+\) \1$/d
    s/^/'"${i}"' /
  '
done \
| sort -k3,3 -k1n,1 -k2Vr,2 \
| uniq -f2 \
| cut -d' ' -f2,3 \
>"${provided}"

printf '%s\n' "${provided}"