Skip to content

Commit

Permalink
Add vagrant.
Browse files Browse the repository at this point in the history
Add a directory contrib/vagrant/ to help creating a vagrant VM.

Add cmake to contrib/conda.sh.

Allow contrib/devenv/create.sh to take an argument.
  • Loading branch information
yungyuc committed Jul 4, 2016
1 parent 95a8ba8 commit 0feada6
Show file tree
Hide file tree
Showing 17 changed files with 3,591 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ script:
# C++ debug build
- mkdir -p ${TRAVIS_BUILD_DIR}/build/debug
- cd ${TRAVIS_BUILD_DIR}/build/debug
- cmake -DTESTFILTER="*" -DCMAKE_BUILD_TYPE=Debug -DPYTHON_EXECUTABLE=`which python` ${TRAVIS_BUILD_DIR}
- cmake -DTESTFILTER="*" -DCMAKE_BUILD_TYPE=Debug ${TRAVIS_BUILD_DIR}
- cd ${TRAVIS_BUILD_DIR}
- make -C build/debug run_gtest
# C++ release build
- mkdir -p ${TRAVIS_BUILD_DIR}/build/release
- cd ${TRAVIS_BUILD_DIR}/build/release
- cmake -DTESTFILTER="*" -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=`which python` ${TRAVIS_BUILD_DIR}
- cmake -DTESTFILTER="*" -DCMAKE_BUILD_TYPE=Release ${TRAVIS_BUILD_DIR}
- cd ${TRAVIS_BUILD_DIR}
- make -C build/release run_gtest
# Build Python extension
Expand Down
2 changes: 1 addition & 1 deletion contrib/conda.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
conda install -y \
six setuptools pip sphinx ipython jupyter \
cmake six setuptools pip sphinx ipython jupyter \
cython numpy netcdf4 nose paramiko boto graphviz
lret=$?; if [[ $lret != 0 ]] ; then exit $lret; fi
conda install -y -c https://conda.anaconda.org/yungyuc \
Expand Down
16 changes: 11 additions & 5 deletions contrib/devenv/create.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
SCDEV_SRC="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCDEV_ROOT=${SCDEV_SRC}/../../build/env
mkdir -p ${SCDEV_ROOT}
conda create -p ${SCDEV_ROOT}/install --no-default-packages -y python
cp -f ${SCDEV_SRC}/start ${SCDEV_ROOT}/start
SCDEVENV_SRC="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -z "$1" ]; then
SCDEVENV_DST=env
else
SCDEVENV_DST=$1
fi
SCDEVENV_DST=${SCDEVENV_SRC}/../../build/${SCDEVENV_DST}
echo "Create environment at ${SCDEVENV_DST}"
mkdir -p ${SCDEVENV_DST}
conda create -p ${SCDEVENV_DST}/install --no-default-packages -y python
cp -f ${SCDEVENV_SRC}/start ${SCDEVENV_DST}/start
6 changes: 3 additions & 3 deletions contrib/devenv/start
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export SCDEV_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export SCSRC="$( cd ${SCDEV_ROOT}/../.. && pwd )"
export SCDEVENV="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export SCSRC="$( cd ${SCDEVENV}/../.. && pwd )"
namemunge () {
if ! echo ${!1} | egrep -q "(^|:)$2($|:)" ; then
if [ -z "${!1}" ] ; then
Expand All @@ -21,5 +21,5 @@ namemunge () {
#fi
namemunge PATH $SCSRC
namemunge PYTHONPATH $SCSRC
source activate ${SCDEV_ROOT}/install
source activate ${SCDEVENV}/install
# vim: set ff=unix fenc=utf8 nobomb ft=sh:
1 change: 1 addition & 0 deletions contrib/vagrant/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vagrant/
33 changes: 33 additions & 0 deletions contrib/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"

config.ssh.forward_agent = true

config.vm.provider "virtualbox" do |vb|
vb.name = "solvcon_trusty64"
vb.memory = "2048"
if ENV["SC_VIRTUALBOX_DESKTOP"]
vb.gui = true
vb.customize ["modifyvm", :id, "--vram", "16"]
vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
else
vb.gui = false
end
end

# expose for jupyter notebook
config.vm.network "forwarded_port", guest: 8888, host: 8888, host_ip: 'localhost', protocol: 'tcp', auto_correct: true

config.vm.provision :shell, path: "bootstrap.sh"
config.vm.provision :shell, path: "bootstrap-anaconda.sh", privileged: false
config.vm.provision :shell, path: "setup-dotfiles.sh", privileged: false
if ENV["SC_VIRTUALBOX_DESKTOP"]
config.vm.provision :shell, path: "bootstrap-desktop.sh"
config.vm.provision :shell, path: "setup-launcher.sh", privileged: false
end

end
22 changes: 22 additions & 0 deletions contrib/vagrant/bootstrap-anaconda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

mkdir -p ${HOME}/tmp/miniconda
cd ${HOME}/tmp/miniconda

miniconda3=Miniconda3-latest-Linux-x86_64.sh
if [[ ! -f $miniconda3 ]]; then
echo "Download from http://repo.continuum.io/miniconda/$miniconda3"
wget --quiet http://repo.continuum.io/miniconda/$miniconda3
if [[ `which conda` != "${HOME}/opt/miniconda3/bin/conda" ]]; then
bash $miniconda3 -b -p ${HOME}/opt/miniconda3
fi
fi

miniconda2=Miniconda2-latest-Linux-x86_64.sh
if [[ ! -f $miniconda2 ]]; then
echo "Download from http://repo.continuum.io/miniconda/$miniconda2"
wget --quiet http://repo.continuum.io/miniconda/$miniconda2
if [[ `which conda` != "${HOME}/opt/miniconda2/bin/conda" ]]; then
bash $miniconda2 -b -p ${HOME}/opt/miniconda2
fi
fi
11 changes: 11 additions & 0 deletions contrib/vagrant/bootstrap-desktop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# NOTE: linux-generic contains drm kernel module, which is required for
# vboxvideo kernel module. Without vboxvideo Ubuntu unity graphics will be
# extremely slow. See
# http://askubuntu.com/questions/287532/how-do-i-resolve-slow-and-choppy-performance-in-virtualbox.
# "/usr/lib/nux/unity_support_test -p" is a convenient tool to check Ubuntu's
# video acceleration status.
apt-get install -y \
ubuntu-desktop linux-generic \
virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11 \
14 changes: 14 additions & 0 deletions contrib/vagrant/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

sudo timedatectl set-timezone Asia/Taipei

# Update repository.
apt-get update

# Make the system up-to-date.
apt-get dist-upgrade -y

# For development environment.
apt-get install -y \
build-essential liblapack-pic liblapack-dev \
git mercurial vim exuberant-ctags cscope
73 changes: 73 additions & 0 deletions contrib/vagrant/dotfiles/dot_bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
umask 002

#[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# set a fancy prompt (non-color, unless we know we "want" color)
PS1='\u@\h[\!]:\w$(__git_ps1 "(%s)")\n\$ '
# locale.
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
# set default editor.
export EDITOR=vim

# determine ls color.
ARCH=`uname`
if [ "$TERM" != "dumb" ]; then
if [ $ARCH == "Linux" ]; then
if [ -f ~/.dir_colors ]; then
eval "`dircolors -b ~/.dir_colors`"
else
eval "`dircolors -b`"
fi
elif [ $ARCH == "FreeBSD" ]; then
export LSCOLORS="Exfxcxdxbxegedabagacad"
elif [ $ARCH == "Darwin" ]; then
export CLICOLOR=1
export LSCOLORS="Exfxcxdxbxegedabagacad"
fi
fi

. ~/.git-completion.bash
. ~/.git-prompt.bash

namemunge () {
if ! echo ${!1} | egrep -q "(^|:)$2($|:)" ; then
if [ -z "${!1}" ] ; then
eval "$1=$2"
else
if [ "$3" == "after" ] ; then
eval "$1=\$$1:$2"
else
eval "$1=$2:\$$1"
fi
fi
fi
eval "export $1"
}

alias j=jobs
alias h=history

alias quota='quota -s'
alias ls='ls -F --color=auto'
alias ll='ls -l'
alias lla='ll -a'
alias dfh='df -h'
alias s='screen -r'
alias sc=screen
alias vi=vim

alias use.conda2="namemunge PATH ${HOME}/opt/miniconda2/bin"
alias use.conda3="namemunge PATH ${HOME}/opt/miniconda3/bin"

if [ -d "${HOME}/opt/miniconda3/bin" ]; then use.conda3; fi

# vim: sw=2 ts=2 tw=76 et nu ft=sh:
146 changes: 146 additions & 0 deletions contrib/vagrant/dotfiles/dot_dir_colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM linux-c
TERM mach-color
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cygwin
TERM dtterm
TERM mlterm
TERM putty
TERM xterm
TERM xterm-color
TERM xterm-debian
TERM rxvt
TERM rxvt-unicode
TERM screen
TERM screen-bce
TERM screen-w
TERM vt100
TERM Eterm
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 00;36 # directory
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file
#SETUID 37;41 # file that is setuid (u+s)
#SETGID 30;43 # file that is setgid (g+s)
#STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
#OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
#STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 01;32
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# If you use DOS-style suffixes, you may want to uncomment the following:
#.cmd 01;32 # executables (bright green)
#.exe 01;32
#.com 01;32
#.btm 01;32
#.bat 01;32
# archives or compressed (bright red)
.tar 01;31
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z 01;31
.Z 01;31
.gz 01;31
.bz2 01;31
.deb 01;31
.rpm 01;31
.jar 01;31
.rar 01;31
# document formats (yellow)
.rtf 01;33
.doc 01;33
.docx 01;33
.xls 01;33
.xlsx 01;33
.ppt 01;33
.pptx 01;33
.tex 01;33
.txt 01;33
.rst 01;33
# compiled documents (blue)
.dvi 01;34
.ps 01;34
.pdf 01;34
# source formats (yellow)
.c 01;33
.cpp 01;33
.f 01;33
.F 01;33
.f90 01;33
.F90 01;33
.py 01;33
.cu 01;33
# image formats (magenta)
.jpg 01;35
.jpeg 01;35
.gif 01;35
.bmp 01;35
.pbm 01;35
.pgm 01;35
.ppm 01;35
.tga 01;35
.xbm 01;35
.xpm 01;35
.tif 01;35
.tiff 01;35
.png 01;35
.eps 01;35
.gl 01;35
.dl 01;35
.xcf 01;35
.xwd 01;35
# video format (magenta)
.mov 01;31
.mpg 01;31
.mpeg 01;31
.avi 01;31
.wmv 01;31
.fli 01;31
.rm 01;31
.rmvb 01;31
.mkv 01;31
.ts 01;31
.mp4 01:31
# audio formats
.flac 01;34
.ape 01;34
.mp3 01;34
.mpc 01;34
.ogg 01;34
.wav 01;34
.wma 01;34

0 comments on commit 0feada6

Please sign in to comment.