aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/build_package.sh
blob: 8189efdc4cf12d7a98ab9e34352bae2bb69ea318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
set -euxo pipefail
IFS=$'\n\t'

SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
APT_PATH=`which apt-get` || true
apt_get=${APT_PATH:-"/usr/local/bin/apt-get"}

BUILD_TOOLS_UBUNTU="build-essential doxygen"
DEPS_UBUNTU="devscripts debhelper python3-all python3-setuptools python3-docutils python3-sphinx python3-networkx python3-openssl python3-pyparsing python3-pip"

setup() {

    DISTRIB_ID=$1

    if [ "$DISTRIB_ID" == "Ubuntu" ]; then
        sudo ${apt_get} update || true
    fi
}

# Parameters:
# $1 = Package name
#
build_package() {

    PACKAGE_NAME=$1

    ARCHITECTURE="all"

    # Figure out what system we are running on
    if [ -f /etc/lsb-release ];then
        . /etc/lsb-release
        DEB=ON
        RPM=OFF
    else
        echo "ERROR: System configuration not recognized. Build failed"
        exit -1
    fi

    echo ARCHITECTURE: $ARCHITECTURE
    echo DISTRIB_ID: $DISTRIB_ID
    echo DISTRIB_RELEASE: $DISTRIB_RELEASE
    echo DISTRIB_CODENAME: $DISTRIB_CODENAME
    echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION

    setup $DISTRIB_ID
    # Install package dependencies
    if [ $DISTRIB_ID == "Ubuntu" ]; then
        echo $BUILD_TOOLS_UBUNTU $DEPS_UBUNTU | xargs sudo ${apt_get} install -y --allow-unauthenticated
    fi

    # do nothing but print the current slave hostname
    hostname

    # Make the package
    VERSION=$(bash $SCRIPT_PATH/version)

    cat << EOF > $SCRIPT_PATH/../debian/changelog
vicn ($VERSION) UNRELEASED; urgency=medium

  * Initial release (Closes: #nnnn)

 -- Mauro Sardara <mauro.sardara@cisco.com>  Tue, 18 Oct 2016 12:10:07 +0200
EOF

    pushd $SCRIPT_PATH/..
    debuild --no-lintian --no-tgz-check -i -us -uc -b
    popd

    echo "*******************************************************************"
    echo "* $PACKAGE_NAME BUILD SUCCESSFULLY COMPLETED"
    echo "*******************************************************************"

    exit 0
}

PACKAGE_NAME="VICN"
pushd $SCRIPT_PATH/..
build_package $PACKAGE_NAME
popd