76838e28a62bf87206bcafe46ef62bcb5315cbbc
[vpp.git] / build-root / vagrant / build.sh
1 #!/bin/bash
2
3 # Get Command Line arguements if present
4 VPP_DIR=$1
5 if [ "x$1" != "x" ]; then
6     VPP_DIR=$1
7 else
8     VPP_DIR=`dirname $0`/../../
9 fi
10
11 if [ "x$2" != "x" ]; then
12     SUDOCMD="sudo -H -u $2"
13 fi
14 echo 0:$0
15 echo 1:$1
16 echo 2:$2
17 echo VPP_DIR: $VPP_DIR
18 echo SUDOCMD: $SUDOCMD
19
20 # Figure out what system we are running on
21 if [ -f /etc/lsb-release ];then
22     . /etc/lsb-release
23 elif [ -f /etc/redhat-release ];then
24     sudo yum install -y redhat-lsb
25     DISTRIB_ID=`lsb_release -si`
26     DISTRIB_RELEASE=`lsb_release -sr`
27     DISTRIB_CODENAME=`lsb_release -sc`
28     DISTRIB_DESCRIPTION=`lsb_release -sd`
29 fi
30 KERNEL_OS=`uname -o`
31 KERNEL_MACHINE=`uname -m`
32 KERNEL_RELEASE=`uname -r`
33 KERNEL_VERSION=`uname -v`
34
35 echo KERNEL_OS: $KERNEL_OS
36 echo KERNEL_MACHINE: $KERNEL_MACHINE
37 echo KERNEL_RELEASE: $KERNEL_RELEASE
38 echo KERNEL_VERSION: $KERNEL_VERSION
39 echo DISTRIB_ID: $DISTRIB_ID
40 echo DISTRIB_RELEASE: $DISTRIB_RELEASE
41 echo DISTRIB_CODENAME: $DISTRIB_CODENAME
42 echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION
43
44 # Install dependencies
45 cd $VPP_DIR
46 make UNATTENDED=yes install-dep
47
48 # Really really clean things up so we can be sure
49 # that the build works even when switching distros
50 $SUDOCMD make wipe
51 (cd build-root/;$SUDOCMD make distclean)
52 rm -f build-root/.bootstrap.ok
53
54 if [ $DISTRIB_ID == "CentOS" ]; then
55     echo rpm -V apr-devel
56     rpm -V apr-devel
57     if [ $? != 0 ]; then sudo yum reinstall -y apr-devel;fi
58     echo rpm -V ganglia-devel
59     rpm -V ganglia-devel
60     if [ $? != 0 ]; then sudo yum reinstall -y ganglia-devel;fi
61     echo rpm -V libconfuse-devel
62     rpm -V libconfuse-devel
63     if [ $? != 0 ]; then sudo yum reinstall -y libconfuse-devel;fi
64 fi
65
66 # Build and install packaging
67 $SUDOCMD make bootstrap
68 if [ $DISTRIB_ID == "Ubuntu" ]; then
69     $SUDOCMD make pkg-deb
70 elif [ $DISTRIB_ID == "CentOS" ]; then
71     (cd $VPP_DIR/vnet ;$SUDOCMD aclocal;$SUDOCMD automake -a)
72     $SUDOCMD make pkg-rpm
73 fi
74