summaryrefslogtreecommitdiff
path: root/pin-dependencies.PKGBUILDpatch
blob: cc0fbd5ae306290c1891204c6093e94e79b8a747 (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
63
64
65
66
67
68
if printf '%s\n' "${arch[@]}" | grep -qvxF any; then
  depends=(
    $(
      {
        printf '%s\n' "${depends[@]}"
        {
          find "${pkgdir}" -type f -exec objdump -x {} \; 2>/dev/null \
          | sed '
            s/^\s*NEEDED\s\+\(\S\+\)\s*$/\1/
            t
            d
          ' \
          | sort -u
        } \
        | sort \
        | uniq -u \
        | while read -r _lib; do
          _pkg=$(
            pacman -Qqo "/usr/lib/${_lib}" 2>/dev/null
          ) || continue
          if pacman -Qi "${_pkg}" \
            | sed '
              :a
                $! N
                s/\n\s\+/  /
                ta
              P
              D
            ' \
            | sed -n '
              s/^Provides\s*:\s*//
              T
              y/ /\n/
              p
            ' \
            | sed -n '
              /^$/d
              s/=.*$//
              T
              /\.so$/p
            ' \
            | grep -qxF "${_lib}"; then
            printf '%s\n' "${_lib}"
          else
            pacman -Q "${_pkg}" \
            | sed '
              s/ \([^-]\+\)-[^-]\+$/=\1/
              t
              w /dev/stderr
              d
            ' \
            | sed '
              s/^glibc=/glibc>=/
            '
          fi
        done \
        | sort -u
      } \
      | sed '
        s/^\([^<>=[:space:]]\+\)\([<>]\?=\(\S\+\)\)\?$/\0 \1 \3/
      ' \
      | sort -k2,2 -k3Vr,3 \
      | cut -d' ' -f1,2 \
      | uniq -f1 \
      | cut -d' ' -f1
    )
  )
fi