]> git.proxmox.com Git - ceph.git/blob - ceph/install-deps.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / install-deps.sh
1 #!/usr/bin/env bash
2 # -*- mode:sh; tab-width:8; indent-tabs-mode:t -*-
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 #
15 set -e
16 DIR=/tmp/install-deps.$$
17 trap "rm -fr $DIR" EXIT
18 mkdir -p $DIR
19 if test $(id -u) != 0 ; then
20 SUDO=sudo
21 fi
22 export LC_ALL=C # the following is vulnerable to i18n
23
24 ARCH=$(uname -m)
25
26 function 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
35 function munge_ceph_spec_in {
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 $for_make_check; then
45 sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE
46 fi
47 }
48
49 function 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
67 function 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)
71 local new=$1
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
79 deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
80 deb [arch=amd64 lang=none] http://mirror.cs.uchicago.edu/ubuntu-toolchain-r $codename main
81 deb [arch=amd64,i386 lang=none] http://mirror.yandex.ru/mirrors/launchpad/ubuntu-toolchain-r $codename main
82 EOF
83 # import PPA's signing key into APT's keyring
84 cat << ENDOFKEY | $SUDO apt-key add -
85 -----BEGIN PGP PUBLIC KEY BLOCK-----
86 Version: SKS 1.1.6
87 Comment: Hostname: keyserver.ubuntu.com
88
89 mI0ESuBvRwEEAMi4cDba7xlKaaoXjO1n1HX8RKrkW+HEIl79nSOSJyvzysajs7zUow/OzCQp
90 9NswqrDmNuH1+lPTTRNAGtK8r2ouq2rnXT1mTl23dpgHZ9spseR73s4ZBGw/ag4bpU5dNUSt
91 vfmHhIjVCuiSpNn7cyy1JSSvSs3N2mxteKjXLBf7ABEBAAG0GkxhdW5jaHBhZCBUb29sY2hh
92 aW4gYnVpbGRziLYEEwECACAFAkrgb0cCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAe
93 k3eiup7yfzGKA/4xzUqNACSlB+k+DxFFHqkwKa/ziFiAlkLQyyhm+iqz80htRZr7Ls/ZRYZl
94 0aSU56/hLe0V+TviJ1s8qdN2lamkKdXIAFfavA04nOnTzyIBJ82EAUT3Nh45skMxo4z4iZMN
95 msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ==
96 =LcUQ
97 -----END PGP PUBLIC KEY BLOCK-----
98 ENDOFKEY
99 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
100 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-7
101 fi
102
103 case $codename in
104 trusty)
105 old=4.8;;
106 xenial)
107 old=5;;
108 esac
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
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
119
120 $SUDO update-alternatives --auto gcc
121
122 # cmake uses the latter by default
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
127 function 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
147 }
148
149 function 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
172 function version_lt {
173 test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
174 }
175
176 function 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
184 Your GCC is too old. Please run following command to add DTS to your environment:
185
186 scl enable devtoolset-7 bash
187
188 Or add following line to the end of ~/.bashrc to add it permanently:
189
190 source scl_source enable devtoolset-7
191
192 see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
193 EOF
194 else
195 # non-interactive shell
196 source /opt/rh/devtoolset-$dts_ver/enable
197 fi
198 fi
199 }
200
201 if [ x$(uname)x = xFreeBSDx ]; then
202 $SUDO pkg install -yq \
203 devel/babeltrace \
204 devel/binutils \
205 devel/git \
206 devel/gperf \
207 devel/gmake \
208 devel/cmake \
209 devel/yasm \
210 devel/boost-all \
211 devel/boost-python-libs \
212 devel/valgrind \
213 devel/pkgconf \
214 devel/libedit \
215 devel/libtool \
216 devel/google-perftools \
217 lang/cython \
218 devel/py-virtualenv \
219 databases/leveldb \
220 net/openldap24-client \
221 archivers/snappy \
222 archivers/liblz4 \
223 ftp/curl \
224 misc/e2fsprogs-libuuid \
225 misc/getopt \
226 net/socat \
227 textproc/expat2 \
228 textproc/gsed \
229 lang/gawk \
230 textproc/libxml2 \
231 textproc/xmlstarlet \
232 textproc/jq \
233 textproc/py-sphinx \
234 emulators/fuse \
235 java/junit \
236 lang/python \
237 lang/python27 \
238 lang/python36 \
239 devel/py-pip \
240 devel/py-flake8 \
241 devel/py-argparse \
242 devel/py-nose \
243 devel/py-prettytable \
244 www/py-routes \
245 www/py-flask \
246 www/node \
247 www/npm \
248 www/fcgi \
249 security/nss \
250 security/kbr5 \
251 security/oath-toolkit \
252 sysutils/flock \
253 sysutils/fusefs-libs \
254
255 # Now use pip to install some extra python modules
256 pip install pecan
257
258 exit
259 else
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
269 source /etc/os-release
270 case $ID in
271 debian|ubuntu|devuan)
272 echo "Using apt-get to install dependencies"
273 $SUDO apt-get install -y devscripts equivs
274 $SUDO apt-get install -y dpkg-dev
275 case "$VERSION" in
276 *Trusty*)
277 ensure_decent_gcc_on_ubuntu 7 trusty
278 ;;
279 *Xenial*)
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
288 ;;
289 esac
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=""
297 control=$(munge_debian_control "$VERSION" "$for_make_check" "debian/control")
298 case "$VERSION" in
299 *squeeze*|*wheezy*)
300 backports="-t $codename-backports"
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
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
312 ;;
313 centos|fedora|rhel|ol|virtuozzo)
314 yumdnf="yum"
315 builddepcmd="yum-builddep -y --setopt=*.skip_if_unavailable=true"
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"
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)
328 if test $yumdnf = yum; then
329 $SUDO $yumdnf install -y yum-utils
330 fi
331 ;;
332 centos|rhel|ol|virtuozzo)
333 MAJOR_VERSION="$(echo $VERSION_ID | cut -d. -f1)"
334 $SUDO yum install -y yum-utils
335 if test $ID = rhel ; then
336 $SUDO yum-config-manager --enable rhel-$MAJOR_VERSION-server-optional-rpms
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*
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
358 fi
359 ;;
360 esac
361 munge_ceph_spec_in $for_make_check $DIR/ceph.spec
362 $SUDO $yumdnf install -y \*rpm-macros
363 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
364 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
365 if [ -n "$dts_ver" ]; then
366 ensure_decent_gcc_on_rh $dts_ver
367 fi
368 ! grep -q -i error: $DIR/yum-builddep.out || exit 1
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
371 ;;
372 opensuse*|suse|sles)
373 echo "Using zypper to install dependencies"
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
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
397 fi
398
399 function 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
405 pip --timeout 300 $install 'setuptools >= 0.8' 'pip >= 7.0' 'wheel >= 0.24' || return 1
406 if test $# != 0 ; then
407 pip --timeout 300 $install $@ || return 1
408 fi
409 }
410
411 function 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
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
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
440 mkdir -p install-deps-cache
441 top_srcdir=$(pwd)
442 export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
443 wip_wheelhouse=wheelhouse-wip
444
445 #
446 # preload python modules so that tox can run without network access
447 #
448 find . -name tox.ini | while read ini ; do
449 (
450 cd $(dirname $ini)
451 require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
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
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
465 md5sum *requirements.txt > $md5
466 fi
467 )
468 done
469
470 for interpreter in python2.7 python3 ; do
471 rm -rf $top_srcdir/install-deps-$interpreter
472 done
473 rm -rf $XDG_CACHE_HOME
474 git --version || (echo "Dashboard uses git to pull dependencies." ; false)