Break boostrap.sh into pieces
[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 echo DISTRIB_ID: $DISTRIB_ID
31 echo DISTRIB_RELEASE: $DISTRIB_RELEASE
32 echo DISTRIB_CODENAME: $DISTRIB_CODENAME
33 echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION
34
35 # Install dependencies
36 cd $VPP_DIR
37 make install-dep
38
39 # Really really clean things up so we can be sure
40 # that the build works even when switching distros
41 make wipe
42 (cd build-root/;make distclean)
43 rm -f build-root/.bootstrap.ok
44
45 # Build and install packaging
46 $SUDOCMD make bootstrap
47 if [ $DISTRIB_ID == "Ubuntu" ]; then
48     $SUDOCMD make pkg-deb
49     (cd build-root/;sudo dpkg -i *.deb)
50 elif [ $DISTRIB_ID == "CentOS" ]; then
51     $SUDOCMD make pkg-rpm
52     (cd build-root/;sudo rpm -Uvh *.rpm)
53 fi
54