Skip to content

Commit

Permalink
Adapt installation script to any machine (p4lang#258)
Browse files Browse the repository at this point in the history
* Adapt script to any machine

Adapt script to any machine, independent of the user. We support for installations in VM Ubuntu

* Clear user-bootstrap.sh

* Update user-bootstrap.sh

* Adapt installation script to any machine
  • Loading branch information
davidcawork authored and jnfoster committed Jun 13, 2019
1 parent 573f716 commit b5c8270
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ You will need the script to execute to completion before you can see the `p4` lo

To install dependencies by hand, please reference the [vm](../vm) installation scripts.
They contain the dependencies, versions, and installation procedure.
You should be able to run them directly on an Ubuntu 16.04 machine, although note that the scripts currently assume the existence of a directory `/home/vagrant`:
You should be able to run them directly on an Ubuntu 16.04 machine:
- `sudo ./root-bootstrap.sh`
- `sudo ./user-bootstrap.sh`
8 changes: 4 additions & 4 deletions vm/root-bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apt-get update

KERNEL=$(uname -r)
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get install -y --no-install-recommends \
apt-get install -y --no-install-recommends --fix-missing\
atom \
autoconf \
automake \
Expand Down Expand Up @@ -73,11 +73,11 @@ chmod 440 /etc/sudoers.d/99_p4
usermod -aG vboxsf p4

cd /usr/share/lubuntu/wallpapers/
cp /home/vagrant/p4-logo.png .
cp ~/p4-logo.png .
rm lubuntu-default-wallpaper.png
ln -s p4-logo.png lubuntu-default-wallpaper.png
rm /home/vagrant/p4-logo.png
cd /home/vagrant
rm ~/p4-logo.png
cd ~
sed -i s@#background=@background=/usr/share/lubuntu/wallpapers/1604-lubuntu-default-wallpaper.png@ /etc/lightdm/lightdm-gtk-greeter.conf

# Disable screensaver
Expand Down
55 changes: 25 additions & 30 deletions vm/user-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#!/bin/bash

# Print script commands.
set -x
# Exit on errors.
set -e
# Print script commands and exit on errors.
set -xe

#Src
BMV2_COMMIT="884e01b531c6fd078cc2438a40258ecae011a65b" # Apr 24, 2019
PI_COMMIT="19de33e83bae7b737a3f8a1c9507c6e84173d96f" # Apr 24, 2019
P4C_COMMIT="61409c890c58d14ec7d6790f263eb44f393e542a" # Apr 24, 2019
PROTOBUF_COMMIT="v3.2.0"
GRPC_COMMIT="v1.3.2"

#Get the number of cores to speed up the compilation process
NUM_CORES=`grep -c ^processor /proc/cpuinfo`

# Mininet
# --- Mininet --- #
git clone git://github.com/mininet/mininet mininet
cd mininet
sudo ./util/install.sh -nwv
cd ..
sudo ./mininet/util/install.sh -nwv

# Protobuf
# --- Protobuf --- #
git clone https://github.com/google/protobuf.git
cd protobuf
git checkout ${PROTOBUF_COMMIT}
Expand All @@ -32,12 +30,12 @@ make -j${NUM_CORES}
sudo make install
sudo ldconfig
unset CFLAGS CXXFLAGS LDFLAGS
# force install python module
# Force install python module
cd python
sudo python setup.py install
cd ../..

# gRPC
# --- gRPC --- #
git clone https://github.com/grpc/grpc.git
cd grpc
git checkout ${GRPC_COMMIT}
Expand All @@ -51,7 +49,7 @@ cd ..
# Install gRPC Python Package
sudo pip install grpcio

# BMv2 deps (needed by PI)
# --- BMv2 deps (needed by PI) --- #
git clone https://github.com/p4lang/behavioral-model.git
cd behavioral-model
git checkout ${BMV2_COMMIT}
Expand All @@ -67,7 +65,7 @@ cd ..
sudo rm -rf $tmpdir
cd ..

# PI/P4Runtime
# --- PI/P4Runtime --- #
git clone https://github.com/p4lang/PI.git
cd PI
git checkout ${PI_COMMIT}
Expand All @@ -79,7 +77,7 @@ sudo make install
sudo ldconfig
cd ..

# Bmv2
# --- Bmv2 --- #
cd behavioral-model
./autogen.sh
./configure --enable-debugger --with-pi
Expand All @@ -93,11 +91,10 @@ cd targets/simple_switch_grpc
make -j${NUM_CORES}
sudo make install
sudo ldconfig
cd ..
cd ..
cd ..
cd ../../..

# P4C

# --- P4C --- #
git clone https://github.com/p4lang/p4c
cd p4c
git checkout ${P4C_COMMIT}
Expand All @@ -106,19 +103,17 @@ mkdir -p build
cd build
cmake ..
make -j${NUM_CORES}
# make -j${NUM_CORES} check <- skip tests as p4c tests are failing currently
sudo make install
sudo ldconfig
cd ..
cd ..
cd ../..

# Tutorials
# --- Tutorials --- #
sudo pip install crcmod
git clone https://github.com/p4lang/tutorials
sudo mv tutorials /home/p4
sudo chown -R p4:p4 /home/p4/tutorials

# Emacs
# --- Emacs --- #
sudo cp p4_16-mode.el /usr/share/emacs/site-lisp/
sudo mkdir /home/p4/.emacs.d/
echo "(autoload 'p4_16-mode' \"p4_16-mode.el\" \"P4 Syntax.\" t)" > init.el
Expand All @@ -127,22 +122,22 @@ sudo mv init.el /home/p4/.emacs.d/
sudo ln -s /usr/share/emacs/site-lisp/p4_16-mode.el /home/p4/.emacs.d/p4_16-mode.el
sudo chown -R p4:p4 /home/p4/.emacs.d/

# Vim
cd /home/vagrant
# --- Vim --- #
cd ~
mkdir .vim
cd .vim
mkdir ftdetect
mkdir syntax
echo "au BufRead,BufNewFile *.p4 set filetype=p4" >> ftdetect/p4.vim
echo "set bg=dark" >> /home/vagrant/.vimrc
sudo mv /home/vagrant/.vimrc /home/p4/.vimrc
cp /home/vagrant/p4.vim syntax/p4.vim
cd /home/vagrant
echo "set bg=dark" >> ~/.vimrc
sudo mv ~/.vimrc /home/p4/.vimrc
cp ~/p4.vim syntax/p4.vim
cd ~
sudo mv .vim /home/p4/.vim
sudo chown -R p4:p4 /home/p4/.vim
sudo chown p4:p4 /home/p4/.vimrc

# Adding Desktop icons
# --- Adding Desktop icons --- #
DESKTOP=/home/${USER}/Desktop
mkdir -p ${DESKTOP}

Expand Down

0 comments on commit b5c8270

Please sign in to comment.