3
# Build a mojo image for development and testing of mojo (https://mojo.canonical.com)
6
# - An image named trusty - https://linuxcontainers.org/lxd/getting-started-cli/
9
#name=mojo-$(date +%Y-%m-%d) # Useful if you are testing multiple versions.
12
lxc launch trusty mojo -c security.privileged=true -c security.nesting=true
13
# unprivileged works but requires manual creation of the lxc environment and is only practical for
14
# non-local juju environments, even then it is difficult to setup the lxc env for mojo
15
# lxd in lxd works well unprivileged so hopefully mojo and juju will switch to lxd.
16
#lxc launch trusty $name -c security.nesting=true
17
sleep 5 # Takes a moment for the network
20
lxc exec $name -- apt-get update
21
lxc exec $name -- apt-get install -y software-properties-common
22
lxc exec $name -- apt-add-repository -y ppa:mojo-maintainers/ppa
23
# The latest or at least backports version of lxc is needed for working with nesting.
24
lxc exec $name -- apt-add-repository -y ppa:ubuntu-lxc/daily
25
lxc exec $name -- apt-get update
26
lxc exec $name -- apt-get dist-upgrade -y
27
# python swiftclient is needed for the mojo-how-to spec most others are build/test deps
28
lxc exec $name -- apt-get install -y mojo bzr juju-local devscripts debhelper python-all python-setuptools python-swiftclient python-nose python-coverage python-mock
31
lxc file push ubuntu.sudoers $name/etc/sudoers.d/ubuntu
32
lxc exec $name -- su ubuntu -c 'juju generate-config'
33
lxc exec $name -- su ubuntu -c 'juju switch local'
34
lxc exec $name -- su ubuntu -c 'juju bootstrap'
36
# Force a juju image to be cached in the container for quicker integration tests
37
lxc exec $name -- su ubuntu -c 'juju add-machine'
38
lxc exec $name -- su ubuntu -c 'while $(juju status --format tabular| grep pending > /dev/null); do sleep 30; done; juju machine remove 1;sleep 30' # That extra 30s is because it takes awhile to remove
40
# Setup bzr identity for some of the mojo tests
41
lxc exec $name -- su ubuntu -c 'bzr whoami "test <integration@test.com>"'
44
for s in "install-from-branch.sh" "run-mojo-spec.sh"; do
45
lxc file push ./$s $name/home/ubuntu/$s
46
lxc exec $name -- chmod +x /home/ubuntu/$s
50
for envrc in $(ls *.envrc); do
51
lxc file push ./$envrc $name/home/ubuntu/$envrc
54
echo "Now run a shell with 'lxc exec $name -- su - ubuntu'"
55
echo "Then you can branch mojo install it and run integration tests, or branch a new spec to test."
56
echo "Refer to README.md in the container for more information"