3 # Ceph distributed storage system
5 # Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
7 # Author: Loic Dachary <loic@dachary.org>
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 DIR=/tmp/install-deps.$$
15 trap "rm -fr $DIR" EXIT
17 if test $(id -u) != 0 ; then
20 export LC_ALL=C # the following is vulnerable to i18n
22 function munge_ceph_spec_in {
24 sed -e 's/@//g' -e 's/%bcond_with make_check/%bcond_without make_check/g' < ceph.spec.in > $OUTFILE
27 function ensure_decent_gcc_on_deb {
28 # point gcc to the one offered by distro if the used one is different
29 local old=$(gcc -dumpversion)
31 if dpkg --compare-versions $old eq $new; then
45 /usr/bin/gcc now points to gcc-$old, which is not the version shipped with the
46 distro: gcc-$new. Reverting...
49 $SUDO update-alternatives --remove-all gcc || true
50 $SUDO update-alternatives \
51 --install /usr/bin/gcc gcc /usr/bin/gcc-${new} 20 \
52 --slave /usr/bin/g++ g++ /usr/bin/g++-${new}
54 $SUDO update-alternatives \
55 --install /usr/bin/gcc gcc /usr/bin/gcc-${old} 10 \
56 --slave /usr/bin/g++ g++ /usr/bin/g++-${old}
58 $SUDO update-alternatives --auto gcc
60 # cmake uses the latter by default
61 $SUDO ln -nsf /usr/bin/gcc /usr/bin/x86_64-linux-gnu-gcc
62 $SUDO ln -nsf /usr/bin/g++ /usr/bin/x86_64-linux-gnu-g++
65 if [ x`uname`x = xFreeBSDx ]; then
66 $SUDO pkg install -yq \
74 devel/boost-python-libs \
79 devel/google-perftools \
88 misc/e2fsprogs-libuuid \
104 devel/py-prettytable \
108 sysutils/fusefs-libs \
110 # Now use pip to install some extra python modules
115 source /etc/os-release
117 debian|ubuntu|devuan)
118 echo "Using apt-get to install dependencies"
119 $SUDO apt-get install -y lsb-release devscripts equivs
120 $SUDO apt-get install -y dpkg-dev gcc
123 ensure_decent_gcc_on_deb 4.8
126 ensure_decent_gcc_on_deb 5
129 if ! test -r debian/control ; then
130 echo debian/control is not a readable file
136 control="debian/control"
137 case $(lsb_release -sc) in
139 control="/tmp/control.$$"
140 grep -v babeltrace debian/control > $control
141 backports="-t $(lsb_release -sc)-backports"
145 # make a metapackage that expresses the build dependencies,
146 # install it, rm the .deb; then uninstall the package as its
148 $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
149 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
150 if [ -n "$backports" ] ; then rm $control; fi
152 centos|fedora|rhel|ol|virtuozzo)
154 builddepcmd="yum-builddep -y"
155 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
157 builddepcmd="dnf -y builddep --allowerasing"
159 echo "Using $yumdnf to install dependencies"
160 $SUDO $yumdnf install -y redhat-lsb-core
161 case $(lsb_release -si) in
163 if test $yumdnf = yum; then
164 $SUDO $yumdnf install -y yum-utils
167 CentOS|RedHatEnterpriseServer|VirtuozzoLinux)
168 $SUDO yum install -y yum-utils
169 MAJOR_VERSION=$(lsb_release -rs | cut -f1 -d.)
170 if test $(lsb_release -si) = RedHatEnterpriseServer ; then
171 $SUDO yum install subscription-manager
172 $SUDO subscription-manager repos --enable=rhel-$MAJOR_VERSION-server-optional-rpms
174 $SUDO yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/$MAJOR_VERSION/x86_64/
175 $SUDO yum install --nogpgcheck -y epel-release
176 $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
177 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
178 if test $(lsb_release -si) = CentOS -a $MAJOR_VERSION = 7 ; then
179 $SUDO yum-config-manager --enable cr
181 if test $(lsb_release -si) = VirtuozzoLinux -a $MAJOR_VERSION = 7 ; then
182 $SUDO yum-config-manager --enable cr
186 munge_ceph_spec_in $DIR/ceph.spec
187 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
188 ! grep -q -i error: $DIR/yum-builddep.out || exit 1
191 echo "Using zypper to install dependencies"
192 $SUDO zypper --gpg-auto-import-keys --non-interactive install lsb-release systemd-rpm-macros
193 munge_ceph_spec_in $DIR/ceph.spec
194 $SUDO zypper --non-interactive install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
197 # for now we need the testing repo for leveldb
198 TESTREPO="http://nl.alpinelinux.org/alpine/edge/testing"
199 if ! grep -qF "$TESTREPO" /etc/apk/repositories ; then
200 $SUDO echo "$TESTREPO" | sudo tee -a /etc/apk/repositories > /dev/null
202 source alpine/APKBUILD.in
203 $SUDO apk --update add abuild build-base ccache $makedepends
204 if id -u build >/dev/null 2>&1 ; then
205 $SUDO addgroup build abuild
209 echo "$ID is unknown, dependencies will have to be installed manually."
215 function populate_wheelhouse() {
219 # although pip comes with virtualenv, having a recent version
220 # of pip matters when it comes to using wheel packages
221 # workaround of https://github.com/pypa/setuptools/issues/1042
222 pip --timeout 300 $install 'setuptools >= 0.8,< 36' 'pip >= 7.0' 'wheel >= 0.24' || return 1
223 if test $# != 0 ; then
224 pip --timeout 300 $install $@ || return 1
228 function activate_virtualenv() {
231 local env_dir=$top_srcdir/install-deps-$interpreter
233 if ! test -d $env_dir ; then
234 # Make a temporary virtualenv to get a fresh version of virtualenv
235 # because CentOS 7 has a buggy old version (v1.10.1)
236 # https://github.com/pypa/virtualenv/issues/463
237 virtualenv ${env_dir}_tmp
238 ${env_dir}_tmp/bin/pip install --upgrade virtualenv
239 ${env_dir}_tmp/bin/virtualenv --python $interpreter $env_dir
240 rm -rf ${env_dir}_tmp
242 . $env_dir/bin/activate
243 if ! populate_wheelhouse install ; then
248 . $env_dir/bin/activate
251 # use pip cache if possible but do not store it outside of the source
253 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
254 mkdir -p install-deps-cache
256 export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
257 wip_wheelhouse=wheelhouse-wip
260 # preload python modules so that tox can run without network access
262 find . -name tox.ini | while read ini ; do
265 require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
266 if test "$require" && ! test -d wheelhouse ; then
267 for interpreter in python2.7 python3 ; do
268 type $interpreter > /dev/null 2>&1 || continue
269 activate_virtualenv $top_srcdir $interpreter || exit 1
270 populate_wheelhouse "wheel -w $wip_wheelhouse" $require || exit 1
272 mv $wip_wheelhouse wheelhouse
277 for interpreter in python2.7 python3 ; do
278 rm -rf $top_srcdir/install-deps-$interpreter
280 rm -rf $XDG_CACHE_HOME