summaryrefslogtreecommitdiff
path: root/cron-jobs/sourceballs
blob: d36da4b9a587b9205e4dd2b0c3dc07f386b942fe (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash

ftpbase="/srv/ftp"
srcbase="/srv/ftp/sources"
repos="core extra testing"
arches="i686 x86_64"

LOCKFILE="/tmp/.sourceball.lock"

if [ ! -f /etc/makepkg.conf ]; then
    echo "/etc/makepkg.conf not found! Aborting"
    exit 1
fi

. /etc/makepkg.conf
cleanup () {
	rm -f "$LOCKFILE"
    exit 0
}

ctrl_c() {
    cleanup
}

if [ -f "$LOCKFILE" ]; then
	owner="$(/usr/bin/stat -c %U $LOCKFILE)"
	echo "error: source tarball generation is already in progress (started by $owner)"
	exit 1
fi

trap cleanup 0
trap ctrl_c 2

/bin/touch "$LOCKFILE"

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

getpkgname() {
	local tmp

	tmp=${1##*/}
	tmp=${tmp%$PKGEXT}
    for a in $arches; do
        tmp=${tmp%-$a}
    done
	echo ${tmp%-*-*}
}


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; do
        export CARCH="$arch"
        ftppath="$ftpbase/$repo/os/$arch"
        cd $ftppath
        for pkg in *$PKGEXT; do
            pkgname=$(getpkgname $pkg)
            srcpath="$srcbase/"
            srcpkg="${pkg//$PKGEXT/$SRCEXT}"
            srcpkg="${srcpkg//-$arch/}"

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

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

            if [ ! -f "$srcpath$srcpkg" ]; then
                if ! $dirname/../misc-scripts/make-sourceball $force \
                    $pkgname $repo $arch 2>>"$srcbase/errors.txt"; then
                    FAILED_PKGS="$FAILED_PKGS $pkg"
                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 packages failed:" > "$srcbase/failed.txt"
    echo -e $FAILED_PKGS | sed "s| |\n|g" | sort -u >> "$srcbase/failed.txt"
fi

cleanup