summaryrefslogtreecommitdiffstats
path: root/build/gmc-build.sh
blob: d227ffb10c45ae9ee5712417f639af23fa11354d (plain)
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
USAGE_ERR=1

BUILD_DIR=/tmp/buckminster/glustermc
BUCKMINSTER_URL=http://download.eclipse.org/tools/buckminster/headless-3.6/
TARGET_PLATFORM_URL=/data/private/gmc-target.git
SRC_URL=/data/private/gmc-src.git

BUCKMINSTER_PRODUCT_NAME=org.eclipse.buckminster.cmdline.product
MAIN_FEATURE=com.gluster.storage.management.console.feature.webstart

TYPE_ALL="a"
TYPE_SETUP="s"
TYPE_BUILD="b"

startBold() {
	tput bold
}

stopBold() {
	tput sgr0
}

# Shows given text in bold
showBold() {
	startBold
	echo ${1}
	stopBold
}

# Get the director that can be used to install headless buckminster
get_director()
{
	echo "Downloading `startBold`director`stopBold`..."
	wget http://ftp.daum.net/eclipse//tools/buckminster/products/director_latest.zip
	echo "Installing director..."
	unzip director_latest.zip
}

install_buckminster()
{
	echo "Installing `startBold`Buckminster`stopBold`..."
	cd director
	./director -r ${BUCKMINSTER_URL} -d ${BUCKMINSTER_HOME} -p Buckminster -i ${BUCKMINSTER_PRODUCT_NAME}

	echo "Setting up Buckminster..."
	cd ${BUCKMINSTER_HOME}
	./buckminster install ${BUCKMINSTER_URL} org.eclipse.buckminster.core.headless.feature
	./buckminster install ${BUCKMINSTER_URL} org.eclipse.buckminster.pde.headless.feature
	./buckminster install ${BUCKMINSTER_URL} org.eclipse.buckminster.git.headless.feature
	./buckminster install ${BUCKMINSTER_URL} org.eclipse.buckminster.emma.headless.feature
}

configure_workspace()
{
	echo "Configuring the workspace..."
	cd ${WORKSPACE_DIR}
	rm -rf *
	git clone ${TARGET_PLATFORM_URL}
	git clone ${SRC_URL}

	echo "Importing target platform..."
	../buckminster importtarget --active gmc-src/com.gluster.storage.management.releng/gluster-management-console.target
	echo "Importing component query for glustermc..."
	../buckminster import gmc-src/com.gluster.storage.management.releng/com.gluster.storage.management.console.feature.webstart.cquery
	cd -
}

build()
{
	echo "Cleaning build directory..."
	rm -rf ${BUILD_DIR}/*

	echo "Exporting the product..."
	./buckminster perform --properties ${PROPERTIES_FILE} ${MAIN_FEATURE}#create.eclipse.jnlp.product
	./buckminster perform --properties ${PROPERTIES_FILE} ${MAIN_FEATURE}#copy.root.files

	# buckminster signs the jars using eclipse certificate - hence unsign and sign them again
	echo "Signing product jars..."
	./buckminster perform --properties ${PROPERTIES_FILE} ${MAIN_FEATURE}#unsign.jars
	./buckminster perform --properties ${PROPERTIES_FILE} ${MAIN_FEATURE}#sign.jars
}

#-----------------------------------
# Main Action Body
#-----------------------------------

echo
if [ $# -ne 2 ]; then
	echo "Usage: ${0} <build-type> <build-directory>"
	echo "build-type value can be one of:"
	echo "	`startBold` ${TYPE_ALL}`stopBold` - Sets up the build directoryand then triggers a full build"
	echo "	`startBold` ${TYPE_SETUP}`stopBold` - Sets up the build directory; doesn't trigger build"
	echo "	`startBold` ${TYPE_BUILD}`stopBold` - Assumes that build directory is set up and simply triggers the build"
	echo
	exit ${USAGE_ERR}
fi

BUILD_MODE=${1}
BUCKMINSTER_HOME=${2}
WORKSPACE_DIR=${BUCKMINSTER_HOME}/workspace
PROPERTIES_FILE=${WORKSPACE_DIR}/gmc-src/com.gluster.storage.management.releng/glustermc_build.properties

if [ "${BUILD_MODE}" == "${TYPE_ALL}" -o "${BUILD_MODE}" == "${TYPE_SETUP}" ]; then
	get_director
	install_buckminster
fi

if [ "${BUILD_MODE}" == "${TYPE_ALL}" -o "${BUILD_MODE}" == "${TYPE_BUILD}" ]; then
	configure_workspace
	build
fi