17417: remove libcloud pin, it is no longer used.
[arvados.git] / build / run-build-packages.sh
1 #!/bin/bash
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 . `dirname "$(readlink -f "$0")"`/run-library.sh || exit 1
7
8 read -rd "\000" helpmessage <<EOF
9 $(basename $0): Build Arvados packages
10
11 Syntax:
12         WORKSPACE=/path/to/arvados $(basename $0) [options]
13
14 Options:
15
16 --build-bundle-packages  (default: false)
17     Build api server and workbench packages with vendor/bundle included
18 --debug
19     Output debug information (default: false)
20 --target <target>
21     Distribution to build packages for (default: debian10)
22 --only-build <package>
23     Build only a specific package (or $ONLY_BUILD from environment)
24 --arch <arch>
25     Build a specific architecture (or $ARCH from environment, defaults to native architecture)
26 --force-build
27     Build even if the package exists upstream or if it has already been
28     built locally
29 --command
30     Build command to execute (defaults to the run command defined in the
31     Docker image)
32
33 WORKSPACE=path         Path to the Arvados source tree to build packages from
34
35 EOF
36
37 # Begin of user configuration
38
39 # set to --no-cache-dir to disable pip caching
40 CACHE_FLAG=
41
42 MAINTAINER="Arvados Package Maintainers <packaging@arvados.org>"
43 VENDOR="The Arvados Project"
44
45 # End of user configuration
46
47 DEBUG=${ARVADOS_DEBUG:-0}
48 FORCE_BUILD=${FORCE_BUILD:-0}
49 EXITCODE=0
50 TARGET=debian10
51 COMMAND=
52
53 PARSEDOPTS=$(getopt --name "$0" --longoptions \
54     help,build-bundle-packages,debug,target:,only-build:,arch:,force-build \
55     -- "" "$@")
56 if [ $? -ne 0 ]; then
57     exit 1
58 fi
59
60 eval set -- "$PARSEDOPTS"
61 while [ $# -gt 0 ]; do
62     case "$1" in
63         --help)
64             echo >&2 "$helpmessage"
65             echo >&2
66             exit 1
67             ;;
68         --target)
69             TARGET="$2"; shift
70             ;;
71         --only-build)
72             ONLY_BUILD="$2"; shift
73             ;;
74         --force-build)
75             FORCE_BUILD=1
76             ;;
77         --arch)
78             ARCH="$2"; shift
79             ;;
80         --debug)
81             DEBUG=1
82             ;;
83         --command)
84             COMMAND="$2"; shift
85             ;;
86         --)
87             if [ $# -gt 1 ]; then
88                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
89                 exit 1
90             fi
91             ;;
92     esac
93     shift
94 done
95
96 if [[ "$COMMAND" != "" ]]; then
97   COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
98 fi
99
100 STDOUT_IF_DEBUG=/dev/null
101 STDERR_IF_DEBUG=/dev/null
102 DASHQ_UNLESS_DEBUG=-q
103 if [[ "$DEBUG" != 0 ]]; then
104     STDOUT_IF_DEBUG=/dev/stdout
105     STDERR_IF_DEBUG=/dev/stderr
106     DASHQ_UNLESS_DEBUG=
107 fi
108
109 declare -a PYTHON3_BACKPORTS
110
111 PYTHON3_VERSION=$(python3 -c 'import sys; print("{v.major}.{v.minor}".format(v=sys.version_info))')
112
113 ## These defaults are suitable for any Debian-based distribution.
114 # You can customize them as needed in distro sections below.
115 PYTHON3_PACKAGE=python$PYTHON3_VERSION
116 PYTHON3_PKG_PREFIX=python3
117 PYTHON3_PREFIX=/usr
118 PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/dist-packages
119 ## End Debian Python defaults.
120
121 case "$TARGET" in
122     debian*)
123         FORMAT=deb
124         ;;
125     ubuntu*)
126         FORMAT=deb
127         ;;
128     centos*)
129         FORMAT=rpm
130         PYTHON3_PACKAGE=$(rpm -qf "$(which python$PYTHON3_VERSION)" --queryformat '%{NAME}\n')
131         PYTHON3_PKG_PREFIX=$PYTHON3_PACKAGE
132         PYTHON3_PREFIX=/usr
133         PYTHON3_INSTALL_LIB=lib/python$PYTHON3_VERSION/site-packages
134         export PYCURL_SSL_LIBRARY=nss
135         ;;
136     *)
137         echo -e "$0: Unknown target '$TARGET'.\n" >&2
138         exit 1
139         ;;
140 esac
141
142
143 if ! [[ -n "$WORKSPACE" ]]; then
144   echo >&2 "$helpmessage"
145   echo >&2
146   echo >&2 "Error: WORKSPACE environment variable not set"
147   echo >&2
148   exit 1
149 fi
150
151 # Test for fpm
152 fpm --version >/dev/null 2>&1
153
154 if [[ "$?" != 0 ]]; then
155   echo >&2 "$helpmessage"
156   echo >&2
157   echo >&2 "Error: fpm not found"
158   echo >&2
159   exit 1
160 fi
161
162 RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
163 RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`"  # absolutized and normalized
164 if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
165   # error; for some reason, the path is not accessible
166   # to the script (e.g. permissions re-evaled after suid)
167   exit 1  # fail
168 fi
169
170 debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
171 debug_echo "Workspace is $WORKSPACE"
172
173 if [[ -f /etc/profile.d/rvm.sh ]]; then
174     source /etc/profile.d/rvm.sh
175     GEM="rvm-exec default gem"
176 else
177     GEM=gem
178 fi
179
180 # Make all files world-readable -- jenkins runs with umask 027, and has checked
181 # out our git tree here
182 chmod o+r "$WORKSPACE" -R
183
184 # More cleanup - make sure all executables that we'll package are 755
185 cd "$WORKSPACE"
186 find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
187
188 # Now fix our umask to something better suited to building and publishing
189 # gems and packages
190 umask 0022
191
192 debug_echo "umask is" `umask`
193
194 if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
195   mkdir -p $WORKSPACE/packages/$TARGET
196   chown --reference="$WORKSPACE" "$WORKSPACE/packages/$TARGET"
197 fi
198
199 # Perl packages
200 debug_echo -e "\nPerl packages\n"
201
202 handle_libarvados_perl
203
204 # Ruby gems
205 debug_echo -e "\nRuby gems\n"
206
207 FPM_GEM_PREFIX=$($GEM environment gemdir)
208
209 cd "$WORKSPACE/sdk/ruby"
210 handle_ruby_gem arvados
211
212 cd "$WORKSPACE/sdk/cli"
213 handle_ruby_gem arvados-cli
214
215 cd "$WORKSPACE/services/login-sync"
216 handle_ruby_gem arvados-login-sync
217
218 # arvados-src
219 handle_arvados_src
220
221 # Go packages
222 debug_echo -e "\nGo packages\n"
223
224 # Go binaries
225 cd $WORKSPACE/packages/$TARGET
226 export GOPATH=~/go
227 package_go_binary cmd/arvados-client arvados-client "$FORMAT" "$ARCH" \
228     "Arvados command line tool (beta)"
229 package_go_binary cmd/arvados-server arvados-server "$FORMAT" "$ARCH" \
230     "Arvados server daemons"
231 package_go_binary cmd/arvados-server arvados-controller "$FORMAT" "$ARCH" \
232     "Arvados cluster controller daemon"
233 package_go_binary cmd/arvados-server arvados-dispatch-cloud "$FORMAT" "$ARCH" \
234     "Arvados cluster cloud dispatch"
235 package_go_binary cmd/arvados-server arvados-dispatch-lsf "$FORMAT" "$ARCH" \
236     "Dispatch Arvados containers to an LSF cluster"
237 package_go_binary services/arv-git-httpd arvados-git-httpd "$FORMAT" "$ARCH" \
238     "Provide authenticated http access to Arvados-hosted git repositories"
239 package_go_binary services/crunch-dispatch-local crunch-dispatch-local "$FORMAT" "$ARCH" \
240     "Dispatch Crunch containers on the local system"
241 package_go_binary services/crunch-dispatch-slurm crunch-dispatch-slurm "$FORMAT" "$ARCH" \
242     "Dispatch Crunch containers to a SLURM cluster"
243 package_go_binary cmd/arvados-server crunch-run "$FORMAT" "$ARCH" \
244     "Supervise a single Crunch container"
245 package_go_binary services/crunchstat crunchstat "$FORMAT" "$ARCH" \
246     "Gather cpu/memory/network statistics of running Crunch jobs"
247 package_go_binary services/health arvados-health "$FORMAT" "$ARCH" \
248     "Check health of all Arvados cluster services"
249 package_go_binary services/keep-balance keep-balance "$FORMAT" "$ARCH" \
250     "Rebalance and garbage-collect data blocks stored in Arvados Keep"
251 package_go_binary services/keepproxy keepproxy "$FORMAT" "$ARCH" \
252     "Make a Keep cluster accessible to clients that are not on the LAN"
253 package_go_binary cmd/arvados-server keepstore "$FORMAT" "$ARCH" \
254     "Keep storage daemon, accessible to clients on the LAN"
255 package_go_binary services/keep-web keep-web "$FORMAT" "$ARCH" \
256     "Static web hosting service for user data stored in Arvados Keep"
257 package_go_binary cmd/arvados-server arvados-ws "$FORMAT" "$ARCH" \
258     "Arvados Websocket server"
259 package_go_binary tools/sync-groups arvados-sync-groups "$FORMAT" "$ARCH" \
260     "Synchronize remote groups into Arvados from an external source"
261 package_go_binary tools/keep-block-check keep-block-check "$FORMAT" "$ARCH" \
262     "Verify that all data from one set of Keep servers to another was copied"
263 package_go_binary tools/keep-rsync keep-rsync "$FORMAT" "$ARCH" \
264     "Copy all data from one set of Keep servers to another"
265 package_go_binary tools/keep-exercise keep-exercise "$FORMAT" "$ARCH" \
266     "Performance testing tool for Arvados Keep"
267 package_go_so lib/pam pam_arvados.so libpam-arvados-go "$FORMAT" "$ARCH" \
268     "Arvados PAM authentication module"
269
270 # Python packages
271 debug_echo -e "\nPython packages\n"
272
273 # The Python SDK - Python3 package
274 fpm_build_virtualenv "arvados-python-client" "sdk/python" "$FORMAT" "$ARCH"
275
276 # Arvados cwl runner - Python3 package
277 fpm_build_virtualenv "arvados-cwl-runner" "sdk/cwl" "$FORMAT" "$ARCH"
278
279 # The FUSE driver - Python3 package
280 fpm_build_virtualenv "arvados-fuse" "services/fuse" "$FORMAT" "$ARCH"
281
282 # The Arvados crunchstat-summary tool
283 fpm_build_virtualenv "crunchstat-summary" "tools/crunchstat-summary" "$FORMAT" "$ARCH"
284
285 # The Docker image cleaner
286 fpm_build_virtualenv "arvados-docker-cleaner" "services/dockercleaner" "$FORMAT" "$ARCH"
287
288 # The Arvados user activity tool
289 fpm_build_virtualenv "arvados-user-activity" "tools/user-activity" "$FORMAT" "$ARCH"
290
291 # The python->python3 metapackages
292 build_metapackage "arvados-fuse" "services/fuse"
293 build_metapackage "arvados-python-client" "services/fuse"
294 build_metapackage "arvados-cwl-runner" "sdk/cwl"
295 build_metapackage "crunchstat-summary" "tools/crunchstat-summary"
296 build_metapackage "arvados-docker-cleaner" "services/dockercleaner"
297 build_metapackage "arvados-user-activity" "tools/user-activity"
298
299 # The cwltest package, which lives out of tree
300 handle_cwltest "$FORMAT" "$ARCH"
301
302 # Rails packages
303 debug_echo -e "\nRails packages\n"
304
305 # The rails api server package
306 handle_api_server "$ARCH"
307 # The rails workbench package
308 handle_workbench "$ARCH"
309
310 # clean up temporary GOPATH
311 rm -rf "$GOPATH"
312
313 exit $EXITCODE