Removing old and formerly deprecated tools for running ONOS locally, for selective build and for patching bundles in place.

Change-Id: Ic342e6c6ba776b0e0effcd3c79637642b0d59df2
diff --git a/tools/build/onos-package-test b/tools/build/onos-package-test
index 1e23786..59d5b42 100755
--- a/tools/build/onos-package-test
+++ b/tools/build/onos-package-test
@@ -3,33 +3,6 @@
 # Packages ONOS test facilities into onos-test.tar.gz
 # -----------------------------------------------------------------------------
 
-echo "Use 'onos-buck build //:onos-test' instead"
-exit 1
-
-set -e
-
 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-. $ONOS_ROOT/tools/build/envDefaults
-
-# Bail on any errors
-set -e
-
-rm -fr $ONOS_TEST_STAGE # Remove this when package script is completed
-
-# Create the stage directory and warp into it
-mkdir -p $ONOS_TEST_STAGE/tools/test \
-    $ONOS_TEST_STAGE/tools/dev/bin \
-    $ONOS_TEST_STAGE/tools/build \
-    $ONOS_TEST_STAGE/tools/package/config
-
-cp -r $ONOS_ROOT/tools/test $ONOS_TEST_STAGE/tools
-cp $ONOS_ROOT/tools/dev/bash_profile $ONOS_TEST_STAGE/tools/dev
-cp $ONOS_ROOT/tools/dev/bin/onos-app $ONOS_ROOT/tools/dev/bin/onos-create-app $ONOS_TEST_STAGE/tools/dev/bin
-cp $ONOS_ROOT/tools/build/envDefaults $ONOS_TEST_STAGE/tools/build
-
-cd $ONOS_TEST_STAGE_ROOT
-
-# Now package up the ONOS test tools tar file
-COPYFILE_DISABLE=1 tar zcf $ONOS_TEST_TAR $ONOS_TEST_BITS
-cd $ONOS_TEST_STAGE_ROOT
-# rm -r $ONOS_TEST_STAGE
+cd $ONOS_ROOT && onos-buck build //:onos-test --show-output
+exit $?
diff --git a/tools/dev/bin/onos-build-selective b/tools/dev/bin/onos-build-selective
deleted file mode 100755
index c3ea6fa..0000000
--- a/tools/dev/bin/onos-build-selective
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-# ----------------------------------------------------------------------------
-# Selectively builds only those projects that contained modified Java files.
-# ----------------------------------------------------------------------------
-
-cd $ONOS_ROOT
-
-projects=$(find $ONOS_ROOT -type f -path '*/src/*' \
-    -exec $ONOS_ROOT/tools/dev/bin/onos-build-selective-hook {} \; | \
-        egrep -v -f $ONOS_ROOT/tools/dev/bin/onos-build-selective.exclude | \
-        sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \
-        sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g')
-
-if [ -n "$projects" ]; then
-    # Ascertain artifact IDs of the projects to be rebuilt
-    modulesERE=""
-    for pd in ${projects//,/ }; do
-        if [ -f ${pd}/pom.xml ]; then
-            artifactId=$(egrep -E "^    <artifactId>.*</artifactId>$" ${pd}/pom.xml | \
-                            sed 's/.[^>]*>//;s/<.*//')
-            modulesERE="$modulesERE|$artifactId"
-        fi
-    done
-    modulesERE=${modulesERE#|*}
-
-    # Search through staged app.xml files for any apps that require one or
-    # more of the modified artifacts.
-    appProjects=$(find $ONOS_ROOT -type f -path '*/target/oar/app.xml' | \
-            xargs egrep '<artifact>' | egrep -E "/($modulesERE)/" | \
-            cut -d: -f1 | sed 's:/target/oar/.*::g' | \
-            sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \
-            sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g')
-
-    # If we found any, append those app projects to the list of projects to
-    # be built.
-    [ -n "$appProjects" ] && projects=$projects,$appProjects
-
-    echo Building projects $projects
-    cd $ONOS_ROOT && mvn --projects $projects ${@:-clean install}
-    status=$?
-
-    [ -n "$appProjects" ] && echo "App staging required for projects $appProjects"
-    exit $status
-else
-    exit 0
-fi
diff --git a/tools/dev/bin/onos-build-selective-hook b/tools/dev/bin/onos-build-selective-hook
deleted file mode 100755
index fbe7752..0000000
--- a/tools/dev/bin/onos-build-selective-hook
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-# ----------------------------------------------------------------------------
-# Echoes project-level directory if a source file within is newer than the
-# target directory.
-# ----------------------------------------------------------------------------
-
-[ ${1/*\//} = "package-info.java" ] && exit 0
-
-project=${1/src*/}
-[ ${project}target -nt $1 ] || echo ${project}
diff --git a/tools/dev/bin/onos-build-selective.exclude b/tools/dev/bin/onos-build-selective.exclude
deleted file mode 100644
index 33bf08a..0000000
--- a/tools/dev/bin/onos-build-selective.exclude
+++ /dev/null
@@ -1,11 +0,0 @@
-.*/archetypes/.*
-.*/maven-plugin/.*
-.*/build/conf/.*
-.*/docs/.*
-.*/openflow/drivers/.*
-.*/cord-gui/.*
-.*/jdvue/.*
-.*/ovsdb/api/.*
-.*/netconf/flow/.*
-.*/vtn/sfcmgr/.*
-/tools/package/yangtools/.*
\ No newline at end of file
diff --git a/tools/dev/bin/onos-karaf b/tools/dev/bin/onos-karaf
deleted file mode 100755
index 8ffe1ab..0000000
--- a/tools/dev/bin/onos-karaf
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Makes sure local ONOS karaf instance is primed & staged and then launches
-# karaf using the supplied arguments.
-# -----------------------------------------------------------------------------
-
-echo "This command is deprecated and will be removed imminently!!!"
-echo "Please use 'buck run onos-local' instead."
-echo "e.g.:  buck run onos-local -- clean debug"
-echo "  or:  buck run onos-local -- debug"
-
-
-. $ONOS_ROOT/tools/build/envDefaults
-if [ -L $ONOS_TAR ]; then
-  echo "WARN: This script does not support deploying buck artifacts"
-fi
-
-SETUP_OPTS=""
-# FIXME: temporarily fix 500 error in GUI, need to be improved with a better way
-if echo $* | egrep "\bclean\b"; then
-    export KARAF_ROOT=${KARAF_ROOT:-~/Applications/apache-karaf-$KARAF_VERSION}
-    export STAGE=$(dirname $KARAF_ROOT)
-    echo "Removing data directories..."
-    [ -d $KARAF_ROOT ] && rm -fr $STAGE/data
-    SETUP_OPTS="${SETUP_OPTS} clean"
-fi
-
-onos-setup-karaf $SETUP_OPTS && karaf "$@"
diff --git a/tools/dev/bin/onos-setup-karaf b/tools/dev/bin/onos-setup-karaf
deleted file mode 100755
index 59b8fa9..0000000
--- a/tools/dev/bin/onos-setup-karaf
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Downloads and sets-up Apache Karaf as a basis for running ONOS locally
-# as a single-instance.
-#
-# Note that this in no way impacts the method for running ONOS remotely.
-# For that, one should use onos-package and onos-install tools.
-# -----------------------------------------------------------------------------
-
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-. $ONOS_ROOT/tools/build/envDefaults
-
-echo "This command is deprecated and will be removed imminently!!!"
-echo "Please use 'buck run onos-local' instead."
-echo "e.g.:  buck run onos-local -- clean debug"
-echo "  or:  buck run onos-local -- debug"
-
-# TODO: consider putting this under ~/Applications/onos/apache-karaf-...
-export KARAF_ROOT=${KARAF_ROOT:-~/Applications/apache-karaf-$KARAF_VERSION}
-export STAGE=$(dirname $KARAF_ROOT)
-
-# Validates the specified IP regular expression against existing adapters.
-# Excludes local-loopback.
-function validateIp {
-    ifconfig | sed -ne 's:[[:space:]]*inet[^6][ adr:]*\([0-9.]*\).*:\1: p' | grep $1
-}
-
-# Parse optional arguments
-while [[ $# > 0 ]]; do
-    case $1 in
-    clean)
-        CLEAN="true";;
-    secure)
-        SECURE="true";;
-    *)
-        break;;
-    esac
-    shift
-done
-
-ONOS_IP=${ONOS_IP:-127.0.0.1}
-IP="${1:-$ONOS_IP}"
-
-# If the installed version does not line-up with ONOS_POM_VERSION force clean install
-if [ ! -f $KARAF_ROOT/etc/org.apache.karaf.features.cfg ] || \
-    ! grep -q "mvn:org.onosproject/onos-features/$ONOS_POM_VERSION/xml/features" \
-        $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then
-    echo "Existing ONOS Karaf uses version different from $ONOS_POM_VERSION; forcing clean install..."
-    CLEAN="true"
-fi
-
-# If clean option was specified, wipe-out existing installation
-if [ "$CLEAN" = "true" ]; then
-    echo "Removing existing ONOS Karaf, apps, data and config directories..."
-    [ -d $KARAF_ROOT ] && rm -fr $KARAF_ROOT $KARAF_ROOT/data $STAGE/apps $STAGE/data $STAGE/config
-fi
-
-# If IP was not given, nor configured attempt to use ONOS_NIC env. variable
-if [ -z "$IP" -a -n "$ONOS_NIC" ]; then
-    IP=$(validateIp $ONOS_NIC)
-    [ -z "$IP" ] && echo "No adapter with IP matching $ONOS_NIC found!"
-else
-    # Otherwise, verify that the IP address given exists among the adapters.
-    saveIp=$IP
-    IP=$(validateIp $IP)
-    [ -z "$IP" ] && echo "No adapter with IP $saveIp found!"
-fi
-
-# If IP is still not surmised or if usage was requested, show usage and IPs.
-if [ -z "$IP" -o "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then
-    echo "usage: $(basename $0) [clean] [secure] <ip-address>"
-    echo "Available IP addresses are:"
-    validateIp .
-    exit 1
-fi
-
-SUBNET="$(echo $IP | cut -d. -f1-3)"
-
-# Bail on any errors
-set -e
-
-# Check if Apache Karaf is already installed.
-if [ ! -d $KARAF_ROOT ]; then
-    # Check if Apache Karaf bits are available and if not, fetch them.
-    if [ ! -f $KARAF_TAR ]; then
-        echo "Downloading $KARAF_TAR..."
-        curl -sL http://downloads.onosproject.org/third-party/apache-karaf-$KARAF_VERSION.tar.gz --create-dirs -o $KARAF_TAR
-    fi
-    [ ! -f $KARAF_ZIP -a ! -f $KARAF_TAR ] && \
-        echo "Apache Karaf bits $KARAF_ZIP or $KARAF_TAR not found" && exit 1
-
-    echo "Unpacking $KARAF_TAR to $STAGE..."
-    mkdir -p $STAGE
-    cd $STAGE
-    tar zxf $KARAF_TAR
-    rm -rf $KARAF_ROOT/demos
-fi
-
-if [ "$SECURE" = "true" ]; then
-    echo "Enabling security mode ONOS..."
-
-    # SM-ONOS step 1: downgrade felix config admin
-    FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar}
-    if [ ! -f $FELIX_CFG_ADMIN ]; then
-        echo "Downloading $FELIX_CFG_ADMIN..."
-        curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN
-    fi
-    [ ! -f $FELIX_CFG_ADMIN ] && \
-        echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1
-
-    mkdir -p $KARAF_ROOT/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
-    cp $FELIX_CFG_ADMIN $KARAF_ROOT/system/org/apache/felix/org.apache.felix.configadmin/1.6.0
-    perl -pi.old -e "s|^(.*org.apache.felix.configadmin.*)|mvn\\\\:org.apache.felix/org.apache.felix.configadmin/1.6.0 = 10|" \
-        $KARAF_ROOT/etc/startup.properties
-
-    # SM-ONOS step 2: stage ONOS Felix framework security (will get downloaded on demand); end
-
-    # SM-ONOS step 3.1: configure karaf
-    perl -pi.old -e "s|#java.security.policy|java.security.policy|" \
-        $KARAF_ROOT/etc/system.properties
-    perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \
-        $KARAF_ROOT/etc/system.properties
-fi
-
-if ! grep -q "/onos-features/" $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then
-    # Patch the Apache Karaf distribution file to add ONOS features repository
-    echo "Adding ONOS feature repository..."
-    perl -pi.old -e "s|^(featuresRepositories=.*)|featuresRepositories=mvn:org.apache.karaf.features/standard/$KARAF_VERSION/xml/features,mvn:org.onosproject/onos-features/$ONOS_POM_VERSION/xml/features|" \
-        $KARAF_ROOT/etc/org.apache.karaf.features.cfg
-fi
-
-if ! grep -q ",onos-api," $KARAF_ROOT/etc/org.apache.karaf.features.cfg; then
-    # Patch the Apache Karaf distribution file to load default ONOS boot features
-    BOOT_FEATURES="standard,ssh,webconsole"
-    if [ "$SECURE" = "true" ]; then
-        # SM-ONOS Step 3.2: add onos-security to featuresBoot
-        BOOT_FEATURES="$BOOT_FEATURES,onos-security"
-    fi
-    BOOT_FEATURES="$BOOT_FEATURES,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui"
-    echo "Adding ONOS boot features $BOOT_FEATURES..."
-    perl -pi.old -e "s|^(featuresBoot=.*)|featuresBoot=$BOOT_FEATURES|" \
-        $KARAF_ROOT/etc/org.apache.karaf.features.cfg
-fi
-
-if [ ! -f $KARAF_ROOT/lib/onos-branding-$ONOS_POM_VERSION.jar ]; then
-    # Patch the Apache Karaf distribution with ONOS branding bundle
-    echo "Branding as ONOS..."
-    rm -f $KARAF_ROOT/lib/onos-branding-*.jar
-    cp $M2_REPO/org/onosproject/onos-branding/$ONOS_POM_VERSION/onos-branding-$ONOS_POM_VERSION.jar \
-        $KARAF_ROOT/lib
-fi
-
-echo "Creating local cluster configs for IP $IP..."
-[ -d $STAGE/config ] || mkdir -p $STAGE/config
-cat > $STAGE/config/cluster.json <<EOF
-{
-  "name": "default",
-  "nodes": [ {"id": "$IP", "ip": "$IP", "port": 9876 } ],
-  "partitions": [ { "id": 1, "members": [ "$IP" ] } ]
-}
-EOF
-
-if [ "$CLEAN" = "true" ]; then
-    echo "Copying package configs..."
-    cp -r $ONOS_ROOT/tools/package/etc/* $KARAF_ROOT/etc/
-    cp -r $ONOS_ROOT/tools/package/config/* $STAGE/config/
-fi
-
-echo "Staging builtin apps..."
-rm -fr $STAGE/apps
-onos-stage-apps $STAGE/apps $KARAF_ROOT/system
-
-ACTIVE_APPS=${ONOS_APPS:-drivers,openflow}
-echo "Customizing apps to be auto-activated: $ACTIVE_APPS..."
-for app in ${ACTIVE_APPS//,/ }; do
-    touch $STAGE/apps/org.onosproject.$app/active
-done
diff --git a/tools/dev/bin/onos-update-bundle b/tools/dev/bin/onos-update-bundle
deleted file mode 100755
index 9e9e08b..0000000
--- a/tools/dev/bin/onos-update-bundle
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Update bundle on locally running karaf.
-# -----------------------------------------------------------------------------
-
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-. $ONOS_ROOT/tools/build/envDefaults
-
-cd ~/.m2/repository
-jar=$(find org/onosproject -type f -name '*.jar' | grep -e $1 | grep -v -e -tests | head -n 1)
-
-[ -z "$jar" ] && echo "No bundle $1 found for" && exit 1
-
-bundle=$(echo $(basename $jar .jar) | sed 's/-[0-9].*//g')
-
-client "bundle:update -f $bundle" 2>/dev/null