Skip to content

Commit

Permalink
Merge pull request #15 from malsami/makefileintegration
Browse files Browse the repository at this point in the history
Makefileintegration
  • Loading branch information
RobertHa authored Dec 20, 2018
2 parents fab4273 + a5d67da commit 3f3194b
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
path = taskgen
url = https://www.github.com/malsami/taskgen.git
branch = master
[submodule "distributor_service"]
path = distributor_service
url = https://github.com/malsami/distributor_service.git
[submodule "distributor"]
path = distributor
url = https://www.github.com/malsami/distributor
branch = master
[submodule "operating-system"]
path = operating-system
Expand Down
124 changes: 100 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,114 @@
# will setup everything for demonstration in vagrant
all: distributor genode binaries #datageneration
# should clone all the repos and build an operating system for pbxa9, then should vagrant up
make vagrant
all:
# should clone all the repos and build an operating system for pbxa9, then should vagrant up
-make venv
make distributor-init
make genode-init
make binaries OS-TARGET=focnados_pbxa9
make datageneration
#-make packages
-make vagrant

distributor: taskgen
# should clone the distributor_service repo and install dependencies (including the taskgen)
@git submodule update --init --remote distributor_service
# todo install dependencies in pyenv
distributor-init: taskgen-init
# clones the distributor_service repo and installs dependencies in venv(including the taskgen)
@-make venv
@git submodule update --init --remote distributor
@-bash -c "source malsami/bin/activate; pip3 install -r ./distributor/requirements.txt > /dev/null ; deactivate"

taskgen:
# should clone taskgen repo and install dependencies
taskgen-init:
# should clone taskgen repo, there are no dependencies
@git submodule update --init --remote taskgen
# todo install dependencies in pyenv

datageneration:
# should clone datageneration and install dependencies
datageneration-init:
# clones datageneration and installs dependencies in venv
@-make venv
@git submodule update --init --remote datageneration
# todo install dependencies in pyenv
@-bash -c "source malsami/bin/activate; pip3 install -r ./datageneration/requirements.txt > /dev/null ; deactivate"

genode:
genode-init:
# should clone operating system and build genode for specified arg
@git submodule update --init --remote operating-system
cd operating-system; make packages

binaries:#takes target as arg
# should build operating system and taskbinaries and put them into the bin folder in client-tools
cd operating-system; ./setup.sh focnados_pbxa9 # should take target
binaries:
# TARGET=focnados_pbxa9, focnados_panda, focnados_...
# should build operating system and taskbinaries and put them into ./bin
ifdef OS-TARGET
cd operating-system; ./setup.sh $(OS-TARGET)
else
@echo "there was no target, provide one via 'OS-TARGET=...'"
endif

vagrant:
@vagrant up
@vagrant ssh
venv: notInVagrant
#this installs python3-venv (if not already installed) and creates a venv called malsami
make install-PKG PKG=python3-venv ASK=NO
python3 -m venv malsami
@bash -c "source malsami/bin/activate; pip3 install --upgrade pip ; deactivate"

#dependencies: dependencies-confirm
#should install the dependencies for the whole setup in pyenv
inVagrant:
# is successful if user is vagrant or ubuntu
@if [ $(USER) = "ubuntu" ] || [ $(USER) = "vagrant" ]; then \
true; \
else \
false; \
fi

#dependencies-confirm:
#@( read -p "This will install qemu12, bridge-utils, screen, isc-dhcp-server, htop, pkg-config, zlib1g-dev, libglib2.0, libpixman-1.0, libpixman-1-dev Are you sure?!? [Y/n]: " sure && case "$$sure" in [nN]) false;; *) true;; esac )
notInVagrant:
# is successful if NOT in the directory /vagrant
@PATH=$$(pwd); \
if [ "$$PATH" = "/vagrant" ]; then \
false; \
else \
true; \
fi

vagrant: notInVagrant
# installs vagrant (if not already installed) and starts the vagrant machine and logs into it
make install-PKG PKG=vagrant ASK=NO
vagrant up
vagrant ssh

install-PKG: install-PKG-confirm
ifdef PKG
@PKG_IS_INSTALLED=$$(dpkg-query -W --showformat='$${Status}\n' $(PKG)|grep "install ok installed"); \
if [ -z "$$PKG_IS_INSTALLED" ]; then \
echo "$(PKG) is not installed yet, will install ..."; \
sudo apt-get --force-yes --yes install $(PKG); \
else \
echo "$(PKG) is already installed"; \
fi
else
@echo "PKG missing, declare package like PKG='package'"
endif

install-PKG-confirm:
#asks for permission to install if ASK is not YES
ifdef PKG
ifeq ($(ASK), YES)
@( read -p "This will install $(PKG) Are you sure?!? [Y/n]: " sure && case "$$sure" in [nN]) false;; *) true;; esac )
else
true
endif
else
@echo "PKG missing, declare package like PKG='package'"
false
endif

packages: notInVagrant
sudo apt-get update -qq
@for pkg in python3.5 python3-pip bridge-utils screen isc-dhcp-server htop pkg-config zlib1g-dev libglib2.0 libpixman-1.0 libpixman-1-dev; do \
echo "$$pkg"; \
make install-PKG PKG="$$pkg" ASK=NO ; \
done

qemu:
# compile qemu
@QEMU_VERSION=2.12.0; \
mkdir -p $$HOME/Downloads/QEMU; \
cd $$HOME/Downloads/QEMU; \
wget -q https://download.qemu.org/qemu-$$QEMU_VERSION.tar.xz; \
tar xvJf qemu-$$QEMU_VERSION.tar.xz; \
cd qemu-$$QEMU_VERSION; \
./configure --target-list=arm-softmmu; \
make; \
sudo cp arm-softmmu/qemu-system-arm /usr/local/bin/
1 change: 1 addition & 0 deletions distributor
Submodule distributor added at cd8867
1 change: 0 additions & 1 deletion distributor_service
Submodule distributor_service deleted from c259f1
9 changes: 6 additions & 3 deletions provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

sudo apt-get update -qq
sudo apt-get install python3.5 python3-pip bridge-utils screen isc-dhcp-server htop pkg-config zlib1g-dev libglib2.0 libpixman-1.0 libpixman-1-dev -qq
sudo pip3 install --upgrade pip
sudo pip3 install -r ./distributor_service/requirements.txt > /dev/null

sudo sh -c 'echo "\nauto br0\niface br0 inet static\n\thwaddress ether DE:AD:BE:EF:69:01\n\taddress 10.200.45.254\n\tnetmask 255.255.255.0\n\tgateway 10.200.45.254\nbridge_ports eth0\nbridge_stp off\nbridge_maxwait 0\nbridge_fd 0\n" >> /etc/network/interfaces'

# compile qemu
Expand All @@ -29,10 +28,14 @@ sudo cp arm-softmmu/qemu-system-arm /usr/local/bin/

if [ $USER == "ubuntu" ] || [ $USER == "vagrant" ]; then
cd /vagrant
sudo pip3 install --upgrade pip
sudo pip3 install -r ./datageneration/requirements.txt > /dev/null
sudo pip3 install -r ./distributor/requirements.txt > /dev/null
fi
sudo cp ./dhcpd.conf /etc/dhcp/

sudo cp ./dhcpd.conf /etc/dhcp/
sudo /etc/init.d/networking restart

sudo systemctl enable isc-dhcp-server
sudo systemctl start isc-dhcp-server

0 comments on commit 3f3194b

Please sign in to comment.