3
# Copyright 2010 Canonical Ltd. This software is licensed under the
4
# GNU Affero General Public License version 3 (see the file LICENSE).
6
# Buildd Slave tool to generate translation templates. Boiler plate code
7
# copied from sbuild-package.
9
# Expects build id as arg 1.
10
# Expects branch url as arg 2.
11
# Expects output tarball name as arg 3.
13
# Must run as user with password-less sudo ability.
17
export LANG=C LC_ALL=C
20
CHROOT=/usr/sbin/chroot
22
INSTALL=/usr/bin/install
32
BUILDD_HOME=/usr/share/launchpad-buildd
33
SLAVEBIN=$BUILDD_HOME/slavebin
34
BUILD_CHROOT="$HOME/build-$BUILDID/chroot-autobuild"
38
echo "Running as $USER for build $BUILDID on $BRANCH_URL."
39
echo "Results expected in $RESULT_NAME."
41
BUILDD_PACKAGE=canonical/buildd
42
POTTERY=$BUILDD_PACKAGE/pottery
43
# The script should be smarter about detecting the python version.
44
PYMODULES=/usr/lib/pymodules/python2.7
45
echo -n "Default Python in the chroot is: "
46
$BUILD_CHROOT/usr/bin/python --version
48
GENERATE_SCRIPT=$PYMODULES/$POTTERY/generate_translation_templates.py
51
echo "Executing '$1'..."
52
$1 || echo "Got error $? from '$1'."
55
# Copy pottery files to chroot.
56
debug_exec "$SUDO $MKDIR -vp $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
57
debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/__init__.py"
58
debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/buildd/__init__.py"
59
debug_exec "$SUDO $CP -vr $BUILDD_HOME/$POTTERY $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
60
debug_exec "$SUDO $CHMOD -v -R go+rX $BUILD_CHROOT$PYMODULES/canonical"
61
debug_exec "$SUDO $CHMOD -v 755 $BUILD_CHROOT$GENERATE_SCRIPT"
63
# Enter chroot, switch back to unprivileged user, execute the generate script.
64
$SUDO $CHROOT $BUILD_CHROOT \
66
-c "PYTHONPATH=$PYMODULES $GENERATE_SCRIPT $BRANCH_URL $RESULT_NAME"