-
Notifications
You must be signed in to change notification settings - Fork 7
/
build_release.sh
executable file
·234 lines (190 loc) · 6.57 KB
/
build_release.sh
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/bin/bash
#
# Copyright © 2012 Akiban Technologies, Inc. All rights reserved.
#
# This program and the accompanying materials are made available
# under the terms of the Eclipse Public License v1.0 which
# accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# This program may also be available under different license terms.
# For more information, see www.akiban.com or contact [email protected].
#
# Contributors:
# Akiban Technologies, Inc.
#
#
# Build build artifacts associated with a release
# - Documentation (apidocs and sphinx html, for website)
# - akiban-persistit-X.X.X-website-docs.tar.gz
# - Bundles/packages
# - akiban-persistit-X.X.X.zip (binary, EPL)
# - akiban-persistit-X.X.X.tar.gz (binary, EPL)
# - akiban-persistit-X.X.X-source.zip (source, EPL)
# - akiban-persistit-X.X.X-source.tar.gz (source, EPL)
# - akiban-persistit-community-X.X.X.zip (binary, EULA)
# - akiban-persistit-community-X.X.X.tar.gz (binary, EULA)
#
set -e
# $1 - APIDOC_URL (empty OK)
function docs_build {
rm -rf target/site/apidocs
rm -rf target/sphinx
mvn javadoc:javadoc >/dev/null
cd doc/build
APIDOC_URL="$1" bash -e build-doc.sh >/dev/null
cd ../../
rm -r target/sphinx/html/{.buildinfo,.doctrees,objects.inv}
}
# $1 - revno
# $2 - args to maven
function maven_build {
mvn $2 -DBZR_REVISION="$1" -DskipTests=true clean compile test-compile package >/dev/null
}
MD5_TYPE=""
function md5_type {
if [ "$(which md5sum)" != "" ]; then
MD5_TYPE="md5sum"
else
if [ "$(which md5)" != "" ]; then
MD5_TYPE="md5"
else
echo " No supported md5 program found in PATH" 1>&2
exit 1
fi
fi
}
function do_md5 {
OUTFILE="${1}.md5"
case "${MD5_TYPE}" in
md5)
$(md5 -r "$1" |sed 's/ / /' > "${OUTFILE}")
;;
md5sum)
$(md5sum "$1" > "${OUTFILE}")
;;
*)
echo "Unknown md5 type: ${MD5_TYPE}"
exit 1
;;
esac
}
REQUIRED_PROGS="bzr mvn javac sphinx-build curl awk sed tr basename zip tar gpg"
BRANCH_DEFAULT="lp:~akiban-technologies/akiban-persistit"
COMM_LICENSE_URL="http://www.akiban.com/akiban-persistit-community-license-agreement-plaintext"
VERSION=""
BRANCH_URL=""
WORKSPACE="/tmp/persistit_release"
while getopts "hb:v:w:" FLAG; do
case "${FLAG}" in
h) ;;
b) BRANCH_URL="${OPTARG}" ;;
v) VERSION="${OPTARG}" ;;
w) WORKSPACE="${OPTARG}" ;;
*) echo "Unhandled option" 1>&2 ; exit 1 ;;
esac
done
if [ "${VERSION}" = "" ]; then
echo "Missing required version arg -v" 1>&2
exit 1
fi
if [ "${BRANCH_URL}" = "" ]; then
BRANCH_URL="${BRANCH_DEFAULT}/${VERSION}"
fi
echo "Build packages for version: ${VERSION}"
echo "Use source branch: ${BRANCH_URL}"
echo "Use workspace location: ${WORKSPACE}"
echo "Checking for required programs"
for PROG in ${REQUIRED_PROGS}; do
if [ "$(which ${PROG})" = "" ]; then
echo " ${PROG} not found in PATH" 1>&2
exit 1
fi
done
echo "Checking for md5 program"
md5_type
NAME="akiban-persistit"
BRANCH_DIR="${WORKSPACE}/${VERSION}"
SOURCE_DIR="${WORKSPACE}/${NAME}-${VERSION}-source"
OPEN_DIR="${WORKSPACE}/${NAME}-${VERSION}"
COMM_DIR="${WORKSPACE}/${NAME}-community-${VERSION}"
WEBDOCS_DIR="${WORKSPACE}/${NAME}-${VERSION}-website-docs"
echo "Cleaning workspace ${WORKSPACE}"
rm -rf "${WORKSPACE}"
mkdir -p "${WORKSPACE}"
cd "${WORKSPACE}"
echo "Fetching revision number"
REVNO=$(bzr revno -q "${BRANCH_URL}")
echo "Revision $REVNO"
echo "Exporting branch"
bzr export -q "${BRANCH_DIR}" "${BRANCH_URL}"
echo "Making package directories"
cp -r "${BRANCH_DIR}" "${SOURCE_DIR}"
cp -r "${BRANCH_DIR}" "${OPEN_DIR}"
rm -r "${OPEN_DIR}"/{doc,examples/scripts,src,pom.xml}
mkdir "${OPEN_DIR}/doc"
cp -r "${OPEN_DIR}" "${COMM_DIR}"
echo "Building open edition and docs"
cd "${BRANCH_DIR}"
maven_build "${REVNO}"
docs_build "../apidocs"
echo "Copying docs and jars"
cd "${WORKSPACE}"
cp -r "${BRANCH_DIR}"/target/{site/apidocs,sphinx/html} "${OPEN_DIR}/doc"
cp -r "${BRANCH_DIR}"/target/sphinx/text/ReleaseNotes "${OPEN_DIR}/ReleaseNotes.txt"
mv "${BRANCH_DIR}"/target/*-sources.jar "${OPEN_DIR}/${NAME}-${VERSION}-sources.jar"
mv "${BRANCH_DIR}"/target/*.jar "${OPEN_DIR}/${NAME}-${VERSION}.jar"
echo "Downloading and formating community license"
cd "${WORKSPACE}"
curl -s "${COMM_LICENSE_URL}" |
# Pull out the content between the two regexes, excluding the matches themselves
awk '/<div class="content">/ {flag=1;next} /<\/div>/ {flag=0} flag {print}' |
# Replace paragraph end marks for the first 4 paragraphs with newlines
awk '{if(NR < 8) sub(/<\/p>/, "\n"); print }' |
# Delete all: <p>, </p>, </div>, and occurrences
sed -e 's/<p>//g' -e 's/<\/p>//g' -e 's/<\/div>//g' -e 's/ //g' |
# Replace unicode quotes with simple ones
sed -e 's/[“”]/"/g' -e "s/’/'/g" |
# Un-link email address(es)
sed -e 's/<a href=".*">//g' -e 's/<\/a>//g' |
# Collapse repeated spaces
tr -s ' ' |
# Wrap nicely at 80 characters
fold -s \
> "${COMM_DIR}/LICENSE.txt"
echo "Building community edition and docs"
cd "${BRANCH_DIR}"
cp "${COMM_DIR}/LICENSE.txt" .
awk 'BEGIN { FS="\n"; RS="";}\
{sub(/[ ]*<licenses>.*<\/licenses>/,\
"<licenses>\n<license>\n<name>Proprietary</name>\n<url>http://www.akiban.com/akiban-persistit-community-license-agreement</url>\n<distribution>manual</distribution>\n</license>\n</licenses>\n"); print;}'\
pom.xml > pom_comm.xml
maven_build "${REVNO}" "-f pom_comm.xml"
docs_build "../apidocs"
cp -r target/{site/apidocs,sphinx/html} "${COMM_DIR}/doc"
cp target/sphinx/text/ReleaseNotes "${COMM_DIR}/ReleaseNotes.txt"
rm target/*-sources.jar
mv target/*.jar "${COMM_DIR}/${NAME}-${VERSION}.jar"
echo "Creating zip and tar.gz files"
cd "${WORKSPACE}"
for DIR in "${OPEN_DIR}" "${SOURCE_DIR}" "${COMM_DIR}"; do
BASE_DIR="`basename ${DIR}`"
zip -r "${DIR}.zip" "$BASE_DIR" >/dev/null
tar czf "${DIR}.tar.gz" "${BASE_DIR}"
done
echo "Building docs for website"
mkdir "${WEBDOCS_DIR}"
cd "${BRANCH_DIR}"
docs_build ""
cp -r target/{site/apidocs,sphinx/html} "${WEBDOCS_DIR}"
cd ${WORKSPACE}
tar czf "${WEBDOCS_DIR}.tar.gz" "$(basename $WEBDOCS_DIR)"
if [ "$SKIP_SIGNING" = "" ]; then
echo "Signing files for Launchpad upload"
for FILE in `ls *.zip *.tar.gz`; do
gpg --armor --sign --detach-sig "${FILE}" 1>/dev/null
do_md5 "${FILE}"
done
fi
echo "All output files are in: ${WORKSPACE}"
echo "Done"