From: William Dieter Date: Thu, 4 Dec 2014 03:35:04 +0000 (-0500) Subject: Added Vagrant config files that will create a build VM X-Git-Tag: 1.2.0+RC1~1949 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b864d1ab9656a2570888b64b8384b406e9212c6;p=platform%2Fupstream%2Fiotivity.git Added Vagrant config files that will create a build VM As described in the tools/vagrant/README.md, Vagrant can use the configuration provided in this commit to provision a build VM for building IoTivity. Change-Id: Ic2ae5a7bfc9e4274aa76be99a0807517f89c94b8 Signed-off-by: William Dieter Reviewed-on: https://gerrit.iotivity.org/gerrit/88 Tested-by: jenkins-iotivity Reviewed-by: Patrick Lankswert --- diff --git a/tools/vagrant/README.md b/tools/vagrant/README.md new file mode 100644 index 0000000..4de319f --- /dev/null +++ b/tools/vagrant/README.md @@ -0,0 +1,57 @@ +IoTivity Build VM from Vagrant +============================== + +Vagrant can use the files in this directory to provision an Ubuntu 12.04 +development environment for IoTivity. To create a new VM type + + % vagrant up + +in the current directory. You can then connect to the VM with + + % vagrant ssh + +On the newly provisioned VM, the IoTivity repo will be checked out in +the `iotivity` directory in the vagrant user's home directory and +configured to use the Arduino SDKs which are automatically downloaded +and installed in the home directory and patched when the VM is provisioned. + +Using Vagrant to build a VM might be useful for: + +* Testing the build process on a clean install to make sure all dependencies + are captured + +* Configuring a Linux build environment for Windows or Mac users + +* Configuring build VMs for build automation + +The bootstrap.sh and iotivity-setup.sh files can be used independent of +Vagrant to configure a existing Ubuntu environment. How to do so is left +as an exercise for the reader. (Hint: try `sudo bootstrap.sh && +iotivity-setup.sh`.) + +For more information about Vagrant, please see https://docs.vagrantup.com/v2/ + +Assumptions +=========== + +* The ${HOME}/.ssh/ directory contains config, id_rsa, id_rsa.pub, and + known_hosts, that when copied to the VM will allow connection to the + git repo. (And that you don't mind those files being copied to the VM.) + +* If a USER environment variable, it has the user name to use for git + otherwise, USERNAME has the user ID for git. USER should work for + Linux and USERNAME works inside Git bash on Windows. + +To Do +===== + +* Everything is dumped into the top-level directory. A cleaner layout + would be better (e.g., move the Arduino libraries to iotivity/extlibs). + +* Verify on more configurations (tested on Git bash under Windows) + +* Try with Ubuntu 14.04 + +* Have a more flexible way to determine the git user name + +* Install Android NDK diff --git a/tools/vagrant/Vagrantfile b/tools/vagrant/Vagrantfile new file mode 100644 index 0000000..d4fc989 --- /dev/null +++ b/tools/vagrant/Vagrantfile @@ -0,0 +1,48 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "hashicorp/precise64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + config.vm.provision :file, source: "~/.gitconfig", destination: ".gitconfig" + # maybe should have a separate key for Vagrant + config.vm.provision :file, source: "~/.ssh/id_rsa", destination: ".ssh/id_rsa" + config.vm.provision :file, source: "~/.ssh/id_rsa.pub", destination: ".ssh/id_rsa.pub" + config.vm.provision :file, source: "~/.ssh/known_hosts", destination: ".ssh/known_hosts" + config.vm.provision :file, source: "~/.ssh/config", destination: ".ssh/config" + + # Simple script configuration + config.vm.provision :shell, path: "bootstrap.sh" + config.vm.provision :shell do |shell| + shell.path = "iotivity-setup.sh" + user = ENV['USER'] + if (user.empty?) + user = ENV['USERNAME'] + end + shell.args = "#{user}" + shell.privileged = false + end +end diff --git a/tools/vagrant/bootstrap.sh b/tools/vagrant/bootstrap.sh new file mode 100644 index 0000000..13602cc --- /dev/null +++ b/tools/vagrant/bootstrap.sh @@ -0,0 +1,10 @@ +apt-get update +apt-get install -y git build-essential ia32-libs scons make g++ unzip +apt-get install -y libboost-dev libboost-program-options-dev libcurl4-nss-dev + +# for Android development +apt-get install -y openjdk-6-jdk +apt-get install -y icedtea-plugin + +# for more pleasant development UX in the VM +apt-get install -y vim diff --git a/tools/vagrant/iotivity-setup.sh b/tools/vagrant/iotivity-setup.sh new file mode 100644 index 0000000..1de6847 --- /dev/null +++ b/tools/vagrant/iotivity-setup.sh @@ -0,0 +1,117 @@ +#!/bin/bash + +# User ID to use with git +GIT_USER=$1 + +function die { + echo $1 + exit 255 +} + +# if file $1 does not exist, call wget on $2 +function wget_if_not_exists { + test -f $1 || wget -q $2 || die "$1 does not exist and wget failed for $2" +} + +# If you are behind a proxy, add all the environment variables required to +# set the proxy appropriately for your environment. +#source /vagrant/proxy_config + +# Protect the private key for better security (and so that ssh will work) +chmod 600 .ssh/id_rsa + +# Cannot use repo directory on host if host is Windows, because +# Windows does not handle symlinks properly +if [ ! -d "iotivity" ] +then + git clone ssh://${GIT_USER}@gerrit.iotivity.org/iotivity || die "git failed" + scp -p -P 29418 ${GIT_USER}@gerrit.iotivity.org:hooks/commit-msg iotivity/.git/hooks/ +fi + +export CEREAL_DIR=iotivity/extlibs/cereal +if [ ! -d ${CEREAL_DIR} ] +then + git clone https://github.com/USCiLab/cereal.git ${CEREAL_DIR} + pushd ${CEREAL_DIR} + git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245 + git apply ../../resource/patches/cereal_gcc46.patch + popd +fi + +####################################### +# Android +####################################### + +echo "Set up Android NDK" +export ANDROID_NDK=${PWD}/iotivity/tools/android-ndk +if [ ! -d ${ANDROID_NDK} ] +then + mkdir -p ${ANDROID_NDK} + pushd ${ANDROID_NDK} + wget_if_not_exists "android-ndk-r10d-linux-x86_64.bin" http://dl.google.com/android/ndk/android-ndk-r10d-linux-x86_64.bin + chmod a+x android-ndk-r10d-linux-x86_64.bin + ./android-ndk-r10d-linux-x86_64.bin + popd +fi + +echo "Set up Android NDK" +export ANDROID_SDK=${PWD}/iotivity/tools/android-sdk-linux +if [ ! -d ${ANDROID_SDK} ] +then + pushd iotivity/tools + cd .. + wget_if_not_exists "android-sdk_r24.0.2-linux.tgz" http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz + tar -xzf http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz + popd +fi + +####################################### +# Arduino Dependencies +####################################### + +# Arduino Mega +echo "Set up Arduino Mega" +export ARDUINO_MEGA_DIR=${PWD}/arduino-1.0.5 +if [ ! -d ${ARDUINO_MEGA_DIR} ] +then + wget_if_not_exists "arduino-1.0.5-linux64.tgz" http://arduino.googlecode.com/files/arduino-1.0.5-linux64.tgz + tar -xzf arduino-1.0.5-linux64.tgz + wget_if_not_exists "Time-1.0.5.zip" http://playground.arduino.cc/uploads/Code/Time.zip + mv Time.zip Time-1.0.5.zip + mkdir -p ${ARDUINO_MEGA_DIR}/libraries/Time + pushd ${ARDUINO_MEGA_DIR}/libraries/Time + unzip ../../../Time-1.0.5.zip + cd ../.. + patch -p5 < ../iotivity/tools/arduino/patches/arduino-1.0.5_linux.patch + popd +fi + +# Arduino Due +echo "Set up Arduino Due" +ARDUINO_DUE_DIR=${PWD}/arduino-1.5.7 +if [ ! -d ${ARDUINO_DUE_DIR} ] +then + wget_if_not_exists "download.php?f=%2Farduino-1.5.7-linux64.tgz" http://arduino.cc/download.php?f=/arduino-1.5.7-linux64.tgz + tar -xzf "download.php?f=%2Farduino-1.5.7-linux64.tgz" + wget_if_not_exists "Time-1.5.7.zip" http://www.pjrc.com/teensy/arduino_libraries/Time.zip + mv Time.zip Time-1.5.7.zip + mkdir -p ${ARDUINO_DUE_DIR}/libraries/Time + pushd ${ARDUINO_DUE_DIR}/libraries/Time + unzip ../../../Time-1.5.7.zip + cd ../.. + patch -p5 < ../iotivity/tools/arduino/patches/arduino-1.5.7_linux.patch + popd +fi + +# local.properties +cat > iotivity/resource/csdk/local.properties <