2
# vi: ts=4 noexpandtab syntax=sh
3
# Setup up the build environment.
4
exec > >(tee /tmp/build.log) 2>&1
5
echo "127.0.1.1 $HOSTNAME $HOSTNAME" >> /etc/hosts
6
error() { echo "$@" 1>&2; }
8
[ $# -eq 0 ] || error "$@";
9
echo "Failed" > /tmp/failed;
10
tar -C /tmp -cvf /dev/vdb failed build.log;
15
debug() { error "$(date -R):" "$@"; }
16
sysfail() { fail "General failure!"; }
18
trap sysfail SIGINT SIGTERM
20
# Variables from configuration step
28
export SRC_D="/tmp/maas"
29
export START_D="/tmp/logs"
32
# Make sure that the root disk is big enough
33
# Work around for https://bugs.launchpad.net/ubuntu/+source/cloud-utils/+bug/1285197
34
sudo cloud-init single --name growpart --frequency=always &&
35
sudo cloud-init single --name=resizefs --frequency=always
39
# Set up the code paths
41
bzr branch "${BZR_MAAS}" "${SRC_D}" ||
42
fail "Failed to check out the BZR branch"
44
bash -x "${SRC_D}/system-setup";
45
OUT_D="/tmp/maas_final"
48
# Extract /dev/vdc (which has all the goodies including the image
50
tar -C / -xvvf /dev/vdd
53
mkdir /tmp/maas_images
59
ARCHES=${ARCHES:-i386 amd64 armhf}
61
debug "building maas ephemerals v3 suite=$suite arches=[${ARCHES}]"
62
for arch in ${ARCHES}; do
63
prefix="${suite}-${stream}-maas-${arch}"
64
work_d="${OUT_D}/${arch}"
65
mkdir -p "${work_d}" ||
66
fail "Unable to create destination directory for ${arch}"
68
debug "beginning arch $arch"
69
env PYTHONPATH=${SRC_D} \
70
PATH=${SRC_D}/bin:$PATH \
71
"${SRC_D}/bin/meph2-cloudimg-sync" \
72
--config ${SRC_D}/conf/meph-v3.yaml \
74
"arch=${arch}" "release=${suite}" || fail "Failed to create MAAS image"
79
echo "Taring up artifacts to /dev/vdb!"
81
tar -C /tmp -cvf /dev/vdb maas_images /var/log/* logs success build.log "${OUT_D}" >> /dev/null
85
# vi: ts=4 noexpandtab syntax=sh