Skip to content

Commit

Permalink
Add Vagrantfile to hack/test xen builds
Browse files Browse the repository at this point in the history
+ update relevant documentation

Conflicts:
	.gitignore
	INSTALL.md
	README.md
	Vagrantfile
  • Loading branch information
proger committed May 5, 2015
1 parent c2cdb82 commit 4872fb6
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -6,7 +6,7 @@
.railing/
domain_config
ling.img
.vagrant/
/.vagrant/
macling
.DS_Store
tags
77 changes: 77 additions & 0 deletions HACKING.md
@@ -0,0 +1,77 @@

## Prerequisites

To build LING from sources, the following prerequisites must be met:

1. Erlang/OTP

You must have [Erlang/OTP release 17 installed](https://www.erlang-solutions.com/downloads/download-erlang-otp).

2. When using OS X, you need to have a [cross-compiling toolchain](http://crossgcc.rts-software.org/doku.php?id=compiling_for_linux)
installed on your system. LING has been tested to build against GCC 4.8.1 and 4.9.

## Build

```
make
make install
```

Make sure to run `git clean -dxf` to start over if you see weird error
messages you can't easily explain.

## Development using Vagrant

To begin, make sure [Vagrant](https://www.vagrantup.com) is available on your system.

Quick start:

```bash
vagrant up
vagrant reload # installs a new kernel
```

You can follow these additional steps to improve your workflow:

```bash
# Prepare your ssh client
vagrant ssh-config --host hackling >> ~/.ssh/config # prepares your ssh client

# Create a remote in your local git working dir to push to Vagrant
git remote add hackling hackling:ling

# Push your current sources to the VM & check them out.
# Vagrantfile provisioner creates a special command `indir'
# accepts a directory as the first argument and runs a following command in it.
git push -u hackling master && ssh hackling indir ling git checkout -f

# Build ling
ssh hackling indir ling make

# Build railing image
ssh hackling indir ling/railing ./railing image

# Run ling
ssh hackling -t indir ling/railing sudo xl create -c domain_config
```

## Running tests with Vagrant

```console
% ssh hackling -t indir ling/test make test.img
% ssh hackling -t indir ling/test sudo xl create -c domain_config

Parsing config from domain_config
Erlang [ling-0.3.2]

Eshell V6.3 (abort with ^G)
1> test:run(lists).
...
Total: 68, Ok: 68, Failed: 0
ok
2> q().
ok
3>
Bye
Shared connection to 127.0.0.1 closed.
```
35 changes: 0 additions & 35 deletions INSTALL.md

This file was deleted.

24 changes: 2 additions & 22 deletions README.md
Expand Up @@ -22,29 +22,9 @@ The easy way is to use pre-built railing utility:

xl create -c domain_config

### How to build/hack LING?

### Erlang on Pi

#### Serial Console

Before you try LING on Pi you need to setup a serial console. A comprehensive setup guide can be found [here](http://elinux.org/RPi_Serial_Connection).

A serial console is the only means of communication supported by LING on Pi now.

#### Quick Start

1. Grab `kernel.img` from the Raspberry Pi 0 [release](https://github.com/cloudozer/ling/releases/tag/v0.3.2r).

1. Copy `kernel.img` to an SD card and boot your Raspberry Pi using the card.

1. After a few second you will see the Erlang prompt on the serial console.

1. Learn more about Erlang [here](http://erlang.org).

### Building from Source

See [INSTALL.md](INSTALL.md).

See [HACKING.md](HACKING.md).

### Using `railing`

Expand Down
32 changes: 25 additions & 7 deletions Vagrantfile
Expand Up @@ -7,14 +7,29 @@ $script = <<EOF
set -xe
export DEBIAN_FRONTEND=noninteractive
sudo sh -c 'echo "deb http://packages.erlang-solutions.com/debian wheezy contrib" > /etc/apt/sources.list.d/erlang.list'
wget -c http://packages.erlang-solutions.com/debian/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
sudo apt-get update
sudo apt-get install -y --force-yes erlang git autoconf gcc-arm-none-eabi make build-essential
if [ ! -x "$(which erl)" -o $(($(date +%s) - $(stat -c '%Z' /var/lib/apt/periodic/update-success-stamp))) -gt 7200 ]; then
sudo sh -c 'echo "deb http://packages.erlang-solutions.com/debian wheezy contrib" > /etc/apt/sources.list.d/erlang.list'
wget -c http://packages.erlang-solutions.com/debian/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
rm -f erlang_solutions.asc
sudo apt-get update
rm -f erlang_solutions.asc
fi
cd /vagrant
make build-arm
sudo apt-get install -y --force-yes erlang git autoconf gcc-arm-none-eabi make build-essential
sudo apt-get install -y xen-hypervisor-4.4-amd64 bridge-utils
# create a workspace for local pushes
sudo -u vagrant -i git init ling
sudo -u vagrant -i sh -c '(cd ling; git config receive.denyCurrentBranch ignore)'
# indir simplifies a lot of interactive scripting
cat > /usr/local/bin/indir << INLING
#!/usr/bin/env bash
cd \\$1; shift
exec "\\$@"
INLING
chmod +x /usr/local/bin/indir
EOF

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
Expand All @@ -24,6 +39,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
vb.memory = 2048
end

config.vm.hostname = "hackling"
config.vm.provision "shell", inline: $script

# xen kernel breaks vboxguest
config.vm.synced_folder ".", "/vagrant", disabled: true
end

0 comments on commit 4872fb6

Please sign in to comment.