3
# Read in the common files
4
myname=$(readlink -f ${0})
5
mydir=$(dirname ${myname})
6
mypdir=$(dirname ${mydir})
8
# Scope stuff locally here
9
# Create a temporary directory for the fun
10
tmp_dir=$(mktemp -d builder.XXXXX --tmpdir=${TMPDIR:-/tmp})
11
export TMPDIR=${tmp_dir}
12
export WORKSPACE=${mydir}
16
clean() { [ -d ${tmp_dir} ] && rm -rf ${tmp_dir};
17
[ -d "${mydir}/Virtualbox\ VMS" ] && rm -rf "${mydir}/Virtualbox\ VMS";
19
error() { echo "$@"; }
20
debug() { error "$(date -R):" "$@"; }
21
fail() { debug "${1:-Something bad happend}"; clean 1; }
23
# Fly with the safety on!
28
which $1 >> /dev/null || fail "Command $1 does not exist! Please install $2"
31
[ "$(lsb_release -c -s)" != "trusty" ] &&
32
fail "This must be run on Ubuntu 14.04"
34
test_cmd_exists qemu-nbd qemu-utils
35
test_cmd_exists vboxmanage virtualbox
36
test_cmd_exists bzr bzr
37
test_cmd_exists sstream-query simplestreams
39
# This defines what gets built
40
build_for=${BUILD_FOR:-trusty:amd64 precise:amd64}
42
for build in ${build_for[@]};
46
builder_img="${mydir}/${suite}-builder-${arch}.img"
47
results_d_arch="${mydir}/${suite}-${arch}"
48
built_img="${suite}-server-cloudimg-${arch}-juju-vagrant-disk1.img"
50
[ ! -e "${results_d_arch}" ] &&
51
mkdir -p "${results_d_arch}"
54
"${mydir}/standalone.sh"
55
"--cloud_cfg ${mydir}/config/cloud-vps.cfg"
56
"--template ${mydir}/templates/img-juju.tmpl"
59
"--use_img ${builder_img}"
60
"--final_img ${built_img}"
64
[ ! -e "${builder_img}" ] && cmd+=("--fetch_new")
66
[ -e "${results_d_arch}/${suite}-server-cloudimg-${arch}-juju-vagrant-disk1.img" ] ||
67
( cd ${results_d_arch} && ${cmd[@]} )
69
# The following Vagrant-ifies the build
73
SRV_D="${mydir}/${suite}-${arch}" \
74
WORKSPACE="${mydir}/${suite}-${arch}" \
75
${mydir}/jenkins/CloudImages_Juju.sh
77
expected_box="${results_d_arch}/${suite}-server-cloudimg-${arch}-juju-vagrant-disk1.box"
78
[ -f "${expected_box}" ] || fail "unable to find ${expected_box}; build failed!"
79
results_out+=("${build} ${expected_box}")
87
debug "Results are in following locations"
88
echo -e "${results_out[@]}"
90
debug "Done with the build!"