This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
install
executable file
·114 lines (104 loc) · 2.69 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /bin/bash
self="${0}"
usage() {
echo "Usage: ${self} [--help | --package | (--build|--clean) [PATH]]"
echo " --help Show this message."
echo " --clean Discard all build results and intermediate files."
echo " --build Install components to ./build (default)"
echo " --package Create a complete grouperfish tarball."
echo " Cleans and rebuilds every component first."
echo
echo " PATH The component to build. Examples:"
echo " ./service"
echo " ./transforms/coclustering"
echo " If omitted, everything is built."
echo
echo "This script must be called from the root directory of the project."
echo
}
cmd="--build"
all="YES"
what="project docs service transforms/* tools/* filters/* integration-test"
if [[ "${#}" -gt "2" ]]; then
usage
exit 1
fi
if [[ "${#}" -eq "2" ]]; then
cmd=$1
all="NO"
what=$2
fi
if [[ "${#}" -eq "1" ]]; then
if [[ "${1}" == -* ]]; then
cmd=$1
else
all="NO"
what=$1
fi
fi
fail() {
echo "Build aborted: ${1}"
exit 1
}
clean() {
what=$1
for component in $what; do
if [[ -x "$component/install" ]]; then
echo $'\n\n'"Cleaning $component ..."
( cd "${component}"
./install --clean || fail "Clean of '${component}' failed." )
fi
rm -rf "./build/${component}"
done
if [[ "YES" = "${all}" ]]; then
rm -rf ./build
version="$(cat ./project/VERSION)"
rm -f "./grouperfish-${version}.tar.gz"
cd ./project && mvn clean ; cd ..
fi
}
build() {
# either --build or --release
mode=$1
what=$2
if [[ "YES" = "${all}" ]]; then
cd ./project && mvn install ; cd ..
fi
for component in $what; do
if [[ -x "$component/install" ]]; then
echo $'\n\n'"Installing $component ..."
( cd "${component}"
./install $mode || fail "Installation of '${component}' failed." )
else
echo "Copying $component ..."
mkdir -p "build/${component}/"
cp -r "${component}"/* "build/${component}/"
fi
done
}
package() {
what=$1
version="$(cat ./project/VERSION)"
clean "${what}"
build --package "${what}"
mv ./build "./grouperfish-${version}"
tar czf "grouperfish-${version}.tar.gz" "./grouperfish-${version}"
}
case "${cmd}" in
--help)
usage
;;
--build)
build --build "${what}"
;;
--clean)
clean "${what}"
;;
--package)
package "${what}"
;;
*)
usage
exit 1
;;
esac