3
# Copyright 2009 Canonical Ltd. This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
11
USER=${BUILDD_USER:-buildd}
12
BUILDDGID=${BUILDD_GID:-2501}
13
BUILDDUID=${BUILDD_UID:-2001}
17
buildd-genconfig --name=default --host=0.0.0.0 --port=8221 > \
18
/etc/launchpad-buildd/default
19
echo Default buildd created.
24
getent group buildd >/dev/null 2>&1 ||
25
addgroup --gid $BUILDDGID buildd
27
getent passwd buildd >/dev/null 2>&1 ||
28
adduser --ingroup buildd --disabled-login --gecos 'Buildd user' \
29
--uid $BUILDDUID ${USER}
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
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
43
${USER} ALL=(ALL) NOPASSWD: ALL
44
%buildd ALL=(buildd) NOPASSWD: ALL, (root) NOPASSWD: /bin/su - buildd
45
%lpbuildd ALL=(ALL) NOPASSWD: ALL
48
chmod 440 /etc/sudoers.d/buildd
49
chown root:root /etc/sudoers.d/buildd
52
install -d -o${USER} -m0755 /home/${USER}
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
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
67
# Prepare a default buildd...
68
test -e /etc/launchpad-buildd/default || make_buildd
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
74
chown $USER:buildd /var/log/launchpad-buildd /var/run/launchpad-buildd
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
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
89
abort-upgrade|abort-remove|abort-deconfigure)
94
echo "postinst called with unknown argument \`$1'" >&2