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 source /etc/profile.d/rvm.sh
75 if [[ "$DEBUG" != 0 ]]; then
76 echo "Workspace is $WORKSPACE"
79 # Make all files world-readable -- jenkins runs with umask 027, and has checked
80 # out our git tree here
81 chmod o+r "$WORKSPACE" -R
83 # Now fix our umask to something better suited to building and publishing
87 if [[ "$DEBUG" != 0 ]]; then
88 echo "umask is" `umask`
92 if [[ "$DEBUG" != 0 ]]; then
93 echo "Build and publish ruby gems"
101 if [[ "$DEBUG" != 0 ]]; then
102 gem build arvados.gemspec
104 # -q appears to be broken in gem version 2.2.2
105 gem build arvados.gemspec -q >/dev/null
108 if [[ "$UPLOAD" != 0 ]]; then
110 gem push arvados-*gem
113 # Build arvados-cli GEM
117 rm -f arvados-cli*gem
119 if [[ "$DEBUG" != 0 ]]; then
120 gem build arvados-cli.gemspec
122 # -q appears to be broken in gem version 2.2.2
123 gem build arvados-cli.gemspec -q >/dev/null
126 if [[ "$UPLOAD" != 0 ]]; then
128 gem push arvados-cli*gem
131 # Build arvados-python-client Python package
132 if [[ "$DEBUG" != 0 ]]; then
133 echo "Build and publish arvados-python-client package"
138 GIT_HASH=`git log --format=format:%ct.%h -n1 .`
142 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
144 if [[ "$UPLOAD" != 0 ]]; then
145 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
146 if [[ "$DEBUG" != 0 ]]; then
147 python setup.py sdist upload
149 python setup.py -q sdist upload
152 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
153 if [[ "$DEBUG" != 0 ]]; then
154 python setup.py sdist
156 python setup.py -q sdist
160 cd ../../services/fuse
162 if [[ "$UPLOAD" != 0 ]]; then
163 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
164 if [[ "$DEBUG" != 0 ]]; then
165 python setup.py sdist upload
167 python setup.py -q sdist upload
170 # Make sure only to use sdist - that's the only format pip can deal with (sigh)
171 if [[ "$DEBUG" != 0 ]]; then
172 python setup.py sdist
174 python setup.py -q sdist
178 # Build debs for everything
179 build_and_scp_deb () {
191 if [[ "$PACKAGE_NAME" == "" ]]; then
192 PACKAGE_NAME=$PACKAGE
195 if [[ "$PACKAGE_TYPE" == "" ]]; then
196 PACKAGE_TYPE='python'
199 declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "-s" "$PACKAGE_TYPE" "-t" "deb")
201 if [[ "$PACKAGE_NAME" != "$PACKAGE" ]]; then
202 COMMAND_ARR+=('-n' "$PACKAGE_NAME")
205 if [[ "$VENDOR" != "" ]]; then
206 COMMAND_ARR+=('--vendor' "$VENDOR")
209 if [[ "$VERSION" != "" ]]; then
210 COMMAND_ARR+=('-v' "$VERSION")
217 COMMAND_ARR+=("$PACKAGE")
219 if [[ "$DEBUG" != 0 ]]; then
222 echo "${COMMAND_ARR[@]}"
226 FPM_RESULTS=$("${COMMAND_ARR[@]}")
230 if [[ $FPM_RESULTS =~ ([A-Za-z0-9_\-.]*\.deb) ]]; then
231 FPM_PACKAGE_NAME=${BASH_REMATCH[1]}
234 if [[ "$FPM_PACKAGE_NAME" == "" ]]; then
236 echo "Error: Unable to figure out package name from fpm results:\n $FPM_RESULTS"
238 if [[ ! $FPM_RESULTS =~ "File already exists" ]]; then
239 if [[ "$FPM_EXIT_CODE" != "0" ]]; then
240 echo "Error building debian package for $1:\n $FPM_RESULTS"
242 if [[ "$UPLOAD" != 0 ]]; then
243 scp -P2222 $FPM_PACKAGE_NAME $APTUSER@$APTSERVER:tmp/
248 echo "Debian package $FPM_PACKAGE_NAME exists, not rebuilding"
253 if [[ ! -d "$WORKSPACE/debs" ]]; then
254 mkdir -p $WORKSPACE/debs
258 # We use $WORKSPACE/src-build-dir as the clean directory from which to build the src package
259 if [[ ! -d "$WORKSPACE/src-build-dir" ]]; then
260 mkdir "$WORKSPACE/src-build-dir"
262 if [[ "$DEBUG" != 0 ]]; then
263 git clone https://github.com/curoverse/arvados.git src-build-dir
265 git clone -q https://github.com/curoverse/arvados.git src-build-dir
269 cd "$WORKSPACE/src-build-dir"
270 # just in case, check out master
271 if [[ "$DEBUG" != 0 ]]; then
274 # go into detached-head state
275 git checkout `git log --format=format:%h -n1 .`
277 git checkout -q master
279 # go into detached-head state
280 git checkout -q `git log --format=format:%h -n1 .`
283 # Build arvados src deb package
285 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"
287 # clean up, check out master and step away from detached-head state
288 cd "$WORKSPACE/src-build-dir"
289 if [[ "$DEBUG" != 0 ]]; then
292 git checkout -q master
296 export GOPATH=$(mktemp -d)
297 mkdir -p "$GOPATH/src/git.curoverse.com"
298 ln -sfn "$WORKSPACE" "$GOPATH/src/git.curoverse.com/arvados.git"
301 go get "git.curoverse.com/arvados.git/services/keepstore"
303 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"
306 go get "git.curoverse.com/arvados.git/services/keepproxy"
308 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"
311 go get "git.curoverse.com/arvados.git/services/crunchstat"
313 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"
316 # Please resist the temptation to add --no-python-fix-name to the fpm call here
317 # (which would remove the python- prefix from the package name), because this
318 # package is a dependency of arvados-fuse, and fpm can not omit the python-
319 # prefix from only one of the dependencies of a package... Maybe I could
320 # whip up a patch and send it upstream, but that will be for another day. Ward,
323 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"
326 # Please seem comment about --no-python-fix-name above; we stay consistent and do
327 # not omit the python- prefix first.
329 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"
332 build_and_scp_deb python-gflags
333 build_and_scp_deb pyvcf
334 build_and_scp_deb google-api-python-client
335 build_and_scp_deb httplib2
336 build_and_scp_deb ws4py
337 build_and_scp_deb virtualenv
339 # Finally, publish the packages, if necessary
340 if [[ "$UPLOAD" != 0 && "$CALL_FREIGHT" != 0 ]]; then
341 ssh -p2222 $APTUSER@$APTSERVER -t "cd tmp && ls -laF *deb && freight add *deb apt/wheezy && freight cache && rm -f *deb"
343 if [[ "$UPLOAD" != 0 ]]; then
344 echo "No new packages generated. No freight run necessary."
348 # clean up temporary GOPATH