summaryrefslogtreecommitdiff
path: root/checkPinnedDependencies
blob: 7f04e768e89ce550e89a72e3d64af21006770137 (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
#!/bin/bash

cd "$(dirname "$0")"

join -1 1 -2 2 -v 2 <(
  find /var/lib/pacman/sync \
    -name '*.db' \
    -exec bsdtar -Oxf {} \; \
  | sed -n '
    /^%FILENAME%/ {
      N
      s/^%FILENAME%\n\(\S\+\)-\([^-]\+-[^-]\+\)-[^-]\+$/\1=\2/
      p
      s/-[^-]\+$//
      p
      d
    }
    /^%PROVIDES%$/,/^$/ {
      s/-64$//
      /^[^%]/p
    }
  ' \
  | sort -u
) <(
  for pkgbuild in */PKGBUILD; do
    sed -n '
      /^\s*_pinned_dependencies[^[:space:]=]*=([^)]*$/,/)/p
      /^\s*_pinned_dependencies[^[:space:]=]*=([^)]*)/p
    ' "${pkgbuild}" \
    | sed '
      s/^\s*_pinned_dependencies[^[:space:]=]*=(//
      s/).*$//
    ' \
    | tr '[:space:]' '\n' \
    | sort -u \
    | grep -vxF '' \
    | sed '
      s@^\(['"'"'"]\)\(\S\+\)\1$@\2@
      /^glibc>=/d
      s@^@'"${pkgbuild%/*}"' @
    '
  done \
  | sort -k2,2
) \
| if [ "x$1" = 'x-m' ]; then
  cut -d' ' -f2
else
  while read -r dep pkg; do
    printf '%s: %s\n' "${pkg}" "${dep}"
  done
fi