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

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

script_lock

set_umask

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

for repo in ${PKGREPOS[@]}; do
    for arch in ${ARCHES[@]}; do
        ftppath="${FTP_BASE}/$repo/os/$arch"
        dbfile="${ftppath}/${repo}${DBEXT}"
        if [ ! -r "${dbfile}" ]; then
            warning "${dbfile} not found, skipping"
            continue
        fi

        repo_lock ${repo} ${arch} || exit 1
        # Read packages from db file
        # Format is: <pkgbase|pkgname>/<pkgver>-<pkgrel>
        pkgs=($(bsdtar -xOf "${dbfile}" \
            | awk '/^%NAME%/{getline b};/^%BASE%/{getline b};/^%VERSION%/{getline v};/^%ARCH%/{printf "%s/%s\n", b, v}' \
            | sort -u))
        repo_unlock ${repo} ${arch}

        for pkg in ${pkgs[@]}; do
            pkgbase=${pkg%/*}
            pkgver=${pkg#*/}
            srcpkg="${pkgbase}-${pkgver}${SRCEXT}"

            # Don't do anything for package in this 'blacklist'
            if grep -q "^${pkgbase}\$" "$dirname/sourceballs.skip"; then
                continue
            fi

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

            if [ ! -f "${FTP_BASE}/${SRCPOOL}/$srcpkg" ]; then
                if ! $dirname/../misc-scripts/make-sourceball $force $pkgbase $repo $arch; then
                    error "Failed to download sources for $pkgbase"
                fi
            fi
        done
    done
done

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

script_unlock