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 \
105 devel
/py-prettytable \
109 sysutils
/fusefs-libs \
111 # Now use pip to install some extra python modules
116 source /etc
/os-release
118 debian|ubuntu|devuan
)
119 echo "Using apt-get to install dependencies"
120 $SUDO apt-get
install -y lsb-release devscripts equivs
121 $SUDO apt-get
install -y dpkg-dev gcc
124 ensure_decent_gcc_on_deb
4.8
127 ensure_decent_gcc_on_deb
5
130 if ! test -r debian
/control
; then
131 echo debian
/control is not a readable
file
137 control
="debian/control"
138 case $
(lsb_release
-sc) in
140 control
="/tmp/control.$$"
141 grep -v babeltrace debian
/control
> $control
142 backports
="-t $(lsb_release -sc)-backports"
146 # make a metapackage that expresses the build dependencies,
147 # install it, rm the .deb; then uninstall the package as its
149 $SUDO env DEBIAN_FRONTEND
=noninteractive mk-build-deps
--install --remove --tool="apt-get -y --no-install-recommends $backports" $control ||
exit 1
150 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
-y remove ceph-build-deps
151 if [ -n "$backports" ] ; then rm $control; fi
153 centos|fedora|rhel|ol|virtuozzo
)
155 builddepcmd
="yum-builddep -y"
156 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
158 builddepcmd
="dnf -y builddep --allowerasing"
160 echo "Using $yumdnf to install dependencies"
161 $SUDO $yumdnf install -y redhat-lsb-core
162 case $
(lsb_release
-si) in
164 if test $yumdnf = yum
; then
165 $SUDO $yumdnf install -y yum-utils
168 CentOS|RedHatEnterpriseServer|VirtuozzoLinux
)
169 $SUDO yum
install -y yum-utils
170 MAJOR_VERSION
=$
(lsb_release
-rs | cut
-f1 -d.
)
171 if test $
(lsb_release
-si) = RedHatEnterpriseServer
; then
172 $SUDO yum
install subscription-manager
173 $SUDO subscription-manager repos
--enable=rhel-
$MAJOR_VERSION-server-optional-rpms
175 $SUDO yum-config-manager
--add-repo https
://dl.fedoraproject.org
/pub
/epel
/$MAJOR_VERSION/x86_64
/
176 $SUDO yum
install --nogpgcheck -y epel-release
177 $SUDO rpm
--import /etc
/pki
/rpm-gpg
/RPM-GPG-KEY-EPEL-
$MAJOR_VERSION
178 $SUDO rm -f /etc
/yum.repos.d
/dl.fedoraproject.org
*
179 if test $
(lsb_release
-si) = CentOS
-a $MAJOR_VERSION = 7 ; then
180 $SUDO yum-config-manager
--enable cr
182 if test $
(lsb_release
-si) = VirtuozzoLinux
-a $MAJOR_VERSION = 7 ; then
183 $SUDO yum-config-manager
--enable cr
187 munge_ceph_spec_in
$DIR/ceph.spec
188 $SUDO $builddepcmd $DIR/ceph.spec
2>&1 |
tee $DIR/yum-builddep.out
189 ! grep -q -i error
: $DIR/yum-builddep.out ||
exit 1
192 echo "Using zypper to install dependencies"
193 $SUDO zypper
--gpg-auto-import-keys --non-interactive install lsb-release systemd-rpm-macros
194 munge_ceph_spec_in
$DIR/ceph.spec
195 $SUDO zypper
--non-interactive install $
(rpmspec
-q --buildrequires $DIR/ceph.spec
) ||
exit 1
198 # for now we need the testing repo for leveldb
199 TESTREPO
="http://nl.alpinelinux.org/alpine/edge/testing"
200 if ! grep -qF "$TESTREPO" /etc
/apk
/repositories
; then
201 $SUDO echo "$TESTREPO" | sudo
tee -a /etc
/apk
/repositories
> /dev
/null
203 source alpine
/APKBUILD.
in
204 $SUDO apk
--update add abuild build-base ccache
$makedepends
205 if id
-u build
>/dev
/null
2>&1 ; then
206 $SUDO addgroup build abuild
210 echo "$ID is unknown, dependencies will have to be installed manually."
216 function populate_wheelhouse
() {
220 # although pip comes with virtualenv, having a recent version
221 # of pip matters when it comes to using wheel packages
222 # workaround of https://github.com/pypa/setuptools/issues/1042
223 pip
--timeout 300 $install 'setuptools >= 0.8,< 36' 'pip >= 7.0' 'wheel >= 0.24' ||
return 1
224 if test $# != 0 ; then
225 pip
--timeout 300 $install $@ ||
return 1
229 function activate_virtualenv
() {
232 local env_dir
=$top_srcdir/install-deps-
$interpreter
234 if ! test -d $env_dir ; then
235 # Make a temporary virtualenv to get a fresh version of virtualenv
236 # because CentOS 7 has a buggy old version (v1.10.1)
237 # https://github.com/pypa/virtualenv/issues/463
238 virtualenv
${env_dir}_tmp
239 ${env_dir}_tmp
/bin
/pip
install --upgrade virtualenv
240 ${env_dir}_tmp
/bin
/virtualenv
--python $interpreter $env_dir
241 rm -rf ${env_dir}_tmp
243 .
$env_dir/bin
/activate
244 if ! populate_wheelhouse
install ; then
249 .
$env_dir/bin
/activate
252 # use pip cache if possible but do not store it outside of the source
254 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
255 mkdir
-p install-deps-cache
257 export XDG_CACHE_HOME
=$top_srcdir/install-deps-cache
258 wip_wheelhouse
=wheelhouse-wip
261 # preload python modules so that tox can run without network access
263 find .
-name tox.ini |
while read ini
; do
266 require
=$
(ls *requirements.txt
2>/dev
/null |
sed -e 's/^/-r /')
267 if test "$require" && ! test -d wheelhouse
; then
268 for interpreter
in python2.7 python3
; do
269 type $interpreter > /dev
/null
2>&1 ||
continue
270 activate_virtualenv
$top_srcdir $interpreter ||
exit 1
271 populate_wheelhouse
"wheel -w $wip_wheelhouse" $require ||
exit 1
273 mv $wip_wheelhouse wheelhouse
278 for interpreter
in python2.7 python3
; do
279 rm -rf $top_srcdir/install-deps-
$interpreter
281 rm -rf $XDG_CACHE_HOME