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
{
36 local for_make_check
=$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
44 if $for_make_check; then
45 sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE
49 function munge_debian_control
{
52 local for_make_check
=$1
57 control
="/tmp/control.$$"
58 grep -v babeltrace debian
/control
> $control
61 if $for_make_check; then
62 sed -i 's/^# Make-Check[[:space:]]/ /g' $control
67 function ensure_decent_gcc_on_ubuntu
{
68 # point gcc to the one offered by g++-7 if the used one is not
70 local old
=$
(gcc
-dumpfullversion -dumpversion)
73 if dpkg
--compare-versions $old ge
${new}.0; then
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
83 # import PPA's signing key into APT's keyring
84 cat << ENDOFKEY | $SUDO apt-key add -
85 -----BEGIN PGP PUBLIC KEY BLOCK-----
87 Comment: Hostname: keyserver.ubuntu.com
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==
97 -----END PGP PUBLIC KEY BLOCK-----
99 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get update
-y || true
100 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
install -y g
++-${new}
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}
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}
120 $SUDO update-alternatives
--auto gcc
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++
127 function install_pkg_on_ubuntu
{
137 if ! dpkg
-s $pkg &> /dev
/null
; then
138 missing_pkgs
+=" $pkg"
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
149 function install_boost_on_ubuntu
{
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
155 local project
=libboost
157 local sha1
=1d7c7a00cc3f37e340bae0360191a757b44ec80c
158 install_pkg_on_ubuntu \
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
180 function version_lt
{
181 test $1 != $
(echo -e "$1\n$2" |
sort -rV |
head -n 1)
184 function ensure_decent_gcc_on_rh
{
185 local old
=$
(gcc
-dumpversion)
188 if version_lt
$old $expected; then
192 Your GCC is too old. Please run following command to add DTS to your environment:
194 scl enable devtoolset-8 bash
196 Or add following line to the end of ~/.bashrc to add it permanently:
198 source scl_source enable devtoolset-8
200 see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
203 # non-interactive shell
204 source /opt
/rh
/devtoolset-
$dts_ver/enable
209 if [ x$
(uname
)x
= xFreeBSDx
]; then
210 $SUDO pkg
install -yq \
219 devel
/boost-python-libs \
224 devel
/google-perftools \
226 devel
/py-virtualenv \
228 net
/openldap24-client \
232 misc
/e2fsprogs-libuuid \
239 textproc
/xmlstarlet \
251 devel
/py-prettytable \
259 security
/oath-toolkit \
261 sysutils
/fusefs-libs \
263 # Now use pip to install some extra python modules
272 elif [ $FOR_MAKE_CHECK ]; then
277 source /etc
/os-release
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
285 ensure_decent_gcc_on_ubuntu
8 trusty
288 ensure_decent_gcc_on_ubuntu
8 xenial
289 install_boost_on_ubuntu xenial
292 install_boost_on_ubuntu bionic
295 $SUDO apt-get
install -y gcc
298 if ! test -r debian
/control
; then
299 echo debian
/control is not a readable
file
305 control
=$
(munge_debian_control
"$VERSION" "$for_make_check" "debian/control")
308 backports
="-t $codename-backports"
312 # make a metapackage that expresses the build dependencies,
313 # install it, rm the .deb; then uninstall the package as its
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
318 if [ "$control" != "debian/control" ] ; then rm $control; fi
319 $SUDO apt-get
install -y libxmlsec1 libxmlsec1-nss libxmlsec1-openssl libxmlsec1-dev
321 centos|fedora|rhel|ol|virtuozzo
)
323 builddepcmd
="yum-builddep -y --setopt=*.skip_if_unavailable=true"
324 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
326 builddepcmd
="dnf -y builddep --allowerasing"
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
336 if test $yumdnf = yum
; then
337 $SUDO $yumdnf install -y yum-utils
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
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
354 $SUDO yum
-y install centos-release-scl
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
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
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
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
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
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
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
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
408 echo "$ID is unknown, dependencies will have to be installed manually."
414 function populate_wheelhouse
() {
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
426 function activate_virtualenv
() {
429 local env_dir
=$top_srcdir/install-deps-
$interpreter
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
443 .
$env_dir/bin
/activate
444 if ! populate_wheelhouse
install ; then
449 .
$env_dir/bin
/activate
452 # use pip cache if possible but do not store it outside of the source
454 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
455 mkdir
-p install-deps-cache
457 export XDG_CACHE_HOME
=$top_srcdir/install-deps-cache
458 wip_wheelhouse
=wheelhouse-wip
461 # preload python modules so that tox can run without network access
463 find .
-name tox.ini |
while read ini
; do
466 require
=$
(ls *requirements.txt
2>/dev
/null |
sed -e 's/^/-r /')
468 if test "$require"; then
469 if ! test -f $md5 ||
! md5sum -c $md5 ; then
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
479 mv $wip_wheelhouse wheelhouse
480 md5sum *requirements.txt
> $md5
485 for interpreter
in python2.7 python3
; do
486 rm -rf $top_srcdir/install-deps-
$interpreter
488 rm -rf $XDG_CACHE_HOME
489 git
--version ||
(echo "Dashboard uses git to pull dependencies." ; false
)