From 22622636b783ca492ff7f2af0cc458483614b486 Mon Sep 17 00:00:00 2001 From: alvin Date: Wed, 30 Jun 2021 17:18:25 +0800 Subject: [PATCH 1/7] Add Build Requirements to README.MD --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e5e63e3a..933107be 100644 --- a/README.md +++ b/README.md @@ -1 +1,47 @@ -# neuronplus \ No newline at end of file +# neuron-lite + +NEURON IIoT System for Industry 4.0 + + + +## Build Requirements + +- nng: https://github.com/nanomsg/nng + + ```shell + $ git clone git@github.com:nanomsg/nng.git + $ cd nng + $ mkdir build + $ cd build + $ cmake -G Ninja .. + $ ninja + $ ninja test + $ ninja install + ``` + +- jansson: https://github.com/akheron/jansson + + ``` + $ git clone git@github.com:akheron/jansson.git + $ cd jansson + $ mkdir build + $ cd build + $ cmake -G Ninja -DJANSSON_BUILD_DOCS=OFF .. + $ ninja + $ ninja install + ``` + +- jwt: https://github.com/benmcollins/libjwt + + ``` + $ git clone git@github.com:benmcollins/libjwt.git + $ cd libjwt + $ mkdir build + $ cd build + $ cmake -G Ninja -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1/lib -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include -DBUILD_EXAMPLES=OFF .. + $ ninja + $ ninja install + ``` + + + From 250d9afe9ffae22a667a864d50fff8c5b0a48ae8 Mon Sep 17 00:00:00 2001 From: alvin Date: Wed, 30 Jun 2021 17:30:10 +0800 Subject: [PATCH 2/7] update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 933107be..de444296 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ NEURON IIoT System for Industry 4.0 - jansson: https://github.com/akheron/jansson - ``` + ```shell $ git clone git@github.com:akheron/jansson.git $ cd jansson $ mkdir build @@ -33,12 +33,12 @@ NEURON IIoT System for Industry 4.0 - jwt: https://github.com/benmcollins/libjwt - ``` + ```shell $ git clone git@github.com:benmcollins/libjwt.git $ cd libjwt $ mkdir build $ cd build - $ cmake -G Ninja -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1/lib -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include -DBUILD_EXAMPLES=OFF .. + $ cmake -G Ninja -DBUILD_EXAMPLES=OFF -DOPENSSL_ROOT_DIR={YOUR_OPENSSL_ROOT_DIR} -DOPENSSL_INCLUDE_DIR={YOUR_OPENSSL_INCLUDE_DIR} .. $ ninja $ ninja install ``` From 9869aa1262c5b1a2154e3345111906e9af4826db Mon Sep 17 00:00:00 2001 From: alvin1221 <68314044+alvin1221@users.noreply.github.com> Date: Wed, 30 Jun 2021 18:37:32 +0800 Subject: [PATCH 3/7] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de444296..256dbd4a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ NEURON IIoT System for Industry 4.0 ## Build Requirements -- nng: https://github.com/nanomsg/nng +- [nng](https://github.com/nanomsg/nng) ```shell $ git clone git@github.com:nanomsg/nng.git @@ -19,7 +19,7 @@ NEURON IIoT System for Industry 4.0 $ ninja install ``` -- jansson: https://github.com/akheron/jansson +- [jansson](https://github.com/akheron/jansson) ```shell $ git clone git@github.com:akheron/jansson.git @@ -31,7 +31,7 @@ NEURON IIoT System for Industry 4.0 $ ninja install ``` -- jwt: https://github.com/benmcollins/libjwt +- [jwt](https://github.com/benmcollins/libjwt) ```shell $ git clone git@github.com:benmcollins/libjwt.git From b650ffe366cf789283c818d48833be5a3fd6674c Mon Sep 17 00:00:00 2001 From: alvin Date: Mon, 5 Jul 2021 15:58:03 +0800 Subject: [PATCH 4/7] add shell script for install libraries --- README.md | 20 ++++++- install-libs.sh | 148 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 165 insertions(+), 3 deletions(-) create mode 100755 install-libs.sh diff --git a/README.md b/README.md index 256dbd4a..c20e3ece 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,12 @@ NEURON IIoT System for Industry 4.0 ## Build Requirements -- [nng](https://github.com/nanomsg/nng) +- [openssl](https://github.com/openssl/openssl) + +- [nng](https://github.com/nanomsg/nng/tree/v1.4.0) ```shell - $ git clone git@github.com:nanomsg/nng.git + $ git clone -b v1.4.0 git@github.com:nanomsg/nng.git $ cd nng $ mkdir build $ cd build @@ -38,10 +40,22 @@ NEURON IIoT System for Industry 4.0 $ cd libjwt $ mkdir build $ cd build - $ cmake -G Ninja -DBUILD_EXAMPLES=OFF -DOPENSSL_ROOT_DIR={YOUR_OPENSSL_ROOT_DIR} -DOPENSSL_INCLUDE_DIR={YOUR_OPENSSL_INCLUDE_DIR} .. + $ cmake -G Ninja -DBUILD_EXAMPLES=OFF -DOPENSSL_ROOT_DIR={YOUR_OPENSSL_ROOT_DIR} .. $ ninja $ ninja install ``` +- [paho-mqtt.c](https://github.com/eclipse/paho.mqtt.c/tree/v1.3.9) + ```shell + $ git clone -b v1.3.9 git@github.com:eclipse/paho.mqtt.c.git + $ cd paho.mqtt.c + $ mkdir build + $ cd build + $ cmake -G Ninja -DPAHO_BUILD_SAMPLES=FALSE -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_SHARED=FALSE -DPAHO_BUILD_STATIC=TRUE -DOPENSSL_ROOT_DIR={YOUR_OPENSSL_ROOT_DIR} -DPAHO_HIGH_PERFORMANCE=TRUE -DCMAKE_BUILD_TYPE=Release .. + $ ninja + $ ninja install + ``` + + diff --git a/install-libs.sh b/install-libs.sh new file mode 100755 index 00000000..5b0d60d1 --- /dev/null +++ b/install-libs.sh @@ -0,0 +1,148 @@ +#!/bin/sh + +lib_list=(nng jansson jwt paho) +list_str="" +for var in ${lib_list[*]};do + list_str+=$var" " +done + +function usage() { + echo "Usage: $0 " + echo " -a \tBuild all dependencies" + echo " -i \tSpecify the dependence (opts: $list_str)" +} + +if [ $# -eq 0 ];then +usage +exit +fi + +if [ `whoami` != "root" ];then + echo "please use root access" + exit 2 +fi + +# nng +function build_nng() +{ + echo "building nng (v1.4.0)" + if [ ! -d nng ];then + git clone -b v1.4.0 https://github.com/nanomsg/nng.git + fi + cd nng + mkdir build + cd build + cmake -G Ninja .. + ninja + ninja install + + echo "leaving nng " + cd ../../ +} + +# jansson +function build_jansson() +{ + echo "building jansson" + if [ ! -d jansson ];then + git clone https://github.com/akheron/jansson.git + fi + cd jansson + rm -rf build + mkdir build + cd build + cmake -G Ninja -DJANSSON_BUILD_DOCS=OFF .. + ninja + ninja install + + echo "leaving jansson " + cd ../../ +} + +# jwt +function build_jwt() +{ + echo "building libjwt" + if [ ! -d libjwt ];then + git clone https://github.com/benmcollins/libjwt.git + fi + cd libjwt + rm -rf build + mkdir build + cd build + cmake -G Ninja -DBUILD_EXAMPLES=OFF $ssl_lib_flag .. + ninja + ninja install + + echo "leaving libjwt " + cd ../../ +} + +# paho.mqtt.c +function build_paho() +{ + echo "building paho.mqtt.c (v1.3.9)" + if [ ! -d paho.mqtt.c ];then + git clone -b v1.3.9 https://github.com/eclipse/paho.mqtt.c.git + fi + cd paho.mqtt.c + rm -rf build + mkdir build + cd build + cmake -G Ninja -DPAHO_BUILD_SAMPLES=FALSE -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_SHARED=FALSE -DPAHO_BUILD_STATIC=TRUE $ssl_lib_flag -DPAHO_HIGH_PERFORMANCE=TRUE -DCMAKE_BUILD_TYPE=Release .. + ninja + ninja install + echo "leaving paho.mqtt.c " + cd ../../ +} + +current=`pwd` +externs="/opt/externs" + +if [ ! -d $externs ];then + mkdir $externs +fi + +echo "entering $externs" +cd $externs + +system=`uname` +echo "System: $system" + +ssl_lib_flag="" +case "$system" in + "Linux") ssl_lib_flag="" + ;; + "Darwin") ssl_lib_flag="-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl" + ;; + *) + ;; +esac + +while getopts "a-:i:h" OPT; do + case ${OPT} in + a) + echo "build ${list_str}" + for var in ${lib_list[*]};do + build_$var + done + ;; + i) + pkgname=$OPTARG + build_$pkgname + ;; + h) + usage + exit 0 + ;; + \?) + usage + exit 1 + ;; + esac +done + + +echo "leaving $extends" +cd $current + From c5f77ed65a562a540765f2a90b4b5c07896350da Mon Sep 17 00:00:00 2001 From: alvin Date: Mon, 5 Jul 2021 16:48:57 +0800 Subject: [PATCH 5/7] update to bash script --- install-libs.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/install-libs.sh b/install-libs.sh index 5b0d60d1..31445672 100755 --- a/install-libs.sh +++ b/install-libs.sh @@ -1,4 +1,9 @@ -#!/bin/sh +#!/bin/bash + +if [ `whoami` != "root" ];then + echo "please use root access" + exit 2 +fi lib_list=(nng jansson jwt paho) list_str="" @@ -9,7 +14,7 @@ done function usage() { echo "Usage: $0 " echo " -a \tBuild all dependencies" - echo " -i \tSpecify the dependence (opts: $list_str)" + echo " -i \tSpecify installation options (opts: $list_str)" } if [ $# -eq 0 ];then @@ -17,11 +22,6 @@ usage exit fi -if [ `whoami` != "root" ];then - echo "please use root access" - exit 2 -fi - # nng function build_nng() { @@ -142,7 +142,6 @@ while getopts "a-:i:h" OPT; do esac done - echo "leaving $extends" cd $current From 54a0e8d2e87499b4a7ee1c26564e8cba3a64a04c Mon Sep 17 00:00:00 2001 From: alvin Date: Tue, 6 Jul 2021 16:12:36 +0800 Subject: [PATCH 6/7] Add "openssl" & "uuid" installation options --- README.md | 25 ++++++++++++++- install-libs.sh | 84 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 88 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c20e3ece..c5a6b4d4 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,19 @@ NEURON IIoT System for Industry 4.0 - [openssl](https://github.com/openssl/openssl) + ```shell + # Ubuntu + $ apt-get install libssl-dev + + # CentOS + $ yum install openssl-devel + + # MacOS + $ brew install openssl + ``` + + + - [nng](https://github.com/nanomsg/nng/tree/v1.4.0) ```shell @@ -56,6 +69,16 @@ NEURON IIoT System for Industry 4.0 $ ninja $ ninja install ``` - +- uuid + ```shell + # Ubuntu + $ apt-get install uuid-dev + + # CentOS + $ yum install libuuid-devel + + # MacOS + $ brew install ossp-uuid + ``` diff --git a/install-libs.sh b/install-libs.sh index 31445672..6b639ae4 100755 --- a/install-libs.sh +++ b/install-libs.sh @@ -1,11 +1,17 @@ #!/bin/bash -if [ `whoami` != "root" ];then - echo "please use root access" - exit 2 +system=`uname` +echo "System: $system" + +if [ $system == 'Linux' ];then + if [ `whoami` != "root" ];then + echo "Please use root access" + exit 2 + fi fi -lib_list=(nng jansson jwt paho) +lib_list=(nng jansson jwt paho uuid openssl) + list_str="" for var in ${lib_list[*]};do list_str+=$var" " @@ -13,8 +19,8 @@ done function usage() { echo "Usage: $0 " - echo " -a \tBuild all dependencies" - echo " -i \tSpecify installation options (opts: $list_str)" + echo " -a Build all dependencies" + echo " -i Specify installation options (opts: $list_str)" } if [ $# -eq 0 ];then @@ -25,7 +31,7 @@ fi # nng function build_nng() { - echo "building nng (v1.4.0)" + echo "Building nng (v1.4.0)" if [ ! -d nng ];then git clone -b v1.4.0 https://github.com/nanomsg/nng.git fi @@ -36,14 +42,14 @@ function build_nng() ninja ninja install - echo "leaving nng " + echo "Leaving nng " cd ../../ } # jansson function build_jansson() { - echo "building jansson" + echo "Building jansson" if [ ! -d jansson ];then git clone https://github.com/akheron/jansson.git fi @@ -55,14 +61,14 @@ function build_jansson() ninja ninja install - echo "leaving jansson " + echo "Leaving jansson " cd ../../ } # jwt function build_jwt() { - echo "building libjwt" + echo "Building libjwt" if [ ! -d libjwt ];then git clone https://github.com/benmcollins/libjwt.git fi @@ -74,14 +80,14 @@ function build_jwt() ninja ninja install - echo "leaving libjwt " + echo "Leaving libjwt " cd ../../ } # paho.mqtt.c function build_paho() { - echo "building paho.mqtt.c (v1.3.9)" + echo "Building paho.mqtt.c (v1.3.9)" if [ ! -d paho.mqtt.c ];then git clone -b v1.3.9 https://github.com/eclipse/paho.mqtt.c.git fi @@ -92,10 +98,51 @@ function build_paho() cmake -G Ninja -DPAHO_BUILD_SAMPLES=FALSE -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_SHARED=FALSE -DPAHO_BUILD_STATIC=TRUE $ssl_lib_flag -DPAHO_HIGH_PERFORMANCE=TRUE -DCMAKE_BUILD_TYPE=Release .. ninja ninja install - echo "leaving paho.mqtt.c " + echo "Leaving paho.mqtt.c " cd ../../ } +function install_tool() +{ + ubuntu=$1 + centos=$2 + darwin=$3 + + case "$system" in + "Linux") release=`awk -F= '/^NAME/{print $2}' /etc/os-release` + case "$release" in + "\"Ubuntu\"") + apt-get -y install $ubuntu + ;; + "\"CentOS Linux\"") + yum install -y $centos + ;; + esac + ;; + + "Darwin") + brew install $darwin + ;; + + *) + echo "Unsupported System!" + echo "Please install library manually!" + ;; + esac +} + +function build_uuid() +{ + echo "Installing uuid" + install_tool uuid-dev libuuid-devel ossp-uuid +} + +function build_openssl() +{ + echo "Installing openssl" + install_tool libssl-dev openssl-devel openssl +} + current=`pwd` externs="/opt/externs" @@ -103,12 +150,9 @@ if [ ! -d $externs ];then mkdir $externs fi -echo "entering $externs" +echo "Entering $externs" cd $externs -system=`uname` -echo "System: $system" - ssl_lib_flag="" case "$system" in "Linux") ssl_lib_flag="" @@ -122,7 +166,7 @@ esac while getopts "a-:i:h" OPT; do case ${OPT} in a) - echo "build ${list_str}" + echo "Build ${list_str}" for var in ${lib_list[*]};do build_$var done @@ -142,6 +186,6 @@ while getopts "a-:i:h" OPT; do esac done -echo "leaving $extends" +echo "Leaving $externs" cd $current From 900e42602ef4f1cf199889e5dc8c63b436cdd2de Mon Sep 17 00:00:00 2001 From: alvin Date: Mon, 12 Jul 2021 12:06:40 +0800 Subject: [PATCH 7/7] Update nng release version --- README.md | 4 ++-- install-libs.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c5a6b4d4..90877b16 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,10 @@ NEURON IIoT System for Industry 4.0 -- [nng](https://github.com/nanomsg/nng/tree/v1.4.0) +- [nng](https://github.com/nanomsg/nng/tree/v1.5.1) ```shell - $ git clone -b v1.4.0 git@github.com:nanomsg/nng.git + $ git clone -b v1.5.1 git@github.com:nanomsg/nng.git $ cd nng $ mkdir build $ cd build diff --git a/install-libs.sh b/install-libs.sh index 6b639ae4..4159a7d7 100755 --- a/install-libs.sh +++ b/install-libs.sh @@ -31,9 +31,9 @@ fi # nng function build_nng() { - echo "Building nng (v1.4.0)" + echo "Building nng (v1.5.1)" if [ ! -d nng ];then - git clone -b v1.4.0 https://github.com/nanomsg/nng.git + git clone -b v1.5.1 https://github.com/nanomsg/nng.git fi cd nng mkdir build