Committed by
Gerrit Code Review
[ONOS-3686] Add a script named onos-blackduck-zip in tools/build/
Change-Id: I578afc6d903cadc5e6b3f392496d4d572c6bc849
Showing
1 changed file
with
68 additions
and
0 deletions
tools/build/onos-blackduck-zip
0 → 100755
1 | +#!/bin/bash | ||
2 | +# ----------------------------------------------------------------------------- | ||
3 | +# Packages specific ONOS codebase with specific tag or branch | ||
4 | +# ----------------------------------------------------------------------------- | ||
5 | + | ||
6 | +# Bail on any errors | ||
7 | +set -e | ||
8 | + | ||
9 | +# Initialize environment variables | ||
10 | +init() { | ||
11 | + # Check if ONOS_ROOT is defined | ||
12 | + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1; | ||
13 | + | ||
14 | + # Setup some environmental context for developers | ||
15 | + if [ -z "${JAVA_HOME}" ]; then | ||
16 | + if [ -x /usr/libexec/java_home ]; then | ||
17 | + export JAVA_HOME=$(/usr/libexec/java_home -v 1.8); | ||
18 | + elif [ -d /usr/lib/jvm/java-8-oracle ]; then | ||
19 | + export JAVA_HOME="/usr/lib/jvm/java-8-oracle"; | ||
20 | + elif [ -d /usr/lib/jvm/java-8-openjdk-amd64 ]; then | ||
21 | + export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"; | ||
22 | + fi | ||
23 | + fi | ||
24 | + # Check if mvn exists | ||
25 | + command -v mvn >/dev/null 2>&1 || { | ||
26 | + # Following the convention, the default location of maven shows as below. | ||
27 | + MAVEN=${MAVEN:-~/Applications/apache-maven-3.3.9}; | ||
28 | + export PATH="$MAVEN/bin:$PATH"; | ||
29 | + } | ||
30 | +} | ||
31 | + | ||
32 | +# checkout $TAG, build project and copy it to other location | ||
33 | +check_copy() { | ||
34 | + CHECK_TAG=`git checkout $TAG` | ||
35 | + if [[ $CHECK_TAG =~ "error" ]]; then | ||
36 | + echo "There is no branch or tag named $TAG in $ONOS_ROOT" >&2 && exit 1 | ||
37 | + fi | ||
38 | + FOLDER=$CURRENT_PATH/onos-$TAG-blackduck | ||
39 | + [ -d "$FOLDER" ] && rm -r $FOLDER | ||
40 | + mkdir $FOLDER | ||
41 | + mvn clean install | ||
42 | + if [$? -eq 0 ]; then | ||
43 | + cp -r -a * $FOLDER; | ||
44 | + if [ -d "$FOLDER/.git" ]; then | ||
45 | + rm -r $FOLDER/.git | ||
46 | + fi; | ||
47 | + else | ||
48 | + git checkout $CURRENT_TAG; | ||
49 | + rm -r $FOLDER | ||
50 | + echo "mvn compilation failed" | ||
51 | + fi | ||
52 | +} | ||
53 | + | ||
54 | +# Script entry point | ||
55 | +CURRENT_PATH=`pwd` | ||
56 | +TAG=${1:-'master'} | ||
57 | + | ||
58 | +init | ||
59 | +cd $ONOS_ROOT | ||
60 | +CURRENT_TAG=`git branch | awk '{print $2}'` | ||
61 | +check_copy | ||
62 | +cd $FOLDER | ||
63 | +zip -rq -m $CURRENT_PATH/onos-$TAG-blackduck.zip * | ||
64 | +cd .. | ||
65 | +rm -r $FOLDER | ||
66 | + | ||
67 | +cd $ONOS_ROOT | ||
68 | +git checkout $CURRENT_TAG | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment