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
54 if [ "$P_VERBOSE" = "yes" ]; then
60 verbose "Build type :" $P_BUILD
61 verbose "Custom configuration:" $P_PROPS
62 verbose "Keep dist/ folder :" $P_KEEPDIST
63 verbose "Custom achive name :" $P_ARCHIVE
64 verbose "Fake it :" $P_FAKEIT
68 echo "failed while $1"
73 if [ -n "$P_ARCHIVE" ]; then
80 if [ "$KEEP" = "no" -a -e $DIST ]; then
81 echo Folder $DIST exists. Removing it.
88 echo Creating dist dirs
98 if [ "$P_BUILD" = "normal" ]; then
100 echo "==============================="
101 echo "=== mvn clean ================="
102 echo "==============================="
104 mvn clean || fail "cleaning compilation artifacts"
106 elif [ "$P_BUILD"="fast" ]; then
108 echo "==============================="
109 echo "=== NOT executing mvn clean ==="
110 echo "==============================="
116 if [ "$P_BUILD" = "normal" ]; then
117 mvn dependency:copy-dependencies
120 cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
125 echo "==============================="
126 echo "=== mvn package ==============="
127 echo "==============================="
129 mvn package -DskipTests && {
131 echo "Copying Aquarium classes"
132 aquariumjar=`find target -type f|egrep "aquarium-[0-9\.]+(-SNAPSHOT)?\.jar"`
133 cp $aquariumjar $DIST/lib || fail "copying $aquariumjar"
139 echo Copying config files from $CONF_SRC
141 cp $CONF_SRC/logback.xml $DIST/conf|| fail "copying logback.xml"
142 cp $CONF_SRC/policy.yaml $DIST/conf || fail "copying policy.yaml"
143 cp $CONF_SRC/roles-agreements.map $DIST/conf || fail "copying roles-agreements.map"
145 if [ -n "$P_PROPS" ]; then
146 cp $P_PROPS $DIST/conf/aquarium.properties || fail "copying $P_PROPS"
148 cp $CONF_SRC/aquarium.properties $DIST/conf || fail "copying aquarium.properties"
154 echo Copying scripts from $SERVER_SCRIPTS_SRC
156 cp $SERVER_SCRIPTS_SRC/aquarium.sh $DIST/bin || fail "copying aquarium.sh"
157 cp $SERVER_SCRIPTS_SRC/start.sh $DIST/bin || fail "copying start.sh"
158 cp $SERVER_SCRIPTS_SRC/stop.sh $DIST/bin || fail "copying stop.sh"
159 cp $SERVER_SCRIPTS_SRC/test.sh $DIST/bin || fail "copying test.sh"
163 echo $SHAFULL > $DIST/gitsha.txt
169 if [ -e "$ARC" ]; then
171 echo Removing previous $ARC
175 echo "Creating archive"
176 tar zcvf "$ARC" $DIST/ || fail "creating archive"
177 echo "File $ARC created succesfully"
183 echo "Usage: $0 [options]"
186 echo " -a NAME Use archive NAME."
187 echo " The full name will be NAME.tar.gz."
188 echo " -b TYPE Use build TYPE. One of 'normal', 'fast'."
189 echo " 'normal' is the default and can be omitted."
190 echo " 'fast' means that it will not run mvn clean."
191 echo " -c FILE Use FILE as aquarium.properties configuration."
192 echo " -k Keep generated dist folder."
193 echo " -h Show this message."
194 echo " -n As in make -n."
195 echo " -v Be verbose."
200 while getopts ":a:b:hkc:nv" opt
217 :) ERROR="Option -$OPTARG requires an argument. Aborting..."
219 \?) ERROR="Invalid option: -$OPTARG"
224 if [ -n "$ERROR" ]; then
229 if [ -n "$P_PROPS" -a ! -f "$P_PROPS" ]; then
230 echo $P_PROPS is not a file. Aborting... >&2
234 if [ ! "$P_BUILD" = "normal" -a ! "$P_BUILD" = "fast" ]; then
235 echo Build type must be one of normal, fast. $P_BUILD was given. Aborting... >&2
239 if [ "$P_FAKEIT" = "yes" ]; then
240 P_VERBOSE=yes verbose_p
255 removedist $P_KEEPDIST