]> git.proxmox.com Git - ceph.git/blame - ceph/install-deps.sh
bump version to 15.2.3-pve1
[ceph.git] / ceph / install-deps.sh
CommitLineData
11fdf7f2
TL
1#!/usr/bin/env bash
2# -*- mode:sh; tab-width:8; indent-tabs-mode:t -*-
7c673cae
FG
3#
4# Ceph distributed storage system
5#
6# Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
7#
8# Author: Loic Dachary <loic@dachary.org>
9#
10# This library is free software; you can redistribute it and/or
11# modify it under the terms of the GNU Lesser General Public
12# License as published by the Free Software Foundation; either
13# version 2.1 of the License, or (at your option) any later version.
14#
11fdf7f2 15set -e
7c673cae
FG
16DIR=/tmp/install-deps.$$
17trap "rm -fr $DIR" EXIT
18mkdir -p $DIR
19if test $(id -u) != 0 ; then
20 SUDO=sudo
21fi
22export LC_ALL=C # the following is vulnerable to i18n
23
11fdf7f2
TL
24ARCH=$(uname -m)
25
c07f9fc5 26function munge_ceph_spec_in {
9f95a23c
TL
27 local with_seastar=$1
28 shift
11fdf7f2
TL
29 local for_make_check=$1
30 shift
c07f9fc5 31 local OUTFILE=$1
11fdf7f2
TL
32 sed -e 's/@//g' < ceph.spec.in > $OUTFILE
33 # http://rpm.org/user_doc/conditional_builds.html
9f95a23c 34 if $with_seastar; then
11fdf7f2
TL
35 sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE
36 fi
37 if $for_make_check; then
38 sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE
39 fi
c07f9fc5
FG
40}
41
11fdf7f2
TL
42function munge_debian_control {
43 local version=$1
44 shift
9f95a23c
TL
45 local with_seastar=$1
46 shift
11fdf7f2
TL
47 local for_make_check=$1
48 shift
49 local control=$1
50 case "$version" in
51 *squeeze*|*wheezy*)
52 control="/tmp/control.$$"
53 grep -v babeltrace debian/control > $control
54 ;;
55 esac
9f95a23c
TL
56 if $with_seastar; then
57 sed -i -e 's/^# Crimson[[:space:]]//g' $control
58 fi
11fdf7f2
TL
59 if $for_make_check; then
60 sed -i 's/^# Make-Check[[:space:]]/ /g' $control
61 fi
62 echo $control
63}
64
65function ensure_decent_gcc_on_ubuntu {
66 # point gcc to the one offered by g++-7 if the used one is not
67 # new enough
68 local old=$(gcc -dumpfullversion -dumpversion)
b32b8144 69 local new=$1
11fdf7f2 70 local codename=$2
eafe8130 71 if dpkg --compare-versions $old ge ${new}.0; then
11fdf7f2
TL
72 return
73 fi
74
75 if [ ! -f /usr/bin/g++-${new} ]; then
76 $SUDO tee /etc/apt/sources.list.d/ubuntu-toolchain-r.list <<EOF
77deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
9f95a23c
TL
78deb [arch=amd64 lang=none] http://mirror.nullivex.com/ppa/ubuntu-toolchain-r-test $codename main
79deb [arch=amd64 lang=none] http://deb.rug.nl/ppa/mirror/ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
11fdf7f2
TL
80EOF
81 # import PPA's signing key into APT's keyring
82 cat << ENDOFKEY | $SUDO apt-key add -
83-----BEGIN PGP PUBLIC KEY BLOCK-----
84Version: SKS 1.1.6
85Comment: Hostname: keyserver.ubuntu.com
86
87mI0ESuBvRwEEAMi4cDba7xlKaaoXjO1n1HX8RKrkW+HEIl79nSOSJyvzysajs7zUow/OzCQp
889NswqrDmNuH1+lPTTRNAGtK8r2ouq2rnXT1mTl23dpgHZ9spseR73s4ZBGw/ag4bpU5dNUSt
89vfmHhIjVCuiSpNn7cyy1JSSvSs3N2mxteKjXLBf7ABEBAAG0GkxhdW5jaHBhZCBUb29sY2hh
90aW4gYnVpbGRziLYEEwECACAFAkrgb0cCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAe
91k3eiup7yfzGKA/4xzUqNACSlB+k+DxFFHqkwKa/ziFiAlkLQyyhm+iqz80htRZr7Ls/ZRYZl
920aSU56/hLe0V+TviJ1s8qdN2lamkKdXIAFfavA04nOnTzyIBJ82EAUT3Nh45skMxo4z4iZMN
93msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ==
94=LcUQ
95-----END PGP PUBLIC KEY BLOCK-----
96ENDOFKEY
97 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
eafe8130 98 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-${new}
b32b8144
FG
99 fi
100
eafe8130 101 case "$codename" in
11fdf7f2 102 trusty)
b32b8144 103 old=4.8;;
11fdf7f2 104 xenial)
b32b8144 105 old=5;;
9f95a23c
TL
106 bionic)
107 old=7;;
b32b8144 108 esac
b32b8144
FG
109 $SUDO update-alternatives --remove-all gcc || true
110 $SUDO update-alternatives \
111 --install /usr/bin/gcc gcc /usr/bin/gcc-${new} 20 \
112 --slave /usr/bin/g++ g++ /usr/bin/g++-${new}
113
11fdf7f2
TL
114 if [ -f /usr/bin/g++-${old} ]; then
115 $SUDO update-alternatives \
116 --install /usr/bin/gcc gcc /usr/bin/gcc-${old} 10 \
117 --slave /usr/bin/g++ g++ /usr/bin/g++-${old}
118 fi
b32b8144
FG
119
120 $SUDO update-alternatives --auto gcc
121
122 # cmake uses the latter by default
eafe8130
TL
123 $SUDO ln -nsf /usr/bin/gcc /usr/bin/${ARCH}-linux-gnu-gcc
124 $SUDO ln -nsf /usr/bin/g++ /usr/bin/${ARCH}-linux-gnu-g++
11fdf7f2
TL
125}
126
127function install_pkg_on_ubuntu {
128 local project=$1
129 shift
130 local sha1=$1
131 shift
132 local codename=$1
133 shift
9f95a23c
TL
134 local force=$1
135 shift
11fdf7f2
TL
136 local pkgs=$@
137 local missing_pkgs
9f95a23c
TL
138 if [ $force = "force" ]; then
139 missing_pkgs="$@"
140 else
141 for pkg in $pkgs; do
142 if ! apt -qq list $pkg 2>/dev/null | grep -q installed; then
143 missing_pkgs+=" $pkg"
144 fi
145 done
146 fi
11fdf7f2
TL
147 if test -n "$missing_pkgs"; then
148 local shaman_url="https://shaman.ceph.com/api/repos/${project}/master/${sha1}/ubuntu/${codename}/repo"
149 $SUDO curl --silent --location $shaman_url --output /etc/apt/sources.list.d/$project.list
150 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y -o Acquire::Languages=none -o Acquire::Translation=none || true
151 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install --allow-unauthenticated -y $missing_pkgs
152 fi
b32b8144
FG
153}
154
11fdf7f2
TL
155function install_boost_on_ubuntu {
156 local codename=$1
9f95a23c 157 if apt -qq list ceph-libboost1.67-dev 2>/dev/null | grep -q installed; then
92f5a8d4
TL
158 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove 'ceph-libboost.*1.67.*'
159 $SUDO rm /etc/apt/sources.list.d/ceph-libboost1.67.list
160 fi
161 local project=libboost
162 local ver=1.72
163 local sha1=1d7c7a00cc3f37e340bae0360191a757b44ec80c
11fdf7f2 164 install_pkg_on_ubuntu \
92f5a8d4
TL
165 $project \
166 $sha1 \
11fdf7f2 167 $codename \
9f95a23c 168 check \
92f5a8d4
TL
169 ceph-libboost-atomic$ver-dev \
170 ceph-libboost-chrono$ver-dev \
171 ceph-libboost-container$ver-dev \
172 ceph-libboost-context$ver-dev \
173 ceph-libboost-coroutine$ver-dev \
174 ceph-libboost-date-time$ver-dev \
175 ceph-libboost-filesystem$ver-dev \
176 ceph-libboost-iostreams$ver-dev \
177 ceph-libboost-program-options$ver-dev \
178 ceph-libboost-python$ver-dev \
179 ceph-libboost-random$ver-dev \
180 ceph-libboost-regex$ver-dev \
181 ceph-libboost-system$ver-dev \
182 ceph-libboost-test$ver-dev \
183 ceph-libboost-thread$ver-dev \
184 ceph-libboost-timer$ver-dev
11fdf7f2
TL
185}
186
187function version_lt {
188 test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
189}
190
191function ensure_decent_gcc_on_rh {
192 local old=$(gcc -dumpversion)
193 local expected=5.1
194 local dts_ver=$1
195 if version_lt $old $expected; then
196 if test -t 1; then
197 # interactive shell
198 cat <<EOF
199Your GCC is too old. Please run following command to add DTS to your environment:
200
eafe8130 201scl enable devtoolset-8 bash
11fdf7f2
TL
202
203Or add following line to the end of ~/.bashrc to add it permanently:
204
eafe8130 205source scl_source enable devtoolset-8
11fdf7f2
TL
206
207see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
208EOF
209 else
210 # non-interactive shell
211 source /opt/rh/devtoolset-$dts_ver/enable
212 fi
213 fi
214}
215
9f95a23c
TL
216for_make_check=false
217if tty -s; then
218 # interactive
219 for_make_check=true
220elif [ $FOR_MAKE_CHECK ]; then
221 for_make_check=true
222else
223 for_make_check=false
224fi
225
11fdf7f2 226if [ x$(uname)x = xFreeBSDx ]; then
7c673cae 227 $SUDO pkg install -yq \
c07f9fc5 228 devel/babeltrace \
11fdf7f2 229 devel/binutils \
7c673cae 230 devel/git \
31f18b77 231 devel/gperf \
7c673cae
FG
232 devel/gmake \
233 devel/cmake \
234 devel/yasm \
235 devel/boost-all \
236 devel/boost-python-libs \
237 devel/valgrind \
238 devel/pkgconf \
7c673cae
FG
239 devel/libedit \
240 devel/libtool \
241 devel/google-perftools \
242 lang/cython \
243 devel/py-virtualenv \
244 databases/leveldb \
11fdf7f2 245 net/openldap24-client \
7c673cae 246 archivers/snappy \
11fdf7f2 247 archivers/liblz4 \
7c673cae
FG
248 ftp/curl \
249 misc/e2fsprogs-libuuid \
250 misc/getopt \
224ce89b 251 net/socat \
7c673cae
FG
252 textproc/expat2 \
253 textproc/gsed \
f64942e4 254 lang/gawk \
7c673cae
FG
255 textproc/libxml2 \
256 textproc/xmlstarlet \
c07f9fc5
FG
257 textproc/jq \
258 textproc/py-sphinx \
7c673cae
FG
259 emulators/fuse \
260 java/junit \
11fdf7f2 261 lang/python36 \
c07f9fc5 262 devel/py-pip \
11fdf7f2 263 devel/py-flake8 \
9f95a23c 264 devel/py-tox \
7c673cae
FG
265 devel/py-argparse \
266 devel/py-nose \
c07f9fc5 267 devel/py-prettytable \
11fdf7f2 268 www/py-routes \
7c673cae 269 www/py-flask \
11fdf7f2
TL
270 www/node \
271 www/npm \
7c673cae 272 www/fcgi \
11fdf7f2 273 security/nss \
9f95a23c 274 security/krb5 \
11fdf7f2 275 security/oath-toolkit \
7c673cae
FG
276 sysutils/flock \
277 sysutils/fusefs-libs \
278
31f18b77
FG
279 # Now use pip to install some extra python modules
280 pip install pecan
281
7c673cae
FG
282 exit
283else
9f95a23c 284 [ $WITH_SEASTAR ] && with_seastar=true || with_seastar=false
7c673cae 285 source /etc/os-release
eafe8130 286 case "$ID" in
7c673cae
FG
287 debian|ubuntu|devuan)
288 echo "Using apt-get to install dependencies"
11fdf7f2
TL
289 $SUDO apt-get install -y devscripts equivs
290 $SUDO apt-get install -y dpkg-dev
b32b8144 291 case "$VERSION" in
11fdf7f2 292 *Bionic*)
9f95a23c
TL
293 ensure_decent_gcc_on_ubuntu 9 bionic
294 [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu bionic
295 ;;
296 *Disco*)
297 [ ! $NO_BOOST_PKGS ] && apt-get install -y libboost1.67-all-dev
11fdf7f2
TL
298 ;;
299 *)
300 $SUDO apt-get install -y gcc
b32b8144
FG
301 ;;
302 esac
7c673cae
FG
303 if ! test -r debian/control ; then
304 echo debian/control is not a readable file
305 exit 1
306 fi
307 touch $DIR/status
308
309 backports=""
9f95a23c 310 control=$(munge_debian_control "$VERSION" "$with_seastar" "$for_make_check" "debian/control")
11fdf7f2
TL
311 case "$VERSION" in
312 *squeeze*|*wheezy*)
313 backports="-t $codename-backports"
7c673cae
FG
314 ;;
315 esac
316
317 # make a metapackage that expresses the build dependencies,
318 # install it, rm the .deb; then uninstall the package as its
319 # work is done
320 $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
321 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
11fdf7f2 322 if [ "$control" != "debian/control" ] ; then rm $control; fi
7c673cae
FG
323 ;;
324 centos|fedora|rhel|ol|virtuozzo)
9f95a23c
TL
325 yumdnf="dnf"
326 builddepcmd="dnf -y builddep --allowerasing"
327 if [[ $ID =~ centos|rhel ]] && version_lt $VERSION_ID 8; then
328 yumdnf="yum"
329 builddepcmd="yum-builddep -y --setopt=*.skip_if_unavailable=true"
7c673cae
FG
330 fi
331 echo "Using $yumdnf to install dependencies"
eafe8130 332 if [ "$ID" = "centos" -a "$ARCH" = "aarch64" ]; then
11fdf7f2
TL
333 $SUDO yum-config-manager --disable centos-sclo-sclo || true
334 $SUDO yum-config-manager --disable centos-sclo-rh || true
335 $SUDO yum remove centos-release-scl || true
336 fi
eafe8130 337 case "$ID" in
11fdf7f2 338 fedora)
9f95a23c 339 $SUDO $yumdnf install -y $yumdnf-utils
7c673cae 340 ;;
11fdf7f2
TL
341 centos|rhel|ol|virtuozzo)
342 MAJOR_VERSION="$(echo $VERSION_ID | cut -d. -f1)"
9f95a23c 343 $SUDO $yumdnf install -y $yumdnf-utils
eafe8130 344 rpm --quiet --query epel-release || \
9f95a23c 345 $SUDO $yumdnf -y install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-$MAJOR_VERSION.noarch.rpm
7c673cae
FG
346 $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
347 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
11fdf7f2 348 if test $ID = centos -a $MAJOR_VERSION = 7 ; then
eafe8130 349 case "$ARCH" in
11fdf7f2 350 x86_64)
9f95a23c 351 $SUDO $yumdnf -y install centos-release-scl
eafe8130 352 dts_ver=8
11fdf7f2
TL
353 ;;
354 aarch64)
9f95a23c 355 $SUDO $yumdnf -y install centos-release-scl-rh
11fdf7f2
TL
356 $SUDO yum-config-manager --disable centos-sclo-rh
357 $SUDO yum-config-manager --enable centos-sclo-rh-testing
92f5a8d4 358 dts_ver=8
11fdf7f2
TL
359 ;;
360 esac
361 elif test $ID = rhel -a $MAJOR_VERSION = 7 ; then
eafe8130
TL
362 $SUDO yum-config-manager \
363 --enable rhel-server-rhscl-7-rpms \
9f95a23c 364 --enable rhel-7-server-optional-rpms \
eafe8130
TL
365 --enable rhel-7-server-devtools-rpms
366 dts_ver=8
9f95a23c
TL
367 elif test $ID = centos -a $MAJOR_VERSION = 8 ; then
368 $SUDO dnf config-manager --set-enabled PowerTools
369 # before EPEL8 and PowerTools provide all dependencies, we use sepia for the dependencies
370 $SUDO dnf config-manager --add-repo http://apt-mirror.front.sepia.ceph.com/lab-extras/8/
371 $SUDO dnf config-manager --setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck=0 --save
372 $SUDO dnf copr enable -y ktdreyer/ceph-el8
373 elif test $ID = rhel -a $MAJOR_VERSION = 8 ; then
374 $SUDO subscription-manager repos --enable "codeready-builder-for-rhel-8-*-rpms"
375 $SUDO dnf config-manager --add-repo http://apt-mirror.front.sepia.ceph.com/lab-extras/8/
376 $SUDO dnf config-manager --setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck=0 --save
377 $SUDO dnf copr enable -y ktdreyer/ceph-el8
7c673cae
FG
378 fi
379 ;;
380 esac
9f95a23c
TL
381 munge_ceph_spec_in $with_seastar $for_make_check $DIR/ceph.spec
382 # for python3_pkgversion macro defined by python-srpm-macros, which is required by python3-devel
383 $SUDO $yumdnf install -y python3-devel
7c673cae 384 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
11fdf7f2
TL
385 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
386 if [ -n "$dts_ver" ]; then
387 ensure_decent_gcc_on_rh $dts_ver
388 fi
9f95a23c
TL
389 IGNORE_YUM_BUILDEP_ERRORS="ValueError: SELinux policy is not managed or store cannot be accessed."
390 sed "/$IGNORE_YUM_BUILDEP_ERRORS/d" $DIR/yum-builddep.out | grep -qi "error:" && exit 1
7c673cae 391 ;;
1adf2230 392 opensuse*|suse|sles)
7c673cae 393 echo "Using zypper to install dependencies"
11fdf7f2 394 zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
92f5a8d4 395 $SUDO $zypp_install systemd-rpm-macros rpm-build || exit 1
9f95a23c 396 munge_ceph_spec_in $with_seastar $for_make_check $DIR/ceph.spec
11fdf7f2 397 $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
7c673cae
FG
398 ;;
399 alpine)
400 # for now we need the testing repo for leveldb
401 TESTREPO="http://nl.alpinelinux.org/alpine/edge/testing"
402 if ! grep -qF "$TESTREPO" /etc/apk/repositories ; then
403 $SUDO echo "$TESTREPO" | sudo tee -a /etc/apk/repositories > /dev/null
404 fi
405 source alpine/APKBUILD.in
406 $SUDO apk --update add abuild build-base ccache $makedepends
407 if id -u build >/dev/null 2>&1 ; then
408 $SUDO addgroup build abuild
409 fi
410 ;;
411 *)
412 echo "$ID is unknown, dependencies will have to be installed manually."
413 exit 1
414 ;;
415 esac
416fi
417
418function populate_wheelhouse() {
419 local install=$1
420 shift
421
422 # although pip comes with virtualenv, having a recent version
423 # of pip matters when it comes to using wheel packages
9f95a23c
TL
424 PIP_OPTS="--timeout 300 --exists-action i"
425 pip $PIP_OPTS $install \
426 'setuptools >= 0.8' 'pip >= 7.0' 'wheel >= 0.24' 'tox >= 2.9.1' || return 1
7c673cae 427 if test $# != 0 ; then
9f95a23c 428 pip $PIP_OPTS $install $@ || return 1
7c673cae
FG
429 fi
430}
431
432function activate_virtualenv() {
433 local top_srcdir=$1
9f95a23c 434 local env_dir=$top_srcdir/install-deps-python3
7c673cae
FG
435
436 if ! test -d $env_dir ; then
9f95a23c 437 virtualenv --python=python3 ${env_dir}
7c673cae
FG
438 . $env_dir/bin/activate
439 if ! populate_wheelhouse install ; then
440 rm -rf $env_dir
441 return 1
442 fi
443 fi
444 . $env_dir/bin/activate
445}
446
9f95a23c
TL
447function preload_wheels_for_tox() {
448 local ini=$1
449 shift
450 pushd . > /dev/null
451 cd $(dirname $ini)
452 local require_files=$(ls *requirements*.txt 2>/dev/null) || true
453 local constraint_files=$(ls *constraints*.txt 2>/dev/null) || true
454 local require=$(echo -n "$require_files" | sed -e 's/^/-r /')
455 local constraint=$(echo -n "$constraint_files" | sed -e 's/^/-c /')
456 local md5=wheelhouse/md5
457 if test "$require"; then
458 if ! test -f $md5 || ! md5sum -c $md5 > /dev/null; then
459 rm -rf wheelhouse
460 fi
461 fi
462 if test "$require" && ! test -d wheelhouse ; then
463 type python3 > /dev/null 2>&1 || continue
464 activate_virtualenv $top_srcdir || exit 1
465 populate_wheelhouse "wheel -w $wip_wheelhouse" $require $constraint || exit 1
466 mv $wip_wheelhouse wheelhouse
467 md5sum $require_files $constraint_files > $md5
468 fi
469 popd > /dev/null
470}
471
7c673cae
FG
472# use pip cache if possible but do not store it outside of the source
473# tree
474# see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
9f95a23c
TL
475if $for_make_check; then
476 mkdir -p install-deps-cache
477 top_srcdir=$(pwd)
478 export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
479 wip_wheelhouse=wheelhouse-wip
480 #
481 # preload python modules so that tox can run without network access
482 #
483 find . -name tox.ini | while read ini ; do
484 preload_wheels_for_tox $ini
485 done
486 rm -rf $top_srcdir/install-deps-python3
487 rm -rf $XDG_CACHE_HOME
488 type git > /dev/null || (echo "Dashboard uses git to pull dependencies." ; false)
489fi