2
# Copyright © 2005-2008 Roger Leigh <rleigh@debian.org>
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.
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.
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/>.
18
#####################################################################
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"
29
if [ $1 = "setup-start" ] && [ "$SBUILD" = "true" ]; then
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.
35
if getent group $(id -G "${AUTH_USER}") | \
36
sed -e 's/^\([^:]*\):.*$/\1/' | \
37
grep -q '^sbuild$'; then
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}"
43
mkdir -p "${CHROOT_PATH}/home/${AUTH_USER}"
45
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
46
echo "Setting ownership of ${CHROOT_PATH}/home/${AUTH_USER} to ${AUTH_USER}:sbuild"
48
chown "${AUTH_USER}:sbuild" "${CHROOT_PATH}/home/${AUTH_USER}"
51
if [ ! -d "${CHROOT_PATH}/build" ]; then
52
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
53
echo "Creating sbuild build directory: ${CHROOT_PATH}/build"
55
mkdir "${CHROOT_PATH}/build"
57
chown root:sbuild "${CHROOT_PATH}/build"
58
chmod 0775 "${CHROOT_PATH}/build"
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}"
64
mkdir "${CHROOT_PATH}/build/${AUTH_USER}"
67
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
68
echo "Setting ownership of ${CHROOT_PATH}/build/${AUTH_USER} to ${AUTH_USER}:sbuild"
70
chown "${AUTH_USER}:sbuild" "${CHROOT_PATH}/build/${AUTH_USER}"
72
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
73
echo "Setting permissions of ${CHROOT_PATH}/build/${AUTH_USER} to 770"
75
chmod 0770 "${CHROOT_PATH}/build/${AUTH_USER}"
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"
81
mkdir -p "${CHROOT_PATH}/var/lib/sbuild/srcdep-lock"
84
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
85
echo "Setting ownership of ${CHROOT_PATH}/var/lib/sbuild to root:sbuild"
87
chown -R root:sbuild "${CHROOT_PATH}/var/lib/sbuild"
89
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
90
echo "Setting permissions of ${CHROOT_PATH}/var/lib/sbuild to 02775"
92
chmod -R 02775 "${CHROOT_PATH}/var/lib/sbuild"
96
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
97
echo "User ${AUTH_USER} is not in group sbuild; skipping sbuild setup"