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
|
#!/bin/bash
#
# Copyright (C) 2009-2013 Akiban Technologies, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
set -e
usage="Usage: ./build_packages.sh [debian|redhat|macosx|binary] [... epoch]"
if [ $# -lt 1 ]; then
echo "${usage}"
exit 1
fi
platform=$1
bzr_revno=`bzr revno`
server_version=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version |grep -o '^[0-9.]\+')
echo "Building Akiban Server"
license=LICENSE.txt
mkdir -p target
mkdir -p packages-common/client
mkdir -p packages-common/plugins
common_dir="config-files/"
if [ ! -d ${common_dir} ]; then
echo "fatal: Couldn't find configuration files in: ${common_dir}"
exit 1
fi
echo "-- packages-common directory: ${common_dir} (Linux only)"
# All licenses become LICENSE.txt
cp ${license} packages-common/LICENSE.txt
cp ${common_dir}/* packages-common/
#
# Add akiban-client tools
#
: ${TOOLS_BRANCH:="lp:akiban-client-tools"}
echo "Using akiban-client-tools bazaar branch: ${TOOLS_BRANCH}"
pushd .
cd target
rm -rf akiban-client-tools
bzr branch ${TOOLS_BRANCH} akiban-client-tools
cd akiban-client-tools
mvn -DskipTests=true install
rm -f target/*-tests.jar target/*-sources.jar
cp bin/akdump ../../packages-common/
cp target/akiban-client-tools-*.jar ../../packages-common/
cp target/dependency/* ../../packages-common/client/
popd
if [ -z "$2" ] ; then
epoch=`date +%s`
else
epoch=$2
fi
# Handle platform-specific packaging process
if [ ${platform} == "debian" ]; then
cp -R packages-common/* ${platform}
mvn -Dmaven.test.skip.exec clean install -DBZR_REVISION=${bzr_revno}
mkdir -p ${platform}/server/
cp ./target/dependency/* ${platform}/server/
cp -R packages-common/plugins/ ${platform}/
debuild
elif [ ${platform} == "redhat" ]; then
mkdir -p ${PWD}/redhat/akserver/redhat
mkdir -p ${PWD}/redhat/rpmbuild/{BUILD,SOURCES,SRPMS,RPMS/noarch}
tar_file=${PWD}/redhat/rpmbuild/SOURCES/akserver.tar
bzr export --format=tar $tar_file
rm -f ${PWD}/redhat/akserver/redhat/* # Clear out old files
cp -R packages-common/* ${PWD}/redhat/akserver/redhat
pushd redhat
# bzr st -S outs lines like "? redhat/akserver/redhat/log4j.properties"
# we want to turn those to just "akserver/redhat/log4j.properties"
for to_add in $(bzr st -S . | sed 's/\?\s\+redhat\///'); do
tar --append -f $tar_file $to_add
done
popd
gzip $tar_file
cat ${PWD}/redhat/akiban-server.spec | sed "9,9s/REVISION/${bzr_revno}/g" > ${PWD}/redhat/akiban-server-${bzr_revno}.spec
sed -i "10,10s/EPOCH/${epoch}/g" ${PWD}/redhat/akiban-server-${bzr_revno}.spec
rpmbuild --target=noarch --define "_topdir ${PWD}/redhat/rpmbuild" -ba ${PWD}/redhat/akiban-server-${bzr_revno}.spec
elif [ ${platform} == "binary" ]; then
mvn -Dmaven.test.skip clean install -DBZR_REVISION=${bzr_revno}
rm -f ./target/*-tests.jar ./target/*-sources.jar
# For releases only
# Expects the ${release} to be defined in the env, i.e. through Jenkins
if [ -z "$release" ]; then
echo "No release number defined. Define the \$release environmental variable."; exit 1
fi
BINARY_NAME="akiban-server-${release}"
BINARY_TAR_NAME="${BINARY_NAME}.tar.gz"
mkdir -p ${BINARY_NAME}
mkdir -p ${BINARY_NAME}/lib/server
mkdir -p ${BINARY_NAME}/lib/client
mkdir -p ${BINARY_NAME}/bin
cp ./target/akiban-server-*.jar ${BINARY_NAME}/lib
cp ./target/dependency/* ${BINARY_NAME}/lib/server/
cp -R ./conf ${BINARY_NAME}/
rm -f ${BINARY_NAME}/conf/config/*.cmd
cp ./bin/akserver ${BINARY_NAME}/bin
cp packages-common/akdump ${BINARY_NAME}/bin
cp packages-common/akiban-client-*.jar ${BINARY_NAME}/lib
cp packages-common/client/* ${BINARY_NAME}/lib/client
cp ${license} ${BINARY_NAME}/LICENSE.txt
tar zcf ${BINARY_TAR_NAME} ${BINARY_NAME}
elif [ ${platform} == "macosx" ]; then
client_jar=packages-common/akiban-client-tools-*.jar
client_deps=packages-common/client
akdump_bin=packages-common/akdump
plugins_dir=packages-common/plugins
mac_app='target/Akiban Server.app'
inst_temp=/tmp/inst_temp
# copy icon data from a "prototype" file
tar xzf macosx/license-icon.tar.gz
xattr -wx com.apple.FinderInfo "`xattr -px com.apple.FinderInfo prototype.txt`" ${license}
cp prototype.txt/..namedfork/rsrc ${license}/..namedfork/rsrc
rm prototype.txt
# build jar
mvn -DskipTests=true -DBZR_REVISION=${bzr_revno} clean install
rm -f ./target/*-tests.jar ./target/*-sources.jar
build_dmg() {
ant_target="$1"
mac_dmg="target/$2"
# build app bundle
curl -Ls -o target/appbundler-1.0.jar http://java.net/projects/appbundler/downloads/download/appbundler-1.0.jar
ant -f macosx/appbundler.xml ${ant_target} -Djdk.home=$(/usr/libexec/java_home) -Dakserver.version="${server_version}-r${bzr_revno}"
# add config files to bundle
mkdir "${mac_app}/Contents/Resources/config/"
cp macosx/config-files/* "${mac_app}/Contents/Resources/config/"
# add client dependencies and binaries to bundle
mkdir -p "$mac_app/Contents/Resources/tools/lib/client"
cp $client_jar "$mac_app/Contents/Resources/tools/lib/"
cp $client_deps/* "$mac_app/Contents/Resources/tools/lib/client/"
mkdir -p "$mac_app/Contents/Resources/tools/bin"
cp $akdump_bin "$mac_app/Contents/Resources/tools/bin/"
cp -R "$plugins_dir" "$mac_app/Contents/Resources/"
# build disk image template
rm -rf $inst_temp
rm -f $inst_temp.dmg
mkdir $inst_temp
mkdir "$inst_temp/Akiban Server.app"
ln -s /Applications $inst_temp
mkdir $inst_temp/.background
cp macosx/dmg_background.png $inst_temp/.background
hdiutil create -fs HFSX -layout SPUD -size 200m $inst_temp.dmg -format UDRW -volname 'Akiban Server' -srcfolder $inst_temp
rm -rf $inst_temp
# update disk image
mkdir $inst_temp
hdiutil attach $inst_temp.dmg -noautoopen -mountpoint $inst_temp
ditto "$mac_app" "$inst_temp/Akiban Server.app"
# == add non-app files here ==
cp macosx/dmg.DS_Store $inst_temp/.DS_Store
cp macosx/dmg_VolumeIcon.icns $inst_temp/.VolumeIcon.icns
cp ${license} $inst_temp/LICENSE.txt
SetFile -a C $inst_temp
hdiutil detach `hdiutil info | grep $inst_temp | grep '^/dev' | cut -f1`
hdiutil convert $inst_temp.dmg -format UDZO -imagekey zlib-level=9 -o "$mac_dmg"
rm $inst_temp.dmg
}
dmg_basename="Akiban_Server_${server_version}"
build_dmg "bundle_app" "${dmg_basename}.dmg"
build_dmg "bundle_app_jre" "${dmg_basename}_JRE.dmg"
else
echo "Invalid Argument: ${platform}"
echo "${usage}"
exit 1
fi
|