~cjwatson/launchpad-buildd/snap-default-branch

« back to all changes in this revision

Viewing changes to generate-translation-templates

  • Committer: Martin Pool
  • Date: 2011-11-09 07:50:56 UTC
  • Revision ID: mbp@canonical.com-20111109075056-mj9ofht4vmu7lto1
Add snapshot of buildd source extracted from the Launchpad tree

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
4
# GNU Affero General Public License version 3 (see the file LICENSE).
 
5
 
 
6
# Buildd Slave tool to generate translation templates. Boiler plate code
 
7
# copied from sbuild-package.
 
8
 
 
9
# Expects build id as arg 1.
 
10
# Expects branch url as arg 2.
 
11
# Expects output tarball name as arg 3.
 
12
 
 
13
# Must run as user with password-less sudo ability.
 
14
 
 
15
exec 2>&1
 
16
 
 
17
export LANG=C LC_ALL=C
 
18
 
 
19
CHMOD=/bin/chmod
 
20
CHROOT=/usr/sbin/chroot
 
21
CP=/bin/cp
 
22
INSTALL=/usr/bin/install
 
23
MKDIR=/bin/mkdir
 
24
SU=/bin/su
 
25
SUDO=/usr/bin/sudo
 
26
TOUCH=/usr/bin/touch
 
27
 
 
28
BUILDID=$1
 
29
BRANCH_URL=$2
 
30
RESULT_NAME=$3
 
31
 
 
32
BUILDD_HOME=/usr/share/launchpad-buildd
 
33
SLAVEBIN=$BUILDD_HOME/slavebin
 
34
BUILD_CHROOT="$HOME/build-$BUILDID/chroot-autobuild"
 
35
USER=$(whoami)
 
36
 
 
37
# Debug output.
 
38
echo "Running as $USER for build $BUILDID on $BRANCH_URL."
 
39
echo "Results expected in $RESULT_NAME."
 
40
 
 
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
 
47
 
 
48
GENERATE_SCRIPT=$PYMODULES/$POTTERY/generate_translation_templates.py
 
49
 
 
50
debug_exec() {
 
51
   echo "Executing '$1'..."
 
52
   $1 || echo "Got error $? from '$1'."
 
53
}
 
54
 
 
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"
 
62
 
 
63
# Enter chroot, switch back to unprivileged user, execute the generate script.
 
64
$SUDO $CHROOT $BUILD_CHROOT \
 
65
  $SU - $USER \
 
66
    -c "PYTHONPATH=$PYMODULES $GENERATE_SCRIPT $BRANCH_URL $RESULT_NAME"