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:"
158 if [[ ! $FPM_RESULTS =~ "File already exists" ]]; then
159 if [[ "$FPM_EXIT_CODE" != "0" ]]; then
160 echo "Error building debian package for $1:\n $FPM_RESULTS"
162 if [[ "$UPLOAD" != 0 ]]; then
163 scp -P2222 $FPM_PACKAGE_NAME $APTUSER@$APTSERVER:tmp/
168 echo "Debian package $FPM_PACKAGE_NAME exists, not rebuilding"
173 source /etc/profile.d/rvm.sh
175 # Make all files world-readable -- jenkins runs with umask 027, and has checked
176 # out our git tree here
177 chmod o+r "$WORKSPACE" -R
179 # Now fix our umask to something better suited to building and publishing
183 if [[ "$DEBUG" != 0 ]]; then
184 echo "umask is" `umask`
188 if [[ "$DEBUG" != 0 ]]; then
199 if [[ "$DEBUG" != 0 ]]; then
200 gem build arvados.gemspec
202 # -q appears to be broken in gem version 2.2.2
203 gem build arvados.gemspec -q >/dev/null
206 if [[ "$UPLOAD" != 0 ]]; then
208 gem push arvados-*gem
211 # Build arvados-cli GEM
215 rm -f arvados-cli*gem
217 if [[ "$DEBUG" != 0 ]]; then
218 gem build arvados-cli.gemspec
220 # -q appears to be broken in gem version 2.2.2
221 gem build arvados-cli.gemspec -q >/dev/null
224 if [[ "$UPLOAD" != 0 ]]; then
226 gem push arvados-cli*gem
230 if [[ "$DEBUG" != 0 ]]; then
232 echo "Python packages"
238 GIT_TIMESTAMP=`git log --format=format:%ct -n1 .`
239 HUMAN_READABLE_TIMESTAMP=`TZ=UTC date -d @$GIT_TIMESTAMP +%Y%m%d%H%M%S`
240 GIT_HASH=`git log --format=format:$HUMAN_READABLE_TIMESTAMP.%h -n1 .`
243 handle_python_package
245 cd ../../services/fuse
246 handle_python_package
248 cd ../../services/nodemanager
249 handle_python_package
251 if [[ ! -d "$WORKSPACE/debs" ]]; then
252 mkdir -p $WORKSPACE/debs
256 # We use $WORKSPACE/src-build-dir as the clean directory from which to build the src package
257 if [[ ! -d "$WORKSPACE/src-build-dir" ]]; then
258 mkdir "$WORKSPACE/src-build-dir"
260 if [[ "$DEBUG" != 0 ]]; then
261 git clone https://github.com/curoverse/arvados.git src-build-dir
263 git clone -q https://github.com/curoverse/arvados.git src-build-dir
267 cd "$WORKSPACE/src-build-dir"
268 # just in case, check out master
269 if [[ "$DEBUG" != 0 ]]; then
272 # go into detached-head state
273 git checkout `git log --format=format:%h -n1 .`
275 git checkout -q master
277 # go into detached-head state
278 git checkout -q `git log --format=format:%h -n1 .`
281 # Build arvados src deb package
283 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"
285 # clean up, check out master and step away from detached-head state
286 cd "$WORKSPACE/src-build-dir"
287 if [[ "$DEBUG" != 0 ]]; then
290 git checkout -q master
294 export GOPATH=$(mktemp -d)
295 mkdir -p "$GOPATH/src/git.curoverse.com"
296 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
299 go get "git.curoverse.com/arvados.git/services/keepstore"
301 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"
304 go get "git.curoverse.com/arvados.git/services/keepproxy"
306 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"
309 go get "git.curoverse.com/arvados.git/services/crunchstat"
311 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"
314 # Please resist the temptation to add --no-python-fix-name to the fpm call here
315 # (which would remove the python- prefix from the package name), because this
316 # package is a dependency of arvados-fuse, and fpm can not omit the python-
317 # prefix from only one of the dependencies of a package... Maybe I could
318 # whip up a patch and send it upstream, but that will be for another day. Ward,
321 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"
324 # Please seem comment about --no-python-fix-name above; we stay consistent and do
325 # not omit the python- prefix first.
327 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"
331 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"
334 build_and_scp_deb python-gflags
335 build_and_scp_deb pyvcf
336 build_and_scp_deb google-api-python-client
337 build_and_scp_deb httplib2
338 build_and_scp_deb ws4py
339 build_and_scp_deb virtualenv
341 # Finally, publish the packages, if necessary
342 if [[ "$UPLOAD" != 0 && "$CALL_FREIGHT" != 0 ]]; then
343 ssh -p2222 $APTUSER@$APTSERVER -t "cd tmp && ls -laF *deb && freight add *deb apt/wheezy && freight cache && rm -f *deb"
345 if [[ "$UPLOAD" != 0 ]]; then
346 echo "No new packages generated. No freight run necessary."
350 # clean up temporary GOPATH