aboutsummaryrefslogtreecommitdiff
path: root/pbuildd/buildd.sh
blob: c12a0e5e6a34d68761402cd5033f12b1e07fc9df (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
# all-rebuilder script.

set -e

. /etc/pbuilder/buildd-config.sh

NOBUILDDEP=${BASEDIRECTORY}/FAILED/NOBUILDDEP
FAILED=${BASEDIRECTORY}/FAILED
DEPWAIT=${BASEDIRECTORY}/DEPWAIT
SUCCESS=${BASEDIRECTORY}/SUCCESS
DEPWAIT=${BASEDIRECTORY}/DEPWAIT
mkdir "$FAILED" || true 
mkdir "$DEPWAIT" || true 
mkdir "$SUCCESS" || true 
mkdir "$DEPWAIT" || true 
mkdir ${BASEDIRECTORY}/WORKING || true 
mkdir ${BASEDIRECTORY}/STATUS || true 
mkdir "$NOBUILDDEP" || true
BUILDRESULTDIR=${PWD}/RESULT-deb
mkdir "$BUILDRESULTDIR" || true

STATUSFILE=${BASEDIRECTORY}/STATUS/$(hostname)-$$
BUILDTMP=${BASEDIRECTORY}/tmp-b-$(hostname)-$$

function status () {
    echo "$@" > $STATUSFILE
    echo "$@"
}

function buildone() {
    local PROGNAME="$1"
    local LOGFILE=${BASEDIRECTORY}/WORKING/"$PROGNAME.log"


    # this part needs to be atomic
    status "considering $PROGNAME"
    if grep "$PROGNAME" avoidlist; then
	echo Skip.
	return
    fi
    if echo "$PROGNAME" | grep "^kernel-image"; then
    	echo I hate kernel images.
	return
    fi

    if [ $(find -name $PROGNAME.log | wc -l ) = "1" ]; then
	echo Already build tried for "$PROGNAME"
	return
    fi
    # end of atomic.

    status "building $PROGNAME"
    mkdir $BUILDTMP || true
    (
	cd $BUILDTMP
	apt-get source -d $PROGNAME
	if sudo pbuilder build --hookdir "${HOOKDIR}" --buildresult . --logfile "$LOGFILE" *.dsc; then
	    mv "$LOGFILE" "$SUCCESS"
	    echo Build successful
	else
	    if grep "^E: pbuilder: Could not satisfy build-dependency." $LOGFILE > /dev/null; then
		mv "$LOGFILE" "$DEPWAIT"
		echo Dependency cannot be satisfied.
	    elif [ $(awk '/ -> Attempting to parse the build-deps/,/^ -> Finished parsing the build-deps/{print $0}' $LOGFILE | wc -l ) = "2" ]; then
		echo "Missing build-deps"
		mv "$LOGFILE" "$NOBUILDDEP"
	    elif grep '^E: Could not satisfy build-dependency' "$LOGFILE" > /dev/null ; then
		echo "Build-dep wait" 
		mv "$LOGFILE" "$DEPWAIT"
	    else
		mv "$LOGFILE" "$FAILED"
		echo Build failed
	    fi
	fi
    )
    status "finished building $PROGNAME"
    rm -rf $BUILDTMP;
}


$ROOTCOMMAND dselect update
$ROOTCOMMAND pbuilder update 

tmpfile=$(tempfile)
wget "${MIRROR}"/debian/dists/unstable/main/source/Sources.gz -O${tmpfile}

for A in $( zcat ${tmpfile} | sed -n 's/^Package: //p' | cut -d\  -f1|sort | uniq | bogosort -n ); do 
    waitingroutine
    buildone $A
done

rm -f ${tmpfile}