4 read -rd "\000" helpmessage <<EOF
5 $(basename $0): Build Arvados packages and (optionally) upload them.
8 $(basename $0) WORKSPACE=/path/to/arvados [options]
12 --upload Upload packages (default: false)
13 --scp-user USERNAME Scp user for apt server (only required when --upload is specified)
14 --apt-server HOSTNAME Apt server hostname (only required when --upload is specified)
15 --debug Output debug information (default: false)
17 WORKSPACE=path Path to the Arvados source tree to build packages from
32 echo >&2 "$helpmessage"
49 echo >&2 "$0: Unrecognized option: '$arg'. Try: $0 --help"
56 if [[ "$UPLOAD" != '0' && ("$APTUSER" == '' || "$APTSERVER" == '') ]]; then
57 echo >&2 "$helpmessage"
59 echo >&2 "Error: please specify --scp-user and --apt-server if --upload is set"
65 if ! [[ -n "$WORKSPACE" ]]; then
66 echo >&2 "$helpmessage"
68 echo >&2 "Error: WORKSPACE environment variable not set"
73 if [[ "$DEBUG" != 0 ]]; then
74 echo "Workspace is $WORKSPACE"
77 handle_python_package () {
78 # This function assumes the current working directory is the python package directory
79 if [[ "$UPLOAD" != 0 ]]; then
80 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
81 if [[ "$DEBUG" != 0 ]]; then
82 python setup.py sdist upload
84 python setup.py -q sdist upload
87 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
88 if [[ "$DEBUG" != 0 ]]; then
91 python setup.py -q sdist
96 # Build debs for everything
97 build_and_scp_deb () {
109 if [[ "$PACKAGE_NAME" == "" ]]; then
110 PACKAGE_NAME=$PACKAGE
113 if [[ "$PACKAGE_TYPE" == "" ]]; then
114 PACKAGE_TYPE='python'
117 declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "-s" "$PACKAGE_TYPE" "-t" "deb")
119 if [[ "$PACKAGE_NAME" != "$PACKAGE" ]]; then
120 COMMAND_ARR+=('-n' "$PACKAGE_NAME")
123 if [[ "$VENDOR" != "" ]]; then
124 COMMAND_ARR+=('--vendor' "$VENDOR")
127 if [[ "$VERSION" != "" ]]; then
128 COMMAND_ARR+=('-v' "$VERSION")
135 COMMAND_ARR+=("$PACKAGE")
137 if [[ "$DEBUG" != 0 ]]; then
139 echo "${COMMAND_ARR[@]}"
143 FPM_RESULTS=$("${COMMAND_ARR[@]}")
147 if [[ $FPM_RESULTS =~ ([A-Za-z0-9_\-.]*\.deb) ]]; then
148 FPM_PACKAGE_NAME=${BASH_REMATCH[1]}
151 if [[ "$FPM_PACKAGE_NAME" == "" ]]; then
153 echo "Error: Unable to figure out package name from fpm results:\n $FPM_RESULTS"
155 if [[ ! $FPM_RESULTS =~ "File already exists" ]]; then
156 if [[ "$FPM_EXIT_CODE" != "0" ]]; then
157 echo "Error building debian package for $1:\n $FPM_RESULTS"
159 if [[ "$UPLOAD" != 0 ]]; then
160 scp -P2222 $FPM_PACKAGE_NAME $APTUSER@$APTSERVER:tmp/
165 echo "Debian package $FPM_PACKAGE_NAME exists, not rebuilding"
170 source /etc/profile.d/rvm.sh
172 # Make all files world-readable -- jenkins runs with umask 027, and has checked
173 # out our git tree here
174 chmod o+r "$WORKSPACE" -R
176 # Now fix our umask to something better suited to building and publishing
180 if [[ "$DEBUG" != 0 ]]; then
181 echo "umask is" `umask`
185 if [[ "$DEBUG" != 0 ]]; then
196 if [[ "$DEBUG" != 0 ]]; then
197 gem build arvados.gemspec
199 # -q appears to be broken in gem version 2.2.2
200 gem build arvados.gemspec -q >/dev/null
203 if [[ "$UPLOAD" != 0 ]]; then
205 gem push arvados-*gem
208 # Build arvados-cli GEM
212 rm -f arvados-cli*gem
214 if [[ "$DEBUG" != 0 ]]; then
215 gem build arvados-cli.gemspec
217 # -q appears to be broken in gem version 2.2.2
218 gem build arvados-cli.gemspec -q >/dev/null
221 if [[ "$UPLOAD" != 0 ]]; then
223 gem push arvados-cli*gem
227 if [[ "$DEBUG" != 0 ]]; then
229 echo "Python packages"
235 GIT_HASH=`git log --format=format:%ct.%h -n1 .`
238 handle_python_package
240 cd ../../services/fuse
241 handle_python_package
243 cd ../../services/nodemanager
244 handle_python_package
246 if [[ ! -d "$WORKSPACE/debs" ]]; then
247 mkdir -p $WORKSPACE/debs
251 # We use $WORKSPACE/src-build-dir as the clean directory from which to build the src package
252 if [[ ! -d "$WORKSPACE/src-build-dir" ]]; then
253 mkdir "$WORKSPACE/src-build-dir"
255 if [[ "$DEBUG" != 0 ]]; then
256 git clone https://github.com/curoverse/arvados.git src-build-dir
258 git clone -q https://github.com/curoverse/arvados.git src-build-dir
262 cd "$WORKSPACE/src-build-dir"
263 # just in case, check out master
264 if [[ "$DEBUG" != 0 ]]; then
267 # go into detached-head state
268 git checkout `git log --format=format:%h -n1 .`
270 git checkout -q master
272 # go into detached-head state
273 git checkout -q `git log --format=format:%h -n1 .`
276 # Build arvados src deb package
278 build_and_scp_deb $WORKSPACE/src-build-dir/=/usr/local/arvados/src arvados-src 'Curoverse, Inc.' 'dir' "0.1.$GIT_HASH" "-x 'usr/local/arvados/src/.git*'" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=The Arvados source code" "--architecture=all"
280 # clean up, check out master and step away from detached-head state
281 cd "$WORKSPACE/src-build-dir"
282 if [[ "$DEBUG" != 0 ]]; then
285 git checkout -q master
289 export GOPATH=$(mktemp -d)
290 mkdir -p "$GOPATH/src/git.curoverse.com"
291 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
294 go get "git.curoverse.com/arvados.git/services/keepstore"
296 build_and_scp_deb $GOPATH/bin/keepstore=/usr/bin/keepstore keepstore 'Curoverse, Inc.' 'dir' "0.1.$GIT_HASH" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Keepstore is the Keep storage daemon, accessible to clients on the LAN"
299 go get "git.curoverse.com/arvados.git/services/keepproxy"
301 build_and_scp_deb $GOPATH/bin/keepproxy=/usr/bin/keepproxy keepproxy 'Curoverse, Inc.' 'dir' "0.1.$GIT_HASH" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Keepproxy makes a Keep cluster accessible to clients that are not on the LAN"
304 go get "git.curoverse.com/arvados.git/services/crunchstat"
306 build_and_scp_deb $GOPATH/bin/crunchstat=/usr/bin/crunchstat crunchstat 'Curoverse, Inc.' 'dir' "0.1.$GIT_HASH" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Crunchstat gathers cpu/memory/network statistics of running Crunch jobs"
309 # Please resist the temptation to add --no-python-fix-name to the fpm call here
310 # (which would remove the python- prefix from the package name), because this
311 # package is a dependency of arvados-fuse, and fpm can not omit the python-
312 # prefix from only one of the dependencies of a package... Maybe I could
313 # whip up a patch and send it upstream, but that will be for another day. Ward,
316 build_and_scp_deb $WORKSPACE/sdk/python python-arvados-python-client 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/sdk/python/arvados_python_client.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados Python SDK"
319 # Please seem comment about --no-python-fix-name above; we stay consistent and do
320 # not omit the python- prefix first.
322 build_and_scp_deb $WORKSPACE/services/fuse python-arvados-fuse 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/fuse/arvados_fuse.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Keep FUSE driver"
326 build_and_scp_deb $WORKSPACE/services/nodemanager arvados-node-manager 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/nodemanager/arvados_node_manager.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados node manager"
329 build_and_scp_deb python-gflags
330 build_and_scp_deb pyvcf
331 build_and_scp_deb google-api-python-client
332 build_and_scp_deb httplib2
333 build_and_scp_deb ws4py
334 build_and_scp_deb virtualenv
336 # Finally, publish the packages, if necessary
337 if [[ "$UPLOAD" != 0 && "$CALL_FREIGHT" != 0 ]]; then
338 ssh -p2222 $APTUSER@$APTSERVER -t "cd tmp && ls -laF *deb && freight add *deb apt/wheezy && freight cache && rm -f *deb"
340 if [[ "$UPLOAD" != 0 ]]; then
341 echo "No new packages generated. No freight run necessary."
345 # clean up temporary GOPATH