~adeuring/vmbuilder/jenkins_kvm-juju-gui-use-port-6079

« back to all changes in this revision

Viewing changes to build-juju-local.sh

  • Committer: Ben Howard
  • Date: 2014-07-25 21:29:07 UTC
  • Revision ID: ben.howard@ubuntu.com-20140725212907-u0qu61waodatbwbs
Modified jenkins/CloudImages_Juju.sh to allow for running on standalone
system outside of Jenkins build. Changed config/cloud-vps.cfg to drop
Launchpad SSH imports. And added build-juju-local.sh for building the
Juju images outside of Jenkins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# Read in the common files
 
4
myname=$(readlink -f ${0})
 
5
mydir=$(dirname ${myname})
 
6
mypdir=$(dirname ${mydir})
 
7
 
 
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}
 
13
export HOME=${mydir}
 
14
export LOCAL_BUILD=1
 
15
 
 
16
clean() { [ -d ${tmp_dir} ] && rm -rf ${tmp_dir};
 
17
          [ -d "${mydir}/Virtualbox\ VMS" ] && rm -rf "${mydir}/Virtualbox\ VMS";
 
18
          exit "${@}"; }
 
19
error() { echo "$@"; }
 
20
debug() { error "$(date -R):" "$@"; }
 
21
fail()  { debug "${1:-Something bad happend}"; clean 1; }
 
22
 
 
23
# Fly with the safety on!
 
24
trap fail EXIT
 
25
trap fail SIGINT
 
26
 
 
27
test_cmd_exists() {
 
28
    which $1 >> /dev/null || fail "Command $1 does not exist! Please install $2"
 
29
}
 
30
 
 
31
[ "$(lsb_release -c -s)" != "trusty" ] &&
 
32
    fail "This must be run on Ubuntu 14.04"
 
33
 
 
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
 
38
 
 
39
# This defines what gets built
 
40
build_for=${BUILD_FOR:-trusty:amd64 precise:amd64}
 
41
 
 
42
for build in ${build_for[@]};
 
43
do
 
44
    suite=${build%%:*}
 
45
    arch=${build##*:}
 
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"
 
49
 
 
50
    [ ! -e "${results_d_arch}" ] &&
 
51
        mkdir -p "${results_d_arch}"
 
52
 
 
53
    cmd=(
 
54
       "${mydir}/standalone.sh"
 
55
        "--cloud_cfg    ${mydir}/config/cloud-vps.cfg"
 
56
        "--template     ${mydir}/templates/img-juju.tmpl"
 
57
        "--suite        ${suite}"
 
58
        "--arch         ${arch}"
 
59
        "--use_img      ${builder_img}"
 
60
        "--final_img    ${built_img}"
 
61
        "--resize_final 40"
 
62
        )
 
63
 
 
64
    [ ! -e "${builder_img}" ] && cmd+=("--fetch_new")
 
65
 
 
66
    [ -e "${results_d_arch}/${suite}-server-cloudimg-${arch}-juju-vagrant-disk1.img" ] ||
 
67
        ( cd ${results_d_arch} && ${cmd[@]} )
 
68
 
 
69
    # The following Vagrant-ifies the build
 
70
    SUITE=${suite} \
 
71
        ARCH_TYPE=${arch} \
 
72
        SERIAL="current" \
 
73
        SRV_D="${mydir}/${suite}-${arch}" \
 
74
        WORKSPACE="${mydir}/${suite}-${arch}" \
 
75
        ${mydir}/jenkins/CloudImages_Juju.sh
 
76
 
 
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}")
 
80
done
 
81
 
 
82
# Clear the traps
 
83
trap - EXIT
 
84
trap - SIGINT
 
85
trap
 
86
 
 
87
debug "Results are in following locations"
 
88
echo -e "${results_out[@]}"
 
89
 
 
90
debug "Done with the build!"
 
91
clean 0