Statistics
| Branch: | Tag: | Revision:

root / make-dist.sh @ 7d01792d

History | View | Annotate | Download (2.7 kB)

1
#!/usr/bin/env bash
2

    
3
# Make an Aquarium binary distribution out of current working directory.
4
# Use at your own risk (i.e. make sure it compiles etc).
5

    
6
WHERE=`dirname $0`
7
SHAFULL=`git rev-parse HEAD`
8
SHA=`echo $SHAFULL | cut -c 1-11`
9
DATE_FORMAT=+'%Y%m%d%H%M%S'
10
NOW=`date $DATE_FORMAT`
11
DIST=aquarium-$SHA
12
SERVER_SCRIPTS_SRC=$WHERE/scripts
13
CONF_SRC=$WHERE/src/main/resources
14
ARG1="$1"
15

    
16
fail() {
17
    echo "failed while $1"
18
    exit 1
19
}
20

    
21
removedist() {
22
  if [ -e $DIST ]; then
23
    echo Folder $DIST exists. Removing it.
24
    rm -rf "$DIST"
25
  fi
26
}
27

    
28
createdist() {
29
  echo
30
  echo Creating dist dirs
31

    
32
  mkdir -pv $DIST
33
  mkdir -pv $DIST/bin
34
  mkdir -pv $DIST/lib
35
  mkdir -pv $DIST/conf
36
  mkdir -pv $DIST/logs
37
}
38

    
39
clean() {
40
  local p="$ARG1"
41
  if [ -z "$p" ]; then
42
    echo
43
    echo "==============================="
44
    echo "=== mvn clean ================="
45
    echo "==============================="
46
    echo
47
    mvn clean || fail "cleaning compilation artifacts"
48
    echo
49
  elif [ "$p"="dev" -o "$p"="fast" -o "$p"="noclean" ]; then
50
    echo
51
    echo "==============================="
52
    echo "=== NOT executing mvn clean ==="
53
    echo "==============================="
54
    echo
55
  fi
56
}
57

    
58
collectdeps() {
59
  mvn dependency:copy-dependencies && cp target/dependency/*.jar $DIST/lib || fail "collecting dependencies"
60
}
61

    
62
build() {
63
  echo
64
  echo "==============================="
65
  echo "=== mvn package ==============="
66
  echo "==============================="
67
  echo
68
  mvn package -DskipTests && {
69
    echo
70
    echo "Copying Aquarium classes"
71
    aquariumjar=`find target -type f|egrep "aquarium-[0-9\.]+(-SNAPSHOT)?\.jar"`
72
    cp $aquariumjar $DIST/lib || fail "copying $aquariumjar"
73
  } || fail "building"
74
}
75

    
76
collectconf() {
77
  echo
78
  echo Copying config files from $CONF_SRC
79
  echo
80
  cp $CONF_SRC/log4j.properties $DIST/conf|| fail "copying log4j.properties"
81
  cp $CONF_SRC/aquarium.properties $DIST/conf || fail "copying aquarium.properties"
82
  cp $CONF_SRC/policy.yaml $DIST/conf || fail "copying policy.yaml"
83
  cp $CONF_SRC/roles-agreements.map $DIST/conf || fail "copying roles-agreements.map"
84
}
85

    
86
collectscripts() {
87
  echo
88
  echo Copying scripts from $SERVER_SCRIPTS_SRC
89
  echo
90
  cp $SERVER_SCRIPTS_SRC/aquarium.sh $DIST/bin || fail "copying aquarium.sh"
91
  cp $SERVER_SCRIPTS_SRC/test.sh $DIST/bin || fail "copying test.sh"
92
}
93

    
94
gitmark() {
95
  echo $SHAFULL > $DIST/gitsha.txt
96
}
97

    
98
archive() {
99
  ARC=$DIST.tar.gz
100
  echo
101
  echo "Creating archive"
102
  tar zcvf $ARC $DIST/ || fail "creating archive"
103
  echo "File $ARC created succesfully"
104
  echo "Cleaning up"
105
  ls -al $ARC
106
}
107

    
108
removedist     && \
109
createdist     && \
110
clean          && \
111
build          && \
112
collectdeps    && \
113
collectconf    && \
114
collectscripts && \
115
gitmark        && \
116
archive        && \
117
removedist