diff --git a/README.md b/README.md index 9ead427..2512172 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,27 @@ # EdgeVPNio tools Various management and configuration tools used with EdgeVPNio software development. + +## Using the repository +One the same directory level as evio clone the repository with: +``` +git clone https://github.com/EdgeVPNio/tools.git +``` + +## Setup +To setup running the evt tool use the following command : +``` +source setup-evt.sh +``` + +## Usage +Run the command to view all options: +``` +evt -h +``` +``` +evt --sync +``` + +## TO DO +Move to one output folder. Run sync before any command. diff --git a/ev-tools.sh b/ev-tools.sh new file mode 120000 index 0000000..752a9c2 --- /dev/null +++ b/ev-tools.sh @@ -0,0 +1 @@ +./scripts/evtool-v20.7.2 \ No newline at end of file diff --git a/evt b/evt new file mode 100755 index 0000000..ef1ef18 --- /dev/null +++ b/evt @@ -0,0 +1,22 @@ +#!/bin/sh + +#Copyright (c) <2020> +# +#Permission is hereby granted, free of charge, to any person obtaining a copy +#of this software and associated documentation files (the "Software"), to deal +#in the Software without restriction, including without limitation the rights +#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +#copies of the Software, and to permit persons to whom the Software is +#furnished to do so, subject to the following conditions: +# +#The above copyright notice and this permission notice shall be included in all +#copies or substantial portions of the Software. +# +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +#SOFTWARE. +python evt-tools.py "$@" \ No newline at end of file diff --git a/evt-tools.py b/evt-tools.py new file mode 100644 index 0000000..1dbfc74 --- /dev/null +++ b/evt-tools.py @@ -0,0 +1,189 @@ +import argparse +import sys +sys.path.append('../') +from scripts.Link import Link +import subprocess + + +class EvtTools: + def __init__(self): + parser = argparse.ArgumentParser( + description="A collection of all the tools which can be used to deploy EdgeVPN") + parser.add_argument("--sync", action="store_true", default=False, dest="sync", + help="Syncs the tools repo with the correct version of the tools script." + "You need to clone the evio repository a directory above for this to work.") + parser.add_argument("--clean", action="store_true", default=False, dest="clean", + help="Cleans the code from all the locations to prepare for a fresh installation.") + parser.add_argument("--deps", action="store_true", default=False, dest="deps", + help="Installs the required build tools.") + parser.add_argument("--src", action="store_true", default=False, dest="src", + help="Clones EVIO repo.") + parser.add_argument("--debpak", action="store_true", default=False, dest="debpak", + help="Generates the Debian package.") + parser.add_argument("--testbed", action="store_true", default=False, dest="testbed", + help="Installs required dependencies for a testbed.") + parser.add_argument("--venv", action="store_true", default=False, dest="venv", + help="Setup the virtual environment.") + parser.add_argument("--xmpp", action="store_true", default=False, dest="xmpp", + help="Install openfire server.") + parser.add_argument("--build_docker", action="store_true", default=False, dest="dkrimg", + help="Builds the docker image if you have already built the debian package.") + parser.add_argument("--build_webrtc", action="store_true", default=False, dest="webrtc", + help="Clones and builds the webrtc libraries for ubuntu and returns a debug build.") + parser.add_argument("--build_webrtc_release", action="store_true", default=False, dest="webrtc_r", + help="Clones and builds the webrtc libraries for ubuntu and returns a release build.") + parser.add_argument("--build_webrtc_raspberry_debug", action="store_true", default=False, dest="webrtc_r_d", + help="Clones and builds the webrtc libraries for raspberry and returns a debug build.") + parser.add_argument("--build_webrtc_raspberry_release", action="store_true", default=False, dest="webrtc_r_r", + help="Clones and builds the webrtc libraries for raspberry and returns a release build.") + parser.add_argument("--build_tincan", action="store_true", default=False, dest="tincan", + help="Builds the tincan debug executable for ubuntu. It assumes you have the webrtc " + "libraries already cloned or built") + parser.add_argument("--build_tincan_release", action="store_true", default=False, dest="tincan_r", + help="Builds the tincan release executable for ubuntu. It assumes you have the webrtc " + "libraries already cloned or built") + parser.add_argument("--build_tincan_raspberry_debug", action="store_true", default=False, dest="tincan_r_d", + help="Builds the tincan debug executable for raspberry. It assumes you have the webrtc " + "libraries already cloned or built") + parser.add_argument("--build_tincan_raspberry_release", action="store_true", default=False, dest="tincan_r_r", + help="Builds the tincan release executable for raspberry. It assumes you have the webrtc " + "libraries already cloned or built") + parser.add_argument("--all", action="store_true", default=False, dest="all", + help="Setup the whole environment.") + self.args = parser.parse_args() + + def sync(self): + link = Link() + link.sync(None) + + def clean(self): + subprocess.run(["ev-tools.sh clean"], shell=True) + + def build_tools(self): + subprocess.run(["ev-tools.sh deps"], shell=True) + + def pull_src(self): + subprocess.run(["ev-tools.sh src"], shell=True) + + def tincan(self): + subprocess.run(["ev-tools.sh tincan"], shell=True) + + def debpak(self): + subprocess.run(["ev-tools.sh debpak"], shell=True) + + def testbed(self): + subprocess.run(["ev-tools.sh testbed"], shell=True) + + def venv(self): + subprocess.run(["ev-tools.sh venv"], shell=True) + + def xmpp(self): + subprocess.run(["ev-tools.sh xmpp"], shell=True) + + def build_docker(self): + subprocess.run(["ev-tools.sh dkrimg"], shell=True) + + def build_webrtc(self): + subprocess.run(["ev-tools.sh build_webrtc"], shell=True) + + def build_webrtc_release_ubuntu(self): + subprocess.run(["ev-tools.sh build_webrtc_with_release_ubuntu"], shell=True) + + def build_webrtc_debug_raspberry(self): + subprocess.run(["ev-tools.sh build_webrtc_with_debug_raspberry_pi"], shell=True) + + def build_webrtc_release_raspberry(self): + subprocess.run(["ev-tools.sh build_webrtc_with_release_raspberry_pi"], shell=True) + + def build_tincan(self): + subprocess.run(["ev-tools.sh build_tincan"], shell=True) + + def build_tincan_release_ubuntu(self): + subprocess.run(["ev-tools.sh build_tincan_release_ubuntu"], shell=True) + + def build_tincan_debug_raspberry(self): + subprocess.run(["ev-tools.sh build_tincan_debug_raspberry"], shell=True) + + def build_tincan_release_raspberry(self): + subprocess.run(["ev-tools.sh build_tincan_release_raspberry"], shell=True) + + def all(self): + subprocess.run(["ev-tools.sh all"], shell=True) + +def main(): + tools = EvtTools() + + if tools.args.clean: + tools.clean() + return + + if tools.args.src: + tools.pull_src() + return + + if tools.args.tincan: + tools.tincan() + return + + if tools.args.debpak: + tools.debpak() + return + + if tools.args.testbed: + tools.testbed() + return + + if tools.args.venv: + tools.venv() + return + + if tools.args.xmpp: + tools.xmpp() + return + + if tools.args.dkrimg: + tools.build_docker() + return + + if tools.args.webrtc: + tools.build_webrtc() + return + + if tools.args.webrtc_r: + tools.build_webrtc_release_ubuntu() + return + + if tools.args.webrtc_r_d: + tools.build_webrtc_debug_raspberry() + return + + if tools.args.webrtc_r_r: + tools.build_webrtc_release_raspberry() + return + + if tools.args.tincan: + tools.build_tincan() + return + + if tools.args.tincan_r: + tools.build_tincan_release_ubuntu() + return + + if tools.args.tincan_r_d: + tools.build_tincan_debug_raspberry() + return + + if tools.args.tincan_r_r: + tools.build_tincan_release_raspberry() + return + + if tools.args.all: + tools.all() + return + + if tools.args.sync: + tools.sync() + return + +if __name__ == "__main__": + main() diff --git a/scripts/Link.py b/scripts/Link.py new file mode 100644 index 0000000..d93ab6b --- /dev/null +++ b/scripts/Link.py @@ -0,0 +1,77 @@ +import stat + +import git +import os +import sys +sys.path.append('../') +from scripts.tool_config import MAPPING as mapping +from os import path + + +class Link: + sym_link = "./ev-tools.sh" + def __init__(self): + self.evio_repo = None + self.tools_repo = None + self.dir_path = None + self.dir_path_tools = None + + @staticmethod + def sync_branch(self): + """ + Syncing the correct script with EVT script if there is no version given by user. + """ + self.get_repository() + try: + if mapping.get(str(self.evio_repo.active_branch)) is not None and \ + mapping.get(str(self.evio_repo.active_branch)).get( + str(self.evio_repo.active_branch.commit)) is not None: + file_to_link = mapping[str(self.evio_repo.active_branch)][""] + elif mapping[str(self.evio_repo.active_branch)] is not None: + file_to_link = mapping[str(self.evio_repo.active_branch)]["default"] + except KeyError: + file_to_link = mapping["default"] + if path.exists(Link.sym_link): + os.remove(Link.sym_link) + os.symlink("./scripts/" + file_to_link, Link.sym_link) + os.chmod("./scripts/" + file_to_link, 0o775) + + def sync(self, version): + """ + Syncing the correct script with EVT script if there is a version given by user. + """ + if version is None: + self.sync_branch(self) + else: + self.get_repository() + if mapping.get(version).get(str(self.evio_repo.tags[0].commit)) is not None: + file_to_link = mapping[str(self.evio_repo.active_branch)][self.evio_repo.tags[0].commit] + else: + file_to_link = mapping[version]["default"] + + def get_repository(self): + """ + Get the active branch name of the Evio and Tools repo. + """ + present_dir = os.getcwd()[0:3] + for root, subdirs, files in os.walk(present_dir): + for d in subdirs: + if d == "evio": + self.dir_path = os.path.join(root, d) + + self.evio_repo = git.Repo(self.dir_path) + #print("Evio Branch name:" + str(self.evio_repo.active_branch)) + for root, subdirs, files in os.walk(present_dir): + for d in subdirs: + if d == "tools": + self.dir_path_tools = os.path.join(root, d) + self.tools_repo = git.Repo(self.dir_path_tools) + #print("Tools Branch name:" + str(self.tools_repo.active_branch)) + + def main(self): + self.sync("20.7.2") + + +if __name__ == "__main__": + link = Link() + link.main() diff --git a/scripts/build_tincan.sh b/scripts/build_tincan.sh new file mode 100644 index 0000000..b258895 --- /dev/null +++ b/scripts/build_tincan.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +#basic parameter checks on script +helpFunction() +{ + echo "" + echo "Usage: $0 -b build_type -t target_os" + echo -e "\t-b build_type can be release or debug" + echo -e "\t-t target_os can be ubuntu or raspberry-pi" + exit 1 # Exit script after printing help +} +while getopts b:t: opt +do + case "$opt" in + b ) build_type="$OPTARG" ;; + t ) target_os="$OPTARG" ;; + ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent + esac +done + +# Print helpFunction in case parameters are empty +if [ -z "$build_type" ] || [ -z "$target_os" ] +then + echo "Some or all of the parameters are empty"; + helpFunction +fi +if [ "$build_type" != "debug" ] && [ "$build_type" != "release" ]; then + echo "Wrong build_type spelling" + helpFunction +elif [ "$target_os" != "ubuntu" ] && [ "$target_os" != "raspberry-pi" ]; then + echo "Wrong OS type spelling" + helpFunction +fi +#for gn cmd +debug_flag=false +if [ "$build_type" == "debug" ]; then + $debug_flag = true; +fi + +#download and install dependencies +python_version="python3" +psutil_version=5.6.3 +sleekxmpp_version=1.3.3 +requests_version=2.21.0 +simplejson_version=3.16.0 +ryu_version=4.30 +sudo apt update -y +sudo apt install -y git make libssl-dev g++-5 $python_version $python_version-pip $python_version-dev openvswitch-switch iproute2 bridge-utils +sudo -H $python_version -m pip install --upgrade pip +sudo -H $python_version -m pip --no-cache-dir install psutil==$psutil_version sleekxmpp==$sleekxmpp_version requests==$requests_version simplejson==$simplejson_version ryu==$ryu_version + +mkdir -p ~/workspace +cd ~/workspace +git clone https://github.com/EdgeVPNio/evio.git +if [[ "$target_os" == "ubuntu" ]]; then + git clone -b ubuntu-x64 --single-branch https://github.com/EdgeVPNio/external.git +fi +#Todo: add git clone cmd for different OS +git clone https://github.com/EdgeVPNio/tools.git + +cd evio/tincan +export PATH=`pwd`/../tools/bin:$PATH + +if [[ "$target_os" == "ubuntu" ]]; then + gn gen out/$build_type "--args='is_debug=$debug_flag target_sysroot_dir=\"/path/to/external/sysroot\"'" +else + gn gen out/$build_type "--args='target_os=\"linux\" target_cpu=\"arm\" is_debug=$debug_flag treat_warnings_as_errors=false use_lld=true target_sysroot_dir=\"/path/to/external/sysroot\" enable_iterator_debugging=false is_component_build=false is_debug=true rtc_build_wolfssl=true rtc_build_ssl=false rtc_ssl_root=\"/usr/local/include\"\'" +fi + +ninja -C out/$build_type \ No newline at end of file diff --git a/scripts/build_webrtc.sh b/scripts/build_webrtc.sh new file mode 100644 index 0000000..e1e40d2 --- /dev/null +++ b/scripts/build_webrtc.sh @@ -0,0 +1,101 @@ +#!/bin/bash +#Ensure git works in the setup +#steps to install webrtc M84[4147] version for debug/release build_type on ubuntu/raspberry-pi target os + + +#basic parameter checks on script +helpFunction() +{ + echo "" + echo "Usage: $0 -b build_type -t target_os" + echo -e "\t-b build_type can be $build_type or debug" + echo -e "\t-t target_os can be ubuntu or raspberry-pi" + exit 1 # Exit script after printing help +} + +while getopts b:t: opt +do + case "$opt" in + b ) build_type="$OPTARG" ;; + t ) target_os="$OPTARG" ;; + ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent + esac +done + +# Print helpFunction in case parameters are empty +if [ -z "$build_type" ] || [ -z "$target_os" ] +then + echo "Some or all of the parameters are empty"; + helpFunction +fi +if [ "$build_type" != "debug" ] && [ "$build_type" != "$build_type" ]; then + echo "Wrong build_type spelling" + helpFunction +elif [ "$target_os" != "ubuntu" ] && [ "$target_os" != "raspberry-pi" ]; then + echo "Wrong OS type spelling" + helpFunction +fi +#for gn cmd +debug_flag=false +if [ "$build_type" == "debug" ]; then + $debug_flag = true; +fi + +#clang installation +sudo apt install clang +sudo apt-get install libc++-dev + +mkdir -p ~/workspace/webrtc-checkout && cd ~/workspace/webrtc-checkout +#install Toolchain according to OS +if [ "$target_os" == "ubuntu" ]; then + sudo apt-get update && sudo apt-get -y install git python + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git + export PATH=`pwd`/depot_tools:"$PATH" +else + sudo apt update && sudo apt install -y debootstrap qemu-user-static git python3-dev + sudo git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /opt/depot_tools + echo "export PATH=/opt/depot_tools:\$PATH" | sudo tee /etc/profile.d/depot_tools.sh + sudo git clone https://github.com/raspberrypi/tools.git /opt/rpi_tools + echo "export PATH=/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:\$PATH" | sudo tee /etc/profile.d/rpi_tools.sh + sudo chown -R `whoami`:`whoami` /opt/depot_tools /opt/rpi_tools + source /etc/profile + sudo debootstrap --arch armhf --foreign --include=g++,libasound2-dev,libpulse-dev,libudev-dev,libexpat1-dev,libnss3-dev,libgtk2.0-dev jessie rootfs + sudo cp /usr/bin/qemu-arm-static rootfs/usr/bin/ + sudo chroot rootfs /debootstrap/debootstrap --second-stage + find rootfs/usr/lib/arm-linux-gnueabihf -lname '/*' -printf '%p %l\n' | while read link target; do sudo ln -snfv "../../..${target}" "${link}"; done + find rootfs/usr/lib/arm-linux-gnueabihf/pkgconfig -printf "%f\n" | while read target; do sudo ln -snfv "../../lib/arm-linux-gnueabihf/pkgconfig/${target}" rootfs/usr/share/pkgconfig/${target}; done +fi + +#build webrtc +errormsg=$( fetch --nohooks webrtc 2>&1) +if [[ "$errormsg" == *"error"* ]]; then + echo $errormsg + exit 1; +fi +cd src +git checkout branch-heads/4147 +errormsg=$( gclient sync 2>&1) +if [[ "$errormsg" == *"error"* ]]; then + echo $errormsg + exit 1; +fi +if [ "$target_os" == "ubuntu" ]; then + sudo apt-get install gtk2.0 +else + ./build/install-build-deps.sh + ./build/linux/sysroot_scripts/install-sysroot.py --arch=arm +fi + +if [ "$target_os" == "ubuntu" ]; then + gn gen out/$build_type "--args=enable_iterator_debugging=false is_component_build=false is_debug=$debug_flag" +else + gn gen out/$build_type "--args='target_os=\"linux\" target_cpu=\"arm\" is_debug=$debug_flag enable_iterator_debugging=false is_component_build=false is_debug=true rtc_build_wolfssl=true rtc_build_ssl=false rtc_ssl_root=\"/usr/local/include\"\'" +fi + +#ninja cmd to compile the required webrtc libraries +webrtc_libs = boringssl boringssl_asm protobuf_lite rtc_p2p rtc_base_approved rtc_base jsoncpp rtc_event logging pc api rtc_pc_base call +errormsg=$( ninja -C out/$build_type/ $webrtc_libs 2>&1) +if [[ "$errormsg" == *"error"* ]] || [[ "$errormsg" == *"fatal"* ]]; then + echo $errormsg + exit 1; +fi diff --git a/scripts/evtool-v20.7.2 b/scripts/evtool-v20.7.2 new file mode 100755 index 0000000..b4987bc --- /dev/null +++ b/scripts/evtool-v20.7.2 @@ -0,0 +1,294 @@ +#!/bin/bash + +EVIO=https://github.com/EdgeVPNio/evio.git +#EXLIBS=https://github.com/ipop-project/3rd-Party-Libs.git +PY=python3.8 + +function install_build_tools +{ + sudo bash -c " + apt-get update -y && \ + apt-get install -y git \ + make clang libc++-dev libssl-dev $PY" +} + +function pull_src +{ + wd=$(pwd) + cd .. + #stat evio dir clone or pull + git clone $EVIO + cd evio/tincan/external + # + git clone -b ubuntu-x64 --single-branch https://github.com/ipop-project/3rd-Party-Libs.git + cd $wd +} + +function make_tincan +{ + wd=$(pwd) + cd ../evio/tincan/trunk/build + make clean; make + cd $wd +} + +function make_debpak +{ + wd=$(pwd) + cp ../evio/controller/Controller.py debian-package/edge-vpnio/opt/edge-vpnio/ && \ + mkdir -p debian-package/edge-vpnio/etc/opt/edge-vpnio/ + cp ../evio/controller/template-config.json debian-package/edge-vpnio/etc/opt/edge-vpnio/config.json && \ + cp -r ../evio/controller/modules/ ../evio/controller/framework/ debian-package/edge-vpnio/opt/edge-vpnio/ && \ + chmod 0775 debian-package/edge-vpnio/opt/edge-vpnio/framework/ && \ + chmod 0664 debian-package/edge-vpnio/opt/edge-vpnio/framework/* && \ + chmod 0775 debian-package/edge-vpnio/opt/edge-vpnio/modules/ && \ + chmod 0664 debian-package/edge-vpnio/opt/edge-vpnio/modules/* && \ + chmod 0664 debian-package/edge-vpnio/opt/edge-vpnio/Controller.py && \ + chmod 0664 debian-package/edge-vpnio/etc/opt/edge-vpnio/config.json && \ + cp ../evio/tincan/trunk/out/release/x86_64/tincan debian-package/edge-vpnio/opt/edge-vpnio/ && \ + chmod 0775 debian-package/edge-vpnio/opt/edge-vpnio/tincan && \ + cd debian-package/ && \ + ./deb-gen && \ + rm -rf edge-vpnio/opt/edge-vpnio/framework \ + edge-vpnio/opt/edge-vpnio/modules \ + edge-vpnio/opt/edge-vpnio/tincan \ + edge-vpnio/opt/edge-vpnio/template-config.json \ + edge-vpnio/opt/edge-vpnio/Controller.py \ + edge-vpnio/etc/opt/edge-vpnio/config.json + cd $wd +} + +function install_testbed_deps +{ + sudo bash -c " + apt-get update -y && \ + apt-get install -y openvswitch-switch \ + $PY $PY-venv $PY-dev python3-pip \ + apt-transport-https \ + ca-certificates \ + curl git \ + software-properties-common && \ + + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ + add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable\" && \ + apt-cache policy docker-ce && \ + apt-get install -y containerd.io \ + docker-ce-cli \ + docker-ce && \ + groupadd -f docker && \ + usermod -a -G docker $USER \ + " + echo "You must logout and relogin for docker group membership to take effect." +} + +function make_venv +{ + wd=$(pwd) + cd ../testbed && \ + $PY -m venv venv && \ + source venv/bin/activate && \ + pip3 install simplejson + cd $wd +} + +function make_dkrimg +{ + mv debian-package/edge-vpnio_20.7_amd64.deb docker-image/ && \ + docker build -f ./../docker-image/evio-base.Dockerfile -t edgevpnio/evio-base:1.0 ./docker-image && \ + docker build -f ./../docker-image/evio-node.Dockerfile -t edgevpnio/evio-node:20.7.3 ./docker-image + +} + +function install_openfire +{ + docker run --name openfire -d \ + -p 9090:9090 -p 5222:5222 \ + -p 5269:5269 -p 5223:5223 \ + -p 7443:7443 -p 7777:7777 \ + -p 7070:7070 -p 5229:5229 \ + -p 5275:5275 \ + edgevpnio/openfire_edgevpn_demo +} + +function install_portal +{ + #Todo: visualizer not yet available + git clone https://github.com/edgevpnio/portal.git + cd portal/setup + ./setup.sh + chown -R $USER /users/$USER/ +} + +function do_clean +{ + # tincan + wd=$(pwd) + + cd ../../evio/tincan/trunk/build + make clean; + cd $wd + #debian pak + cd debian-package/ && \ + rm -ri ./../edge-vpnio_20.7_amd64.deb \ + edge-vpnio/opt/edge-vpnio/framework \ + edge-vpnio/opt/edge-vpnio/modules \ + edge-vpnio/opt/edge-vpnio/tincan \ + edge-vpnio/opt/edge-vpnio/template-config.json \ + edge-vpnio/opt/edge-vpnio/Controller.py && \ + cd $wd + # docker-image + rm -f docker-image/edge-vpnio_20.7_amd64.deb + docker rmi edgevpnio/evio-base:1.0 edgevpnio/evio-node:20.7 + docker rmi $(docker images -q --filter "dangling=true") + # testbed + cd ../testbed + rm -rf config log cert venv + cd $wd +} + +function build_webrtc +{ + wd=$(pwd) + cd scripts + chmod +x build_webrtc.sh get_archives.sh get_include.sh + ./build_webrtc.sh -b debug -t ubuntu + ./get_archives.sh -b debug -t ubuntu + ./get_include.sh -b debug -t ubuntu +} + +function build_webrtc_with_release_ubuntu +{ + wd=$(pwd) + cd scripts + chmod +x build_webrtc.sh get_archives.sh get_include.sh + ./build_webrtc.sh -b release -t ubuntu + ./get_archives.sh -b release -t ubuntu + ./get_include.sh -b release -t ubuntu + cd $wd +} + +function build_webrtc_with_debug_raspberry_pi +{ + wd=$(pwd) + cd scripts + chmod +x build_webrtc.sh get_archives.sh get_include.sh + ./build_webrtc.sh -b debug -t raspberry-pi + ./get_archives.sh -b debug -t raspberry-pi + ./get_include.sh -b debug -t raspberry-pi + cd $wd +} + +function build_webrtc_with_release_raspberry_pi +{ + wd=$(pwd) + cd scripts + chmod +x build_webrtc.sh get_archives.sh get_include.sh + ./build_webrtc.sh -b release -t raspberry-pi + ./get_archives.sh -b release -t raspberry-pi + ./get_include.sh -b release -t raspberry-pi + cd $wd +} + +function build_tincan { + wd=$(pwd) + cd scripts + chmod +x ./build_tincan.sh + ./build_tincan.sh -b debug -t ubuntu + cd $wd +} + +function build_tincan_release_ubuntu { + wd=$(pwd) + cd scripts + chmod +x ./build_tincan.sh + ./build_tincan.sh -b release -t ubuntu + cd $wd +} + +function build_tincan_debug_raspberry { + wd=$(pwd) + cd scripts + chmod +x ./build_tincan.sh + ./build_tincan.sh -b debug -t raspberry-pi + cd $wd +} + +function build_tincan_release_raspberry { + wd=$(pwd) + cd scripts + chmod +x ./build_tincan.sh + ./build_tincan.sh -b debug -t raspberry-pi + cd $wd +} + +function do_full_setup +{ + install_build_tools + pull_src + build_webrtc + build_tincan + make_debpak + make_dkrimg + make_testbed_prereqs + make_venv +} + +case $1 in + deps) + install_build_tools + ;; + src) + pull_src + ;; + tincan) + build_tincan + ;; + debpak) + make_debpak + ;; + dkrimg) + make_dkrimg + ;; + testbed) + install_testbed_deps + ;; + venv) + make_venv + ;; + xmpp) + install_openfire + ;; + clean) + do_clean + ;; + build_webrtc) + build_webrtc + ;; + build_webrtc_with_release_ubuntu) + build_webrtc_with_release_ubuntu + ;; + build_webrtc_with_debug_raspberry_pi) + build_webrtc_with_debug_raspberry_pi + ;; + build_webrtc_with_release_raspberry_pi) + build_webrtc_with_release_raspberry_pi + ;; + build_tincan) + build_tincan + ;; + build_tincan_release_ubuntu) + build_tincan_release_ubuntu + ;; + build_tincan_debug_raspberry) + build_tincan_debug_raspberry + ;; + build_tincan_release_raspberry) + build_tincan_release_raspberry + ;; + all) + do_full_setup + ;; + *) + echo "no match on input -> $1" + ;; +esac diff --git a/scripts/get_archives.sh b/scripts/get_archives.sh new file mode 100644 index 0000000..aa59cd4 --- /dev/null +++ b/scripts/get_archives.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +helpFunction() +{ + echo "" + echo "Usage: $0 -b build_type -t target_os" + echo -e "\t-b build_type can be release or debug" + echo -e "\t-t target_os can be ubuntu or raspberry-pi" + exit 1 # Exit script after printing help +} + +while getopts b:t: opt +do + case "$opt" in + b ) build_type="$OPTARG" ;; + t ) target_os="$OPTARG" ;; + ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent + esac +done + +# Print helpFunction in case parameters are empty +if [ -z "$build_type" ] || [ -z "$target_os" ] +then + echo "Some or all of the parameters are empty"; + helpFunction +fi +if [ "$build_type" != "debug" ] && [ "$build_type" != "release" ]; then + echo "Wrong build_type spelling" + helpFunction +elif [ "$target_os" != "ubuntu" ] && [ "$target_os" != "raspberry-pi" ]; then + echo "Wrong OS type spelling" + helpFunction +fi + +mkdir -p out/debian-x64/external/libs +#getting the required .o files and .a files to 3rd party libs from webrtc-checkout +#build_type="$build_type" +llvm-ar -rcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/rtc_base/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/rtc_base_approved/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/p2p/rtc_p2p/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/logging/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/rtc_event/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/stringutils/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/timeutils/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/platform_thread_types/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/criticalsection/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/crypto/options/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/pc/rtc_pc_base/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/checks/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/synchronization/sequence_checker/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/synchronization/yield_policy/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/rtc_error/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/system_wrappers/metrics/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/system_wrappers/field_trial/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/logging/ice_log/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/experiments/field_trial_parser/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/transport/stun_types/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/libjingle_peerconnection_api/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/weak_ptr/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/network/sent_packet/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/rtc_numerics/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/third_party/base64/base64/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/task_queue/task_queue/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/system/file_wrapper/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/rtc_base/platform_thread/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/rtc_event_log/rtc_event_log/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/rtp_parameters/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/transport/media/media_transport_interface/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/call/rtp_receiver/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/modules/rtp_rtcp/rtp_rtcp_format/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/media/rtc_media_base/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/units/data_size/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/units/time_delta/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/units/data_rate/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/api/video/video_rtp_headers/*.o +llvm-ar -qcs out/debian-x64/external/libs/libwebrtc_lite.a webrtc-checkout/src/out/$build_type/obj/pc/media_protocol_names/*.o +#archives from third-party directory +llvm-ar -rcs out/debian-x64/external/libs/libboringssl_asm.a webrtc-checkout/src/out/$build_type/obj/third_party/boringssl/boringssl_asm/*.o +llvm-ar -qcs out/debian-x64/external/libs/libjsoncxx.a webrtc-checkout/src/out/$build_type/obj/third_party/jsoncpp/jsoncpp/json_reader.o webrtc-checkout/src/out/$build_type/obj/third_party/jsoncpp/jsoncpp/json_value.o webrtc-checkout/src/out/$build_type/obj/third_party/jsoncpp/jsoncpp/json_writer.o +llvm-ar -rcs out/debian-x64/external/libs/libboringssl.a webrtc-checkout/src/out/$build_type/obj/third_party/boringssl/boringssl/*.o +llvm-ar -rcs out/debian-x64/external/libs/libprotobuf_lite.a webrtc-checkout/src/out/$build_type/obj/third_party/protobuf/protobuf_lite/*.o +llvm-ar -qcs out/debian-x64/external/libs/libabseil_cpp.a webrtc-checkout/src/out/$build_type/obj/third_party/abseil-cpp/absl/strings/strings/*.o webrtc-checkout/src/out/$build_type/obj/third_party/abseil-cpp/absl/base/throw_delegate/*.o webrtc-checkout/src/out/$build_type/obj/third_party/abseil-cpp/absl/types/bad_optional_access/*.o webrtc-checkout/src/out/$build_type/obj/third_party/abseil-cpp/absl/base/raw_logging_internal/*.o +llvm-ar -rcs out/debian-x64/external/libs/libsrtp.a webrtc-checkout/src/out/$build_type/obj/third_party/libsrtp/libsrtp/*.o +llvm-ar -rcs out/debian-x64/external/libs/libc++.a webrtc-checkout/src/out/$build_type/obj/buildtools/third_party/libc++/libc++/*.o +llvm-ar -rcs out/debian-x64/external/libs/libc++abi.a webrtc-checkout/src/out/$build_type/obj/buildtools/third_party/libc++abi/libc++abi/*.o \ No newline at end of file diff --git a/scripts/get_include.sh b/scripts/get_include.sh new file mode 100644 index 0000000..f02aee5 --- /dev/null +++ b/scripts/get_include.sh @@ -0,0 +1,58 @@ +#!/bin/bash +helpFunction() +{ + echo "" + echo "Usage: $0 -b build_type -t target_os" + echo -e "\t-b build_type can be release or debug" + echo -e "\t-t target_os can be ubuntu or raspberry-pi" + exit 1 # Exit script after printing help +} + +while getopts b:t: opt +do + case "$opt" in + b ) build_type="$OPTARG" ;; + t ) target_os="$OPTARG" ;; + ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent + esac +done + +# Print helpFunction in case parameters are empty +if [ -z "$build_type" ] || [ -z "$target_os" ] +then + echo "Some or all of the parameters are empty"; + helpFunction +fi +if [ "$build_type" != "debug" ] && [ "$build_type" != "release" ]; then + echo "Wrong build_type spelling" + helpFunction +elif [ "$target_os" != "ubuntu" ] && [ "$target_os" != "raspberry-pi" ]; then + echo "Wrong OS type spelling" + helpFunction +fi + +#getting the required include files and folders from webrtc-checkout +# folders required: absl,api,base,call,common_video,logging,media,modules,p2p,pc,system_wrappers,rtc_base,build,common_types.h, jni.h, logging_buildflags.h +mkdir -p external/include/webrtc +cp -r webrtc-checkout/src/third_party/abseil-cpp/absl external/include +cp -r webrtc-checkout/src/api external/include/webrtc +cp -r webrtc-checkout/src/base external/include/webrtc +cp -r webrtc-checkout/src/call external/include/webrtc +cp -r webrtc-checkout/src/common_video external/include/webrtc +cp -r webrtc-checkout/src/logging/rtc_event_log external/include/webrtc +cp -r webrtc-checkout/src/media external/include/webrtc +cp -r webrtc-checkout/src/modules external/include/webrtc +cp -r webrtc-checkout/src/p2p external/include/webrtc +cp -r webrtc-checkout/src/pc external/include/webrtc +cp -r webrtc-checkout/src/system_wrappers/include external/include/webrtc +cp -r webrtc-checkout/src/rtc_base external/include/webrtc +cp -r webrtc-checkout/src/third_party/jsoncpp/source/include/json external/include +cp webrtc-checkout/src/third_party/jsoncpp/generated/version.h external/include/json +cp webrtc-checkout/src/common_types.h external/include/webrtc +cp webrtc-checkout/src/third_party/ffmpeg/libavcodec/jni.h external/include/webrtc +mkdir -p external/include/libc++ +mkdir -p external/include/libc++abi +cp -r webrtc-checkout/src/buildtools/third_party/libc++/trunk/include external/include/libc++ +cp -r webrtc-checkout/src/buildtools/third_party/libc++abi/trunk/include external/include/libc++abi +#mkdir -p /external/include/build && cp webrtc-checkout/src/build/build_config.h "$_" +#cp webrtc-checkout/src/build/buildflag.h /external/include/build \ No newline at end of file diff --git a/scripts/tool_config.py b/scripts/tool_config.py new file mode 100644 index 0000000..5f331b3 --- /dev/null +++ b/scripts/tool_config.py @@ -0,0 +1,9 @@ +MAPPING = { + "master": { + "default": "evtool-v20.7.2" + }, + "20.7.2": { + "default": "evtool-v20.7.2" + }, + "default" : "evtool-v20.7.2" +} diff --git a/update-limits.sh b/scripts/update-limits.sh old mode 100755 new mode 100644 similarity index 100% rename from update-limits.sh rename to scripts/update-limits.sh diff --git a/setup-evt.sh b/setup-evt.sh new file mode 100755 index 0000000..652d031 --- /dev/null +++ b/setup-evt.sh @@ -0,0 +1,7 @@ +#!/bin/bash +deactivate 2>/dev/null +python -m venv myenv && \ +source myenv/bin/activate && \ +export PATH="$PATH:." && \ +chmod 775 ./evt && \ +pip3 install gitpython simplejson