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
53 if [ "$P_VERBOSE" = "yes" ]; then
59 verbose "Build type :" $P_BUILD
60 verbose "Custom configuration:" $P_PROPS
61 verbose "Keep dist/ folder :" $P_KEEPDIST
62 verbose "Fake it :" $P_FAKEIT
66 echo "failed while $1"
72 if [ "$KEEP" = "no" -a -e $DIST ]; then
73 echo Folder $DIST exists. Removing it.
80 echo Creating dist dirs
90 if [ "$P_BUILD" = "normal" ]; then
92 echo "==============================="
93 echo "=== mvn clean ================="
94 echo "==============================="
96 mvn clean || fail "cleaning compilation artifacts"
98 elif [ "$P_BUILD"="fast" ]; then
100 echo "==============================="
101 echo "=== NOT executing mvn clean ==="
102 echo "==============================="
108 mvn dependency:copy-dependencies && cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
113 echo "==============================="
114 echo "=== mvn package ==============="
115 echo "==============================="
117 mvn package -DskipTests && {
119 echo "Copying Aquarium classes"
120 aquariumjar=`find target -type f|egrep "aquarium-[0-9\.]+(-SNAPSHOT)?\.jar"`
121 cp $aquariumjar $DIST/lib || fail "copying $aquariumjar"
127 echo Copying config files from $CONF_SRC
129 cp $CONF_SRC/logback.xml $DIST/conf|| fail "copying logback.xml"
130 cp $CONF_SRC/policy.yaml $DIST/conf || fail "copying policy.yaml"
131 cp $CONF_SRC/roles-agreements.map $DIST/conf || fail "copying roles-agreements.map"
133 if [ -n "$P_PROPS" ]; then
134 cp $P_PROPS $DIST/conf/aquarium.properties || fail "copying $P_PROPS"
136 cp $CONF_SRC/aquarium.properties $DIST/conf || fail "copying aquarium.properties"
142 echo Copying scripts from $SERVER_SCRIPTS_SRC
144 cp $SERVER_SCRIPTS_SRC/aquarium.sh $DIST/bin || fail "copying aquarium.sh"
145 cp $SERVER_SCRIPTS_SRC/start.sh $DIST/bin || fail "copying start.sh"
146 cp $SERVER_SCRIPTS_SRC/stop.sh $DIST/bin || fail "copying stop.sh"
147 cp $SERVER_SCRIPTS_SRC/test.sh $DIST/bin || fail "copying test.sh"
151 echo $SHAFULL > $DIST/gitsha.txt
156 if [ -e "$ARC" ]; then
158 echo Removing previous $ARC
161 echo "Creating archive"
162 tar zcvf $ARC $DIST/ || fail "creating archive"
163 echo "File $ARC created succesfully"
169 echo "Usage: $0 [options]"
172 echo " -b TYPE Use build TYPE. One of 'normal', 'fast'."
173 echo " 'normal' is the default and can be omitted."
174 echo " 'fast' means that it will not run mvn clean."
175 echo " -c FILE Use FILE as aquarium.properties configuration."
176 echo " -k Keep generated dist folder."
177 echo " -h Show this message."
178 echo " -n As in make -n."
179 echo " -v Be verbose."
184 while getopts ":b:hkc:nv" opt
199 :) ERROR="Option -$OPTARG requires an argument. Aborting..."
201 \?) ERROR="Invalid option: -$OPTARG"
206 if [ -n "$ERROR" ]; then
211 if [ -n "$P_PROPS" -a ! -f "$P_PROPS" ]; then
212 echo $P_PROPS is not a file. Aborting... >&2
216 if [ ! "$P_BUILD" = "normal" -a ! "$P_BUILD" = "fast" ]; then
217 echo Build type must be one of normal, fast. $P_BUILD was given. Aborting... >&2
221 if [ "$P_FAKEIT" = "yes" ]; then
222 P_VERBOSE=yes verbose_p
236 removedist $P_KEEPDIST