build.sh revision e7a79873
1#!/usr/bin/env bash
2set -xe -o pipefail
3# Figure out what system we are running on
4if [ -f /etc/lsb-release ];then
5    . /etc/lsb-release
6elif [ -f /etc/redhat-release ];then
7    sudo yum install -y redhat-lsb
8    DISTRIB_ID=`lsb_release -si`
9    DISTRIB_RELEASE=`lsb_release -sr`
10    DISTRIB_CODENAME=`lsb_release -sc`
11    DISTRIB_DESCRIPTION=`lsb_release -sd`
12fi
13KERNEL_OS=`uname -o`
14KERNEL_MACHINE=`uname -m`
15KERNEL_RELEASE=`uname -r`
16KERNEL_VERSION=`uname -v`
17
18echo KERNEL_OS: $KERNEL_OS
19echo KERNEL_MACHINE: $KERNEL_MACHINE
20echo KERNEL_RELEASE: $KERNEL_RELEASE
21echo KERNEL_VERSION: $KERNEL_VERSION
22echo DISTRIB_ID: $DISTRIB_ID
23echo DISTRIB_RELEASE: $DISTRIB_RELEASE
24echo DISTRIB_CODENAME: $DISTRIB_CODENAME
25echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION
26
27NSH_PLUGIN_DIR=$(dirname $0)
28NSH_INSTALL_PREFIX=${NSH_INSTALL_PREFIX:-/usr}
29cd ${NSH_PLUGIN_DIR}
30autoreconf -i -f
31[ -d build ] ||  mkdir build
32[ -d ${NSH_INSTALL_PREFIX} ] || mkdir -p ${NSH_INSTALL_PREFIX}
33cd build
34../configure --prefix ${NSH_INSTALL_PREFIX}
35if [ $DISTRIB_ID == "CentOS" ]; then
36    echo "Start building rpms"
37    make V=1 PATH=${PATH} pkg-rpm
38    echo "Finished building rpms"
39elif [ $DISTRIB_ID == "Ubuntu" ]; then
40    echo "Start building debs"
41    make V=1 PATH=${PATH} pkg-deb
42    echo "Finished building debs"
43else
44    echo "Not packing.  Start make install"
45    ${SUDOCMD-sudo} make PATH=${PATH} install
46    echo "Not packing.  Finished make install"
47fi
48
49