]> git.proxmox.com Git - ceph.git/blame - ceph/install-deps.sh
bump version to 14.2.6-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
26function install_seastar_deps {
27 if [ $WITH_SEASTAR ]; then
28 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y \
29 ragel libc-ares-dev libhwloc-dev libnuma-dev libpciaccess-dev \
30 libcrypto++-dev libgnutls28-dev libsctp-dev libprotobuf-dev \
31 protobuf-compiler systemtap-sdt-dev libyaml-cpp-dev
32 fi
33}
34
c07f9fc5 35function munge_ceph_spec_in {
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
41 if [ $WITH_SEASTAR ]; then
42 sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE
43 fi
44 if $for_make_check; then
45 sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE
46 fi
c07f9fc5
FG
47}
48
11fdf7f2
TL
49function munge_debian_control {
50 local version=$1
51 shift
52 local for_make_check=$1
53 shift
54 local control=$1
55 case "$version" in
56 *squeeze*|*wheezy*)
57 control="/tmp/control.$$"
58 grep -v babeltrace debian/control > $control
59 ;;
60 esac
61 if $for_make_check; then
62 sed -i 's/^# Make-Check[[:space:]]/ /g' $control
63 fi
64 echo $control
65}
66
67function ensure_decent_gcc_on_ubuntu {
68 # point gcc to the one offered by g++-7 if the used one is not
69 # new enough
70 local old=$(gcc -dumpfullversion -dumpversion)
b32b8144 71 local new=$1
11fdf7f2 72 local codename=$2
eafe8130 73 if dpkg --compare-versions $old ge ${new}.0; then
11fdf7f2
TL
74 return
75 fi
76
77 if [ ! -f /usr/bin/g++-${new} ]; then
78 $SUDO tee /etc/apt/sources.list.d/ubuntu-toolchain-r.list <<EOF
79deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
80deb [arch=amd64 lang=none] http://mirror.cs.uchicago.edu/ubuntu-toolchain-r $codename main
81deb [arch=amd64,i386 lang=none] http://mirror.yandex.ru/mirrors/launchpad/ubuntu-toolchain-r $codename main
82EOF
83 # import PPA's signing key into APT's keyring
84 cat << ENDOFKEY | $SUDO apt-key add -
85-----BEGIN PGP PUBLIC KEY BLOCK-----
86Version: SKS 1.1.6
87Comment: Hostname: keyserver.ubuntu.com
88
89mI0ESuBvRwEEAMi4cDba7xlKaaoXjO1n1HX8RKrkW+HEIl79nSOSJyvzysajs7zUow/OzCQp
909NswqrDmNuH1+lPTTRNAGtK8r2ouq2rnXT1mTl23dpgHZ9spseR73s4ZBGw/ag4bpU5dNUSt
91vfmHhIjVCuiSpNn7cyy1JSSvSs3N2mxteKjXLBf7ABEBAAG0GkxhdW5jaHBhZCBUb29sY2hh
92aW4gYnVpbGRziLYEEwECACAFAkrgb0cCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAe
93k3eiup7yfzGKA/4xzUqNACSlB+k+DxFFHqkwKa/ziFiAlkLQyyhm+iqz80htRZr7Ls/ZRYZl
940aSU56/hLe0V+TviJ1s8qdN2lamkKdXIAFfavA04nOnTzyIBJ82EAUT3Nh45skMxo4z4iZMN
95msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ==
96=LcUQ
97-----END PGP PUBLIC KEY BLOCK-----
98ENDOFKEY
99 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
eafe8130 100 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-${new}
b32b8144
FG
101 fi
102
eafe8130 103 case "$codename" in
11fdf7f2 104 trusty)
b32b8144 105 old=4.8;;
11fdf7f2 106 xenial)
b32b8144 107 old=5;;
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
134 local pkgs=$@
135 local missing_pkgs
136 for pkg in $pkgs; do
137 if ! dpkg -s $pkg &> /dev/null; then
138 missing_pkgs+=" $pkg"
139 fi
140 done
141 if test -n "$missing_pkgs"; then
142 local shaman_url="https://shaman.ceph.com/api/repos/${project}/master/${sha1}/ubuntu/${codename}/repo"
143 $SUDO curl --silent --location $shaman_url --output /etc/apt/sources.list.d/$project.list
144 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y -o Acquire::Languages=none -o Acquire::Translation=none || true
145 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install --allow-unauthenticated -y $missing_pkgs
146 fi
b32b8144
FG
147}
148
11fdf7f2
TL
149function install_boost_on_ubuntu {
150 local codename=$1
151 install_pkg_on_ubuntu \
152 ceph-libboost1.67 \
153 dd38c27740c1f9a9e6719a07eef84a1369dc168b \
154 $codename \
155 ceph-libboost-atomic1.67-dev \
156 ceph-libboost-chrono1.67-dev \
157 ceph-libboost-container1.67-dev \
158 ceph-libboost-context1.67-dev \
159 ceph-libboost-coroutine1.67-dev \
160 ceph-libboost-date-time1.67-dev \
161 ceph-libboost-filesystem1.67-dev \
162 ceph-libboost-iostreams1.67-dev \
163 ceph-libboost-program-options1.67-dev \
164 ceph-libboost-python1.67-dev \
165 ceph-libboost-random1.67-dev \
166 ceph-libboost-regex1.67-dev \
167 ceph-libboost-system1.67-dev \
168 ceph-libboost-thread1.67-dev \
169 ceph-libboost-timer1.67-dev
170}
171
172function version_lt {
173 test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
174}
175
176function ensure_decent_gcc_on_rh {
177 local old=$(gcc -dumpversion)
178 local expected=5.1
179 local dts_ver=$1
180 if version_lt $old $expected; then
181 if test -t 1; then
182 # interactive shell
183 cat <<EOF
184Your GCC is too old. Please run following command to add DTS to your environment:
185
eafe8130 186scl enable devtoolset-8 bash
11fdf7f2
TL
187
188Or add following line to the end of ~/.bashrc to add it permanently:
189
eafe8130 190source scl_source enable devtoolset-8
11fdf7f2
TL
191
192see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
193EOF
194 else
195 # non-interactive shell
196 source /opt/rh/devtoolset-$dts_ver/enable
197 fi
198 fi
199}
200
201if [ x$(uname)x = xFreeBSDx ]; then
7c673cae 202 $SUDO pkg install -yq \
c07f9fc5 203 devel/babeltrace \
11fdf7f2 204 devel/binutils \
7c673cae 205 devel/git \
31f18b77 206 devel/gperf \
7c673cae
FG
207 devel/gmake \
208 devel/cmake \
209 devel/yasm \
210 devel/boost-all \
211 devel/boost-python-libs \
212 devel/valgrind \
213 devel/pkgconf \
7c673cae
FG
214 devel/libedit \
215 devel/libtool \
216 devel/google-perftools \
217 lang/cython \
218 devel/py-virtualenv \
219 databases/leveldb \
11fdf7f2 220 net/openldap24-client \
7c673cae 221 archivers/snappy \
11fdf7f2 222 archivers/liblz4 \
7c673cae
FG
223 ftp/curl \
224 misc/e2fsprogs-libuuid \
225 misc/getopt \
224ce89b 226 net/socat \
7c673cae
FG
227 textproc/expat2 \
228 textproc/gsed \
f64942e4 229 lang/gawk \
7c673cae
FG
230 textproc/libxml2 \
231 textproc/xmlstarlet \
c07f9fc5
FG
232 textproc/jq \
233 textproc/py-sphinx \
7c673cae
FG
234 emulators/fuse \
235 java/junit \
c07f9fc5 236 lang/python \
7c673cae 237 lang/python27 \
11fdf7f2 238 lang/python36 \
c07f9fc5 239 devel/py-pip \
11fdf7f2 240 devel/py-flake8 \
7c673cae
FG
241 devel/py-argparse \
242 devel/py-nose \
c07f9fc5 243 devel/py-prettytable \
11fdf7f2 244 www/py-routes \
7c673cae 245 www/py-flask \
11fdf7f2
TL
246 www/node \
247 www/npm \
7c673cae 248 www/fcgi \
11fdf7f2
TL
249 security/nss \
250 security/kbr5 \
251 security/oath-toolkit \
7c673cae
FG
252 sysutils/flock \
253 sysutils/fusefs-libs \
254
31f18b77
FG
255 # Now use pip to install some extra python modules
256 pip install pecan
257
7c673cae
FG
258 exit
259else
11fdf7f2
TL
260 for_make_check=false
261 if tty -s; then
262 # interactive
263 for_make_check=true
264 elif [ $FOR_MAKE_CHECK ]; then
265 for_make_check=true
266 else
267 for_make_check=false
268 fi
7c673cae 269 source /etc/os-release
eafe8130 270 case "$ID" in
7c673cae
FG
271 debian|ubuntu|devuan)
272 echo "Using apt-get to install dependencies"
11fdf7f2
TL
273 $SUDO apt-get install -y devscripts equivs
274 $SUDO apt-get install -y dpkg-dev
b32b8144
FG
275 case "$VERSION" in
276 *Trusty*)
eafe8130 277 ensure_decent_gcc_on_ubuntu 8 trusty
b32b8144
FG
278 ;;
279 *Xenial*)
eafe8130 280 ensure_decent_gcc_on_ubuntu 8 xenial
11fdf7f2
TL
281 install_boost_on_ubuntu xenial
282 ;;
283 *Bionic*)
284 install_boost_on_ubuntu bionic
285 ;;
286 *)
287 $SUDO apt-get install -y gcc
b32b8144
FG
288 ;;
289 esac
7c673cae
FG
290 if ! test -r debian/control ; then
291 echo debian/control is not a readable file
292 exit 1
293 fi
294 touch $DIR/status
295
296 backports=""
11fdf7f2
TL
297 control=$(munge_debian_control "$VERSION" "$for_make_check" "debian/control")
298 case "$VERSION" in
299 *squeeze*|*wheezy*)
300 backports="-t $codename-backports"
7c673cae
FG
301 ;;
302 esac
303
304 # make a metapackage that expresses the build dependencies,
305 # install it, rm the .deb; then uninstall the package as its
306 # work is done
307 $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
308 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
11fdf7f2
TL
309 install_seastar_deps
310 if [ "$control" != "debian/control" ] ; then rm $control; fi
311 $SUDO apt-get install -y libxmlsec1 libxmlsec1-nss libxmlsec1-openssl libxmlsec1-dev
7c673cae
FG
312 ;;
313 centos|fedora|rhel|ol|virtuozzo)
314 yumdnf="yum"
11fdf7f2 315 builddepcmd="yum-builddep -y --setopt=*.skip_if_unavailable=true"
7c673cae
FG
316 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
317 yumdnf="dnf"
318 builddepcmd="dnf -y builddep --allowerasing"
319 fi
320 echo "Using $yumdnf to install dependencies"
eafe8130 321 if [ "$ID" = "centos" -a "$ARCH" = "aarch64" ]; then
11fdf7f2
TL
322 $SUDO yum-config-manager --disable centos-sclo-sclo || true
323 $SUDO yum-config-manager --disable centos-sclo-rh || true
324 $SUDO yum remove centos-release-scl || true
325 fi
eafe8130 326 case "$ID" in
11fdf7f2 327 fedora)
7c673cae
FG
328 if test $yumdnf = yum; then
329 $SUDO $yumdnf install -y yum-utils
330 fi
331 ;;
11fdf7f2
TL
332 centos|rhel|ol|virtuozzo)
333 MAJOR_VERSION="$(echo $VERSION_ID | cut -d. -f1)"
7c673cae 334 $SUDO yum install -y yum-utils
11fdf7f2
TL
335 if test $ID = rhel ; then
336 $SUDO yum-config-manager --enable rhel-$MAJOR_VERSION-server-optional-rpms
7c673cae 337 fi
eafe8130
TL
338 rpm --quiet --query epel-release || \
339 $SUDO yum -y install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-$MAJOR_VERSION.noarch.rpm
7c673cae
FG
340 $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
341 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
11fdf7f2 342 if test $ID = centos -a $MAJOR_VERSION = 7 ; then
eafe8130
TL
343 $SUDO $yumdnf install -y python36-devel
344 case "$ARCH" in
11fdf7f2
TL
345 x86_64)
346 $SUDO yum -y install centos-release-scl
eafe8130 347 dts_ver=8
11fdf7f2
TL
348 ;;
349 aarch64)
350 $SUDO yum -y install centos-release-scl-rh
351 $SUDO yum-config-manager --disable centos-sclo-rh
352 $SUDO yum-config-manager --enable centos-sclo-rh-testing
353 dts_ver=7
354 ;;
355 esac
356 elif test $ID = rhel -a $MAJOR_VERSION = 7 ; then
eafe8130
TL
357 $SUDO yum-config-manager \
358 --enable rhel-server-rhscl-7-rpms \
359 --enable rhel-7-server-devtools-rpms
360 dts_ver=8
7c673cae
FG
361 fi
362 ;;
363 esac
11fdf7f2
TL
364 munge_ceph_spec_in $for_make_check $DIR/ceph.spec
365 $SUDO $yumdnf install -y \*rpm-macros
7c673cae 366 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
11fdf7f2
TL
367 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
368 if [ -n "$dts_ver" ]; then
369 ensure_decent_gcc_on_rh $dts_ver
370 fi
7c673cae 371 ! grep -q -i error: $DIR/yum-builddep.out || exit 1
11fdf7f2
TL
372 # for building python-saml and its dependencies
373 $SUDO $yumdnf install -y xmlsec1 xmlsec1-nss xmlsec1-openssl xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel
7c673cae 374 ;;
1adf2230 375 opensuse*|suse|sles)
7c673cae 376 echo "Using zypper to install dependencies"
11fdf7f2
TL
377 zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
378 $SUDO $zypp_install systemd-rpm-macros
379 munge_ceph_spec_in $for_make_check $DIR/ceph.spec
380 $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
381 $SUDO $zypp_install libxmlsec1-1 libxmlsec1-nss1 libxmlsec1-openssl1 xmlsec1-devel xmlsec1-openssl-devel
7c673cae
FG
382 ;;
383 alpine)
384 # for now we need the testing repo for leveldb
385 TESTREPO="http://nl.alpinelinux.org/alpine/edge/testing"
386 if ! grep -qF "$TESTREPO" /etc/apk/repositories ; then
387 $SUDO echo "$TESTREPO" | sudo tee -a /etc/apk/repositories > /dev/null
388 fi
389 source alpine/APKBUILD.in
390 $SUDO apk --update add abuild build-base ccache $makedepends
391 if id -u build >/dev/null 2>&1 ; then
392 $SUDO addgroup build abuild
393 fi
394 ;;
395 *)
396 echo "$ID is unknown, dependencies will have to be installed manually."
397 exit 1
398 ;;
399 esac
400fi
401
402function populate_wheelhouse() {
403 local install=$1
404 shift
405
406 # although pip comes with virtualenv, having a recent version
407 # of pip matters when it comes to using wheel packages
11fdf7f2 408 pip --timeout 300 $install 'setuptools >= 0.8' 'pip >= 7.0' 'wheel >= 0.24' || return 1
7c673cae
FG
409 if test $# != 0 ; then
410 pip --timeout 300 $install $@ || return 1
411 fi
412}
413
414function activate_virtualenv() {
415 local top_srcdir=$1
416 local interpreter=$2
417 local env_dir=$top_srcdir/install-deps-$interpreter
418
419 if ! test -d $env_dir ; then
420 # Make a temporary virtualenv to get a fresh version of virtualenv
421 # because CentOS 7 has a buggy old version (v1.10.1)
422 # https://github.com/pypa/virtualenv/issues/463
423 virtualenv ${env_dir}_tmp
11fdf7f2
TL
424 # install setuptools before upgrading virtualenv, as the latter needs
425 # a recent setuptools for setup commands like `extras_require`.
426 ${env_dir}_tmp/bin/pip install --upgrade setuptools
7c673cae
FG
427 ${env_dir}_tmp/bin/pip install --upgrade virtualenv
428 ${env_dir}_tmp/bin/virtualenv --python $interpreter $env_dir
429 rm -rf ${env_dir}_tmp
430
431 . $env_dir/bin/activate
432 if ! populate_wheelhouse install ; then
433 rm -rf $env_dir
434 return 1
435 fi
436 fi
437 . $env_dir/bin/activate
438}
439
440# use pip cache if possible but do not store it outside of the source
441# tree
442# see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
443mkdir -p install-deps-cache
444top_srcdir=$(pwd)
445export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
446wip_wheelhouse=wheelhouse-wip
447
448#
449# preload python modules so that tox can run without network access
450#
451find . -name tox.ini | while read ini ; do
452 (
453 cd $(dirname $ini)
454 require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
11fdf7f2
TL
455 md5=wheelhouse/md5
456 if test "$require"; then
457 if ! test -f $md5 || ! md5sum -c $md5 ; then
458 rm -rf wheelhouse
459 fi
460 fi
7c673cae
FG
461 if test "$require" && ! test -d wheelhouse ; then
462 for interpreter in python2.7 python3 ; do
463 type $interpreter > /dev/null 2>&1 || continue
464 activate_virtualenv $top_srcdir $interpreter || exit 1
465 populate_wheelhouse "wheel -w $wip_wheelhouse" $require || exit 1
466 done
467 mv $wip_wheelhouse wheelhouse
11fdf7f2 468 md5sum *requirements.txt > $md5
7c673cae
FG
469 fi
470 )
471done
472
473for interpreter in python2.7 python3 ; do
474 rm -rf $top_srcdir/install-deps-$interpreter
475done
476rm -rf $XDG_CACHE_HOME
11fdf7f2 477git --version || (echo "Dashboard uses git to pull dependencies." ; false)