2 # -*- mode:sh; tab-width:8; indent-tabs-mode:t -*-
4 # Ceph distributed storage system
6 # Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
8 # Author: Loic Dachary <loic@dachary.org>
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.
16 DIR=/tmp/install-deps.$$
17 trap "rm -fr $DIR" EXIT
19 if test $(id -u) != 0 ; then
22 export LC_ALL=C # the following is vulnerable to i18n
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
35 function munge_ceph_spec_in {
37 sed -e 's/@//g' -e 's/%bcond_with make_check/%bcond_without make_check/g' < ceph.spec.in > $OUTFILE
38 if type python2 > /dev/null 2>&1 ; then
39 sed -i -e 's/%bcond_with python2/%bcond_without python2/g' $OUTFILE
41 sed -i -e 's/%bcond_without python2/%bcond_with python2/g' $OUTFILE
43 if [ $WITH_SEASTAR ]; then
44 sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE
48 function ensure_decent_gcc_on_ubuntu {
49 # point gcc to the one offered by g++-7 if the used one is not
51 local old=$(gcc -dumpfullversion -dumpversion)
54 if dpkg --compare-versions $old ge 7.0; then
58 if [ ! -f /usr/bin/g++-${new} ]; then
59 $SUDO tee /etc/apt/sources.list.d/ubuntu-toolchain-r.list <<EOF
60 deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
61 deb [arch=amd64 lang=none] http://mirror.cs.uchicago.edu/ubuntu-toolchain-r $codename main
62 deb [arch=amd64,i386 lang=none] http://mirror.yandex.ru/mirrors/launchpad/ubuntu-toolchain-r $codename main
64 # import PPA's signing key into APT's keyring
65 cat << ENDOFKEY | $SUDO apt-key add -
66 -----BEGIN PGP PUBLIC KEY BLOCK-----
68 Comment: Hostname: keyserver.ubuntu.com
70 mI0ESuBvRwEEAMi4cDba7xlKaaoXjO1n1HX8RKrkW+HEIl79nSOSJyvzysajs7zUow/OzCQp
71 9NswqrDmNuH1+lPTTRNAGtK8r2ouq2rnXT1mTl23dpgHZ9spseR73s4ZBGw/ag4bpU5dNUSt
72 vfmHhIjVCuiSpNn7cyy1JSSvSs3N2mxteKjXLBf7ABEBAAG0GkxhdW5jaHBhZCBUb29sY2hh
73 aW4gYnVpbGRziLYEEwECACAFAkrgb0cCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAe
74 k3eiup7yfzGKA/4xzUqNACSlB+k+DxFFHqkwKa/ziFiAlkLQyyhm+iqz80htRZr7Ls/ZRYZl
75 0aSU56/hLe0V+TviJ1s8qdN2lamkKdXIAFfavA04nOnTzyIBJ82EAUT3Nh45skMxo4z4iZMN
76 msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ==
78 -----END PGP PUBLIC KEY BLOCK-----
80 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y || true
81 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install -y g++-7
90 $SUDO update-alternatives --remove-all gcc || true
91 $SUDO update-alternatives \
92 --install /usr/bin/gcc gcc /usr/bin/gcc-${new} 20 \
93 --slave /usr/bin/g++ g++ /usr/bin/g++-${new}
95 if [ -f /usr/bin/g++-${old} ]; then
96 $SUDO update-alternatives \
97 --install /usr/bin/gcc gcc /usr/bin/gcc-${old} 10 \
98 --slave /usr/bin/g++ g++ /usr/bin/g++-${old}
101 $SUDO update-alternatives --auto gcc
103 # cmake uses the latter by default
104 $SUDO ln -nsf /usr/bin/gcc /usr/bin/$(uname -m)-linux-gnu-gcc
105 $SUDO ln -nsf /usr/bin/g++ /usr/bin/$(uname -m)-linux-gnu-g++
108 function install_pkg_on_ubuntu {
118 if ! dpkg -s $pkg &> /dev/null; then
119 missing_pkgs+=" $pkg"
122 if test -n "$missing_pkgs"; then
123 local shaman_url="https://shaman.ceph.com/api/repos/${project}/master/${sha1}/ubuntu/${codename}/repo"
124 $SUDO curl --silent --location $shaman_url --output /etc/apt/sources.list.d/$project.list
125 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get update -y -o Acquire::Languages=none -o Acquire::Translation=none || true
126 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get install --allow-unauthenticated -y $missing_pkgs
130 function install_boost_on_ubuntu {
132 install_pkg_on_ubuntu \
134 dd38c27740c1f9a9e6719a07eef84a1369dc168b \
136 ceph-libboost-atomic1.67-dev \
137 ceph-libboost-chrono1.67-dev \
138 ceph-libboost-container1.67-dev \
139 ceph-libboost-context1.67-dev \
140 ceph-libboost-coroutine1.67-dev \
141 ceph-libboost-date-time1.67-dev \
142 ceph-libboost-filesystem1.67-dev \
143 ceph-libboost-iostreams1.67-dev \
144 ceph-libboost-program-options1.67-dev \
145 ceph-libboost-python1.67-dev \
146 ceph-libboost-random1.67-dev \
147 ceph-libboost-regex1.67-dev \
148 ceph-libboost-system1.67-dev \
149 ceph-libboost-thread1.67-dev \
150 ceph-libboost-timer1.67-dev
153 function version_lt {
154 test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
157 function ensure_decent_gcc_on_rh {
158 local old=$(gcc -dumpversion)
161 if version_lt $old $expected; then
165 Your GCC is too old. Please run following command to add DTS to your environment:
167 scl enable devtoolset-7 bash
169 Or add following line to the end of ~/.bashrc to add it permanently:
171 source scl_source enable devtoolset-7
173 see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
176 # non-interactive shell
177 source /opt/rh/devtoolset-$dts_ver/enable
182 if [ x$(uname)x = xFreeBSDx ]; then
183 $SUDO pkg install -yq \
191 devel/boost-python-libs \
196 devel/google-perftools \
198 devel/py-virtualenv \
200 net/openldap24-client \
205 misc/e2fsprogs-libuuid \
212 textproc/xmlstarlet \
222 devel/py-prettytable \
228 security/oath-toolkit \
230 sysutils/fusefs-libs \
232 # Now use pip to install some extra python modules
237 source /etc/os-release
239 debian|ubuntu|devuan)
240 echo "Using apt-get to install dependencies"
241 $SUDO apt-get install -y devscripts equivs
242 $SUDO apt-get install -y dpkg-dev
245 ensure_decent_gcc_on_ubuntu 7 trusty
248 ensure_decent_gcc_on_ubuntu 7 xenial
249 install_boost_on_ubuntu xenial
252 install_boost_on_ubuntu bionic
255 $SUDO apt-get install -y gcc
258 if ! test -r debian/control ; then
259 echo debian/control is not a readable file
265 control="debian/control"
268 control="/tmp/control.$$"
269 grep -v babeltrace debian/control > $control
270 backports="-t $codename-backports"
274 # make a metapackage that expresses the build dependencies,
275 # install it, rm the .deb; then uninstall the package as its
277 $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
278 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
280 if [ -n "$backports" ] ; then rm $control; fi
281 $SUDO apt-get install -y libxmlsec1 libxmlsec1-nss libxmlsec1-openssl libxmlsec1-dev
283 centos|fedora|rhel|ol|virtuozzo)
285 builddepcmd="yum-builddep -y"
286 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
288 builddepcmd="dnf -y builddep --allowerasing"
290 echo "Using $yumdnf to install dependencies"
291 if [ "$ID" = "centos" -a $(uname -m) = aarch64 ]; then
292 $SUDO yum-config-manager --disable centos-sclo-sclo || true
293 $SUDO yum-config-manager --disable centos-sclo-rh || true
294 $SUDO yum remove centos-release-scl || true
299 if test $yumdnf = yum; then
300 $SUDO $yumdnf install -y yum-utils
303 centos|rhel|ol|virtuozzo)
304 $SUDO yum install -y yum-utils
305 if test $ID = rhel ; then
306 $SUDO yum-config-manager --enable rhel-$VERSION_ID-server-optional-rpms
308 $SUDO yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/$VERSION_ID/x86_64/
309 $SUDO yum install --nogpgcheck -y epel-release
310 $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$VERSION_ID
311 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
312 if test $ID = centos -a $VERSION_ID = 7 ; then
313 $SUDO yum-config-manager --enable cr
316 $SUDO yum -y install centos-release-scl
320 $SUDO yum -y install centos-release-scl-rh
321 $SUDO yum-config-manager --disable centos-sclo-rh
322 $SUDO yum-config-manager --enable centos-sclo-rh-testing
326 elif test $ID = rhel -a $MAJOR_VERSION = 7 ; then
327 $SUDO yum-config-manager --enable rhel-server-rhscl-7-rpms
329 elif test $ID = virtuozzo -a $MAJOR_VERSION = 7 ; then
330 $SUDO yum-config-manager --enable cr
334 munge_ceph_spec_in $DIR/ceph.spec
335 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
336 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
337 if [ -n "$dts_ver" ]; then
338 ensure_decent_gcc_on_rh $dts_ver
340 ! grep -q -i error: $DIR/yum-builddep.out || exit 1
341 # for building python-saml and its dependencies
342 $SUDO $yumdnf install -y xmlsec1 xmlsec1-nss xmlsec1-openssl xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel
345 echo "Using zypper to install dependencies"
346 zypp_install="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
347 $SUDO $zypp_install systemd-rpm-macros
348 munge_ceph_spec_in $DIR/ceph.spec
349 $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
350 $SUDO $zypp_install libxmlsec1-1 libxmlsec1-nss1 libxmlsec1-openssl1 xmlsec1-devel xmlsec1-openssl-devel
353 # for now we need the testing repo for leveldb
354 TESTREPO="http://nl.alpinelinux.org/alpine/edge/testing"
355 if ! grep -qF "$TESTREPO" /etc/apk/repositories ; then
356 $SUDO echo "$TESTREPO" | sudo tee -a /etc/apk/repositories > /dev/null
358 source alpine/APKBUILD.in
359 $SUDO apk --update add abuild build-base ccache $makedepends
360 if id -u build >/dev/null 2>&1 ; then
361 $SUDO addgroup build abuild
365 echo "$ID is unknown, dependencies will have to be installed manually."
371 function populate_wheelhouse() {
375 # although pip comes with virtualenv, having a recent version
376 # of pip matters when it comes to using wheel packages
377 # workaround of https://github.com/pypa/setuptools/issues/1042
378 pip --timeout 300 $install 'setuptools >= 0.8,< 36' 'pip >= 7.0' 'wheel >= 0.24' || return 1
379 if test $# != 0 ; then
380 pip --timeout 300 $install $@ || return 1
384 function activate_virtualenv() {
387 local env_dir=$top_srcdir/install-deps-$interpreter
389 if ! test -d $env_dir ; then
390 # Make a temporary virtualenv to get a fresh version of virtualenv
391 # because CentOS 7 has a buggy old version (v1.10.1)
392 # https://github.com/pypa/virtualenv/issues/463
393 virtualenv ${env_dir}_tmp
394 # install setuptools before upgrading virtualenv, as the latter needs
395 # a recent setuptools for setup commands like `extras_require`.
396 ${env_dir}_tmp/bin/pip install --upgrade setuptools
397 ${env_dir}_tmp/bin/pip install --upgrade virtualenv
398 ${env_dir}_tmp/bin/virtualenv --python $interpreter $env_dir
399 rm -rf ${env_dir}_tmp
401 . $env_dir/bin/activate
402 if ! populate_wheelhouse install ; then
407 . $env_dir/bin/activate
410 # use pip cache if possible but do not store it outside of the source
412 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
413 mkdir -p install-deps-cache
415 export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
416 wip_wheelhouse=wheelhouse-wip
419 # preload python modules so that tox can run without network access
421 find . -name tox.ini | while read ini ; do
424 require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
426 if test "$require"; then
427 if ! test -f $md5 || ! md5sum -c $md5 ; then
431 if test "$require" && ! test -d wheelhouse ; then
432 for interpreter in python2.7 python3 ; do
433 type $interpreter > /dev/null 2>&1 || continue
434 activate_virtualenv $top_srcdir $interpreter || exit 1
435 populate_wheelhouse "wheel -w $wip_wheelhouse" $require || exit 1
437 mv $wip_wheelhouse wheelhouse
438 md5sum *requirements.txt > $md5
443 for interpreter in python2.7 python3 ; do
444 rm -rf $top_srcdir/install-deps-$interpreter
446 rm -rf $XDG_CACHE_HOME
447 git --version || (echo "Dashboard uses git to pull dependencies." ; false)