Revert "Full Juju Charm support"
[osm/SO.git] / BUILD.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright 2016,2017 RIFT.IO Inc
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # Author(s): Jeremy Mordkoff, Lezz Giles
18 # Creation Date: 08/29/2016
19 #
20 #
21
22 # BUILD.sh
23 #
24 # This is a top-level build script for OSM SO or UI
25 #
26 # Arguments and options: use -h or --help
27 #
28 # dependencies -- requires sudo rights
29
30 MODULE=SO
31
32 # Defensive bash programming flags
33 set -o errexit # Exit on any error
34 trap 'echo ERROR: Command failed: \"$BASH_COMMAND\"' ERR
35 set -o nounset # Expanding an unset variable is an error. Variables must be
36 # set before they can be used.
37
38 ###############################################################################
39 # Options and arguments
40
41 # There
42 params="$(getopt -o h -l install,help --name "$0" -- "$@")"
43 if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
44
45 eval set -- $params
46
47 installFromPackages=false
48
49 while true; do
50 case "$1" in
51 --install) installFromPackages=true; shift;;
52 -h|--help)
53 echo
54 echo "NAME:"
55 echo " $0"
56 echo
57 echo "SYNOPSIS:"
58 echo " $0 -h|--help"
59 echo " $0 [--install] [PLATFORM_REPOSITORY] [PLATFORM_VERSION]"
60 echo
61 echo "DESCRIPTION:"
62 echo " Prepare current system to run $MODULE. By default, the system"
63 echo " is set up to support building $MODULE; optionally, "
64 echo " $MODULE can be installed from a Debian package repository."
65 echo
66 echo " --install: install $MODULE from package"
67 echo " PLATFORM_REPOSITORY (optional): name of the RIFT.ware repository."
68 echo " PLATFORM_VERSION (optional): version of the platform packages to be installed."
69 echo
70 exit 0;;
71 --) shift; break;;
72 *) echo "Not implemented: $1" >&2; exit 1;;
73 esac
74 done
75
76 # Turn this on after handling options, so the output doesn't get cluttered.
77 set -x # Print commands before executing them
78
79 ###############################################################################
80 # Set up repo and version
81
82 PLATFORM_REPOSITORY=${1:-OSM3}
83 PLATFORM_VERSION=${2:-5.2.0.2.72254}
84
85 ###############################################################################
86 # Main block
87
88 # must be run from the top of a workspace
89 cd $(dirname $0)
90
91 # enable the right repos
92 curl http://repos.riftio.com/public/xenial-riftware-public-key | sudo apt-key add -
93
94 # always use the same file name so that updates will overwrite rather than enable a second repo
95 sudo curl -o /etc/apt/sources.list.d/rift.list http://buildtracker.riftio.com/repo_file/ub16/${PLATFORM_REPOSITORY}/
96 sudo apt-get update
97
98 sudo apt install -y --allow-downgrades rw.tools-container-tools=${PLATFORM_VERSION} rw.tools-scripts=${PLATFORM_VERSION}
99
100 if $installFromPackages; then
101
102 # Install module and platform from packages
103 sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE --repo ${PLATFORM_REPOSITORY} --rw-version ${PLATFORM_VERSION}
104
105 else
106
107 # Install environment to build module
108 sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE-dev --repo ${PLATFORM_REPOSITORY} --rw-version ${PLATFORM_VERSION}
109 sudo -H pip3 install --upgrade pip
110 sudo -H pip3 install setuptools
111 sudo -H pip3 install juju
112 sudo mkdir -p /usr/rift/etc/default
113 sudo chmod 777 /usr/rift/etc/default
114 echo LAUNCHPAD_OPTIONS="--use-xml-mode" >> /usr/rift/etc/default/launchpad
115 sudo systemctl daemon-reload || true
116
117 IM_FILES="
118 ietf-l2-topology.yang
119 ietf-network-topology.yang
120 ietf-network.yang
121 mano-rift-groupings.yang
122 mano-types.yang
123 nsd-base.yang
124 nsd.yang
125 nsr.yang
126 odl-network-topology.yang
127 project-nsd.yang
128 project-vnfd.yang
129 vlr.yang
130 vnfd-base.yang
131 vnfd.yang
132 vnffgd.yang
133 vnfr.yang
134 "
135 echo "installing IM files"
136 if [ ! -d ../IM ]; then
137 echo cloning IM
138 # note that this cannot be inside the SO or else CMAKE will find it
139 git clone $(dirname $(git remote get-url origin))/IM.git ../IM
140 fi
141 for file in $IM_FILES; do
142 rm -f models/plugins/yang/$file
143 cp ../IM/models/yang/$file models/plugins/yang
144 done
145
146 # Build and install module
147 make -j16
148 sudo make install
149
150 fi
151
152 if [[ $MODULE == SO ]]; then
153 echo "Creating Service ...."
154 sudo /usr/rift/bin/create_launchpad_service
155 fi
156
157