summaryrefslogtreecommitdiff
path: root/cron-jobs/sourceballs
blob: a6f7a19d5b8c8f2f0a49dcebcff38d58fdb79c48 (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
#!/bin/bash

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

ftpbase="${FTP_BASE}"
srcbase="${FTP_BASE}/sources"
repos=(core extra testing community community-testing staging)

script_lock

set_umask

dirname="$(/bin/readlink -f $(/usr/bin/dirname $0))"

FAILED_PKGS=""

[ -e "$srcbase/errors.txt" ] && /bin/mv "$srcbase/errors.txt" "$srcbase/errors.txt.old"
echo "Errors occured during run:" > "$srcbase/errors.txt"

for repo in ${repos[@]}; do
    for arch in ${ARCHES[@]} any; do
        ftppath="$ftpbase/$repo/os/$arch"
        if [ ! -d "$ftppath" ]; then
            error "FTP path does not exist: $ftppath"
            continue
        fi
        cd $ftppath
        for pkg in *$PKGEXT; do
            [ -f "$pkg" ] || continue
            pkgbase=$(getpkgbase $pkg)
            srcpath="$srcbase/"
            srcpkg="${pkg//$PKGEXT/$SRCEXT}"
            srcpkg="${srcpkg//-$arch/}"
            srcpkgname="${srcpkg%-*-*$SRCEXT}"
            srcpkgbase="${srcpkg/$srcpkgname/$pkgbase}"

            #Don't do anything for package in this 'blacklist'
            if grep "^$pkgbase\$" "$dirname/sourceballs.skip" >/dev/null 2>&1; then
                continue
            fi

            #This pkgbase has already failed. No sense in trying it again this run
            if echo $FAILED_PKGS | grep "\<$pkgbase\>" >&/dev/null; then
                continue
            fi

            #Use this file to 'whitelist' or force building some sourceballs,
            # skipping the license check
            force=""
            if grep "^$pkgbase\$" "$dirname/sourceballs.force" >/dev/null 2>&1; then
                force="-f"
            fi

            if [ ! \( -f "$srcpath$srcpkg" -o -f "$srcpath$srcpkgbase" \) ]; then
                if ! $dirname/../misc-scripts/make-sourceball $force \
                    $pkgbase $repo $arch 2>>"$srcbase/errors.txt"; then
                    FAILED_PKGS="$FAILED_PKGS $pkgbase"
                fi
            fi
        done
    done
done

if [ -n "$FAILED_PKGS" ]; then
    [ -e "$srcbase/failed.txt" ] && /bin/mv "$srcbase/failed.txt" "$srcbase/failed.txt.old"
    echo "The following package bases failed:" > "$srcbase/failed.txt"
    echo -e $FAILED_PKGS | sed "s| |\n|g" | sort -u >> "$srcbase/failed.txt"
fi

$dirname/../misc-scripts/sourceballs-cleanup

script_unlock