summaryrefslogtreecommitdiff
path: root/bin/sanity-check
blob: 631143f4c3b26726200317186abaebc3e30b47dd (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
#!/bin/sh

# do some basic sanity checks

. "${0%/*}/../conf/default.conf"

while [ $# -gt 0 ]; do

  case "$1" in

    mirror)

      >&2 echo 'sanity-check: checking mirror ...'

      repos='community-staging community-testing community core extra gnome-unstable kde-unstable staging testing'

      errors="$(
        (
          printf '%s\n' ${repos}
          ls_master_mirror 'i686'
        ) | \
          sort | \
          uniq -u
      )"
      if [ -n "${errors}" ]; then
        echo "The following repos are missing or obsolete on the mirror:"
        echo "${errors}"
        exit 1
      fi

      for repo in ${repos}; do

        packages="$(
          ls_master_mirror "i686/${repo}" | \
            grep '\.pkg\.tar\.xz\(\.sig\)\?$'
        )"

        errors="$(
          echo "${packages}" | \
            sed 's|\.sig$||' | \
            uniq -c | \
            grep -v '^\s*2\s' | \
            awk '{print $2}'
        )"
        if [ -n "${errors}" ]; then
          echo "The following packages in ${repo} are missing a signature or vice versa:"
          echo "${errors}"
          exit 1
        fi

      done

      >&2 echo '... passed.'

    ;;

    *)

      >&2 printf 'sanity-check: unknown check "%s".' "$1"
      exit 2

    ;;

  esac

  shift

done