]> git.proxmox.com Git - ceph.git/blob - ceph/install-deps.sh
import new upstream nautilus stable release 14.2.8
[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 ${new}.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++-${new}
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/${ARCH}-linux-gnu-gcc
124 $SUDO ln -nsf /usr/bin/g++ /usr/bin/${ARCH}-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 if dpkg -s ceph-libboost1.67-dev &> /dev/null; then
152 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove 'ceph-libboost.*1.67.*'
153 $SUDO rm /etc/apt/sources.list.d/ceph-libboost1.67.list
154 fi
155 local project=libboost
156 local ver=1.72
157 local sha1=1d7c7a00cc3f37e340bae0360191a757b44ec80c
158 install_pkg_on_ubuntu \
159 $project \
160 $sha1 \
161 $codename \
162 ceph-libboost-atomic$ver-dev \
163 ceph-libboost-chrono$ver-dev \
164 ceph-libboost-container$ver-dev \
165 ceph-libboost-context$ver-dev \
166 ceph-libboost-coroutine$ver-dev \
167 ceph-libboost-date-time$ver-dev \
168 ceph-libboost-filesystem$ver-dev \
169 ceph-libboost-iostreams$ver-dev \
170 ceph-libboost-program-options$ver-dev \
171 ceph-libboost-python$ver-dev \
172 ceph-libboost-random$ver-dev \
173 ceph-libboost-regex$ver-dev \
174 ceph-libboost-system$ver-dev \
175 ceph-libboost-test$ver-dev \
176 ceph-libboost-thread$ver-dev \
177 ceph-libboost-timer$ver-dev
178 }
179
180 function version_lt {
181 test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
182 }
183
184 function ensure_decent_gcc_on_rh {
185 local old=$(gcc -dumpversion)
186 local expected=5.1
187 local dts_ver=$1
188 if version_lt $old $expected; then
189 if test -t 1; then
190 # interactive shell
191 cat <<EOF
192 Your GCC is too old. Please run following command to add DTS to your environment:
193
194 scl enable devtoolset-8 bash
195
196 Or add following line to the end of ~/.bashrc to add it permanently:
197
198 source scl_source enable devtoolset-8
199
200 see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
201 EOF
202 else
203 # non-interactive shell
204 source /opt/rh/devtoolset-$dts_ver/enable
205 fi
206 fi
207 }
208
209 if [ x$(uname)x = xFreeBSDx ]; then
210 $SUDO pkg install -yq \
211 devel/babeltrace \
212 devel/binutils \
213 devel/git \
214 devel/gperf \
215 devel/gmake \
216 devel/cmake \
217 devel/yasm \
218 devel/boost-all \
219 devel/boost-python-libs \
220 devel/valgrind \
221 devel/pkgconf \
222 devel/libedit \
223 devel/libtool \
224 devel/google-perftools \
225 lang/cython \
226 devel/py-virtualenv \
227 databases/leveldb \
228 net/openldap24-client \
229 archivers/snappy \
230 archivers/liblz4 \
231 ftp/curl \
232 misc/e2fsprogs-libuuid \
233 misc/getopt \
234 net/socat \
235 textproc/expat2 \
236 textproc/gsed \
237 lang/gawk \
238 textproc/libxml2 \
239 textproc/xmlstarlet \
240 textproc/jq \
241 textproc/py-sphinx \
242 emulators/fuse \
243 java/junit \
244 lang/python \
245 lang/python27 \
246 lang/python36 \
247 devel/py-pip \
248 devel/py-flake8 \
249 devel/py-argparse \
250 devel/py-nose \
251 devel/py-prettytable \
252 www/py-routes \
253 www/py-flask \
254 www/node \
255 www/npm \
256 www/fcgi \
257 security/nss \
258 security/kbr5 \
259 security/oath-toolkit \
260 sysutils/flock \
261 sysutils/fusefs-libs \
262
263 # Now use pip to install some extra python modules
264 pip install pecan
265
266 exit
267 else
268 for_make_check=false
269 if tty -s; then
270 # interactive
271 for_make_check=true
272 elif [ $FOR_MAKE_CHECK ]; then
273 for_make_check=true
274 else
275 for_make_check=false
276 fi
277 source /etc/os-release
278 case "$ID" in
279 debian|ubuntu|devuan)
280 echo "Using apt-get to install dependencies"
281 $SUDO apt-get install -y devscripts equivs
282 $SUDO apt-get install -y dpkg-dev
283 case "$VERSION" in
284 *Trusty*)
285 ensure_decent_gcc_on_ubuntu 8 trusty
286 ;;
287 *Xenial*)
288 ensure_decent_gcc_on_ubuntu 8 xenial
289 install_boost_on_ubuntu xenial
290 ;;
291 *Bionic*)
292 install_boost_on_ubuntu bionic
293 ;;
294 *)
295 $SUDO apt-get install -y gcc
296 ;;
297 esac
298 if ! test -r debian/control ; then
299 echo debian/control is not a readable file
300 exit 1
301 fi
302 touch $DIR/status
303
304 backports=""
305 control=$(munge_debian_control "$VERSION" "$for_make_check" "debian/control")
306 case "$VERSION" in
307 *squeeze*|*wheezy*)
308 backports="-t $codename-backports"
309 ;;
310 esac
311
312 # make a metapackage that expresses the build dependencies,
313 # install it, rm the .deb; then uninstall the package as its
314 # work is done
315 $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
316 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
317 install_seastar_deps
318 if [ "$control" != "debian/control" ] ; then rm $control; fi
319 $SUDO apt-get install -y libxmlsec1 libxmlsec1-nss libxmlsec1-openssl libxmlsec1-dev
320 ;;
321 centos|fedora|rhel|ol|virtuozzo)
322 yumdnf="yum"
323 builddepcmd="yum-builddep -y --setopt=*.skip_if_unavailable=true"
324 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
325 yumdnf="dnf"
326 builddepcmd="dnf -y builddep --allowerasing"
327 fi
328 echo "Using $yumdnf to install dependencies"
329 if [ "$ID" = "centos" -a "$ARCH" = "aarch64" ]; then
330 $SUDO yum-config-manager --disable centos-sclo-sclo || true
331 $SUDO yum-config-manager --disable centos-sclo-rh || true
332 $SUDO yum remove centos-release-scl || true
333 fi
334 case "$ID" in
335 fedora)
336 if test $yumdnf = yum; then
337 $SUDO $yumdnf install -y yum-utils
338 fi
339 ;;
340 centos|rhel|ol|virtuozzo)
341 MAJOR_VERSION="$(echo $VERSION_ID | cut -d. -f1)"
342 $SUDO yum install -y yum-utils
343 if test $ID = rhel ; then
344 $SUDO yum-config-manager --enable rhel-$MAJOR_VERSION-server-optional-rpms
345 fi
346 rpm --quiet --query epel-release || \
347 $SUDO yum -y install --nogpgcheck https://dl.fedoraproject.org/pub/epel/epel-release-latest-$MAJOR_VERSION.noarch.rpm
348 $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
349 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
350 if test $ID = centos -a $MAJOR_VERSION = 7 ; then
351 $SUDO $yumdnf install -y python36-devel
352 case "$ARCH" in
353 x86_64)
354 $SUDO yum -y install centos-release-scl
355 dts_ver=8
356 ;;
357 aarch64)
358 $SUDO yum -y install centos-release-scl-rh
359 $SUDO yum-config-manager --disable centos-sclo-rh
360 $SUDO yum-config-manager --enable centos-sclo-rh-testing
361 dts_ver=8
362 ;;
363 esac
364 elif test $ID = rhel -a $MAJOR_VERSION = 7 ; then
365 $SUDO yum-config-manager \
366 --enable rhel-server-rhscl-7-rpms \
367 --enable rhel-7-server-devtools-rpms
368 dts_ver=8
369 fi
370 ;;
371 esac
372 munge_ceph_spec_in $for_make_check $DIR/ceph.spec
373 $SUDO $yumdnf install -y \*rpm-macros
374 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
375 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
376 if [ -n "$dts_ver" ]; then
377 ensure_decent_gcc_on_rh $dts_ver
378 fi
379 ! grep -q -i error: $DIR/yum-builddep.out || exit 1
380 # for building python-saml and its dependencies
381 $SUDO $yumdnf install -y xmlsec1 xmlsec1-nss xmlsec1-openssl xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel
382 ;;
383 opensuse*|suse|sles)
384 echo "Using zypper to install dependencies"
385 zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
386 $SUDO $zypp_install systemd-rpm-macros rpm-build || exit 1
387 if [ -e /usr/bin/python2 ] ; then
388 # see https://tracker.ceph.com/issues/23981
389 $SUDO $zypp_install python2-virtualenv python2-devel || exit 1
390 fi
391 munge_ceph_spec_in $for_make_check $DIR/ceph.spec
392 $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
393 $SUDO $zypp_install libxmlsec1-1 libxmlsec1-nss1 libxmlsec1-openssl1 xmlsec1-devel xmlsec1-openssl-devel
394 ;;
395 alpine)
396 # for now we need the testing repo for leveldb
397 TESTREPO="http://nl.alpinelinux.org/alpine/edge/testing"
398 if ! grep -qF "$TESTREPO" /etc/apk/repositories ; then
399 $SUDO echo "$TESTREPO" | sudo tee -a /etc/apk/repositories > /dev/null
400 fi
401 source alpine/APKBUILD.in
402 $SUDO apk --update add abuild build-base ccache $makedepends
403 if id -u build >/dev/null 2>&1 ; then
404 $SUDO addgroup build abuild
405 fi
406 ;;
407 *)
408 echo "$ID is unknown, dependencies will have to be installed manually."
409 exit 1
410 ;;
411 esac
412 fi
413
414 function populate_wheelhouse() {
415 local install=$1
416 shift
417
418 # although pip comes with virtualenv, having a recent version
419 # of pip matters when it comes to using wheel packages
420 pip --timeout 300 $install 'setuptools >= 0.8' 'pip >= 7.0' 'wheel >= 0.24' || return 1
421 if test $# != 0 ; then
422 pip --timeout 300 $install $@ || return 1
423 fi
424 }
425
426 function activate_virtualenv() {
427 local top_srcdir=$1
428 local interpreter=$2
429 local env_dir=$top_srcdir/install-deps-$interpreter
430
431 if ! test -d $env_dir ; then
432 # Make a temporary virtualenv to get a fresh version of virtualenv
433 # because CentOS 7 has a buggy old version (v1.10.1)
434 # https://github.com/pypa/virtualenv/issues/463
435 virtualenv ${env_dir}_tmp
436 # install setuptools before upgrading virtualenv, as the latter needs
437 # a recent setuptools for setup commands like `extras_require`.
438 ${env_dir}_tmp/bin/pip install --upgrade setuptools
439 ${env_dir}_tmp/bin/pip install --upgrade virtualenv
440 ${env_dir}_tmp/bin/virtualenv --python $interpreter $env_dir
441 rm -rf ${env_dir}_tmp
442
443 . $env_dir/bin/activate
444 if ! populate_wheelhouse install ; then
445 rm -rf $env_dir
446 return 1
447 fi
448 fi
449 . $env_dir/bin/activate
450 }
451
452 # use pip cache if possible but do not store it outside of the source
453 # tree
454 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
455 mkdir -p install-deps-cache
456 top_srcdir=$(pwd)
457 export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
458 wip_wheelhouse=wheelhouse-wip
459
460 #
461 # preload python modules so that tox can run without network access
462 #
463 find . -name tox.ini | while read ini ; do
464 (
465 cd $(dirname $ini)
466 require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
467 md5=wheelhouse/md5
468 if test "$require"; then
469 if ! test -f $md5 || ! md5sum -c $md5 ; then
470 rm -rf wheelhouse
471 fi
472 fi
473 if test "$require" && ! test -d wheelhouse ; then
474 for interpreter in python2.7 python3 ; do
475 type $interpreter > /dev/null 2>&1 || continue
476 activate_virtualenv $top_srcdir $interpreter || exit 1
477 populate_wheelhouse "wheel -w $wip_wheelhouse" $require || exit 1
478 done
479 mv $wip_wheelhouse wheelhouse
480 md5sum *requirements.txt > $md5
481 fi
482 )
483 done
484
485 for interpreter in python2.7 python3 ; do
486 rm -rf $top_srcdir/install-deps-$interpreter
487 done
488 rm -rf $XDG_CACHE_HOME
489 git --version || (echo "Dashboard uses git to pull dependencies." ; false)