2
# This file is part of Checkbox.
4
# Copyright 2013 Canonical Ltd.
6
# Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
8
# Checkbox is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License version 3,
10
# as published by the Free Software Foundation.
13
# Checkbox is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
21
# Helper script to provision testing containers or environments
22
# =============================================================
24
# Vagrant and LXC are explicitly supported, other types of containers (KVM)
25
# can be made to work but aren't yet guaranteed to.
27
# This script is entirely run *inside* the VM/container.
29
# Set CHECKBOX_TOP for all shared scripts. This should indicate the location
30
# of the checkbox source tree in the VM/container.
31
# If not passed as the first argument to the script, it defaults to /vagrant
32
# since by default vagrant mounts the current directory in the host system
33
# as /vagrant in the VM.
34
export CHECKBOX_TOP=${1:-/vagrant}
36
# Make sure that dpkg never stops to have a chat with the user
37
export DEBIAN_FRONTEND=noninteractive
39
if [ $CHECKBOX_TOP = "/vagrant" ] ; then
40
# Vagrant sanity check, see if /vagrant really works.
42
# On various installations of Ubuntu this is not the case as the cloud images
43
# we depend on seem to have broken virtualbox tools installation inside. This
44
# causes the filesystem mounted on /vagrant to crash horribly and kill all
45
# processes attempting to use it.
46
if ! find /vagrant -mindepth 1 -maxdepth 1 >/dev/null; then
48
E: It seems that /vagrant directory is broken
49
E: This is a known issue.
50
E: See this link for a workaround if you have recent-enough VirtualBox:
51
E: https://bugs.launchpad.net/ubuntu/+source/virtualbox/+bug/1252872
52
E: Alternatively you can use NFS on any version of VirtualBox:
53
E: http://docs.vagrantup.com/v2/synced-folders/nfs.html
57
echo "I: it seems that /vagrant is working okay"
60
# Add any necessary PPA repositories
61
$CHECKBOX_TOP/support/install-ppa-dependencies
63
# Update to have the latest packages, this is needed because the image comes
64
# with an old (and no longer working) apt cache and links to many packages no
65
# longer work. This is also needed if the step above actually added any PPAs.
68
# Update all packages to latest version
69
# NOTE: this is disabled as it takes a lot of time and we haven't found the
70
# need to run this. It might have to be re-enabled later if we find that some
71
# bug (that gets fixed) is affecting our behavior but so far that has not been
73
# apt-get dist-upgrade --yes
75
# Ensure that certain Debian dependencies are *not* installed
76
$CHECKBOX_TOP/support/remove-deb-anty-dependencies
79
$CHECKBOX_TOP/support/install-deb-dependencies
80
$CHECKBOX_TOP/support/get-external-tarballs
81
$CHECKBOX_TOP/support/install-pip-from-source
82
# Pip executable name is a variable that depends on python version
83
export PIP=/usr/local/bin/pip-3.*
84
$CHECKBOX_TOP/support/install-pip-dependencies
85
$CHECKBOX_TOP/support/develop-projects
87
# Create a cool symlink so that everyone knows where to go to.
89
# Vagrant runs the provision script as root, but we want the symlink to /vagrant,
90
# so we're reduced to assuming the stuff is there and blindly linking.
91
if [ -d /vagrant ]; then
92
[ -d /home/vagrant ] && ln --no-dereference --force --symbolic /vagrant /home/vagrant/src
93
elif [ "$container" = "lxc" ]; then
94
# In LXC, $HOME is inherited from the invoking environment. Link the source
95
# location to /home/$user-invoking-lxc/src. This should work consistently
96
# since all the lxc-attach commands will use the same inherited environment, so
97
# $user-invoking-lxc should always point to the same place. Under LXC,
98
# however, the home dir may not exist (as lxc creates only the ubuntu user by
99
# default), so we need to create the home dir ourselves.
100
[ ! -d $HOME ] && mkdir -p $HOME
101
ln --no-dereference --force --symbolic $CHECKBOX_TOP $HOME/src