summaryrefslogtreecommitdiff
path: root/checkPinnedDependencies
blob: 1f5186ed8aff2d94821577e685b5b09acbe41d15 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash

cd "$(dirname "$0")"

machineReadable=false
provided=()

while [ $# -gt 0 ]; do

  if [ "x$1" = 'x-m' ]; then
    machineReadable=true
  elif [ -f "$1" ]; then
    provided=("${provided[@]}" "$1")
  else
    >&2 printf 'unknown option "%s"\n' "$1"
  fi

  shift

done

if [ ${#provided[@]} -eq 0 ]; then
  provided=(
    $(
      printf 'arch\n%s\n' 'i486' 'i686' 'pentium4' 'x86_64' \
      | parallel -l2 "${0%/*}/liste-verfuegbare-Versionen"
    )
  )
  trap 'rm -f "${provided[@]}"' EXIT
fi

for provid in "${provided[@]}"; do
  arch="${provid##*.}"
  dist="${provid%.${arch}}"
  dist="${dist##*.}"
  if printf '%s\n' "${arch}" | grep -qvxFf <(printf '%s\n' 'i486' 'i686' 'pentium4' 'x86_64'); then
    unset arch
    unset dist
  else
    arch="_${arch}"
    dist="_${dist}"
  fi
  join -1 1 -2 2 -v 2 <(
    awk '{print $2 "=" $1}' <"${provid}" \
    | sort -u
  ) <(
    for pkgbuild in */PKGBUILD; do
      sed -n '
        /^\s*arch=(.*)/p
        /^\s*arch=([^)]*$/,/)/p
      ' "${pkgbuild}" \
      | sed '
        s/^\s*arch=(//
        s/).*$//
      ' \
      | grep -qwF "${arch}" \
      || continue
      sed -n '
        /^\s*_pinned_dependencies\('"${arch}"'\|'"${dist}"'\)\?=([^)]*$/,/)/p
        /^\s*_pinned_dependencies\('"${arch}"'\|'"${dist}"'\)\?=([^)]*)/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
  )
done \
| if ${machineReadable}; then
  cut -d' ' -f2
else
  while read -r dep pkg; do
    printf '%s: %s\n' "${pkg}" "${dep}"
  done
fi