]> git.proxmox.com Git - ceph.git/blame - ceph/install-deps.sh
update sources to ceph Nautilus 14.2.1
[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
TL
72 local codename=$2
73 if dpkg --compare-versions $old ge 7.0; then
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
100 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-7
b32b8144
FG
101 fi
102
11fdf7f2
TL
103 case $codename in
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
11fdf7f2
TL
123 $SUDO ln -nsf /usr/bin/gcc /usr/bin/$(uname -m)-linux-gnu-gcc
124 $SUDO ln -nsf /usr/bin/g++ /usr/bin/$(uname -m)-linux-gnu-g++
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
186scl enable devtoolset-7 bash
187
188Or add following line to the end of ~/.bashrc to add it permanently:
189
190source scl_source enable devtoolset-7
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
FG
269 source /etc/os-release
270 case $ID in
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*)
11fdf7f2 277 ensure_decent_gcc_on_ubuntu 7 trusty
b32b8144
FG
278 ;;
279 *Xenial*)
11fdf7f2
TL
280 ensure_decent_gcc_on_ubuntu 7 xenial
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"
11fdf7f2
TL
321 if [ "$ID" = "centos" -a $(uname -m) = aarch64 ]; then
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
326 case $ID in
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
FG
337 fi
338 $SUDO yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/$MAJOR_VERSION/x86_64/
339 $SUDO yum install --nogpgcheck -y epel-release
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
TL
342 if test $ID = centos -a $MAJOR_VERSION = 7 ; then
343 case $(uname -m) in
344 x86_64)
345 $SUDO yum -y install centos-release-scl
346 dts_ver=7
347 ;;
348 aarch64)
349 $SUDO yum -y install centos-release-scl-rh
350 $SUDO yum-config-manager --disable centos-sclo-rh
351 $SUDO yum-config-manager --enable centos-sclo-rh-testing
352 dts_ver=7
353 ;;
354 esac
355 elif test $ID = rhel -a $MAJOR_VERSION = 7 ; then
356 $SUDO yum-config-manager --enable rhel-server-rhscl-7-rpms
357 dts_ver=7
7c673cae
FG
358 fi
359 ;;
360 esac
11fdf7f2
TL
361 munge_ceph_spec_in $for_make_check $DIR/ceph.spec
362 $SUDO $yumdnf install -y \*rpm-macros
7c673cae 363 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
11fdf7f2
TL
364 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
365 if [ -n "$dts_ver" ]; then
366 ensure_decent_gcc_on_rh $dts_ver
367 fi
7c673cae 368 ! grep -q -i error: $DIR/yum-builddep.out || exit 1
11fdf7f2
TL
369 # for building python-saml and its dependencies
370 $SUDO $yumdnf install -y xmlsec1 xmlsec1-nss xmlsec1-openssl xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel
7c673cae 371 ;;
1adf2230 372 opensuse*|suse|sles)
7c673cae 373 echo "Using zypper to install dependencies"
11fdf7f2
TL
374 zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
375 $SUDO $zypp_install systemd-rpm-macros
376 munge_ceph_spec_in $for_make_check $DIR/ceph.spec
377 $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
378 $SUDO $zypp_install libxmlsec1-1 libxmlsec1-nss1 libxmlsec1-openssl1 xmlsec1-devel xmlsec1-openssl-devel
7c673cae
FG
379 ;;
380 alpine)
381 # for now we need the testing repo for leveldb
382 TESTREPO="http://nl.alpinelinux.org/alpine/edge/testing"
383 if ! grep -qF "$TESTREPO" /etc/apk/repositories ; then
384 $SUDO echo "$TESTREPO" | sudo tee -a /etc/apk/repositories > /dev/null
385 fi
386 source alpine/APKBUILD.in
387 $SUDO apk --update add abuild build-base ccache $makedepends
388 if id -u build >/dev/null 2>&1 ; then
389 $SUDO addgroup build abuild
390 fi
391 ;;
392 *)
393 echo "$ID is unknown, dependencies will have to be installed manually."
394 exit 1
395 ;;
396 esac
397fi
398
399function populate_wheelhouse() {
400 local install=$1
401 shift
402
403 # although pip comes with virtualenv, having a recent version
404 # of pip matters when it comes to using wheel packages
11fdf7f2 405 pip --timeout 300 $install 'setuptools >= 0.8' 'pip >= 7.0' 'wheel >= 0.24' || return 1
7c673cae
FG
406 if test $# != 0 ; then
407 pip --timeout 300 $install $@ || return 1
408 fi
409}
410
411function activate_virtualenv() {
412 local top_srcdir=$1
413 local interpreter=$2
414 local env_dir=$top_srcdir/install-deps-$interpreter
415
416 if ! test -d $env_dir ; then
417 # Make a temporary virtualenv to get a fresh version of virtualenv
418 # because CentOS 7 has a buggy old version (v1.10.1)
419 # https://github.com/pypa/virtualenv/issues/463
420 virtualenv ${env_dir}_tmp
11fdf7f2
TL
421 # install setuptools before upgrading virtualenv, as the latter needs
422 # a recent setuptools for setup commands like `extras_require`.
423 ${env_dir}_tmp/bin/pip install --upgrade setuptools
7c673cae
FG
424 ${env_dir}_tmp/bin/pip install --upgrade virtualenv
425 ${env_dir}_tmp/bin/virtualenv --python $interpreter $env_dir
426 rm -rf ${env_dir}_tmp
427
428 . $env_dir/bin/activate
429 if ! populate_wheelhouse install ; then
430 rm -rf $env_dir
431 return 1
432 fi
433 fi
434 . $env_dir/bin/activate
435}
436
437# use pip cache if possible but do not store it outside of the source
438# tree
439# see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
440mkdir -p install-deps-cache
441top_srcdir=$(pwd)
442export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
443wip_wheelhouse=wheelhouse-wip
444
445#
446# preload python modules so that tox can run without network access
447#
448find . -name tox.ini | while read ini ; do
449 (
450 cd $(dirname $ini)
451 require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
11fdf7f2
TL
452 md5=wheelhouse/md5
453 if test "$require"; then
454 if ! test -f $md5 || ! md5sum -c $md5 ; then
455 rm -rf wheelhouse
456 fi
457 fi
7c673cae
FG
458 if test "$require" && ! test -d wheelhouse ; then
459 for interpreter in python2.7 python3 ; do
460 type $interpreter > /dev/null 2>&1 || continue
461 activate_virtualenv $top_srcdir $interpreter || exit 1
462 populate_wheelhouse "wheel -w $wip_wheelhouse" $require || exit 1
463 done
464 mv $wip_wheelhouse wheelhouse
11fdf7f2 465 md5sum *requirements.txt > $md5
7c673cae
FG
466 fi
467 )
468done
469
470for interpreter in python2.7 python3 ; do
471 rm -rf $top_srcdir/install-deps-$interpreter
472done
473rm -rf $XDG_CACHE_HOME
11fdf7f2 474git --version || (echo "Dashboard uses git to pull dependencies." ; false)