~josvaz/vmbuilder/jenkins_kvm-no-eth1+

« back to all changes in this revision

Viewing changes to templates/img-maasv3.tmpl

  • Committer: Daniel Watkins
  • Date: 2016-10-04 15:35:19 UTC
  • mfrom: (763.1.4 jenkins_kvm)
  • Revision ID: daniel.watkins@canonical.com-20161004153519-xn4am1sdc2z98dvj
MAAS v3 streams/images: Repurpose v2 scripts for v3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
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; }
 
7
fail() {
 
8
    [ $# -eq 0 ] || error "$@";
 
9
    echo "Failed" > /tmp/failed;
 
10
    tar -C /tmp -cvf /dev/vdb failed build.log;
 
11
    shutdown -P now;
 
12
    exit 1;
 
13
}
 
14
 
 
15
debug() { error "$(date -R):" "$@"; }
 
16
sysfail() { fail "General failure!"; }
 
17
 
 
18
trap sysfail SIGINT SIGTERM
 
19
 
 
20
# Variables from configuration step
 
21
PACK_D="%D"
 
22
BZR_MAAS="%M"
 
23
suite="%d"
 
24
stream="%S"
 
25
serial="%s"
 
26
 
 
27
# Set up the stuff
 
28
export SRC_D="/tmp/maas"
 
29
export START_D="/tmp/logs"
 
30
export OUT_D="%O"
 
31
 
 
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
 
36
df -h
 
37
 
 
38
 
 
39
# Set up the code paths
 
40
cd /tmp
 
41
bzr branch "${BZR_MAAS}" "${SRC_D}" ||
 
42
    fail "Failed to check out the BZR branch"
 
43
 
 
44
bash -x "${SRC_D}/system-setup";
 
45
OUT_D="/tmp/maas_final"
 
46
mkdir -p "${OUT_D}"
 
47
 
 
48
# Extract /dev/vdc (which has all the goodies including the image
 
49
# for conversion)
 
50
tar -C / -xvvf /dev/vdd
 
51
 
 
52
# Make the dirs
 
53
mkdir /tmp/maas_images
 
54
mkdir "${START_D}"
 
55
 
 
56
 
 
57
# Do the work
 
58
ARCHES="%A"
 
59
ARCHES=${ARCHES:-i386 amd64 armhf}
 
60
 
 
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}"
 
67
 
 
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 \
 
73
         "-vvv" "${OUT_D}" \
 
74
         "arch=${arch}" "release=${suite}" || fail "Failed to create MAAS image"
 
75
 
 
76
done
 
77
 
 
78
# Finish the work
 
79
echo "Taring up artifacts to /dev/vdb!"
 
80
touch /tmp/success
 
81
tar -C /tmp -cvf /dev/vdb maas_images /var/log/* logs success build.log "${OUT_D}" >> /dev/null
 
82
sync
 
83
shutdown -P now
 
84
 
 
85
# vi: ts=4 noexpandtab syntax=sh