X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=BUILD.sh;h=7ccdebad17c0a69d73fa7ba25aa99828fd6403a0;hb=737b14126c9e1266da4e5e3e0ff93e9de0a58b55;hp=c1adc1cf93236f0d6730e4c50004b444f4708646;hpb=b2f92c8398e1ac6036011db59464ad4304220e43;p=osm%2FSO.git diff --git a/BUILD.sh b/BUILD.sh index c1adc1cf..7ccdebad 100755 --- a/BUILD.sh +++ b/BUILD.sh @@ -1,5 +1,6 @@ +#!/usr/bin/env bash # -# Copyright 2016 RIFT.IO Inc +# Copyright 2016,2017 RIFT.IO Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,82 +14,115 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Author(s): Jeremy Mordkoff +# Author(s): Jeremy Mordkoff, Lezz Giles # Creation Date: 08/29/2016 # # # BUILD.sh # -# This is a top-level build script for RIFT.io +# This is a top-level build script for OSM SO or UI # -# args none +# Arguments and options: use -h or --help # # dependencies -- requires sudo rights +MODULE=SO + +# Defensive bash programming flags +set -o errexit # Exit on any error +trap 'echo ERROR: Command failed: \"$BASH_COMMAND\"' ERR +set -o nounset # Expanding an unset variable is an error. Variables must be + # set before they can be used. + +############################################################################### +# Options and arguments + +# There +params="$(getopt -o h -l install,help --name "$0" -- "$@")" +if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi + +eval set -- $params + +installFromPackages=false + +while true; do + case "$1" in + --install) installFromPackages=true; shift;; + -h|--help) + echo + echo "NAME:" + echo " $0" + echo + echo "SYNOPSIS:" + echo " $0 -h|--help" + echo " $0 [--install] [PLATFORM_REPOSITORY] [PLATFORM_VERSION]" + echo + echo "DESCRIPTION:" + echo " Prepare current system to run $MODULE. By default, the system" + echo " is set up to support building $MODULE; optionally, " + echo " $MODULE can be installed from a Debian package repository." + echo + echo " --install: install $MODULE from package" + echo " PLATFORM_REPOSITORY (optional): name of the RIFT.ware repository." + echo " PLATFORM_VERSION (optional): version of the platform packages to be installed." + echo + exit 0;; + --) shift; break;; + *) echo "Not implemented: $1" >&2; exit 1;; + esac +done -# ARGS - -PLATFORM_REPOSITORY=${1:-OSM} # change to OSM when published -PLATFORM_VERSION=${2:-4.3.1.0.49553} - -# must be run from the top of a workspace -cd $(dirname $0) - - +# Turn this on after handling options, so the output doesn't get cluttered. +set -x # Print commands before executing them +############################################################################### +# Set up repo and version -# inside RIFT.io this is an NFS mount -# so just to be safe -test -h /usr/rift && sudo rm -f /usr/rift +PLATFORM_REPOSITORY=${1:-OSM3} +PLATFORM_VERSION=${2:-5.2.0.2.72254} -# get the container tools from the correct repository -sudo rm -f /etc/yum.repos.d/private.repo -sudo curl -o /etc/yum.repos.d/${PLATFORM_REPOSITORY}.repo \ - http://buildtracker.riftio.com/repo_file/fc20/${PLATFORM_REPOSITORY}/ -sudo yum install --assumeyes rw.tools-container-tools rw.tools-scripts +############################################################################### +# Main block +# must be run from the top of a workspace +cd $(dirname $0) -# enable the OSM repository hosted by RIFT.io -# this contains the RIFT platform code and tools -# and install of the packages required to build and run -# this module -sudo /usr/rift/container_tools/mkcontainer --modes build --modes ext --repo ${PLATFORM_REPOSITORY} +# enable the right repos +curl http://repos.riftio.com/public/xenial-riftware-public-key | sudo apt-key add - -temp=$(mktemp -d /tmp/rw.XXX) -pushd $temp +# always use the same file name so that updates will overwrite rather than enable a second repo +sudo curl -o /etc/apt/sources.list.d/rift.list http://buildtracker.riftio.com/repo_file/ub16/${PLATFORM_REPOSITORY}/ +sudo apt-get update -# yum does not accept the --nodeps and --replacefiles options so we -# download first and then install -yumdownloader rw.toolchain-rwbase-${PLATFORM_VERSION} \ - rw.toolchain-rwtoolchain-${PLATFORM_VERSION} \ - rw.core.mgmt-mgmt-${PLATFORM_VERSION} \ - rw.core.util-util-${PLATFORM_VERSION} \ - rw.core.rwvx-rwvx-${PLATFORM_VERSION} \ - rw.core.rwvx-rwha-1.0-${PLATFORM_VERSION} \ - rw.core.rwvx-rwdts-${PLATFORM_VERSION} \ - rw.automation.core-RWAUTO-${PLATFORM_VERSION} +sudo apt install -y --allow-downgrades rw.tools-container-tools=${PLATFORM_VERSION} rw.tools-scripts=${PLATFORM_VERSION} -sudo rpm -i --replacefiles --nodeps *rpm -popd -rm -rf $temp +if $installFromPackages; then + + # Install module and platform from packages + sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE --repo ${PLATFORM_REPOSITORY} --rw-version ${PLATFORM_VERSION} + +else -# this file gets in the way of the one generated by the build -sudo rm -f /usr/rift/usr/lib/libmano_yang_gen.so + # Install environment to build module + sudo -H /usr/rift/container_tools/mkcontainer --modes $MODULE-dev --repo ${PLATFORM_REPOSITORY} --rw-version ${PLATFORM_VERSION} + sudo -H pip3 install --upgrade pip + sudo -H pip3 install setuptools + sudo -H pip3 install juju + sudo mkdir -p /usr/rift/etc/default + sudo chmod 777 /usr/rift/etc/default + echo LAUNCHPAD_OPTIONS="--use-xml-mode" >> /usr/rift/etc/default/launchpad + sudo systemctl daemon-reload + # Build and install module + make -j16 + sudo make install -sudo chmod 777 /usr/rift /usr/rift/usr/share +fi -# install some base files used to create VNFs -test -d /usr/rift/images || mkdir /usr/rift/images -for file in Fedora-x86_64-20-20131211.1-sda-ping.qcow2 Fedora-x86_64-20-20131211.1-sda-pong.qcow2 Fedora-x86_64-20-20131211.1-sda.qcow2; do - test -f /usr/rift/images/$file || curl -o /usr/rift/images/$file http://repo.riftio.com/releases/open.riftio.com/4.3.1/$file -done +if [[ $MODULE == SO ]]; then + echo "Creating Service ...." + sudo /usr/rift/bin/create_launchpad_service +fi -####### If you are re-building, you just need to run -# these two steps -make -j16 -sudo make install -# note to start the RIFT.io UI please run -echo 'sudo /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode --no-ui'