summaryrefslogtreecommitdiff
path: root/cron-jobs/repo-sanity-check
blob: a6249b53a85c3a31b3a42ad08aa85fe4d4cb72e5 (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
#!/bin/bash
# Solves issue165

. "$(dirname $0)/../db-functions"
. "$(dirname $0)/../config"

# Traverse all repos
for _repo in ${REPOS[@]}; do

# Find all pkgnames on this repo's abs
    on_abs=($(
        find ${SVNREPO}/${_repo} -name PKGBUILD | \
        while read pkgbuild; do
            source ${pkgbuild} >/dev/null 2>&1
# cleanup to save memory
            unset build package source md5sums pkgdesc pkgver pkgrel epoch \
                  url license arch depends makedepends optdepends options \
                  >/dev/null 2>&1

# also cleanup package functions
            for _pkg in ${pkgname[@]}; do
                unset package_${pkg} >/dev/null 2>&1
            done
            
# this fills the on_abs array
            echo ${pkgname[@]}
        done
    ))

# Find all pkgnames on repos
    on_repo=($(
        find ${FTP_BASE}/${_repo} -name "*.pkg.tar.?z" -printf "%f\n" | \
        sed "s/^\(.\+\)-[^-]\+-[^-]\+-[^-]\+$/\1/"
    ))

# Compares them, whatever is on repos but not on abs should be removed
    remove=($(comm -13 <(echo ${on_abs[@]} | tr ' ' "\n" | sort) \
             <(echo ${on_repo[@]} | tr ' ' "\n" | sort)))

# Remove them from databases, ftpdir-cleanup will take care of the rest
    find ${FTP_BASE}/${_repo} -name "*.db.tar.?z" -print0 | \
        xargs -0 repo-remove {} ${remove[@]}

done

exit $?