summaryrefslogtreecommitdiffstats
path: root/packaging/build.sh
blob: a8cd54cd2e8b11269443dc349bca9ff4b1ad6bae (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/bin/bash
#requirements:
# Jargon
# Java SDK 1.6+
# Maven 3+
# Grails
# EPM packager

SCRIPTNAME=`basename $0`

# define which idrop-lite applet to use
IDROP_LITE_APPLET=idrop-lite-2.0.0-SNAPSHOT-jar-with-dependencies.jar

# in case we need to download maven
MAVENVER=3.0.4
MAVENFILE=apache-maven-$MAVENVER
MAVENDOWNLOAD=http://apache.cs.utah.edu/maven/maven-3/$MAVENVER/binaries/$MAVENFILE-bin.zip

# in case we need to download grails
GRAILSVER=2.1.1
GRAILSFILE=grails-$GRAILSVER
GRAILSDOWNLOAD=http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/$GRAILSFILE.zip


# define usage
USAGE="

Usage: $SCRIPTNAME [<proxy hostname> <proxy portnum>]

Example:
$SCRIPTNAME www.myhost.com 80
"

# check for correct num of args
if [[ $# -gt 0  &&  $# -lt 2 || $# -gt 2 ]]; then
	echo $USAGE
	exit 1
fi
PROXYHOST=$1
PROXYPORT=$2

# setup MAVEN settings file
UGLYSETTINGSFILESTRING='
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <proxies>
    <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>'$PROXYHOST'</host>
      <port>'$PROXYPORT'</port>
    </proxy>
   </proxies>
</settings>'


# get into the correct directory
BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $BUILDDIR


# check to make sure mvn, grails, and epm commands are in path
MAVEN=`which mvn`
if [[ "$?" != "0" || `echo $MAVEN | awk '{print $1}'` == "no" ]] ; then
	echo "Apache Maven required to build project - downloading from $MAVENDOWNLOAD"

	# clean up any old one first
	rm -rf $MAVENFILE*

	# download maven
	wget $MAVENDOWNLOAD

	# install and setup environment
	unzip $MAVENFILE-bin.zip
	export M2_HOME=$BUILDDIR/$MAVENFILE
	export M2=$M2_HOME/bin
	export PATH=$M2:$PATH

	# create the .m2 dir
	mvn --version > /dev/null 2>&1
	
	# if proxy specified set it up in settings.xml
	if [[ $PROXYHOST ]]; then
		# save old maven settings file if one exists
		mv ~/.m2/settings.xml save_settings.xml > /dev/null 2>&1
		echo $UGLYSETTINGSFILESTRING > ~/.m2/settings.xml
	fi
else
	MAVENVERSION=`mvn --version`
	echo "Detected maven [$MAVEN] version[$MAVENVERSION]"
fi

GRAILS=`which grails`
if [[ "$?" != "0" || `echo $GRAILS | awk '{print $1}'` == "no" ]] ; then
	echo "GRAILS required to build project - downloading from $GRAILSDOWNLOAD"

	# clean up any old one first
	rm -rf $GRAILSFILE*

	# download grails
	wget $GRAILSDOWNLOAD

	# install and setup environment
	unzip $GRAILSFILE.zip
	export GRAILS_HOME=$BUILDDIR/$GRAILSFILE
	export PATH=$GRAILS_HOME/bin:$PATH

	# setup proxy if needed
	if [[ $PROXYHOST ]]; then
		grails add-proxy idrop_proxy --host=$PROXYHOST --port=$PROXYPORT
		grails set-proxy idrop_proxy
	fi
else
	GRAILSVERSION=`grails --version`
	echo "Detected grails [$GRAILS] version[$GRAILSVERSION]"
fi

# now get our version of EPM
RENCIEPM="epm42-renci.tar.gz"
rm -rf epm
rm -f $RENCIEPM
wget ftp://ftp.renci.org/pub/eirods/build/$RENCIEPM
tar -xf $RENCIEPM
cd $BUILDDIR/epm
echo "Configuring EPM"
./configure > /dev/null
if [ "$?" != "0" ]; then
	exit 1
fi
echo "Building EPM"
if [ "$?" != "0" ]; then
	exit 1
fi
make > /dev/null

cd $BUILDDIR

# build idrop swing first
echo "Building iDrop Swing ..."
cd ../idrop-swing
#mvn assembly:assembly -Dmaven.test.skip=true
# TODO: jar (JNLP) created is signed and expire is 6 months????
mvn clean package webstart:jnlp-inline -Dmaven.test.skip=true
RETVAL=$?
if [ $RETVAL -eq 1 ]; then
  echo "iDrop Swing Build Failed - Exiting"
  echo "Packaging Failed"
  exit 1
fi

# now build idrop-lite
echo "Building iDrop Lite ..."
cd ../idrop-lite
mvn clean assembly:assembly -Dmaven.test.skip=true
RETVAL=$?
if [ $RETVAL -eq 1 ]; then
  echo "iDrop Lite Build Failed - Exiting"
  echo "Packaging Failed"
  exit 1
fi

# now build grails war file
echo "Building iDrop Web ..."
cd ../idrop-web
grails war idrop-web.war
RETVAL=$?
if [ $RETVAL -eq 1 ]; then
  echo "iDrop Web Build Failed - Exiting"
  echo "Packaging Failed"
  exit 1
fi

#create EPM .list file
# available from: http://fossies.org/unix/privat/epm-4.2-source.tar.gz
# md5sum 3805b1377f910699c4914ef96b273943

echo "Creating Package ..."
cd ../packaging
if [ -d idrop-web ]; then
  rm -rf idrop-web
fi

if [ -f idrop-web.list ]; then
  rm idrop-web.list
fi

mkdir idrop-web
cd idrop-web
cp ../../idrop-web/idrop-web.war .
unzip idrop-web.war
mkdir idrop-web-extras
# get idrop-lite applet
cp ../../idrop-lite/target/$IDROP_LITE_APPLET idrop-web-extras
# get idrop-swing app
cp -r ../../idrop-swing/target/jnlp/* idrop-web-extras
rm -f idrop-web.war
cd ..

./epm/mkepmlist -u idropweb -g idropweb --prefix /var/lib/idrop-web idrop-web > idrop-web.list
sed 's/\$/$$/g' idrop-web.list > tmp.list
cat idrop-web.list.template tmp.list > idrop-web.list
rm tmp.list

if [ -f "/etc/redhat-release" ]; then # CentOS and RHEL and Fedora
  echo "Running EPM :: Generating RPM"
  ./epm/epm -f rpm idrop-web RPM=true idrop-web.list
elif [ -f "/etc/SuSE-release" ]; then # SuSE
  echo "Running EPM :: Generating RPM"
  ./epm/epm -f rpm idrop-web RPM=true idrop-web.list
elif [ -f "/etc/lsb-release" ]; then  # Ubuntu
  echo "Running EPM :: Generating DEB"
  ./epm/epm -a amd64 -f deb idrop-web DEB=true idrop-web.list
elif [ -f "/usr/bin/sw_vers" ]; then  # MacOSX
  echo "TODO: generate package for MacOSX"
fi