Skip to content

Commit e5d901b

Browse files
committed
Add cs4120 VM setup files
- Unzipped the course-supplied vm.zip and added the setup files for common use. - Added vim swap file extension and vm/.vagrant to gitignore since they are local files.
1 parent c00cd64 commit e5d901b

File tree

9 files changed

+323
-0
lines changed

9 files changed

+323
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Custom ignores
2+
*.swp
3+
vm/.vagrant
4+
15
# Created by .ignore support plugin (hsz.mobi)
26
### Gradle template
37
.gradle

vm/INSTALL

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
== INSTALL ====================================================================
2+
3+
(1) Install VirtualBox _and_ VirtualBox Extension Pack:
4+
https://www.virtualbox.org/wiki/Downloads
5+
6+
(2) Install Vagrant:
7+
* Windows, Mac OS X: https://www.vagrantup.com/downloads.html
8+
* Ubuntu: apt-get install vagrant
9+
10+
(2.5) Under Windows, you may have to reboot...
11+
12+
(3) Make sure you are connected to the Internet, preferably via a fast
13+
connection. Run 'vagrant up && vagrant ssh' from inside this directory (NOT the "base" directory).
14+
15+
(4) You are now accessing the VM via ssh.
16+
To look around, run 'ls -l'. (Note the shared folder.)
17+
To exit, run 'exit'.
18+
19+
(5) To halt the VM, run 'vagrant halt'.
20+
To spin it back up, run 'vagrant up && vagrant ssh' again.
21+
To remove the VM, run 'vagrant destroy'.
22+
23+
(6) The folder ./shared on your host machine is accessible from the virtual
24+
machine at ~/shared. You can do all editing etc on your physical machine and
25+
use the virtual machine only for building & running your application.
26+
27+
(7) Refer to the README for more options and frequently asked questions.
28+
29+
(*) Tip: You may want to run `vagrant plugin install vagrant-vbguest` in the
30+
vagrant folder on your physical machine. This will ensure your
31+
"VirtualBox Guest Additons" are always up to date (outdated Guest Additions
32+
can sometimes cause problems).
33+
34+
(*) Tip: You can restart the virtual machine by running `vagrant reload`. This
35+
can sometimes fix problems (and will update your Guest Additions, provided
36+
you followed the tip above).
37+
38+
--------------------------------------------------------------------------------
39+
- Jan 2019

vm/README

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
== CS 4120 VM ==================================================================
2+
3+
We provide this virtual machine to avoid cross-platform issues. It comes
4+
with Java 11, Scala, (Ant, Maven, Gradle, sbt), JFlex, OCaml (Opam, Oasis), Haskell (ghcup,
5+
cabal-install, stack), and Python 2/3 preinstalled.
6+
7+
It also comes with the test harness (xth) preinstalled. To execute it, simple
8+
execute `xth` inside the VM.
9+
10+
Note that the folder 'shared' is mounted at the path '~/shared' in the VM to
11+
facilitate easy sharing of project files. You can do all editing etc. on your
12+
physical machine and use the virtual machine only to build and run your
13+
application.
14+
15+
To get started, refer to the INSTALL file.
16+
17+
Note: do NOT use the files inside the "base" folder, unless you would like to customize the VM
18+
and/or troubleshoot environment issues with the course staff.
19+
20+
Note that the Scala, OCaml, and Haskell installs have not been extensively verified.
21+
If you run into issues, please let us know.
22+
23+
24+
-- FAQ -------------------------------------------------------------------------
25+
26+
How can I mount my xic folder on the physical machine to the virtual machine?
27+
28+
Modify the file "Vagrantfile.local" in the vagrant directory and add the
29+
following command to it:
30+
config.vm.synced_folder "<path on physical machine>", "/home/vagrant/xic"
31+
Then run `vagrant reload`.
32+
33+
34+
The course VM has been updated. How do I update my machine?
35+
36+
First, make sure that any files on the VM are backed up. Then, just
37+
run `vagrant box update`, `vagrant destroy`, then `vagrant up` to bring
38+
it back up.
39+
40+
41+
How can I make my compiler executable by typing just `xic` instead of
42+
`<path>/xic`?
43+
44+
Your xic executable must be on the PATH. The easiest way to achieve this is to
45+
execute
46+
ln -s <absolute path to xic> ~/bin
47+
which creates a symbolic link to xic in the folder ~/bin; ~/bin is on the PATH
48+
by default.
49+
50+
51+
I want to use a custom Vagrant file!
52+
53+
Sure. Add any commands you want to "Vagrantfile.local" in the vagrant folder.
54+
add any vagrant commands you want. Execute `vagrant reload` to restart the VM
55+
and reload the Vagrantfiles.
56+
57+
58+
--------------------------------------------------------------------------------
59+
- Jan 2019

vm/Vagrantfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure("2") do |config|
5+
config.vm.box = "cs4120-cornell/cs4120-sp19"
6+
# config.vm.box_version = " = 4.0.0" # to declare a specific version
7+
8+
# Add local definitions.
9+
eval File.read("Vagrantfile.local") if File.exist?("Vagrantfile.local")
10+
11+
config.ssh.forward_x11 = true
12+
13+
config.vm.provider "virtualbox" do |vb|
14+
vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
15+
end
16+
17+
end

vm/Vagrantfile.local

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Default shared folder
2+
config.vm.synced_folder "./shared", "/home/vagrant/shared"

vm/base/Vagrantfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
include_root_bootstrap = File.expand_path("../include/root-bootstrap.sh", __FILE__)
5+
include_user_bootstrap = File.expand_path("../include/user-bootstrap.sh", __FILE__)
6+
7+
Vagrant.configure(2) do |config|
8+
9+
config.vm.box = "ubuntu/bionic64"
10+
11+
config.vm.provider "virtualbox" do |vb|
12+
vb.memory = "1024"
13+
vb.cpus = 1
14+
end
15+
16+
config.vm.hostname = "cs4120"
17+
18+
# Add local definitions.
19+
eval File.read("Vagrantfile.local") if File.exist?("Vagrantfile.local")
20+
21+
config.ssh.forward_x11 = true
22+
# Don't replace insecure SSH key in the base image. This will automatically be overwritten by
23+
# Vagrant when running the derived image.
24+
config.ssh.insert_key = false
25+
26+
config.vm.provision "shell", path: include_root_bootstrap
27+
config.vm.provision "shell", privileged: false, path: include_user_bootstrap
28+
29+
end

vm/base/include/profile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
# Prompt
3+
PROMPT_COMMAND="RET=$?; printf '\n'"
4+
PS1="\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\]\[\e[0;32m\]$ \[\e[m\]"
5+
6+
# Aliases for convenience
7+
alias grep='grep --color=always'
8+
alias less='less -R'
9+
alias ls="ls -G"
10+
11+
# update xth on login
12+
~/xth/update

vm/base/include/root-bootstrap.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
set -x
3+
set -e
4+
5+
export DEBIAN_FRONTEND="noninteractive"
6+
7+
# basics - do not modify!
8+
apt-get -qq update
9+
apt-get -qq install \
10+
software-properties-common \
11+
python3-software-properties \
12+
pkg-config \
13+
wget \
14+
unzip \
15+
zip \
16+
dpkg \
17+
m4 \
18+
nano vim \
19+
ncdu \
20+
htop \
21+
x11-apps
22+
23+
# Oracle JDK 11 (LTS)
24+
add-apt-repository ppa:linuxuprising/java
25+
apt-get -qq update
26+
echo oracle-java11-installer shared/accepted-oracle-license-v1-2 select true | debconf-set-selections
27+
echo oracle-java11-installer shared/accepted-oracle-license-v1-2 seen true | debconf-set-selections
28+
apt-get -qq install oracle-java11-installer
29+
30+
# Ant
31+
apt-get -qq install ant
32+
33+
# Maven
34+
apt-get -qq install maven
35+
36+
# Qt
37+
apt-get -qq install cmake libqt4-dev libqt4-designer libqt4-opengl libqt4-svg libqtgui4 libqtwebkit4 libstdc++-4.8-dev g++
38+
39+
# Gradle
40+
GRADLE=gradle-5.1.1
41+
GRADLEZIP=gradle-5.1.1-bin.zip
42+
wget -nv -N https://services.gradle.org/distributions/$GRADLEZIP
43+
unzip -d /opt/ $GRADLEZIP
44+
ln -s /opt/$GRADLE/bin/gradle /usr/local/bin/
45+
rm $GRADLEZIP
46+
47+
# Scala
48+
SCALA=scala-2.12.8.deb
49+
wget -nv -N www.scala-lang.org/files/archive/$SCALA
50+
dpkg -i $SCALA &>/dev/null
51+
apt-get -qq update &>/dev/null
52+
apt-get -qq install scala 2>/dev/null
53+
rm "$SCALA"
54+
55+
# Scala sbt
56+
echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
57+
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
58+
apt-get -qq update
59+
apt-get -qq install sbt
60+
sbt update
61+
62+
# OCaml
63+
apt-get -qq install ocaml opam
64+
65+
# Haskell dependencies
66+
apt-get -qq install libgmp-dev libnuma-dev
67+
68+
# for backwards compatability
69+
chown -R vagrant $HOME
70+
71+
# see user-bootstrap.sh for more non-sudo bootstrapping

vm/base/include/user-bootstrap.sh

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
set -x
3+
set -e
4+
5+
command_exists () {
6+
type "$1" &> /dev/null ;
7+
}
8+
9+
# put or link binaries here
10+
BIN=$HOME/bin
11+
12+
# put things that should only be run once here
13+
MARK=$HOME/.initialized
14+
if [ ! -e $MARK ] ; then
15+
# add $BIN to PATH
16+
mkdir -p $BIN
17+
echo "PATH+=:$BIN" >> $HOME/.profile
18+
19+
# nice prompt
20+
cat /vagrant/include/profile >> $HOME/.profile
21+
22+
# Jflex
23+
JFLEX="jflex-1.6.1"
24+
ARCHIVE="$JFLEX.tar.gz"
25+
wget -nv -N http://jflex.de/release/$ARCHIVE
26+
tar -zxf $ARCHIVE
27+
rm $ARCHIVE
28+
ln -sf $HOME/$JFLEX/bin/jflex $HOME/bin
29+
echo -e "\nexport JFLEX_HOME=$HOME/jflex/" >> $HOME/.profile
30+
31+
# OCaml opam
32+
if command_exists opam ; then
33+
opam init -y #&>/dev/null
34+
eval `opam config env`
35+
echo '' >> $HOME/.profile
36+
echo '#OPAM' >> $HOME/.profile
37+
echo 'eval `opam config env`' >> $HOME/.profile
38+
39+
# Oasis
40+
opam install oasis -y &>/dev/null
41+
fi
42+
43+
# Haskell - install ghcup, GHC, and cabal-install
44+
mkdir -p ~/.ghcup/bin
45+
curl -sSL https://raw.githubusercontent.com/haskell/ghcup/master/ghcup > ~/.ghcup/bin/ghcup
46+
chmod +x ~/.ghcup/bin/ghcup
47+
PATH+=:"$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"
48+
echo 'PATH+=:"$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"' >> $HOME/.profile
49+
ghcup install
50+
ghcup set
51+
ghcup install-cabal
52+
cabal new-update
53+
54+
# Haskell stack - install to $BIN
55+
curl -sSL https://get.haskellstack.org/ | sh -s - -d $BIN
56+
57+
# insecure SSH setup
58+
# https://www.vagrantup.com/docs/boxes/base.html
59+
curl -sSL https://github.com/hashicorp/vagrant/raw/master/keys/vagrant.pub >> ~/.ssh/authorized_keys
60+
61+
touch $MARK
62+
echo "VAGRANT: DO NOT REMOVE" >> $MARK
63+
fi
64+
65+
WEBSEMESTER=2019sp
66+
67+
#Everything below will be used later in the semester
68+
69+
# test harness - do not modify!
70+
XTH=xth.tar.gz
71+
wget -nv -N http://www.cs.cornell.edu/courses/cs4120/$WEBSEMESTER/project/$XTH
72+
mkdir -p xth
73+
tar -zxf $XTH -C xth --owner=vagrant
74+
ln -sf $HOME/xth/xth $BIN
75+
76+
## runtime libraries - do not modify!
77+
#XIRT=pa5-release.zip
78+
#wget -nv -N -q http://www.cs.cornell.edu/courses/cs4120/$WEBSEMESTER/pa/pa5/$XIRT && \
79+
# mkdir -p runtime && \
80+
# unzip -q $XIRT "pa5_student/runtime/*" -d runtime && \
81+
# (cd runtime ; cp -frp pa5_student/runtime/* . ; rm -rf pa5_student ; make) || \
82+
#true
83+
#
84+
## QtXi libraries - do not modify!
85+
#XIRT=pa7-release.zip
86+
#wget -nv -N -q http://www.cs.cornell.edu/courses/cs4120/$WEBSEMESTER/pa/pa7/$XIRT && \
87+
# mkdir -p runtime && \
88+
# unzip -q $XIRT "pa7_student/QtXi/*" -d QtXi && \
89+
# (cd QtXi ; cp -frp pa7_student/QtXi/* . ; rm -rf pa7_student ; make) || \
90+
#true

0 commit comments

Comments
 (0)