File: elidad

package info (click to toggle)
elida 0.3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 84 kB
  • ctags: 4
  • sloc: sh: 355; makefile: 36
file content (133 lines) | stat: -rwxr-xr-x 4,391 bytes parent folder | download
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash

# Copyright 2007-2008 Anibal Monsalve Salazar <anibal@debian.org>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

. /etc/elida/elida.conf
. $FUNCTIONS

$LOGGER -p syslog.info $BASENAME: starting

makedirs

piupart_mirrors=
for mirror in $MIRRORS
do
    piupart_mirrors="-m $mirror $piupart_mirrors"
done

tmp=$(mktemp $TMP-XXXXXX)

if [ -n "$(ls $ELIDAHOME/inprogress)" ]
then
    mv $ELIDAHOME/inprogress/* $ELIDAHOME/ready
fi

while [ ! -f $ELIDAHOME/elida-stop ]
do
    for pdv in $(ls -1rt $ELIDAHOME/ready)
    do
        [ -f $ELIDAHOME/elida-stop ] && break

        log=$ELIDAHOME/apt-get_update.log
        apt-get update > $log 2>&1
        chmod 664 $log
        chown $USERNAME:$GROUPNAME $log
        dt=$(perl -e '$dt=time-(stat("'$ELIDAHOME/pbuilder_update_unstable.log'"))[9];print"$dt\n"')
        if [ $dt -gt 10800 ]
        then
            log=$ELIDAHOME/pbuilder_update_unstable.log
            pbuilder update unstable >> $log 2>&1
            chmod 664 $log
            chown $USERNAME:$GROUPNAME $log
        fi

        [ -f $ELIDAHOME/ready/$pdv ] || continue

        mv $ELIDAHOME/ready/$pdv $ELIDAHOME/inprogress/$pdv
        pkg=${pdv%_*}
        ver=${pdv#*_}
        . $ELIDAHOME/inprogress/$pdv
        makedir $ELIDAHOME/result/$pkg
        rm -f $ELIDAHOME/result/$pkg/*
        log=$ELIDAHOME/result/$pkg/${pdv}_$ARCH.result.log
        rm -f $ELIDAHOME/result/$pkg/*$ver*

        date -R > $log
        chmod 664 $log
        echo $(hostname; dpkg --print-architecture; dpkg -l elida lintian piuparts pbuilder | grep ^ii | awk '{print $2,$3}') >> $log
        echo >> $log
        pbuilder build --buildresult $ELIDAHOME/result/$pkg $ELIDAHOME/source/$pkg/$pdv.dsc 2>&1 | grep -v 'using uid of process' >> $log
        chmod 2775 $ELIDAHOME/result $ELIDAHOME/result/$pkg
        chmod 664 $ELIDAHOME/result/$pkg/*
        chown $USERNAME:$GROUPNAME $ELIDAHOME/result/$pkg/*

        if [ -e $ELIDAHOME/result/$pkg/${pdv}_$ARCH.changes ]
        then
            #rm -f $ELIDAHOME/public_html/debian/pool/$pkg
            #su - pbuilder -c "ln -s  ../../../result/$pkg $ELIDAHOME/public_html/debian/pool/$pkg; $ELIDAHOME/bin/pkgs"

            echo >> $log
            echo "$ELIDAHOME/result/$pkg/${pdv}_$ARCH.changes:" >> $log
            cat $ELIDAHOME/result/$pkg/${pdv}_$ARCH.changes >> $log

            for f in $ELIDAHOME/result/$pkg/*$ver*deb
            do
                echo >> $log
                echo "dpkg -I $f" >> $log
                dpkg -I $f >> $log 2>&1
            done

            for f in $ELIDAHOME/result/$pkg/*$ver*deb
            do
                echo >> $log
                echo "dpkg -c $f" >> $log
                dpkg -c $f >> $log 2>&1
            done

            for f in $ELIDAHOME/result/$pkg/*$ver*deb
            do
                echo >> $log
                echo "piuparts -p -N $piupart_mirrors $f" >> $log
                piuparts -p -N $piupart_mirrors $f >> $log 2>&1
            done

            echo >> $log
            echo "lintian -i --show-overrides $ELIDAHOME/result/$pkg/${pdv}_$ARCH.changes" >> $log
            su - $USERNAME -c "lintian -i --show-overrides $ELIDAHOME/result/$pkg/${pdv}_$ARCH.changes" >> $log 2>&1
        fi

        bzip2 -f -9 $log
        log="$log.bz2"

        rm -f $tmp
        mpack -s "Re: $subject" -o $tmp $log
        (echo -e "To: $from\nFrom: $FROM\nBcc: $BCC\nIn-Reply-To: $message_id\nUser-Agent: elida/$ELIDAVERSION"; cat $tmp) | $SENDMAIL -t

        mv $ELIDAHOME/inprogress/$pdv $ELIDAHOME/done/$pdv

        if [ -f $ELIDAHOME/elida-hup ]
        then
            rm -f $ELIDAHOME/elida-hup
            break
        fi
    done
    sleep 3
done

rm -f $ELIDAHOME/elida-stop

exit 0