diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build.sh | 214 | ||||
-rwxr-xr-x | scripts/build_dmm_dep.sh | 35 | ||||
-rwxr-xr-x | scripts/build_dpdk.sh | 124 | ||||
-rwxr-xr-x | scripts/build_dpdk1802.sh | 94 | ||||
-rwxr-xr-x | scripts/build_dpdk1805.sh | 82 | ||||
-rwxr-xr-x | scripts/build_rsocket.sh | 34 | ||||
-rwxr-xr-x | scripts/build_vpp.sh | 29 | ||||
-rwxr-xr-x | scripts/check_hugepage.sh | 41 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/checkstyle.sh | 13 | ||||
-rwxr-xr-x | scripts/compile_dmm.sh | 29 | ||||
-rw-r--r-- | scripts/dmm.spec | 45 | ||||
-rwxr-xr-x | scripts/generate_dmm_deb.sh | 42 | ||||
-rwxr-xr-x | scripts/generate_dmm_rpm.sh | 6 | ||||
-rwxr-xr-x | scripts/git/commit-msg-hook.py | 136 | ||||
-rw-r--r-- | scripts/git/commit-msg-template | 28 | ||||
-rwxr-xr-x | scripts/git/pre-commit | 14 | ||||
-rwxr-xr-x | scripts/install_prereq.sh | 39 | ||||
-rwxr-xr-x | scripts/perf_test.sh | 24 | ||||
-rwxr-xr-x | scripts/prep_app_test.sh | 80 | ||||
-rwxr-xr-x | scripts/print_os_info.sh | 17 |
20 files changed, 811 insertions, 315 deletions
diff --git a/scripts/build.sh b/scripts/build.sh index a4b0278..eaa0f0e 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,3 +1,4 @@ +#!/bin/bash -x ######################################################################### # Copyright (c) 2018 Huawei Technologies Co.,Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,17 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. ######################################################################### -#!/bin/bash -x set -x TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S) -log_file="/dmm/scripts/build_log.txt-$TIMESTAMP" +log_file="/tmp/build_log.txt-$TIMESTAMP" exec 1> >(tee -a "$log_file") 2>&1 # Get Command Line arguements if present DMM_DIR=$1 -if [ "x$1" != "x" ]; then +if [ "$1" == "all" ]; then + BUILD_ALL="YES" +fi + +if [ "x$1" != "x" ] && [ "$1" != "all" ]; then DMM_DIR=$1 else DMM_DIR=`dirname $(readlink -f $0)`/../ @@ -34,199 +38,29 @@ echo 2:$2 echo DMM_DIR: $DMM_DIR BUILD_DIR=${DMM_DIR}/build -LIB_PATH=${DMM_DIR}/release/lib64 - -OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') -OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') -KERNEL_OS=`uname -o` -KERNEL_MACHINE=`uname -m` -KERNEL_RELEASE=`uname -r` -KERNEL_VERSION=`uname -v` - -echo KERNEL_OS: $KERNEL_OS -echo KERNEL_MACHINE: $KERNEL_MACHINE -echo KERNEL_RELEASE: $KERNEL_RELEASE -echo KERNEL_VERSION: $KERNEL_VERSION -echo OS_ID: $OS_ID -echo OS_VERSION_ID: $OS_ID -#DPDK download path -DPDK_DOWNLOAD_PATH=/tmp/dpdk +#print os information +bash -x $DMM_DIR/scripts/print_os_info.sh -#dpdk installation path -DPDK_INSTALL_PATH=/usr +# add inherited proxy for sudo user +LINE='Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"' +FILE=/etc/sudoers +grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" >> "$FILE" #set and check the environment for Linux -if [ "$OS_ID" == "ubuntu" ]; then - export DEBIAN_FRONTEND=noninteractive - export DEBCONF_NONINTERACTIVE_SEEN=true - - APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" - sudo apt-get update ${APT_OPTS} - sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim -elif [ "$OS_ID" == "debian" ]; then - export DEBIAN_FRONTEND=noninteractive - export DEBCONF_NONINTERACTIVE_SEEN=true - - APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" - sudo apt-get update ${APT_OPTS} - sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim -elif [ "$OS_ID" == "centos" ]; then - sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel -elif [ "$OS_ID" == "opensuse" ]; then - sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel -fi - - -#DPDK will be having dependancy on linux headers -if [ "$OS_ID" == "ubuntu" ]; then - sudo apt-get -y install git build-essential linux-headers-`uname -r` -elif [ "$OS_ID" == "debian" ]; then - sudo apt-get -y install git build-essential linux-headers-`uname -r` -elif [ "$OS_ID" == "centos" ]; then - sudo yum groupinstall -y "Development Tools" - sudo yum install -y kernel-headers -elif [ "$OS_ID" == "opensuse" ]; then - sudo yum groupinstall -y "Development Tools" - sudo yum install -y kernel-headers -fi - +bash -x $DMM_DIR/scripts/build_dmm_dep.sh || exit 1 #===========build DPDK================ - -if [ "$OS_ID" == "centos" ]; then - bash -x $DMM_DIR/scripts/build_dpdk.sh -else - - if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then - mkdir -p $DPDK_DOWNLOAD_PATH - - DPDK_FOLDER=$DPDK_DOWNLOAD_PATH/dpdk-16.04-$TIMESTAMP - cd $DPDK_DOWNLOAD_PATH - mkdir $DPDK_FOLDER - wget -N https://fast.dpdk.org/rel/dpdk-16.04.tar.xz --no-check-certificate - tar xvf dpdk-16.04.tar.xz -C $DPDK_FOLDER - cd $DPDK_FOLDER/dpdk-16.04 - - sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base - sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base - sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base - - sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4 - - fi -fi +bash -x $DMM_DIR/scripts/build_dpdk.sh || exit 1 #===========build DMM================= -echo "DMM build started....." - -cd $DMM_DIR/thirdparty/glog/glog-0.3.4/ && autoreconf -ivf -cd $BUILD_DIR -rm -rf * -cmake .. -make -j 8 - -if [ $? -eq 0 ] -then - echo "DMM build is SUCCESS" -else - echo "DMM build has FAILED" - exit 1 -fi - -if [ "$OS_ID" == "centos" ]; then - make pkg-rpm -fi - -#===========check running env ================= -sudo sysctl -w vm.nr_hugepages=1024 -HUGEPAGES=`sysctl -n vm.nr_hugepages` -if [ $HUGEPAGES != 1024 ]; then - echo "ERROR: Unable to get 1024 hugepages, only got $HUGEPAGES. Cannot finish." - exit -fi -hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0") -if [ $hugepageTotal -ne 0 ]; then - echo "HugePages_Total is zero" - exit -fi - -hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0") -if [ $hugepageFree -ne 0 ]; then - echo "HugePages_Free is zero" - exit -fi - -hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB") -if [ $hugepageSize -ne 0 ]; then - echo "Hugepagesize is zero" - exit +bash -x $DMM_DIR/scripts/compile_dmm.sh || exit 1 + +if [ "${BUILD_ALL}" == "YES" ]; then + #===========build LWIP================ + bash -x $DMM_DIR/stacks/lwip_stack/vagrant/build.sh "from-base-build" || exit 1 + #============build rsocket============================ + bash -x $DMM_DIR/scripts/build_rsocket.sh || exit 1 + #=======other new stacks build can be called from here + echo "SUCCESSFULLY built all the stacks" fi - - -sudo mkdir /mnt/nstackhuge -p -sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/ -sudo mkdir -p /var/run/ip_module/ - -export LD_LIBRARY_PATH=$LIB_PATH -export NSTACK_LOG_ON=DBG - -############### Preapre APP test directory -echo -e "\e[41m Preapring APP test directory.....\e[0m" - -mkdir -p $DMM_DIR/config/app_test -cd $DMM_DIR/config/app_test - -if [ "$OS_ID" == "ubuntu" ]; then - ifaddress1=$(ifconfig eth1 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') - echo $ifaddress1 - ifaddress2=$(ifconfig eth2 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') - echo $ifaddress2 -elif [ "$OS_ID" == "centos" ]; then - ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}') - echo $ifaddress1 - ifaddress2=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}') - echo $ifaddress2 -fi - -echo '{ - "default_stack_name": "kernel", - "module_list": [ - { - "stack_name": "kernel", - "function_name": "kernel_stack_register", - "libname": "./", - "loadtype": "static", - "deploytype": "1", - "maxfd": "1024", - "minfd": "0", - "priorty": "1", - "stackid": "0", - }, - ] -}' | tee module_config.json - -echo '{ - "ip_route": [ - { - "subnet": "'$ifaddress1'/24", - "type": "nstack-kernel", - }, - { - "subnet": "'$ifaddress2'/24", - "type": "nstack-kernel", - }, - ], - "prot_route": [ - { - "proto_type": "1", - "type": "nstack-kernel", - }, - { - "proto_type": "2", - "type": "nstack-kernel", - } - ], -}' | tee rd_config.json - -echo "DMM build finished....." diff --git a/scripts/build_dmm_dep.sh b/scripts/build_dmm_dep.sh new file mode 100755 index 0000000..ecbb686 --- /dev/null +++ b/scripts/build_dmm_dep.sh @@ -0,0 +1,35 @@ +#!/bin/bash -x + +set -x + +# add inherited proxy for sudo user +LINE='Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"' +FILE=/etc/sudoers +grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" >> "$FILE" + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + +#set and check the environment for Linux +if [ "$OS_ID" == "ubuntu" ]; then + export DEBIAN_FRONTEND=noninteractive + export DEBCONF_NONINTERACTIVE_SEEN=true + + APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" + sudo apt-get update ${APT_OPTS} + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim pkg-config tcl libnl-route-3-200 flex graphviz tk debhelper dpatch gfortran ethtool libgfortran3 bison dkms quilt chrpath swig python-libxml2 unzip +elif [ "$OS_ID" == "debian" ]; then + echo "not tested for debian and exit" + exit 1 + export DEBIAN_FRONTEND=noninteractive + export DEBCONF_NONINTERACTIVE_SEEN=true + + APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" + sudo apt-get update ${APT_OPTS} + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim +elif [ "$OS_ID" == "centos" ]; then + sudo yum install -y deltarpm git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel libiverbs tk tcl tcsh redhat-lsb-core +elif [ "$OS_ID" == "opensuse" ]; then + echo "not tested for opensuse and exit" + exit 1 + sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel +fi diff --git a/scripts/build_dpdk.sh b/scripts/build_dpdk.sh index 80a78b6..f631b27 100755 --- a/scripts/build_dpdk.sh +++ b/scripts/build_dpdk.sh @@ -1,85 +1,63 @@ -######################################################################### -# -# Copyright (c) 2018 Huawei Technologies Co.,Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -######################################################################### #!/bin/bash -x -echo "check whether dpdk installed" -cur_directory=${PWD} -check_dpdk=$(rpm -qa | grep dpdk) -if [ -z "$check_dpdk" ]; then - echo "system will install the dpdk" -else - echo "system has installed the dpdk" - echo "$check_dpdk" - exit 0 -fi - -cd ~ -mkdir -p rpmbuild/SOURCES - -cd ~/rpmbuild/SOURCES - -if [ ! -s dpdk-16.04.tar.gz ]; then -wget http://dpdk.org/browse/dpdk/snapshot/dpdk-16.04.tar.gz +set -x + +SCRIPT_DIR=`dirname $(readlink -f $0)` + +#DPDK download path +#if any change kindly update DPDK_DOWNLOAD_PATH in DMM/stacks/lwip_stack/vagrant/start_nStackMain.sh +DPDK_DOWNLOAD_PATH=/tmp/dpdk + +#dpdk installation path +DPDK_INSTALL_PATH=/usr + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +echo OS_ID: $OS_ID + +#DPDK will be having dependancy on linux headers +if [ "$OS_ID" == "ubuntu" ]; then + sudo apt-get -y install git build-essential linux-headers-`uname -r` + sudo apt-get -y install libnuma-dev +elif [ "$OS_ID" == "debian" ]; then + sudo apt-get -y install git build-essential linux-headers-`uname -r` +elif [ "$OS_ID" == "centos" ]; then + sudo yum groupinstall -y "Development Tools" + sudo yum install -y kernel-headers + sudo yum install -y numactl-devel +elif [ "$OS_ID" == "opensuse" ]; then + sudo yum groupinstall -y "Development Tools" + sudo yum install -y kernel-headers fi -tar xzvf dpdk-16.04.tar.gz -cp dpdk-16.04/pkg/dpdk.spec ~/rpmbuild/SOURCES/ - -echo "modify the spec" +#===========build DPDK================ -#get rid of the dependence of xen-devel -sed -i '48d' dpdk.spec -sed -i '47a BuildRequires: kernel-devel, kernel-headers, libpcap-devel' dpdk.spec - -#get rid of the dependence of texlive-collection -sed -i '/BuildRequires: texlive-collection/s/^/#&/' dpdk.spec - -#delete something about xen -sed -i '/LIBRTE_PMD_XENVIRT/s/^/#&/' dpdk.spec -sed -i '/LIBRTE_XEN_DOM0/s/^/#&/' dpdk.spec +if [ "$OS_ID" == "centos" ]; then + bash -x $SCRIPT_DIR/build_dpdk1802.sh || exit 1 +else -#delete something of generating doc -sed -i '/%{target} doc/s/^/#&/' dpdk.spec -sed -i '94d' dpdk.spec -sed -i '93a datadir=%{_datadir}/dpdk' dpdk.spec -sed -i '94a # datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk' dpdk.spec -sed -i '/%files doc/s/^/#&/' dpdk.spec -sed -i '/%doc %{_docdir}/s/^/#&/' dpdk.spec + if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then + mkdir -p $DPDK_DOWNLOAD_PATH -sed -i '76a sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base' dpdk.spec -sed -i '77a sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base' dpdk.spec -sed -i '78a sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base' dpdk.spec + cd $DPDK_DOWNLOAD_PATH + wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate + tar xvf dpdk-18.02.tar.xz + cd dpdk-18.02 -echo "build the dependence" -#sudo yum-builddep -y dpdk.spec + sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base + sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base + sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base + sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base -sudo yum install -y libpcap-devel python-sphinx inkscape + sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4 + if [ $? -eq 0 ]; then + echo "DPDK build is SUCCESS" + else + echo "DPDK build has FAILED" + exit 1 + fi -echo "generate the rpm package" -rpmbuild -ba dpdk.spec --define "_sourcedir ${PWD}" -if [ $? -eq 0 ]; then - echo "rpm build success" -else - echo "rpm build error" - exit + mkdir -p /tmp/dpdk/drivers/ + cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/ + fi fi - -echo "install the rpm" -cd ../RPMS/x86_64/ -sudo rpm -ivh dpdk-16.04-1.x86_64.rpm -sudo rpm -ivh dpdk-devel-16.04-1.x86_64.rpm -cd ${cur_directory} diff --git a/scripts/build_dpdk1802.sh b/scripts/build_dpdk1802.sh new file mode 100755 index 0000000..74d4860 --- /dev/null +++ b/scripts/build_dpdk1802.sh @@ -0,0 +1,94 @@ +#!/bin/bash -x +######################################################################### +# +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################### + +echo "check whether dpdk installed" +cur_directory=${PWD} +check_dpdk=$(rpm -qa | grep dpdk-devel) +if [ -z "$check_dpdk" ]; then + echo "system will install the dpdk" +else + echo "system has installed the dpdk" + echo "$check_dpdk" + exit 0 +fi + +cd ~ +mkdir -p rpmbuild/SOURCES + +cd ~/rpmbuild/SOURCES + +if [ ! -s dpdk-18.02.tar.gz ]; then +wget http://dpdk.org/browse/dpdk/snapshot/dpdk-18.02.tar.gz +fi + +tar xzvf dpdk-18.02.tar.gz +cp dpdk-18.02/pkg/dpdk.spec ~/rpmbuild/SOURCES/ + +echo "modify the spec" + +#get rid of the dependence of texlive-collection +sed -i '/BuildRequires: texlive-collection/s/^/#&/' dpdk.spec + +#delete something of generating doc +sed -i '/%{target} doc/s/^/#&/' dpdk.spec +sed -i '98d' dpdk.spec +sed -i '97a datadir=%{_datadir}/dpdk' dpdk.spec +sed -i '98a # datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk' dpdk.spec +sed -i '/%files doc/s/^/#&/' dpdk.spec +sed -i '/%doc %{_docdir}/s/^/#&/' dpdk.spec + +sed -i '82a sed -i '\''s!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1'\'' config/common_base' dpdk.spec +sed -i '83a sed -i '\''s!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1'\'' config/common_base' dpdk.spec +sed -i '84a sed -i '\''s!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1'\'' config/common_base' dpdk.spec +sed -i '85a sed -i '\''s!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1'\'' config/common_base' dpdk.spec + +#disable KNI mode by default +sed -i '93a sed -ri '\''s!CONFIG_RTE_LIBRARY_KNI=.*!CONFIG_RTE_LIBRARY_KNI=n!1'\'' %{target}/.config' dpdk.spec +sed -i '94a sed -ri '\''s!CONFIG_RTE_LIBRARY_PMD_KNI=.*!CONFIG_RTE_LIBRARY_PMD_KNI=n!1'\'' %{target}/.config' dpdk.spec +sed -i '95a sed -ri '\''s!CONFIG_RTE_KNI_KMOD=.*!CONFIG_RTE_KNI_KMOD=n!1'\'' %{target}/.config' dpdk.spec +sed -i '96a sed -ri '\''s!CONFIG_RTE_KNI_PREEMPT_DEFAULT=.*!CONFIG_RTE_KNI_PREEMPT_DEFAULT=n!1'\'' %{target}/.config' dpdk.spec + +#Add debug info +sed -i '98s!$! EXTRA_CFLAGS="-O0 -g" !' dpdk.spec + +#Not strip the debug info when generate the rpm +sed -i '43 i%global __os_install_post %{nil}\n%define debug_package %{nil}' dpdk.spec + +echo "build the dependence" +#sudo yum-builddep -y dpdk.spec +sudo yum install -y libpcap-devel python-sphinx inkscape kernel-devel-`uname -r` doxygen libnuma-devel kernel-`uname -r` + + +echo "generate the rpm package" +rpmbuild -ba dpdk.spec --define "_sourcedir ${PWD}" +if [ $? -eq 0 ]; then + echo "dpdk rpm build success" +else + echo "dpdk rpm build error" + exit 1 +fi + +echo "install the rpm" +cd ../RPMS/x86_64/ +sudo rpm -ivh dpdk-18.02-1.x86_64.rpm || exit 1 +sudo rpm -ivh dpdk-devel-18.02-1.x86_64.rpm || exit 1 + +mkdir -p /tmp/dpdk/drivers/ +cp -f /usr/lib64/librte_mempool_ring.so /tmp/dpdk/drivers/ +cp -f /usr/share/dpdk/usertools/dpdk-devbind.py /usr/sbin/ + +cd ${cur_directory} diff --git a/scripts/build_dpdk1805.sh b/scripts/build_dpdk1805.sh new file mode 100755 index 0000000..2727877 --- /dev/null +++ b/scripts/build_dpdk1805.sh @@ -0,0 +1,82 @@ +#!/bin/bash -x +######################################################################### +# +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################### + +echo "check whether dpdk installed" +cur_directory=${PWD} +check_dpdk=$(rpm -qa | grep dpdk) +if [ -z "$check_dpdk" ]; then + echo "system will install the dpdk" +else + echo "system has installed the dpdk" + echo "$check_dpdk" + exit 0 +fi + +cd ~ +mkdir -p rpmbuild/SOURCES + +cd ~/rpmbuild/SOURCES + +if [ ! -s dpdk-18.05.tar.gz ]; then +wget http://dpdk.org/browse/dpdk/snapshot/dpdk-18.05.tar.gz +fi + +tar xzvf dpdk-18.05.tar.gz +cp dpdk-18.05/pkg/dpdk.spec ~/rpmbuild/SOURCES/ + +echo "modify the spec" + +#get rid of the dependence of texlive-collection +sed -i '/BuildRequires: texlive-collection/s/^/#&/' dpdk.spec + +#delete something of generating doc +sed -i '/%{target} doc/s/^/#&/' dpdk.spec +sed -i '70d' dpdk.spec +sed -i '69a datadir=%{_datadir}/dpdk' dpdk.spec +sed -i '70a # datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk' dpdk.spec +sed -i '/%files doc/s/^/#&/' dpdk.spec +sed -i '/%doc %{_docdir}/s/^/#&/' dpdk.spec + +sed -i '54a sed -i '\''s!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1'\'' config/common_base' dpdk.spec +sed -i '55a sed -i '\''s!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1'\'' config/common_base' dpdk.spec +sed -i '56a sed -i '\''s!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1'\'' config/common_base' dpdk.spec +sed -i '57a sed -i '\''s!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1'\'' config/common_base' dpdk.spec +sed -i '58a sed -i '\''s!CONFIG_RTE_LIBRTE_DPAA2_USE_PHYS_IOVA=.*!CONFIG_RTE_LIBRTE_DPAA2_USE_PHYS_IOVA=n!1'\'' config/common_base' dpdk.spec + +echo "build the dependence" +#sudo yum-builddep -y dpdk.spec +sudo yum install -y libpcap-devel python-sphinx inkscape kernel-devel-`uname -r` doxygen libnuma-devel kernel-`uname -r` + + +echo "generate the rpm package" +rpmbuild -ba dpdk.spec --define "_sourcedir ${PWD}" +if [ $? -eq 0 ]; then + echo "dpdk rpm build success" +else + echo "dpdk rpm build error" + exit 1 +fi + +echo "install the rpm" +cd ../RPMS/x86_64/ +sudo rpm -ivh dpdk-18.05-1.x86_64.rpm || exit 1 +sudo rpm -ivh dpdk-devel-18.05-1.x86_64.rpm || exit 1 + +mkdir -p /tmp/dpdk/drivers/ +cp -f /usr/lib64/librte_mempool_ring.so /tmp/dpdk/drivers/ + +cd ${cur_directory} diff --git a/scripts/build_rsocket.sh b/scripts/build_rsocket.sh new file mode 100755 index 0000000..ef31c88 --- /dev/null +++ b/scripts/build_rsocket.sh @@ -0,0 +1,34 @@ +#!/bin/bash -x + +set -x + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + +DMM_DIR=`dirname $(readlink -f $0)`/../ +BUILD_DIR=${DMM_DIR}/build + +############### build rsocket +echo "rsocket build start" +cd $DMM_DIR/stacks/rsocket +if [ "$OS_ID" == "ubuntu" ]; then + wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz + tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz + cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64 +elif [ "$OS_ID" == "centos" ]; then + CENT_VERSION=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release` + wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz + tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz + cd MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64 +fi + +sudo ./mlnxofedinstall --force || exit 1 + +cd $BUILD_DIR +make dmm_rsocket +if [ $? -eq 0 ]; then + echo "rsocket build has SUCCESS" +else + echo "rsocket build has FAILED" + exit 1 +fi +echo "rsocket build finished"
\ No newline at end of file diff --git a/scripts/build_vpp.sh b/scripts/build_vpp.sh new file mode 100755 index 0000000..555aa9f --- /dev/null +++ b/scripts/build_vpp.sh @@ -0,0 +1,29 @@ +#!/bin/bash +######################################################################### +# +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################### + +set -x + +cd ../stacks/vpp + +git clone https://gerrit.fd.io/r/vpp + +cd vpp +git checkout origin/stable/1804 -b vpp_1804_br +cp ../adapt/* src/vcl/ +git am ../patch/* +make UNATTENDED=yes install-dep +make build diff --git a/scripts/check_hugepage.sh b/scripts/check_hugepage.sh new file mode 100755 index 0000000..bde11a9 --- /dev/null +++ b/scripts/check_hugepage.sh @@ -0,0 +1,41 @@ +#!/bin/bash -x + +set -x + +hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'}) +if [ "$hugepagesize" == "2048" ]; then + pages=1536 +elif [ "$hugepagesize" == "1048576" ]; then + pages=3 +fi +sudo sysctl -w vm.nr_hugepages=$pages +HUGEPAGES=`sysctl -n vm.nr_hugepages` +if [ $HUGEPAGES != $pages ]; then + echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish." + exit 1 +fi + +hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0") +if [ $hugepageTotal -ne 0 ]; then + echo "HugePages_Total is zero" + exit 1 +fi + +hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0") +if [ $hugepageFree -ne 0 ]; then + echo "HugePages_Free is zero" + exit 1 +fi + +hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB") +if [ $hugepageSize -ne 0 ]; then + echo "Hugepagesize is zero" + exit 1 +fi + +sudo mkdir /mnt/nstackhuge -p +if [ "$hugepagesize" == "2048" ]; then + sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/ +elif [ "$hugepagesize" == "1048576" ]; then + sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/ +fi diff --git a/scripts/checkstyle.sh b/scripts/checkstyle.sh index 55f4f73..4f3c0a0 100644..100755 --- a/scripts/checkstyle.sh +++ b/scripts/checkstyle.sh @@ -17,13 +17,14 @@ #!/bin/bash CURR_DIR=`dirname $0` -DMM_DIR=${CURR_DIR}/.. +DMM_DIR=${CURR_DIR}/../ EXIT_CODE=0 FIX="0" FULL="0" CHECKSTYLED_FILES="" UNCHECKSTYLED_FILES="" UNCHECK_LIST="" +DOS2UNIX="0" SHOW_HELP="1" FIX="0" @@ -39,6 +40,7 @@ key="$1" case $key in -f|--fixstyle) FIX="1" + DOS2UNIX="1" SHOW_HELP="0" shift # past argument ;; @@ -106,9 +108,12 @@ HAVE_CLANG_FORMAT=0 #fi for i in ${FILELIST}; do - if [ -f ${i} ] && ( [ ${i: -2} == ".c" ] || [ ${i: -2} == ".h" ] ) && [[ ${i} != *"thirdparty"* ]] && [[ ${i} != *"testcode"* ]] ; then + if [ -f ${i} ] && ( [ ${i: -2} == ".c" ] || [ ${i: -2} == ".h" ] ) && [[ ${i} != *"glog"* ]] && [[ ${i} != *"lwip_src/lwip"* ]] && [[ ${i} != *"lwip_helper_files"* ]]; then #grep -q "fd.io coding-style-patch-verification: ON" ${i} if [ $? == 0 ]; then + if [ ${DOS2UNIX} == 1 ]; then + dos2unix ${i} + fi EXTENSION=`basename ${i} | sed 's/^\w\+.//'` case ${EXTENSION} in hpp|cpp|cc|hh) @@ -173,8 +178,8 @@ done if [ ${FULL} == "1" ] && [ ${FULL} == "1" ] ; then for i in ${FILELIST}; do - #egrep -qlr $'\r'\$ ${i} - if [ $? == 0 ] && [[ ${i} != *"thirdparty"* ]] && [[ ${i} != *"testcode"* ]] && [[ ${i} != *"resources"* ]] && [[ ${i} != *"build"* ]] && ( [ ${i: -2} == ".c" ] || [ ${i: -2} == ".h" ] || [ ${i: -3} == ".sh" ] ); then + egrep -qlr $'\r'\$ ${i} + if [ $? == 0 ] && [[ ${i} != *"glog"* ]] && [[ ${i} != *"lwip_src/lwip"* ]] && [[ ${i} != *"lwip_helper_files"* ]] && [[ ${i} != *"resources"* ]] && [[ ${i} != *"build"* ]] && ( [ ${i: -2} == ".c" ] || [ ${i: -2} == ".h" ] || [ ${i: -3} == ".sh" ] && [ ${i} != "checkstyle.sh" ]); then sed -e 's/\r//g' ${i} > ${i}.tmp echo "dos2unix conoversion happened for ${i}" mv ${i}.tmp ${i} diff --git a/scripts/compile_dmm.sh b/scripts/compile_dmm.sh new file mode 100755 index 0000000..b4bc455 --- /dev/null +++ b/scripts/compile_dmm.sh @@ -0,0 +1,29 @@ +#!/bin/bash -x + +set -x + +BUILD_DIR=`dirname $(readlink -f $0)`/../build + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + +echo "DMM build started....." + +cd $BUILD_DIR +rm -rf * +cmake .. +make -j 8 + +if [ $? -eq 0 ]; then + echo "DMM build is SUCCESS" +else + echo "DMM build has FAILED" + exit 1 +fi + +if [ "$OS_ID" == "centos" ]; then + make pkg-rpm +elif [ "$OS_ID" == "ubuntu" ]; then + make pkg-deb +fi + +echo "DMM build has FINISHED" diff --git a/scripts/dmm.spec b/scripts/dmm.spec deleted file mode 100644 index 4869140..0000000 --- a/scripts/dmm.spec +++ /dev/null @@ -1,45 +0,0 @@ -Name: dmm -Version: 18.04 -Release: 1%{?dist} -Summary: DMM Project - -License: GPL -URL: https://gerrit.fd.io/r/dmm -Source: %{name}-%{version}.tar.gz - -%description -The DMM framework provides posix socket APIs to the application. A protocol -stack could be plugged into the DMM. DMM will choose the most suitable stack -for the application. - -%prep -%setup -q - - -%build -cd build/ -cmake .. -make -j 8 - -%install -cd ../../BUILDROOT -mkdir -p %{name}-%{version}-%{release}.x86_64/usr/bin -mkdir -p %{name}-%{version}-%{release}.x86_64/usr/lib64 - -install -c ../BUILD/%{name}-%{version}/release/bin/kc_common %{name}-%{version}-%{release}.x86_64/usr/bin -install -c ../BUILD/%{name}-%{version}/release/bin/ks_epoll %{name}-%{version}-%{release}.x86_64/usr/bin -install -c ../BUILD/%{name}-%{version}/release/bin/vc_common %{name}-%{version}-%{release}.x86_64/usr/bin -install -c ../BUILD/%{name}-%{version}/release/bin/vs_epoll %{name}-%{version}-%{release}.x86_64/usr/bin -install -c ../BUILD/%{name}-%{version}/release/bin/ks_select %{name}-%{version}-%{release}.x86_64/usr/bin -install -c ../BUILD/%{name}-%{version}/release/bin/vs_select %{name}-%{version}-%{release}.x86_64/usr/bin - -install -c ../BUILD/%{name}-%{version}/release/lib64/libdmm_api.a %{name}-%{version}-%{release}.x86_64/usr/lib64 -install -c ../BUILD/%{name}-%{version}/release/lib64/libnStackAPI.so %{name}-%{version}-%{release}.x86_64/usr/lib64 - -%files -/usr/bin/* -/usr/lib64/* -%doc - - -%changelog diff --git a/scripts/generate_dmm_deb.sh b/scripts/generate_dmm_deb.sh new file mode 100755 index 0000000..5168d07 --- /dev/null +++ b/scripts/generate_dmm_deb.sh @@ -0,0 +1,42 @@ +######################################################################### +# +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################### +#!/bin/sh + +cur_directory=${PWD} + +mkdir -p /tmp/mkdeb +mkdir -p /tmp/mkdeb/DEBIAN +mkdir -p /tmp/mkdeb/usr/bin +mkdir -p /tmp/mkdeb/usr/lib + +cd ../ +git archive --format=tar.gz -o /tmp/dmm.tar.gz --prefix=dmm/ HEAD + +cd /tmp/ +tar xzvf dmm.tar.gz +cd dmm/build +cmake .. +make -j 8 + +cd ../ +cp -f release/bin/* /tmp/mkdeb/usr/bin +cp -f release/lib64/* /tmp/mkdeb/usr/lib +cp -f pkg/deb/control /tmp/mkdeb/DEBIAN/ + +cd /tmp/ +dpkg-deb -b mkdeb/ ${cur_directory}/../release/deb/dmm.deb + +cd ${cur_directory} diff --git a/scripts/generate_dmm_rpm.sh b/scripts/generate_dmm_rpm.sh index bce4580..76d65a1 100755 --- a/scripts/generate_dmm_rpm.sh +++ b/scripts/generate_dmm_rpm.sh @@ -17,17 +17,17 @@ cur_directory=${PWD} name="dmm" -version="18.04" +version="18.07" mkdir -p ~/rpmbuild/SOURCES cd ../ -git archive --format=tar.gz -o ~/rpmbuild/SOURCES/${name}-${version}.tar.gz --prefix=${name}-${version}/ master +git archive --format=tar.gz -o ~/rpmbuild/SOURCES/${name}-${version}.tar.gz --prefix=${name}-${version}/ HEAD cd ~/rpmbuild/SOURCES tar xzvf ${name}-${version}.tar.gz -cp ${name}-${version}/scripts/dmm.spec ~/rpmbuild/SOURCES +cp ${name}-${version}/pkg/rpm/dmm.spec ~/rpmbuild/SOURCES echo "generate the rpm package" #QA_RPATHS=$[ 0x0002 ] is to shield the warning about rpath when generating the rpm package diff --git a/scripts/git/commit-msg-hook.py b/scripts/git/commit-msg-hook.py new file mode 100755 index 0000000..9c397ed --- /dev/null +++ b/scripts/git/commit-msg-hook.py @@ -0,0 +1,136 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +import sys + + +# format: \033[type;fg;bgm +# +# fg bg color +# ------------------------------------------- +# 30 40 black +# 31 41 red +# 32 42 green +# 33 43 yellow +# 34 44 blue +# 35 45 purple +# 36 46 cyan +# 37 47 white +# +# type +# ------------------------- +# 0 normal +# 1 bold +# 4 underline +# 5 blink +# 7 invert +# 8 hide +# +# examples: +# \033[1;31;40m <!--1-bold 31-red fg 40-black bg--> +# \033[0m <!--back to normal--> + + +STYLE = { + 'fore': + { + 'black' : 30, + 'red' : 31, + 'green' : 32, + 'yellow' : 33, + 'blue' : 34, + 'purple' : 35, + 'cyan' : 36, + 'white' : 37, + }, + + 'back': + { + 'black' : 40, + 'red' : 41, + 'green' : 42, + 'yellow' : 43, + 'blue' : 44, + 'purple' : 45, + 'cyan' : 46, + 'white' : 47, + }, + + 'mode': + { + 'normal' : 0, + 'bold' : 1, + 'underline' : 4, + 'blink' : 5, + 'invert' : 7, + 'hide' : 8, + }, + + 'default': + { + 'end': 0, + }, +} + + +def style(string, mode='', fore='', back=''): + + mode = '%s' % STYLE['mode'][mode] if STYLE['mode'].has_key(mode) else '' + + fore = '%s' % STYLE['fore'][fore] if STYLE['fore'].has_key(fore) else '' + + back = '%s' % STYLE['back'][back] if STYLE['back'].has_key(back) else '' + + style = ';'.join([s for s in [mode, fore, back] if s]) + + style = '\033[%sm' % style if style else '' + + end = '\033[%sm' % STYLE['default']['end'] if style else '' + + return '%s%s%s' % (style, string, end) + + +def check_subject(subject_line): + types = ['Feat', 'Fix', 'Refactor', 'Style', 'Docs', 'Test', 'Chore'] + + if subject_line.startswith(' '): + print style('Error: Subject line starts with whitespace\n', fore='red') + return 1 + + if len(subject_line) > 50: + print style('Error: Subject line should be limited to 50 chars\n', fore='red') + return 1 + + ll = subject_line.split(':') + if len(ll) < 2: + print style('Error: Subject line should have a type\n', fore='red') + return 1 + + type = ll[0] + if type not in types: + print style('Error: Subject line starts with unknown type\n', fore='red') + return 1 + + return 0 + + +contents = [] +ret = 0 +subject = True + +with open(sys.argv[1], 'r') as commit_msg: + contents = commit_msg.readlines() + +for line in contents: + dup = line.lstrip() + if dup.startswith('#') or dup.startswith("Change-Id") or dup.startswith("Signed-of-by"): + continue + if subject is True: + ret = check_subject(line) + subject = False + else: + if len(line) > 72: + print style('Error: Body line should be limited to 72 chars\n', fore='red') + ret = 1 + +exit(ret) diff --git a/scripts/git/commit-msg-template b/scripts/git/commit-msg-template new file mode 100644 index 0000000..6d72af1 --- /dev/null +++ b/scripts/git/commit-msg-template @@ -0,0 +1,28 @@ +# <type>: (if applied, this commit will...) <subject> (Max 50 chars) +# |<---- Using a Maximum Of 50 Characters ---->| + + +# Explain why this change is being made +# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->| + +# Provide links or keys to any relevant tickets, articles or other resources +# Example: Github issue #23 + +# --- COMMIT END --- +# Type can be +# Feat (new feature) +# Fix (bug fix) +# Refactor (refactoring production code) +# Style (formatting, missing semi colons, etc; no code change) +# Docs (changes to documentation) +# Test (adding or refactoring tests; no production code change) +# Chore (updating grunt tasks etc; no production code change) +# -------------------- +# Remember to +# Choose one of types above in subject line +# Use the imperative mood in the subject line +# Do not end the subject line with a period +# Separate subject from body with a blank line +# Use the body to explain what and why vs. how +# Can use multiple lines with "-" for bullet points in body +# -------------------- diff --git a/scripts/git/pre-commit b/scripts/git/pre-commit new file mode 100755 index 0000000..58cd14f --- /dev/null +++ b/scripts/git/pre-commit @@ -0,0 +1,14 @@ +#!/bin/bash + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# autoremove trailing whitespace +for file in `git diff-index --check --cached $against -- | sed '/^[-+]/d' | sed -r 's/:[0-9]+:.*//' | uniq` ; do + sed -i 's/[ \t]*$//g' $file +done diff --git a/scripts/install_prereq.sh b/scripts/install_prereq.sh new file mode 100755 index 0000000..ae8d442 --- /dev/null +++ b/scripts/install_prereq.sh @@ -0,0 +1,39 @@ +#!/bin/bash -x +log_file="/DMM/thirdpary/stackpool/vagrant/pre_install_log.txt-`date +'%Y-%m-%d_%H-%M-%S'`" +exec 1> >(tee -a "$log_file") 2>&1 + +if [ "$(uname)" <> "Darwin" ]; then + OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +fi + +if [ "$OS_ID" == "ubuntu" ]; then + # Standard update + upgrade dance + cat << EOF >> /etc/apt/sources.list + deb http://in.archive.ubuntu.com/ubuntu/ trusty main restricted + deb-src http://in.archive.ubuntu.com/ubuntu/ trusty main restricted + deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted + deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates main restricted + deb http://in.archive.ubuntu.com/ubuntu/ trusty universe + deb-src http://in.archive.ubuntu.com/ubuntu/ trusty universe + deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe + deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates universe + deb http://in.archive.ubuntu.com/ubuntu/ trusty multiverse + deb-src http://in.archive.ubuntu.com/ubuntu/ trusty multiverse + deb http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse + deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-updates multiverse + deb http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse + deb-src http://in.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse + deb http://security.ubuntu.com/ubuntu trusty-security main restricted + deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted + deb http://security.ubuntu.com/ubuntu trusty-security universe + deb-src http://security.ubuntu.com/ubuntu trusty-security universe + deb http://security.ubuntu.com/ubuntu trusty-security multiverse + deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse + deb http://extras.ubuntu.com/ubuntu trusty main + deb-src http://extras.ubuntu.com/ubuntu trusty main +EOF +elif [ "$OS_ID" == "centos" ]; then + + echo centos +fi diff --git a/scripts/perf_test.sh b/scripts/perf_test.sh new file mode 100755 index 0000000..e3646bc --- /dev/null +++ b/scripts/perf_test.sh @@ -0,0 +1,24 @@ +#! /bin/bash + +exec=$1 +shift + +while getopts ":d:s:h" arg; do + case $arg in + d) # destination ip addr + dest=${OPTARG} + ;; + s) # source ip addr + src=${OPTARG} + ;; + h) # help + echo '-d destination ip address' + echo '-s source ip address' + exit 0 + ;; + esac +done + +dir=`dirname $0` + +${dir}/../release/bin/${exec} -p 20000 -d ${dest} -a 10000 -s ${src} -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1 diff --git a/scripts/prep_app_test.sh b/scripts/prep_app_test.sh new file mode 100755 index 0000000..23bfa8b --- /dev/null +++ b/scripts/prep_app_test.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +set -x +DMM_DIR=`dirname $(readlink -f $0)`/.. +LIB_PATH=$DMM_DIR/release/lib64/ + +mkdir -p $DMM_DIR/config/app_test +cd $DMM_DIR/config/app_test + +#===========check hugepages================= +source $DMM_DIR/scripts/check_hugepage.sh + +echo -e "\e[41m Preapring APP test directory.....\e[0m" + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +if [ "$OS_ID" == "ubuntu" ]; then + ifaddress1=$(ifconfig enp0s8 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') + echo $ifaddress1 + ifaddress2=$(ifconfig enp0s9 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') + echo $ifaddress2 +elif [ "$OS_ID" == "centos" ]; then + ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}') + echo $ifaddress1 + ifaddress2=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}') + echo $ifaddress2 +fi + +echo '{ + "default_stack_name": "kernel", + "module_list": [ + { + "stack_name": "kernel", + "function_name": "kernel_stack_register", + "libname": "./", + "loadtype": "static", + "deploytype": "1", + "maxfd": "1024", + "minfd": "0", + "priorty": "1", + "stackid": "0", + }, + ] +}' | tee module_config.json + +echo '{ + "ip_route": [ + { + "subnet": "'$ifaddress1'/24", + "type": "nstack-kernel", + }, + { + "subnet": "'$ifaddress2'/24", + "type": "nstack-kernel", + }, + ], + "prot_route": [ + { + "proto_type": "1", + "type": "nstack-kernel", + }, + { + "proto_type": "2", + "type": "nstack-kernel", + } + ], +}' | tee rd_config.json + +cp -r ${DMM_DIR}/release/lib64/* . +cp -r ${DMM_DIR}/release/configure/* . +cp -r ${DMM_DIR}/release/bin/* . +chmod 775 * + +#disable ASLR, othewise it may have some problems when mapping memory for secondary process +echo 0 > /proc/sys/kernel/randomize_va_space + +sudo mkdir -p /var/run/ip_module/ +sudo mkdir -p /var/log/nStack/ip_module/ + +export LD_LIBRARY_PATH=$LIB_PATH +export NSTACK_LOG_ON=DBG
\ No newline at end of file diff --git a/scripts/print_os_info.sh b/scripts/print_os_info.sh new file mode 100755 index 0000000..4d61c7b --- /dev/null +++ b/scripts/print_os_info.sh @@ -0,0 +1,17 @@ +#!/bin/bash -x + +set -x + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +KERNEL_OS=`uname -o` +KERNEL_MACHINE=`uname -m` +KERNEL_RELEASE=`uname -r` +KERNEL_VERSION=`uname -v` + +echo KERNEL_OS: $KERNEL_OS +echo KERNEL_MACHINE: $KERNEL_MACHINE +echo KERNEL_RELEASE: $KERNEL_RELEASE +echo KERNEL_VERSION: $KERNEL_VERSION +echo OS_ID: $OS_ID +echo OS_VERSION_ID: $OS_VERSION_ID |