--- /dev/null
+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
--- /dev/null
+# -*- 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
--- /dev/null
+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
--- /dev/null
+#!/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 <<EOF
+ifeq (\$(PLATFORM), arduinomega)
+ #Location of arduino sdk for Arduino Mega
+ ARDUINO_DIR := ${ARDUINO_MEGA_DIR}
+ ARDUINO_TOOLS_DIR := \$(ARDUINO_DIR)/hardware/tools/avr/bin
+else
+ #Location of arduino sdk for Arduino Due
+ ARDUINO_DIR := ${ARDUINO_DUE_DIR}
+ ARDUINO_TOOLS_DIR := \$(ARDUINO_DIR)/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin
+endif
+EOF