#!/bin/sh
#
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# Buildd Slave tool to mount a chroot

# Expects build id as arg 1, makes build-id to contain the build

# Needs SUDO to be set to a sudo instance for passwordless access

SUDO=/usr/bin/sudo
BUILDID="$1"

set -e

exec 2>&1

echo "Mounting chroot for build $BUILDID"

$SUDO mount -t proc none "$HOME/build-$BUILDID/chroot-autobuild/proc"
$SUDO mount -t devpts -o gid=5,mode=620 none "$HOME/build-$BUILDID/chroot-autobuild/dev/pts"
$SUDO mount -t sysfs none "$HOME/build-$BUILDID/chroot-autobuild/sys"
$SUDO mount -t tmpfs none "$HOME/build-$BUILDID/chroot-autobuild/dev/shm"
$SUDO cp /etc/hosts /etc/hostname /etc/resolv.conf $HOME/build-$BUILDID/chroot-autobuild/etc/
