]> git.proxmox.com Git - ceph.git/blob - ceph/install-deps.sh
update ceph source to reef 18.2.0
[ceph.git] / ceph / install-deps.sh
1 #!/usr/bin/env bash
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 #
14 set -e
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
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
24
25 ARCH=$(uname -m)
26
27 function in_jenkins() {
28 test -n "$JENKINS_HOME"
29 }
30
31 function munge_ceph_spec_in {
32 local with_seastar=$1
33 shift
34 local with_zbd=$1
35 shift
36 local for_make_check=$1
37 shift
38 local OUTFILE=$1
39 sed -e 's/@//g' < ceph.spec.in > $OUTFILE
40 # http://rpm.org/user_doc/conditional_builds.html
41 if $with_seastar; then
42 sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE
43 fi
44 if $with_zbd; then
45 sed -i -e 's/%bcond_with zbd/%bcond_without zbd/g' $OUTFILE
46 fi
47 if $for_make_check; then
48 sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE
49 fi
50 }
51
52 function munge_debian_control {
53 local version=$1
54 shift
55 local control=$1
56 case "$version" in
57 *squeeze*|*wheezy*)
58 control="/tmp/control.$$"
59 grep -v babeltrace debian/control > $control
60 ;;
61 esac
62 echo $control
63 }
64
65 function ensure_decent_gcc_on_ubuntu {
66 in_jenkins && echo "CI_DEBUG: Start ensure_decent_gcc_on_ubuntu() in install-deps.sh"
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)
70 local new=$1
71 local codename=$2
72 if dpkg --compare-versions $old ge ${new}.0; then
73 return
74 fi
75
76 if [ ! -f /usr/bin/g++-${new} ]; then
77 $SUDO tee /etc/apt/sources.list.d/ubuntu-toolchain-r.list <<EOF
78 deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
79 deb [arch=amd64 lang=none] http://mirror.nullivex.com/ppa/ubuntu-toolchain-r-test $codename main
80 EOF
81 # import PPA's signing key into APT's keyring
82 cat << ENDOFKEY | $SUDO apt-key add -
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
97 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
98 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-${new}
99 fi
100 }
101
102 function ensure_python3_sphinx_on_ubuntu {
103 in_jenkins && echo "CI_DEBUG: Running ensure_python3_sphinx_on_ubuntu() in install-deps.sh"
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
113 function install_pkg_on_ubuntu {
114 in_jenkins && echo "CI_DEBUG: Running install_pkg_on_ubuntu() in install-deps.sh"
115 local project=$1
116 shift
117 local sha1=$1
118 shift
119 local codename=$1
120 shift
121 local force=$1
122 shift
123 local pkgs=$@
124 local missing_pkgs
125 if [ $force = "force" ]; then
126 missing_pkgs="$@"
127 else
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
134 fi
135 if test -n "$missing_pkgs"; then
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
141 fi
142 }
143
144 function install_boost_on_ubuntu {
145 in_jenkins && echo "CI_DEBUG: Running install_boost_on_ubuntu() in install-deps.sh"
146 local ver=1.79
147 local installed_ver=$(apt -qq list --installed ceph-libboost*-dev 2>/dev/null |
148 grep -e 'libboost[0-9].[0-9]\+-dev' |
149 cut -d' ' -f2 |
150 cut -d'.' -f1,2)
151 if test -n "$installed_ver"; then
152 if echo "$installed_ver" | grep -q "^$ver"; then
153 return
154 else
155 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove "ceph-libboost.*${installed_ver}.*"
156 $SUDO rm -f /etc/apt/sources.list.d/ceph-libboost${installed_ver}.list
157 fi
158 fi
159 local codename=$1
160 local project=libboost
161 local sha1=892ab89e76b91b505ffbf083f6fb7f2a666d4132
162 install_pkg_on_ubuntu \
163 $project \
164 $sha1 \
165 $codename \
166 check \
167 ceph-libboost-atomic$ver-dev \
168 ceph-libboost-chrono$ver-dev \
169 ceph-libboost-container$ver-dev \
170 ceph-libboost-context$ver-dev \
171 ceph-libboost-coroutine$ver-dev \
172 ceph-libboost-date-time$ver-dev \
173 ceph-libboost-filesystem$ver-dev \
174 ceph-libboost-iostreams$ver-dev \
175 ceph-libboost-program-options$ver-dev \
176 ceph-libboost-python$ver-dev \
177 ceph-libboost-random$ver-dev \
178 ceph-libboost-regex$ver-dev \
179 ceph-libboost-system$ver-dev \
180 ceph-libboost-test$ver-dev \
181 ceph-libboost-thread$ver-dev \
182 ceph-libboost-timer$ver-dev
183 }
184
185 function install_libzbd_on_ubuntu {
186 in_jenkins && echo "CI_DEBUG: Running install_libzbd_on_ubuntu() in install-deps.sh"
187 local codename=$1
188 local project=libzbd
189 local sha1=1fadde94b08fab574b17637c2bebd2b1e7f9127b
190 install_pkg_on_ubuntu \
191 $project \
192 $sha1 \
193 $codename \
194 check \
195 libzbd-dev
196 }
197
198 motr_pkgs_url='https://github.com/Seagate/cortx-motr/releases/download/2.0.0-rgw'
199
200 function install_cortx_motr_on_ubuntu {
201 if dpkg -l cortx-motr-dev &> /dev/null; then
202 return
203 fi
204 if [ "$(lsb_release -sc)" = "jammy" ]; then
205 install_pkg_on_ubuntu \
206 cortx-motr \
207 39f89fa1c6945040433a913f2687c4b4e6cbeb3f \
208 jammy \
209 check \
210 cortx-motr \
211 cortx-motr-dev
212 else
213 local deb_arch=$(dpkg --print-architecture)
214 local motr_pkg="cortx-motr_2.0.0.git3252d623_$deb_arch.deb"
215 local motr_dev_pkg="cortx-motr-dev_2.0.0.git3252d623_$deb_arch.deb"
216 $SUDO curl -sL -o/var/cache/apt/archives/$motr_pkg $motr_pkgs_url/$motr_pkg
217 $SUDO curl -sL -o/var/cache/apt/archives/$motr_dev_pkg $motr_pkgs_url/$motr_dev_pkg
218 # For some reason libfabric pkg is not available in arm64 version
219 # of Ubuntu 20.04 (Focal Fossa), so we borrow it from more recent
220 # versions for now.
221 if [[ "$deb_arch" == 'arm64' ]]; then
222 local lf_pkg='libfabric1_1.11.0-2_arm64.deb'
223 $SUDO curl -sL -o/var/cache/apt/archives/$lf_pkg http://ports.ubuntu.com/pool/universe/libf/libfabric/$lf_pkg
224 $SUDO apt-get install -y /var/cache/apt/archives/$lf_pkg
225 fi
226 $SUDO apt-get install -y /var/cache/apt/archives/{$motr_pkg,$motr_dev_pkg}
227 $SUDO apt-get install -y libisal-dev
228 fi
229 }
230
231 function version_lt {
232 test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
233 }
234
235 function ensure_decent_gcc_on_rh {
236 local old=$(gcc -dumpversion)
237 local dts_ver=$1
238 if version_lt $old $dts_ver; then
239 if test -t 1; then
240 # interactive shell
241 cat <<EOF
242 Your GCC is too old. Please run following command to add DTS to your environment:
243
244 scl enable gcc-toolset-$dts_ver bash
245
246 Or add the following line to the end of ~/.bashrc and run "source ~/.bashrc" to add it permanently:
247
248 source scl_source enable gcc-toolset-$dts_ver
249 EOF
250 else
251 # non-interactive shell
252 source /opt/rh/gcc-toolset-$dts_ver/enable
253 fi
254 fi
255 }
256
257 for_make_check=false
258 if tty -s; then
259 # interactive
260 for_make_check=true
261 elif [ $FOR_MAKE_CHECK ]; then
262 for_make_check=true
263 else
264 for_make_check=false
265 fi
266
267 if [ x$(uname)x = xFreeBSDx ]; then
268 $SUDO pkg install -yq \
269 devel/babeltrace \
270 devel/binutils \
271 devel/git \
272 devel/gperf \
273 devel/gmake \
274 devel/cmake \
275 devel/nasm \
276 devel/boost-all \
277 devel/boost-python-libs \
278 devel/valgrind \
279 devel/pkgconf \
280 devel/libedit \
281 devel/libtool \
282 devel/google-perftools \
283 lang/cython \
284 databases/leveldb \
285 net/openldap24-client \
286 archivers/snappy \
287 archivers/liblz4 \
288 ftp/curl \
289 misc/e2fsprogs-libuuid \
290 misc/getopt \
291 net/socat \
292 textproc/expat2 \
293 textproc/gsed \
294 lang/gawk \
295 textproc/libxml2 \
296 textproc/xmlstarlet \
297 textproc/jq \
298 textproc/py-sphinx \
299 emulators/fuse \
300 java/junit \
301 lang/python36 \
302 devel/py-pip \
303 devel/py-flake8 \
304 devel/py-tox \
305 devel/py-argparse \
306 devel/py-nose \
307 devel/py-prettytable \
308 devel/py-yaml \
309 www/py-routes \
310 www/py-flask \
311 www/node \
312 www/npm \
313 www/fcgi \
314 security/nss \
315 security/krb5 \
316 security/oath-toolkit \
317 sysutils/flock \
318 sysutils/fusefs-libs \
319
320 # Now use pip to install some extra python modules
321 pip install pecan
322
323 exit
324 else
325 [ $WITH_SEASTAR ] && with_seastar=true || with_seastar=false
326 [ $WITH_ZBD ] && with_zbd=true || with_zbd=false
327 [ $WITH_PMEM ] && with_pmem=true || with_pmem=false
328 [ $WITH_RADOSGW_MOTR ] && with_rgw_motr=true || with_rgw_motr=false
329 source /etc/os-release
330 case "$ID" in
331 debian|ubuntu|devuan|elementary|softiron)
332 echo "Using apt-get to install dependencies"
333 $SUDO apt-get install -y devscripts equivs
334 $SUDO apt-get install -y dpkg-dev
335 ensure_python3_sphinx_on_ubuntu
336 case "$VERSION" in
337 *Bionic*)
338 ensure_decent_gcc_on_ubuntu 9 bionic
339 [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu bionic
340 $with_zbd && install_libzbd_on_ubuntu bionic
341 ;;
342 *Focal*)
343 ensure_decent_gcc_on_ubuntu 11 focal
344 [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu focal
345 $with_zbd && install_libzbd_on_ubuntu focal
346 ;;
347 *Jammy*)
348 [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu jammy
349 $SUDO apt-get install -y gcc
350 ;;
351 *)
352 $SUDO apt-get install -y gcc
353 ;;
354 esac
355 if ! test -r debian/control ; then
356 echo debian/control is not a readable file
357 exit 1
358 fi
359 touch $DIR/status
360
361 in_jenkins && echo "CI_DEBUG: Running munge_debian_control() in install-deps.sh"
362 backports=""
363 control=$(munge_debian_control "$VERSION" "debian/control")
364 case "$VERSION" in
365 *squeeze*|*wheezy*)
366 backports="-t $codename-backports"
367 ;;
368 esac
369
370 # make a metapackage that expresses the build dependencies,
371 # install it, rm the .deb; then uninstall the package as its
372 # work is done
373 build_profiles=""
374 if $for_make_check; then
375 build_profiles+=",pkg.ceph.check"
376 fi
377 if $with_seastar; then
378 build_profiles+=",pkg.ceph.crimson"
379 fi
380 if $with_pmem; then
381 build_profiles+=",pkg.ceph.pmdk"
382 fi
383
384 in_jenkins && cat <<EOF
385 CI_DEBUG: for_make_check=$for_make_check
386 CI_DEBUG: with_seastar=$with_seastar
387 CI_DEBUG: with_jaeger=$with_jaeger
388 CI_DEBUG: build_profiles=$build_profiles
389 CI_DEBUG: Now running 'mk-build-deps' and installing ceph-build-deps package
390 EOF
391
392 $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps \
393 --build-profiles "${build_profiles#,}" \
394 --install --remove \
395 --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
396 in_jenkins && echo "CI_DEBUG: Removing ceph-build-deps"
397 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
398 if [ "$control" != "debian/control" ] ; then rm $control; fi
399
400 # for rgw motr backend build checks
401 if $with_rgw_motr; then
402 install_cortx_motr_on_ubuntu
403 fi
404 ;;
405 rocky|centos|fedora|rhel|ol|virtuozzo)
406 builddepcmd="dnf -y builddep --allowerasing"
407 echo "Using dnf to install dependencies"
408 case "$ID" in
409 fedora)
410 $SUDO dnf install -y dnf-utils
411 ;;
412 rocky|centos|rhel|ol|virtuozzo)
413 MAJOR_VERSION="$(echo $VERSION_ID | cut -d. -f1)"
414 $SUDO dnf install -y dnf-utils selinux-policy-targeted
415 rpm --quiet --query epel-release || \
416 $SUDO dnf -y install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-$MAJOR_VERSION.noarch.rpm
417 $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
418 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
419 if test $ID = centos -a $MAJOR_VERSION = 8 ; then
420 # Enable 'powertools' or 'PowerTools' repo
421 $SUDO dnf config-manager --set-enabled $(dnf repolist --all 2>/dev/null|gawk 'tolower($0) ~ /^powertools\s/{print $1}')
422 dts_ver=11
423 # before EPEL8 and PowerTools provide all dependencies, we use sepia for the dependencies
424 $SUDO dnf config-manager --add-repo http://apt-mirror.front.sepia.ceph.com/lab-extras/8/
425 $SUDO dnf config-manager --setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck=0 --save
426 $SUDO dnf -y module enable javapackages-tools
427 elif test $ID = rhel -a $MAJOR_VERSION = 8 ; then
428 dts_ver=11
429 $SUDO dnf config-manager --set-enabled "codeready-builder-for-rhel-8-${ARCH}-rpms"
430 $SUDO dnf config-manager --add-repo http://apt-mirror.front.sepia.ceph.com/lab-extras/8/
431 $SUDO dnf config-manager --setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck=0 --save
432 $SUDO dnf -y module enable javapackages-tools
433 fi
434 ;;
435 esac
436 munge_ceph_spec_in $with_seastar $with_zbd $for_make_check $DIR/ceph.spec
437 # for python3_pkgversion macro defined by python-srpm-macros, which is required by python3-devel
438 $SUDO dnf install -y python3-devel
439 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
440 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
441 if [ -n "$dts_ver" ]; then
442 ensure_decent_gcc_on_rh $dts_ver
443 fi
444 IGNORE_YUM_BUILDEP_ERRORS="ValueError: SELinux policy is not managed or store cannot be accessed."
445 sed "/$IGNORE_YUM_BUILDEP_ERRORS/d" $DIR/yum-builddep.out | grep -i "error:" && exit 1
446 # for rgw motr backend build checks
447 if ! rpm --quiet -q cortx-motr-devel &&
448 { [[ $FOR_MAKE_CHECK ]] || $with_rgw_motr; }; then
449 $SUDO dnf install -y \
450 "$motr_pkgs_url/isa-l-2.30.0-1.el7.${ARCH}.rpm" \
451 "$motr_pkgs_url/cortx-motr-2.0.0-1_git3252d623_any.el8.${ARCH}.rpm" \
452 "$motr_pkgs_url/cortx-motr-devel-2.0.0-1_git3252d623_any.el8.${ARCH}.rpm"
453 fi
454 ;;
455 opensuse*|suse|sles)
456 echo "Using zypper to install dependencies"
457 zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
458 $SUDO $zypp_install systemd-rpm-macros rpm-build || exit 1
459 munge_ceph_spec_in $with_seastar false $for_make_check $DIR/ceph.spec
460 $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
461 ;;
462 *)
463 echo "$ID is unknown, dependencies will have to be installed manually."
464 exit 1
465 ;;
466 esac
467 fi
468
469 function populate_wheelhouse() {
470 in_jenkins && echo "CI_DEBUG: Running populate_wheelhouse() in install-deps.sh"
471 local install=$1
472 shift
473
474 # although pip comes with virtualenv, having a recent version
475 # of pip matters when it comes to using wheel packages
476 PIP_OPTS="--timeout 300 --exists-action i"
477 pip $PIP_OPTS $install \
478 'setuptools >= 0.8' 'pip >= 21.0' 'wheel >= 0.24' 'tox >= 2.9.1' || return 1
479 if test $# != 0 ; then
480 pip $PIP_OPTS $install $@ || return 1
481 fi
482 }
483
484 function activate_virtualenv() {
485 in_jenkins && echo "CI_DEBUG: Running activate_virtualenv() in install-deps.sh"
486 local top_srcdir=$1
487 local env_dir=$top_srcdir/install-deps-python3
488
489 if ! test -d $env_dir ; then
490 python3 -m venv ${env_dir}
491 . $env_dir/bin/activate
492 if ! populate_wheelhouse install ; then
493 rm -rf $env_dir
494 return 1
495 fi
496 fi
497 . $env_dir/bin/activate
498 }
499
500 function preload_wheels_for_tox() {
501 in_jenkins && echo "CI_DEBUG: Running preload_wheels_for_tox() in install-deps.sh"
502 local ini=$1
503 shift
504 pushd . > /dev/null
505 cd $(dirname $ini)
506 local require_files=$(ls *requirements*.txt 2>/dev/null) || true
507 local constraint_files=$(ls *constraints*.txt 2>/dev/null) || true
508 local require=$(echo -n "$require_files" | sed -e 's/^/-r /')
509 local constraint=$(echo -n "$constraint_files" | sed -e 's/^/-c /')
510 local md5=wheelhouse/md5
511 if test "$require"; then
512 if ! test -f $md5 || ! md5sum -c $md5 > /dev/null; then
513 rm -rf wheelhouse
514 fi
515 fi
516 if test "$require" && ! test -d wheelhouse ; then
517 type python3 > /dev/null 2>&1 || continue
518 activate_virtualenv $top_srcdir || exit 1
519 python3 -m pip install --upgrade pip
520 populate_wheelhouse "wheel -w $wip_wheelhouse" $require $constraint || exit 1
521 mv $wip_wheelhouse wheelhouse
522 md5sum $require_files $constraint_files > $md5
523 fi
524 popd > /dev/null
525 }
526
527 # use pip cache if possible but do not store it outside of the source
528 # tree
529 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
530 if $for_make_check; then
531 mkdir -p install-deps-cache
532 top_srcdir=$(pwd)
533 export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
534 wip_wheelhouse=wheelhouse-wip
535 #
536 # preload python modules so that tox can run without network access
537 #
538 find . -name tox.ini | while read ini ; do
539 preload_wheels_for_tox $ini
540 done
541 rm -rf $top_srcdir/install-deps-python3
542 rm -rf $XDG_CACHE_HOME
543 type git > /dev/null || (echo "Dashboard uses git to pull dependencies." ; false)
544 fi
545
546 in_jenkins && echo "CI_DEBUG: End install-deps.sh" || true