3 # Copyright 2012 GRNET S.A. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 # The views and conclusions contained in the software and documentation are
29 # those of the authors and should not be interpreted as representing official
30 # policies, either expressed or implied, of GRNET S.A.
32 # Make an Aquarium binary distribution out of current working directory.
33 # Use at your own risk (i.e. make sure it compiles etc).
36 SHAFULL=`git rev-parse HEAD`
37 SHA=`echo $SHAFULL | cut -c 1-11`
38 DATE_FORMAT=+'%Y%m%d%H%M%S'
39 NOW=`date $DATE_FORMAT`
41 SERVER_SCRIPTS_SRC=$WHERE/scripts
42 CONF_SRC=$WHERE/src/main/resources
56 if [ "$P_VERBOSE" = "yes" ]; then
62 verbose "Build type :" $P_BUILD
63 verbose "Custom configuration:" $P_PROPS
64 verbose "Keep dist/ folder :" $P_KEEPDIST
65 verbose "Custom achive name :" $P_ARCHIVE
66 verbose "Fake it :" $P_FAKEIT
67 verbose "maven offline mode :" $P_OFFLINE
71 echo "failed while $1"
76 if [ -n "$P_ARCHIVE" ]; then
83 if [ "$KEEP" = "no" -a -e $DIST ]; then
84 echo Folder $DIST exists. Removing it.
91 echo Creating dist dirs
101 if [ "$P_BUILD" = "normal" ]; then
103 echo "==============================="
104 echo "=== mvn clean ================="
105 echo "==============================="
107 echo mvn ${MVN_OPTS} clean
108 mvn ${MVN_OPTS} clean || fail "cleaning compilation artifacts"
110 elif [ "$P_BUILD"="fast" ]; then
112 echo "==============================="
113 echo "=== NOT executing mvn clean ==="
114 echo "==============================="
120 if [ "$P_BUILD" = "normal" ]; then
121 echo mvn ${MVN_OPTS} dependency:copy-dependencies
122 mvn ${MVN_OPTS} dependency:copy-dependencies
125 cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
130 echo "==============================="
131 echo "=== mvn package ==============="
132 echo "==============================="
134 echo mvn ${MVN_OPTS} package -DskipTests
135 mvn ${MVN_OPTS} package -DskipTests && {
137 echo "Copying Aquarium classes"
138 aquariumjar=`find target -type f|egrep "aquarium-[0-9\.]+(-SNAPSHOT)?\.jar"`
139 cp $aquariumjar $DIST/lib || fail "copying $aquariumjar"
145 echo Copying config files from $CONF_SRC
147 cp $CONF_SRC/policy.json $DIST/conf || fail "copying policy.json"
148 # cp $CONF_SRC/roles-agreements.map $DIST/conf || fail "copying roles-agreements.map"
150 if [ -n "$P_PROPS" ]; then
151 cp $P_PROPS $DIST/conf/aquarium.properties || fail "copying $P_PROPS"
153 cp $CONF_SRC/aquarium.properties $DIST/conf || fail "copying aquarium.properties"
159 echo Copying scripts from $SERVER_SCRIPTS_SRC
161 cp $SERVER_SCRIPTS_SRC/aquarium.sh $DIST/bin || fail "copying aquarium.sh"
162 cp $SERVER_SCRIPTS_SRC/start.sh $DIST/bin || fail "copying start.sh"
163 cp $SERVER_SCRIPTS_SRC/stop.sh $DIST/bin || fail "copying stop.sh"
167 echo $SHAFULL > $DIST/gitsha.txt
173 if [ -e "$ARC" ]; then
175 echo Removing previous $ARC
179 echo "Creating archive"
180 tar zcvf "$ARC" $DIST/ || fail "creating archive"
181 echo "File $ARC created succesfully"
187 echo "Usage: $0 [options]"
190 echo " -a NAME Use archive NAME."
191 echo " The full name will be NAME.tar.gz."
192 echo " -b TYPE Use build TYPE. One of 'normal', 'fast'."
193 echo " 'normal' is the default and can be omitted."
194 echo " 'fast' means that it will not run mvn clean."
195 echo " -c FILE Use FILE as aquarium.properties configuration."
196 echo " -k Keep generated dist folder."
197 echo " -h Show this message."
198 echo " -n As in make -n."
199 echo " -o Use mvn in offline mode (--offline, -o)"
200 echo " -v Be verbose."
205 while getopts ":a:b:hkc:nov" opt
220 o) P_OFFLINE="yes"; MVN_OPTS="-o"
224 :) ERROR="Option -$OPTARG requires an argument. Aborting..."
226 \?) ERROR="Invalid option: -$OPTARG"
231 if [ -n "$ERROR" ]; then
236 if [ -n "$P_PROPS" -a ! -f "$P_PROPS" ]; then
237 echo $P_PROPS is not a file. Aborting... >&2
241 if [ ! "$P_BUILD" = "normal" -a ! "$P_BUILD" = "fast" ]; then
242 echo Build type must be one of normal, fast. $P_BUILD was given. Aborting... >&2
246 if [ "$P_FAKEIT" = "yes" ]; then
247 P_VERBOSE=yes verbose_p
262 removedist $P_KEEPDIST