summaryrefslogtreecommitdiff
path: root/manually-check-pinned-dependencies
blob: a07f860c20356909dce646baf95a9199149d282e (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
#!/bin/bash

set -e

if [ $# -ne 1 ]; then
  >&2 printf 'usage: %s $package\n' "${0##*/}"
  exit 1
fi

my_dir=$(dirname $(readlink -e "$0"))

cd "$1"
. PKGBUILD

tmp_dir=$(mktemp -d)
trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT

err=0
check_it() {
  eval "$(
    {
      declare -f "package_${name}" || declare -f package
    } \
    | sed -n '
      /^\s*_pinned_dependencies/p
    '
  )"
  pkgdir="${tmp_dir}/pkg"
  eval "$(
    sed '
      s/\${FUNCNAME\[1]}/package_'"${name}"'/
    ' "${my_dir}/pin-dependencies.PKGBUILDpatch"
  )"
}

for name in "${pkgname[@]}"; do
  for prel in ${pkgrel} $((pkgrel-1)); do
    for r in \
      "/mnt/archlinuxewe/os/x86_64" \
      "/mnt/archlinux32/releng/x86_64"; do
      for a in x86_64 any; do
        pkgfile="${r}/${name}-${epoch:+${epoch}:}${pkgver}-${prel}-${a}.pkg.tar.zst"
        [ -e "${pkgfile}" ] && break
      done
      [ -e "${pkgfile}" ] && break
    done
    [ -e "${pkgfile}" ] && break
  done
  if [ ! -e "${pkgfile}" ]; then
    >&2 printf 'cannot find package %s\n' "${name}-${epoch:+${epoch}:}${pkgver}-${pkgrel}"
    exit 1
  fi
  mkdir "${tmp_dir}/pkg"
  bsdtar -C "${tmp_dir}/pkg" -xf "${pkgfile}"
  check_it || err=$?
  rm -rf --one-file-system "${tmp_dir}/pkg"
done

exit ${err}