]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | #!/usr/bin/env bash |
7c673cae FG |
2 | # |
3 | # Ceph distributed storage system | |
4 | # | |
5 | # Copyright (C) 2014, 2015 Red Hat <contact@redhat.com> | |
6 | # | |
7 | # Author: Loic Dachary <loic@dachary.org> | |
8 | # | |
9 | # This library is free software; you can redistribute it and/or | |
10 | # modify it under the terms of the GNU Lesser General Public | |
11 | # License as published by the Free Software Foundation; either | |
12 | # version 2.1 of the License, or (at your option) any later version. | |
13 | # | |
11fdf7f2 | 14 | set -e |
7c673cae FG |
15 | DIR=/tmp/install-deps.$$ |
16 | trap "rm -fr $DIR" EXIT | |
17 | mkdir -p $DIR | |
18 | if test $(id -u) != 0 ; then | |
19 | SUDO=sudo | |
20 | fi | |
1e59de90 TL |
21 | # enable UTF-8 encoding for programs like pip that expect to |
22 | # print more than just ascii chars | |
23 | export LC_ALL=C.UTF-8 | |
7c673cae | 24 | |
11fdf7f2 TL |
25 | ARCH=$(uname -m) |
26 | ||
1e59de90 TL |
27 | function in_jenkins() { |
28 | test -n "$JENKINS_HOME" | |
29 | } | |
30 | ||
c07f9fc5 | 31 | function munge_ceph_spec_in { |
9f95a23c TL |
32 | local with_seastar=$1 |
33 | shift | |
f67539c2 TL |
34 | local with_zbd=$1 |
35 | shift | |
11fdf7f2 TL |
36 | local for_make_check=$1 |
37 | shift | |
c07f9fc5 | 38 | local OUTFILE=$1 |
11fdf7f2 TL |
39 | sed -e 's/@//g' < ceph.spec.in > $OUTFILE |
40 | # http://rpm.org/user_doc/conditional_builds.html | |
9f95a23c | 41 | if $with_seastar; then |
11fdf7f2 TL |
42 | sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE |
43 | fi | |
f67539c2 TL |
44 | if $with_zbd; then |
45 | sed -i -e 's/%bcond_with zbd/%bcond_without zbd/g' $OUTFILE | |
46 | fi | |
11fdf7f2 TL |
47 | if $for_make_check; then |
48 | sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE | |
49 | fi | |
c07f9fc5 FG |
50 | } |
51 | ||
11fdf7f2 TL |
52 | function munge_debian_control { |
53 | local version=$1 | |
54 | shift | |
11fdf7f2 TL |
55 | local control=$1 |
56 | case "$version" in | |
57 | *squeeze*|*wheezy*) | |
1e59de90 TL |
58 | control="/tmp/control.$$" |
59 | grep -v babeltrace debian/control > $control | |
60 | ;; | |
11fdf7f2 | 61 | esac |
11fdf7f2 TL |
62 | echo $control |
63 | } | |
64 | ||
65 | function ensure_decent_gcc_on_ubuntu { | |
1e59de90 | 66 | in_jenkins && echo "CI_DEBUG: Start ensure_decent_gcc_on_ubuntu() in install-deps.sh" |
11fdf7f2 TL |
67 | # point gcc to the one offered by g++-7 if the used one is not |
68 | # new enough | |
69 | local old=$(gcc -dumpfullversion -dumpversion) | |
b32b8144 | 70 | local new=$1 |
11fdf7f2 | 71 | local codename=$2 |
eafe8130 | 72 | if dpkg --compare-versions $old ge ${new}.0; then |
1e59de90 | 73 | return |
11fdf7f2 TL |
74 | fi |
75 | ||
76 | if [ ! -f /usr/bin/g++-${new} ]; then | |
1e59de90 | 77 | $SUDO tee /etc/apt/sources.list.d/ubuntu-toolchain-r.list <<EOF |
11fdf7f2 | 78 | deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main |
9f95a23c | 79 | deb [arch=amd64 lang=none] http://mirror.nullivex.com/ppa/ubuntu-toolchain-r-test $codename main |
11fdf7f2 | 80 | EOF |
1e59de90 TL |
81 | # import PPA's signing key into APT's keyring |
82 | cat << ENDOFKEY | $SUDO apt-key add - | |
11fdf7f2 TL |
83 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
84 | Version: SKS 1.1.6 | |
85 | Comment: Hostname: keyserver.ubuntu.com | |
86 | ||
87 | mI0ESuBvRwEEAMi4cDba7xlKaaoXjO1n1HX8RKrkW+HEIl79nSOSJyvzysajs7zUow/OzCQp | |
88 | 9NswqrDmNuH1+lPTTRNAGtK8r2ouq2rnXT1mTl23dpgHZ9spseR73s4ZBGw/ag4bpU5dNUSt | |
89 | vfmHhIjVCuiSpNn7cyy1JSSvSs3N2mxteKjXLBf7ABEBAAG0GkxhdW5jaHBhZCBUb29sY2hh | |
90 | aW4gYnVpbGRziLYEEwECACAFAkrgb0cCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAe | |
91 | k3eiup7yfzGKA/4xzUqNACSlB+k+DxFFHqkwKa/ziFiAlkLQyyhm+iqz80htRZr7Ls/ZRYZl | |
92 | 0aSU56/hLe0V+TviJ1s8qdN2lamkKdXIAFfavA04nOnTzyIBJ82EAUT3Nh45skMxo4z4iZMN | |
93 | msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ== | |
94 | =LcUQ | |
95 | -----END PGP PUBLIC KEY BLOCK----- | |
96 | ENDOFKEY | |
1e59de90 TL |
97 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true |
98 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-${new} | |
11fdf7f2 | 99 | fi |
11fdf7f2 TL |
100 | } |
101 | ||
f67539c2 | 102 | function ensure_python3_sphinx_on_ubuntu { |
1e59de90 | 103 | in_jenkins && echo "CI_DEBUG: Running ensure_python3_sphinx_on_ubuntu() in install-deps.sh" |
f67539c2 TL |
104 | local sphinx_command=/usr/bin/sphinx-build |
105 | # python-sphinx points $sphinx_command to | |
106 | # ../share/sphinx/scripts/python2/sphinx-build when it's installed | |
107 | # let's "correct" this | |
108 | if test -e $sphinx_command && head -n1 $sphinx_command | grep -q python$; then | |
109 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove python-sphinx | |
110 | fi | |
111 | } | |
112 | ||
11fdf7f2 | 113 | function install_pkg_on_ubuntu { |
1e59de90 | 114 | in_jenkins && echo "CI_DEBUG: Running install_pkg_on_ubuntu() in install-deps.sh" |
11fdf7f2 TL |
115 | local project=$1 |
116 | shift | |
117 | local sha1=$1 | |
118 | shift | |
119 | local codename=$1 | |
120 | shift | |
9f95a23c TL |
121 | local force=$1 |
122 | shift | |
11fdf7f2 TL |
123 | local pkgs=$@ |
124 | local missing_pkgs | |
9f95a23c | 125 | if [ $force = "force" ]; then |
1e59de90 | 126 | missing_pkgs="$@" |
9f95a23c | 127 | else |
1e59de90 TL |
128 | for pkg in $pkgs; do |
129 | if ! apt -qq list $pkg 2>/dev/null | grep -q installed; then | |
130 | missing_pkgs+=" $pkg" | |
131 | in_jenkins && echo "CI_DEBUG: missing_pkgs=$missing_pkgs" | |
132 | fi | |
133 | done | |
9f95a23c | 134 | fi |
11fdf7f2 | 135 | if test -n "$missing_pkgs"; then |
1e59de90 TL |
136 | local shaman_url="https://shaman.ceph.com/api/repos/${project}/master/${sha1}/ubuntu/${codename}/repo" |
137 | in_jenkins && echo -n "CI_DEBUG: Downloading $shaman_url ... " | |
138 | $SUDO curl --silent --fail --write-out "%{http_code}" --location $shaman_url --output /etc/apt/sources.list.d/$project.list | |
139 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y -o Acquire::Languages=none -o Acquire::Translation=none || true | |
140 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install --allow-unauthenticated -y $missing_pkgs | |
11fdf7f2 | 141 | fi |
b32b8144 FG |
142 | } |
143 | ||
aee94f69 TL |
144 | boost_ver=1.79 |
145 | ||
146 | function clean_boost_on_ubuntu { | |
147 | in_jenkins && echo "CI_DEBUG: Running clean_boost_on_ubuntu() in install-deps.sh" | |
148 | # Find currently installed version. If there are multiple | |
149 | # versions, they end up newline separated | |
150 | local installed_ver=$(apt -qq list --installed ceph-libboost*-dev 2>/dev/null | | |
151 | cut -d' ' -f2 | | |
152 | cut -d'.' -f1,2 | | |
153 | sort -u) | |
154 | # If installed_ver contains whitespace, we can't really count on it, | |
155 | # but otherwise, bail out if the version installed is the version | |
156 | # we want. | |
157 | if test -n "$installed_ver" && | |
158 | echo -n "$installed_ver" | tr '[:space:]' ' ' | grep -v -q ' '; then | |
159 | if echo "$installed_ver" | grep -q "^$boost_ver"; then | |
160 | return | |
161 | fi | |
162 | fi | |
163 | ||
164 | # Historical packages | |
165 | $SUDO rm -f /etc/apt/sources.list.d/ceph-libboost*.list | |
166 | # Currently used | |
167 | $SUDO rm -f /etc/apt/sources.list.d/libboost.list | |
168 | # Refresh package list so things aren't in the available list. | |
169 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true | |
170 | # Remove all ceph-libboost packages. We have an early return if | |
171 | # the desired version is already (and the only) version installed, | |
172 | # so no need to spare it. | |
173 | if test -n "$installed_ver"; then | |
174 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y --fix-missing remove "ceph-libboost*" | |
175 | fi | |
176 | } | |
177 | ||
11fdf7f2 | 178 | function install_boost_on_ubuntu { |
1e59de90 | 179 | in_jenkins && echo "CI_DEBUG: Running install_boost_on_ubuntu() in install-deps.sh" |
aee94f69 TL |
180 | # Once we get to this point, clean_boost_on_ubuntu() should ensure |
181 | # that there is no more than one installed version. | |
f67539c2 TL |
182 | local installed_ver=$(apt -qq list --installed ceph-libboost*-dev 2>/dev/null | |
183 | grep -e 'libboost[0-9].[0-9]\+-dev' | | |
184 | cut -d' ' -f2 | | |
185 | cut -d'.' -f1,2) | |
186 | if test -n "$installed_ver"; then | |
aee94f69 | 187 | if echo "$installed_ver" | grep -q "^$boost_ver"; then |
f67539c2 | 188 | return |
f67539c2 | 189 | fi |
92f5a8d4 | 190 | fi |
f67539c2 | 191 | local codename=$1 |
92f5a8d4 | 192 | local project=libboost |
1e59de90 | 193 | local sha1=892ab89e76b91b505ffbf083f6fb7f2a666d4132 |
11fdf7f2 | 194 | install_pkg_on_ubuntu \ |
1e59de90 TL |
195 | $project \ |
196 | $sha1 \ | |
197 | $codename \ | |
198 | check \ | |
aee94f69 TL |
199 | ceph-libboost-atomic${boost_ver}-dev \ |
200 | ceph-libboost-chrono${boost_ver}-dev \ | |
201 | ceph-libboost-container${boost_ver}-dev \ | |
202 | ceph-libboost-context${boost_ver}-dev \ | |
203 | ceph-libboost-coroutine${boost_ver}-dev \ | |
204 | ceph-libboost-date-time${boost_ver}-dev \ | |
205 | ceph-libboost-filesystem${boost_ver}-dev \ | |
206 | ceph-libboost-iostreams${boost_ver}-dev \ | |
207 | ceph-libboost-program-options${boost_ver}-dev \ | |
208 | ceph-libboost-python${boost_ver}-dev \ | |
209 | ceph-libboost-random${boost_ver}-dev \ | |
210 | ceph-libboost-regex${boost_ver}-dev \ | |
211 | ceph-libboost-system${boost_ver}-dev \ | |
212 | ceph-libboost-test${boost_ver}-dev \ | |
213 | ceph-libboost-thread${boost_ver}-dev \ | |
214 | ceph-libboost-timer${boost_ver}-dev | |
11fdf7f2 TL |
215 | } |
216 | ||
f67539c2 | 217 | function install_libzbd_on_ubuntu { |
1e59de90 | 218 | in_jenkins && echo "CI_DEBUG: Running install_libzbd_on_ubuntu() in install-deps.sh" |
f67539c2 TL |
219 | local codename=$1 |
220 | local project=libzbd | |
221 | local sha1=1fadde94b08fab574b17637c2bebd2b1e7f9127b | |
222 | install_pkg_on_ubuntu \ | |
223 | $project \ | |
224 | $sha1 \ | |
225 | $codename \ | |
226 | check \ | |
227 | libzbd-dev | |
11fdf7f2 TL |
228 | } |
229 | ||
1e59de90 TL |
230 | motr_pkgs_url='https://github.com/Seagate/cortx-motr/releases/download/2.0.0-rgw' |
231 | ||
232 | function install_cortx_motr_on_ubuntu { | |
233 | if dpkg -l cortx-motr-dev &> /dev/null; then | |
234 | return | |
235 | fi | |
236 | if [ "$(lsb_release -sc)" = "jammy" ]; then | |
237 | install_pkg_on_ubuntu \ | |
238 | cortx-motr \ | |
239 | 39f89fa1c6945040433a913f2687c4b4e6cbeb3f \ | |
240 | jammy \ | |
241 | check \ | |
242 | cortx-motr \ | |
243 | cortx-motr-dev | |
244 | else | |
245 | local deb_arch=$(dpkg --print-architecture) | |
246 | local motr_pkg="cortx-motr_2.0.0.git3252d623_$deb_arch.deb" | |
247 | local motr_dev_pkg="cortx-motr-dev_2.0.0.git3252d623_$deb_arch.deb" | |
248 | $SUDO curl -sL -o/var/cache/apt/archives/$motr_pkg $motr_pkgs_url/$motr_pkg | |
249 | $SUDO curl -sL -o/var/cache/apt/archives/$motr_dev_pkg $motr_pkgs_url/$motr_dev_pkg | |
250 | # For some reason libfabric pkg is not available in arm64 version | |
251 | # of Ubuntu 20.04 (Focal Fossa), so we borrow it from more recent | |
252 | # versions for now. | |
253 | if [[ "$deb_arch" == 'arm64' ]]; then | |
254 | local lf_pkg='libfabric1_1.11.0-2_arm64.deb' | |
255 | $SUDO curl -sL -o/var/cache/apt/archives/$lf_pkg http://ports.ubuntu.com/pool/universe/libf/libfabric/$lf_pkg | |
256 | $SUDO apt-get install -y /var/cache/apt/archives/$lf_pkg | |
257 | fi | |
258 | $SUDO apt-get install -y /var/cache/apt/archives/{$motr_pkg,$motr_dev_pkg} | |
259 | $SUDO apt-get install -y libisal-dev | |
260 | fi | |
261 | } | |
262 | ||
f67539c2 TL |
263 | function version_lt { |
264 | test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1) | |
11fdf7f2 TL |
265 | } |
266 | ||
1e59de90 TL |
267 | function ensure_decent_gcc_on_rh { |
268 | local old=$(gcc -dumpversion) | |
269 | local dts_ver=$1 | |
270 | if version_lt $old $dts_ver; then | |
271 | if test -t 1; then | |
272 | # interactive shell | |
273 | cat <<EOF | |
274 | Your GCC is too old. Please run following command to add DTS to your environment: | |
275 | ||
276 | scl enable gcc-toolset-$dts_ver bash | |
277 | ||
278 | Or add the following line to the end of ~/.bashrc and run "source ~/.bashrc" to add it permanently: | |
279 | ||
280 | source scl_source enable gcc-toolset-$dts_ver | |
281 | EOF | |
282 | else | |
283 | # non-interactive shell | |
284 | source /opt/rh/gcc-toolset-$dts_ver/enable | |
285 | fi | |
286 | fi | |
287 | } | |
288 | ||
9f95a23c TL |
289 | for_make_check=false |
290 | if tty -s; then | |
291 | # interactive | |
292 | for_make_check=true | |
293 | elif [ $FOR_MAKE_CHECK ]; then | |
294 | for_make_check=true | |
295 | else | |
296 | for_make_check=false | |
297 | fi | |
298 | ||
11fdf7f2 | 299 | if [ x$(uname)x = xFreeBSDx ]; then |
7c673cae | 300 | $SUDO pkg install -yq \ |
c07f9fc5 | 301 | devel/babeltrace \ |
11fdf7f2 | 302 | devel/binutils \ |
7c673cae | 303 | devel/git \ |
31f18b77 | 304 | devel/gperf \ |
7c673cae FG |
305 | devel/gmake \ |
306 | devel/cmake \ | |
f67539c2 | 307 | devel/nasm \ |
7c673cae FG |
308 | devel/boost-all \ |
309 | devel/boost-python-libs \ | |
310 | devel/valgrind \ | |
311 | devel/pkgconf \ | |
7c673cae FG |
312 | devel/libedit \ |
313 | devel/libtool \ | |
314 | devel/google-perftools \ | |
315 | lang/cython \ | |
7c673cae | 316 | databases/leveldb \ |
11fdf7f2 | 317 | net/openldap24-client \ |
7c673cae | 318 | archivers/snappy \ |
11fdf7f2 | 319 | archivers/liblz4 \ |
7c673cae FG |
320 | ftp/curl \ |
321 | misc/e2fsprogs-libuuid \ | |
322 | misc/getopt \ | |
224ce89b | 323 | net/socat \ |
7c673cae FG |
324 | textproc/expat2 \ |
325 | textproc/gsed \ | |
f64942e4 | 326 | lang/gawk \ |
7c673cae FG |
327 | textproc/libxml2 \ |
328 | textproc/xmlstarlet \ | |
c07f9fc5 FG |
329 | textproc/jq \ |
330 | textproc/py-sphinx \ | |
7c673cae FG |
331 | emulators/fuse \ |
332 | java/junit \ | |
11fdf7f2 | 333 | lang/python36 \ |
c07f9fc5 | 334 | devel/py-pip \ |
11fdf7f2 | 335 | devel/py-flake8 \ |
9f95a23c | 336 | devel/py-tox \ |
7c673cae FG |
337 | devel/py-argparse \ |
338 | devel/py-nose \ | |
c07f9fc5 | 339 | devel/py-prettytable \ |
20effc67 | 340 | devel/py-yaml \ |
11fdf7f2 | 341 | www/py-routes \ |
7c673cae | 342 | www/py-flask \ |
11fdf7f2 TL |
343 | www/node \ |
344 | www/npm \ | |
7c673cae | 345 | www/fcgi \ |
11fdf7f2 | 346 | security/nss \ |
9f95a23c | 347 | security/krb5 \ |
11fdf7f2 | 348 | security/oath-toolkit \ |
7c673cae FG |
349 | sysutils/flock \ |
350 | sysutils/fusefs-libs \ | |
351 | ||
1e59de90 TL |
352 | # Now use pip to install some extra python modules |
353 | pip install pecan | |
31f18b77 | 354 | |
7c673cae FG |
355 | exit |
356 | else | |
9f95a23c | 357 | [ $WITH_SEASTAR ] && with_seastar=true || with_seastar=false |
f67539c2 | 358 | [ $WITH_ZBD ] && with_zbd=true || with_zbd=false |
1e59de90 TL |
359 | [ $WITH_PMEM ] && with_pmem=true || with_pmem=false |
360 | [ $WITH_RADOSGW_MOTR ] && with_rgw_motr=true || with_rgw_motr=false | |
7c673cae | 361 | source /etc/os-release |
eafe8130 | 362 | case "$ID" in |
20effc67 | 363 | debian|ubuntu|devuan|elementary|softiron) |
7c673cae | 364 | echo "Using apt-get to install dependencies" |
aee94f69 TL |
365 | # Put this before any other invocation of apt so it can clean |
366 | # up in a broken case. | |
367 | clean_boost_on_ubuntu | |
11fdf7f2 TL |
368 | $SUDO apt-get install -y devscripts equivs |
369 | $SUDO apt-get install -y dpkg-dev | |
f67539c2 | 370 | ensure_python3_sphinx_on_ubuntu |
b32b8144 | 371 | case "$VERSION" in |
11fdf7f2 | 372 | *Bionic*) |
9f95a23c TL |
373 | ensure_decent_gcc_on_ubuntu 9 bionic |
374 | [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu bionic | |
f67539c2 | 375 | $with_zbd && install_libzbd_on_ubuntu bionic |
11fdf7f2 | 376 | ;; |
20effc67 | 377 | *Focal*) |
1e59de90 | 378 | ensure_decent_gcc_on_ubuntu 11 focal |
20effc67 TL |
379 | [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu focal |
380 | $with_zbd && install_libzbd_on_ubuntu focal | |
20effc67 | 381 | ;; |
1e59de90 TL |
382 | *Jammy*) |
383 | [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu jammy | |
384 | $SUDO apt-get install -y gcc | |
385 | ;; | |
11fdf7f2 TL |
386 | *) |
387 | $SUDO apt-get install -y gcc | |
b32b8144 FG |
388 | ;; |
389 | esac | |
7c673cae FG |
390 | if ! test -r debian/control ; then |
391 | echo debian/control is not a readable file | |
392 | exit 1 | |
393 | fi | |
394 | touch $DIR/status | |
395 | ||
1e59de90 TL |
396 | in_jenkins && echo "CI_DEBUG: Running munge_debian_control() in install-deps.sh" |
397 | backports="" | |
398 | control=$(munge_debian_control "$VERSION" "debian/control") | |
11fdf7f2 TL |
399 | case "$VERSION" in |
400 | *squeeze*|*wheezy*) | |
401 | backports="-t $codename-backports" | |
7c673cae FG |
402 | ;; |
403 | esac | |
404 | ||
1e59de90 TL |
405 | # make a metapackage that expresses the build dependencies, |
406 | # install it, rm the .deb; then uninstall the package as its | |
407 | # work is done | |
408 | build_profiles="" | |
409 | if $for_make_check; then | |
410 | build_profiles+=",pkg.ceph.check" | |
411 | fi | |
412 | if $with_seastar; then | |
413 | build_profiles+=",pkg.ceph.crimson" | |
414 | fi | |
415 | if $with_pmem; then | |
416 | build_profiles+=",pkg.ceph.pmdk" | |
417 | fi | |
418 | ||
419 | in_jenkins && cat <<EOF | |
420 | CI_DEBUG: for_make_check=$for_make_check | |
421 | CI_DEBUG: with_seastar=$with_seastar | |
422 | CI_DEBUG: with_jaeger=$with_jaeger | |
423 | CI_DEBUG: build_profiles=$build_profiles | |
424 | CI_DEBUG: Now running 'mk-build-deps' and installing ceph-build-deps package | |
425 | EOF | |
426 | ||
427 | $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps \ | |
428 | --build-profiles "${build_profiles#,}" \ | |
429 | --install --remove \ | |
430 | --tool="apt-get -y --no-install-recommends $backports" $control || exit 1 | |
431 | in_jenkins && echo "CI_DEBUG: Removing ceph-build-deps" | |
432 | $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps | |
433 | if [ "$control" != "debian/control" ] ; then rm $control; fi | |
434 | ||
435 | # for rgw motr backend build checks | |
436 | if $with_rgw_motr; then | |
437 | install_cortx_motr_on_ubuntu | |
438 | fi | |
7c673cae | 439 | ;; |
1e59de90 | 440 | rocky|centos|fedora|rhel|ol|virtuozzo) |
9f95a23c | 441 | builddepcmd="dnf -y builddep --allowerasing" |
f67539c2 | 442 | echo "Using dnf to install dependencies" |
eafe8130 | 443 | case "$ID" in |
11fdf7f2 | 444 | fedora) |
f67539c2 | 445 | $SUDO dnf install -y dnf-utils |
7c673cae | 446 | ;; |
1e59de90 | 447 | rocky|centos|rhel|ol|virtuozzo) |
11fdf7f2 | 448 | MAJOR_VERSION="$(echo $VERSION_ID | cut -d. -f1)" |
2a845540 | 449 | $SUDO dnf install -y dnf-utils selinux-policy-targeted |
eafe8130 | 450 | rpm --quiet --query epel-release || \ |
1e59de90 | 451 | $SUDO dnf -y install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-$MAJOR_VERSION.noarch.rpm |
7c673cae FG |
452 | $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION |
453 | $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org* | |
1e59de90 | 454 | if test $ID = centos -a $MAJOR_VERSION = 8 ; then |
adb31ebb TL |
455 | # Enable 'powertools' or 'PowerTools' repo |
456 | $SUDO dnf config-manager --set-enabled $(dnf repolist --all 2>/dev/null|gawk 'tolower($0) ~ /^powertools\s/{print $1}') | |
1e59de90 TL |
457 | dts_ver=11 |
458 | # before EPEL8 and PowerTools provide all dependencies, we use sepia for the dependencies | |
9f95a23c TL |
459 | $SUDO dnf config-manager --add-repo http://apt-mirror.front.sepia.ceph.com/lab-extras/8/ |
460 | $SUDO dnf config-manager --setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck=0 --save | |
1e59de90 | 461 | $SUDO dnf -y module enable javapackages-tools |
9f95a23c | 462 | elif test $ID = rhel -a $MAJOR_VERSION = 8 ; then |
1e59de90 | 463 | dts_ver=11 |
20effc67 | 464 | $SUDO dnf config-manager --set-enabled "codeready-builder-for-rhel-8-${ARCH}-rpms" |
1e59de90 TL |
465 | $SUDO dnf config-manager --add-repo http://apt-mirror.front.sepia.ceph.com/lab-extras/8/ |
466 | $SUDO dnf config-manager --setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck=0 --save | |
467 | $SUDO dnf -y module enable javapackages-tools | |
7c673cae FG |
468 | fi |
469 | ;; | |
470 | esac | |
1e59de90 | 471 | munge_ceph_spec_in $with_seastar $with_zbd $for_make_check $DIR/ceph.spec |
9f95a23c | 472 | # for python3_pkgversion macro defined by python-srpm-macros, which is required by python3-devel |
f67539c2 | 473 | $SUDO dnf install -y python3-devel |
7c673cae | 474 | $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out |
11fdf7f2 | 475 | [ ${PIPESTATUS[0]} -ne 0 ] && exit 1 |
1e59de90 TL |
476 | if [ -n "$dts_ver" ]; then |
477 | ensure_decent_gcc_on_rh $dts_ver | |
478 | fi | |
9f95a23c | 479 | IGNORE_YUM_BUILDEP_ERRORS="ValueError: SELinux policy is not managed or store cannot be accessed." |
2a845540 | 480 | sed "/$IGNORE_YUM_BUILDEP_ERRORS/d" $DIR/yum-builddep.out | grep -i "error:" && exit 1 |
1e59de90 TL |
481 | # for rgw motr backend build checks |
482 | if ! rpm --quiet -q cortx-motr-devel && | |
483 | { [[ $FOR_MAKE_CHECK ]] || $with_rgw_motr; }; then | |
484 | $SUDO dnf install -y \ | |
485 | "$motr_pkgs_url/isa-l-2.30.0-1.el7.${ARCH}.rpm" \ | |
486 | "$motr_pkgs_url/cortx-motr-2.0.0-1_git3252d623_any.el8.${ARCH}.rpm" \ | |
487 | "$motr_pkgs_url/cortx-motr-devel-2.0.0-1_git3252d623_any.el8.${ARCH}.rpm" | |
488 | fi | |
7c673cae | 489 | ;; |
1adf2230 | 490 | opensuse*|suse|sles) |
7c673cae | 491 | echo "Using zypper to install dependencies" |
11fdf7f2 | 492 | zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends" |
92f5a8d4 | 493 | $SUDO $zypp_install systemd-rpm-macros rpm-build || exit 1 |
1e59de90 | 494 | munge_ceph_spec_in $with_seastar false $for_make_check $DIR/ceph.spec |
11fdf7f2 | 495 | $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1 |
7c673cae | 496 | ;; |
7c673cae FG |
497 | *) |
498 | echo "$ID is unknown, dependencies will have to be installed manually." | |
1e59de90 | 499 | exit 1 |
7c673cae FG |
500 | ;; |
501 | esac | |
502 | fi | |
503 | ||
504 | function populate_wheelhouse() { | |
1e59de90 | 505 | in_jenkins && echo "CI_DEBUG: Running populate_wheelhouse() in install-deps.sh" |
7c673cae FG |
506 | local install=$1 |
507 | shift | |
508 | ||
509 | # although pip comes with virtualenv, having a recent version | |
510 | # of pip matters when it comes to using wheel packages | |
9f95a23c TL |
511 | PIP_OPTS="--timeout 300 --exists-action i" |
512 | pip $PIP_OPTS $install \ | |
20effc67 | 513 | 'setuptools >= 0.8' 'pip >= 21.0' 'wheel >= 0.24' 'tox >= 2.9.1' || return 1 |
7c673cae | 514 | if test $# != 0 ; then |
05a536ef | 515 | pip $PIP_OPTS $install $@ || return 1 |
7c673cae FG |
516 | fi |
517 | } | |
518 | ||
519 | function activate_virtualenv() { | |
1e59de90 | 520 | in_jenkins && echo "CI_DEBUG: Running activate_virtualenv() in install-deps.sh" |
7c673cae | 521 | local top_srcdir=$1 |
9f95a23c | 522 | local env_dir=$top_srcdir/install-deps-python3 |
7c673cae FG |
523 | |
524 | if ! test -d $env_dir ; then | |
a4b75251 | 525 | python3 -m venv ${env_dir} |
7c673cae FG |
526 | . $env_dir/bin/activate |
527 | if ! populate_wheelhouse install ; then | |
528 | rm -rf $env_dir | |
529 | return 1 | |
530 | fi | |
531 | fi | |
532 | . $env_dir/bin/activate | |
533 | } | |
534 | ||
9f95a23c | 535 | function preload_wheels_for_tox() { |
1e59de90 | 536 | in_jenkins && echo "CI_DEBUG: Running preload_wheels_for_tox() in install-deps.sh" |
9f95a23c TL |
537 | local ini=$1 |
538 | shift | |
539 | pushd . > /dev/null | |
540 | cd $(dirname $ini) | |
541 | local require_files=$(ls *requirements*.txt 2>/dev/null) || true | |
542 | local constraint_files=$(ls *constraints*.txt 2>/dev/null) || true | |
543 | local require=$(echo -n "$require_files" | sed -e 's/^/-r /') | |
544 | local constraint=$(echo -n "$constraint_files" | sed -e 's/^/-c /') | |
545 | local md5=wheelhouse/md5 | |
546 | if test "$require"; then | |
547 | if ! test -f $md5 || ! md5sum -c $md5 > /dev/null; then | |
548 | rm -rf wheelhouse | |
549 | fi | |
550 | fi | |
551 | if test "$require" && ! test -d wheelhouse ; then | |
552 | type python3 > /dev/null 2>&1 || continue | |
553 | activate_virtualenv $top_srcdir || exit 1 | |
1e59de90 | 554 | python3 -m pip install --upgrade pip |
9f95a23c TL |
555 | populate_wheelhouse "wheel -w $wip_wheelhouse" $require $constraint || exit 1 |
556 | mv $wip_wheelhouse wheelhouse | |
557 | md5sum $require_files $constraint_files > $md5 | |
558 | fi | |
559 | popd > /dev/null | |
560 | } | |
561 | ||
7c673cae FG |
562 | # use pip cache if possible but do not store it outside of the source |
563 | # tree | |
564 | # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching | |
9f95a23c TL |
565 | if $for_make_check; then |
566 | mkdir -p install-deps-cache | |
567 | top_srcdir=$(pwd) | |
568 | export XDG_CACHE_HOME=$top_srcdir/install-deps-cache | |
569 | wip_wheelhouse=wheelhouse-wip | |
570 | # | |
571 | # preload python modules so that tox can run without network access | |
572 | # | |
573 | find . -name tox.ini | while read ini ; do | |
574 | preload_wheels_for_tox $ini | |
575 | done | |
576 | rm -rf $top_srcdir/install-deps-python3 | |
577 | rm -rf $XDG_CACHE_HOME | |
578 | type git > /dev/null || (echo "Dashboard uses git to pull dependencies." ; false) | |
579 | fi | |
1e59de90 TL |
580 | |
581 | in_jenkins && echo "CI_DEBUG: End install-deps.sh" || true |