~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/buildd/debian/postinst

  • Committer: mbp at canonical
  • Date: 2011-11-20 23:37:23 UTC
  • mto: This revision was merged to the branch mainline in revision 14344.
  • Revision ID: mbp@canonical.com-20111120233723-370p96db2crru5tm
Delete canonical.buildd again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
#
3
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
4
 
# GNU Affero General Public License version 3 (see the file LICENSE).
5
 
 
6
 
# Post install script
7
 
 
8
 
set -e
9
 
set -u
10
 
 
11
 
USER=${BUILDD_USER:-buildd}
12
 
BUILDDGID=${BUILDD_GID:-2501}
13
 
BUILDDUID=${BUILDD_UID:-2001}
14
 
 
15
 
make_buildd()
16
 
{
17
 
 buildd-genconfig --name=default --host=0.0.0.0 --port=8221 > \
18
 
  /etc/launchpad-buildd/default
19
 
 echo Default buildd created.
20
 
}
21
 
 
22
 
case "$1" in
23
 
    configure)
24
 
        getent group buildd >/dev/null 2>&1 ||
25
 
                addgroup --gid $BUILDDGID buildd
26
 
 
27
 
        getent passwd buildd >/dev/null 2>&1 ||
28
 
        adduser --ingroup buildd --disabled-login --gecos 'Buildd user' \
29
 
                --uid $BUILDDUID ${USER}
30
 
 
31
 
        SUDO_VERSION=$(sudo -V | sed -n '/^Sudo version/s/.* //p')
32
 
        if dpkg --compare-versions $SUDO_VERSION lt 1.7 ||
33
 
           ! grep -q '^#includedir /etc/sudoers.d' /etc/sudoers; then
34
 
                grep -q ^${USER} /etc/sudoers ||
35
 
                    echo "${USER}  ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
36
 
        else
37
 
                if ! sudo -l -U ${USER} | grep -q '(ALL) NOPASSWD: ALL' ||
38
 
                   ! sudo -l -U ${USER} | grep -q umask_override; then
39
 
                    cat << EOF >> /etc/sudoers.d/buildd
40
 
Defaults:buildd umask_override
41
 
Defaults>buildd umask_override
42
 
 
43
 
${USER}  ALL=(ALL) NOPASSWD: ALL
44
 
%buildd ALL=(buildd) NOPASSWD: ALL, (root) NOPASSWD: /bin/su - buildd
45
 
%lpbuildd ALL=(ALL) NOPASSWD: ALL
46
 
EOF
47
 
                fi
48
 
                chmod 440 /etc/sudoers.d/buildd
49
 
                chown root:root /etc/sudoers.d/buildd
50
 
        fi
51
 
 
52
 
        install -d -o${USER} -m0755 /home/${USER}
53
 
 
54
 
        # Create ~buildd/.sbuildrc if needed
55
 
        if [ ! -f /home/${USER}/.sbuildrc ]; then
56
 
            cp  /usr/share/launchpad-buildd/sbuildrc \
57
 
                /home/${USER}/sbuildrc.tmp
58
 
            cd /home/${USER}
59
 
            sed -e's/@ARCHTAG@/'$(dpkg --print-architecture)'/g' \
60
 
                -e's/@FQDN@/'$(hostname --fqdn)'/g' \
61
 
                <sbuildrc.tmp > .sbuildrc
62
 
            chown $USER:buildd .sbuildrc
63
 
            chmod 0644 .sbuildrc
64
 
            rm sbuildrc.tmp
65
 
        fi
66
 
 
67
 
        # Prepare a default buildd...
68
 
        test -e /etc/launchpad-buildd/default || make_buildd
69
 
 
70
 
        # Create any missing directories and chown them appropriately
71
 
        test -d /home/${USER}/filecache-default || mkdir /home/${USER}/filecache-default
72
 
        chown $USER:buildd /home/${USER}/filecache-default
73
 
 
74
 
        chown $USER:buildd /var/log/launchpad-buildd /var/run/launchpad-buildd
75
 
 
76
 
        # Check for the presence of the /etc/source-dependencies file
77
 
        # which sbuild will rant about the absence of...
78
 
        test -e /etc/source-dependencies || touch /etc/source-dependencies
79
 
 
80
 
        # Now check if we're upgrading a previous version...
81
 
        if [ "x$2" != "x" ]; then
82
 
            for CONFIG in $(ls /etc/launchpad-buildd/* \
83
 
                          | grep -v "^-" | grep -v "~$"); do
84
 
                /usr/share/launchpad-buildd/upgrade-config $2 $CONFIG
85
 
            done
86
 
        fi
87
 
 
88
 
        ;;
89
 
    abort-upgrade|abort-remove|abort-deconfigure)
90
 
 
91
 
    ;;
92
 
 
93
 
    *)
94
 
        echo "postinst called with unknown argument \`$1'" >&2
95
 
        exit 1
96
 
    ;;
97
 
esac
98
 
 
99
 
#DEBHELPER#
100
 
 
101
 
exit 0