~ubuntu-branches/debian/squeeze/sbuild/squeeze

« back to all changes in this revision

Viewing changes to etc/50sbuild

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh
  • Date: 2008-08-18 11:15:05 UTC
  • mfrom: (0.1.1 upstream) (3.1.6 hardy)
  • Revision ID: james.westby@ubuntu.com-20080818111505-5j8x6j4d4krxbjdv
Tags: 0.57.7-1
* New release.
* sbuild-checkpackages handles --list and --set options correctly
  (Closes: #495490).
* sbuild-createchroot: Correctly parse --arch option (Closes: #495517).
  Thanks to Cyril Brulebois for this patch.
* sbuild-setup.7.in: Change permissions of /build to 02775
  (Closes: #494076).  Thanks to Lucas Nussbaum for finding this missing
  step.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Copyright © 2005-2008  Roger Leigh <rleigh@debian.org>
 
3
#
 
4
# sbuild is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation, either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# sbuild is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
# General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program.  If not, see
 
16
# <http://www.gnu.org/licenses/>.
 
17
#
 
18
#####################################################################
 
19
 
 
20
set -e
 
21
 
 
22
if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
 
23
    . "$CHROOT_SCRIPT_CONFIG"
 
24
elif [ "$2" = "ok" ]; then
 
25
    echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist"
 
26
    exit 1
 
27
fi
 
28
 
 
29
if [ $1 = "setup-start" ] && [ "$SBUILD" = "true" ]; then
 
30
 
 
31
    # If the session user is a member of the sbuild group, make sure
 
32
    # that the chroot environment has the sbuild build directory
 
33
    # exists, and has the correct ownership permissions.
 
34
 
 
35
    if getent group $(id -G "${AUTH_USER}") | \
 
36
        sed -e 's/^\([^:]*\):.*$/\1/' | \
 
37
        grep -q '^sbuild$'; then
 
38
 
 
39
        if [ ! -d "${CHROOT_PATH}/home/${AUTH_USER}" ]; then
 
40
            if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
41
                echo "Creating user home directory: ${CHROOT_PATH}/home/${AUTH_USER}"
 
42
            fi
 
43
            mkdir -p "${CHROOT_PATH}/home/${AUTH_USER}"
 
44
 
 
45
            if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
46
                echo "Setting ownership of ${CHROOT_PATH}/home/${AUTH_USER} to ${AUTH_USER}:sbuild"
 
47
            fi
 
48
            chown "${AUTH_USER}:sbuild" "${CHROOT_PATH}/home/${AUTH_USER}"
 
49
        fi
 
50
 
 
51
        if [ ! -d "${CHROOT_PATH}/build" ]; then
 
52
            if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
53
                echo "Creating sbuild build directory: ${CHROOT_PATH}/build"
 
54
            fi
 
55
            mkdir "${CHROOT_PATH}/build"
 
56
        fi
 
57
        chown root:sbuild "${CHROOT_PATH}/build"
 
58
        chmod 0775 "${CHROOT_PATH}/build"
 
59
 
 
60
        if [ ! -d "${CHROOT_PATH}/build/${AUTH_USER}" ]; then
 
61
            if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
62
                echo "Creating sbuild build directory: ${CHROOT_PATH}/build/${AUTH_USER}"
 
63
            fi
 
64
            mkdir "${CHROOT_PATH}/build/${AUTH_USER}"
 
65
        fi
 
66
 
 
67
        if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
68
            echo "Setting ownership of ${CHROOT_PATH}/build/${AUTH_USER} to ${AUTH_USER}:sbuild"
 
69
        fi
 
70
        chown "${AUTH_USER}:sbuild" "${CHROOT_PATH}/build/${AUTH_USER}"
 
71
 
 
72
        if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
73
            echo "Setting permissions of ${CHROOT_PATH}/build/${AUTH_USER} to 770"
 
74
        fi
 
75
        chmod 0770 "${CHROOT_PATH}/build/${AUTH_USER}"
 
76
 
 
77
        if [ ! -d "${CHROOT_PATH}/var/lib/sbuild/srcdep-lock" ]; then
 
78
            if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
79
                echo "Creating srcdep-lock directory: ${CHROOT_PATH}/var/lib/sbuild/srcdep-lock"
 
80
            fi
 
81
            mkdir -p "${CHROOT_PATH}/var/lib/sbuild/srcdep-lock"
 
82
        fi
 
83
 
 
84
        if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
85
            echo "Setting ownership of ${CHROOT_PATH}/var/lib/sbuild to root:sbuild"
 
86
        fi
 
87
        chown -R root:sbuild "${CHROOT_PATH}/var/lib/sbuild"
 
88
 
 
89
        if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
90
            echo "Setting permissions of ${CHROOT_PATH}/var/lib/sbuild to 02775"
 
91
        fi
 
92
        chmod -R 02775 "${CHROOT_PATH}/var/lib/sbuild"
 
93
 
 
94
    else
 
95
 
 
96
        if [ "$AUTH_VERBOSITY" = "verbose" ]; then
 
97
            echo "User ${AUTH_USER} is not in group sbuild; skipping sbuild setup"
 
98
        fi
 
99
 
 
100
    fi
 
101
 
 
102
fi