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 if [ x
`uname`x
= xFreeBSDx
]; then
28 $SUDO pkg
install -yq \
36 devel
/boost-python-libs \
41 devel
/google-perftools \
50 misc
/e2fsprogs-libuuid \
66 devel
/py-prettytable \
70 sysutils
/fusefs-libs \
72 # Now use pip to install some extra python modules
77 source /etc
/os-release
80 echo "Using apt-get to install dependencies"
81 $SUDO apt-get
install -y lsb-release devscripts equivs
82 $SUDO apt-get
install -y dpkg-dev gcc
83 if ! test -r debian
/control
; then
84 echo debian
/control is not a readable
file
90 control
="debian/control"
91 case $
(lsb_release
-sc) in
93 control
="/tmp/control.$$"
94 grep -v babeltrace debian
/control
> $control
95 backports
="-t $(lsb_release -sc)-backports"
99 # make a metapackage that expresses the build dependencies,
100 # install it, rm the .deb; then uninstall the package as its
102 $SUDO env DEBIAN_FRONTEND
=noninteractive mk-build-deps
--install --remove --tool="apt-get -y --no-install-recommends $backports" $control ||
exit 1
103 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
-y remove ceph-build-deps
104 if [ -n "$backports" ] ; then rm $control; fi
106 centos|fedora|rhel|ol|virtuozzo
)
108 builddepcmd
="yum-builddep -y"
109 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
111 builddepcmd
="dnf -y builddep --allowerasing"
113 echo "Using $yumdnf to install dependencies"
114 $SUDO $yumdnf install -y redhat-lsb-core
115 case $
(lsb_release
-si) in
117 if test $yumdnf = yum
; then
118 $SUDO $yumdnf install -y yum-utils
121 CentOS|RedHatEnterpriseServer|VirtuozzoLinux
)
122 $SUDO yum
install -y yum-utils
123 MAJOR_VERSION
=$
(lsb_release
-rs | cut
-f1 -d.
)
124 if test $
(lsb_release
-si) = RedHatEnterpriseServer
; then
125 $SUDO yum
install subscription-manager
126 $SUDO subscription-manager repos
--enable=rhel-
$MAJOR_VERSION-server-optional-rpms
128 $SUDO yum-config-manager
--add-repo https
://dl.fedoraproject.org
/pub
/epel
/$MAJOR_VERSION/x86_64
/
129 $SUDO yum
install --nogpgcheck -y epel-release
130 $SUDO rpm
--import /etc
/pki
/rpm-gpg
/RPM-GPG-KEY-EPEL-
$MAJOR_VERSION
131 $SUDO rm -f /etc
/yum.repos.d
/dl.fedoraproject.org
*
132 if test $
(lsb_release
-si) = CentOS
-a $MAJOR_VERSION = 7 ; then
133 $SUDO yum-config-manager
--enable cr
135 if test $
(lsb_release
-si) = VirtuozzoLinux
-a $MAJOR_VERSION = 7 ; then
136 $SUDO yum-config-manager
--enable cr
140 munge_ceph_spec_in
$DIR/ceph.spec
141 $SUDO $builddepcmd $DIR/ceph.spec
2>&1 |
tee $DIR/yum-builddep.out
142 ! grep -q -i error
: $DIR/yum-builddep.out ||
exit 1
145 echo "Using zypper to install dependencies"
146 $SUDO zypper
--gpg-auto-import-keys --non-interactive install lsb-release systemd-rpm-macros
147 munge_ceph_spec_in
$DIR/ceph.spec
148 $SUDO zypper
--non-interactive install $
(rpmspec
-q --buildrequires $DIR/ceph.spec
) ||
exit 1
151 # for now we need the testing repo for leveldb
152 TESTREPO
="http://nl.alpinelinux.org/alpine/edge/testing"
153 if ! grep -qF "$TESTREPO" /etc
/apk
/repositories
; then
154 $SUDO echo "$TESTREPO" | sudo
tee -a /etc
/apk
/repositories
> /dev
/null
156 source alpine
/APKBUILD.
in
157 $SUDO apk
--update add abuild build-base ccache
$makedepends
158 if id
-u build
>/dev
/null
2>&1 ; then
159 $SUDO addgroup build abuild
163 echo "$ID is unknown, dependencies will have to be installed manually."
169 function populate_wheelhouse
() {
173 # although pip comes with virtualenv, having a recent version
174 # of pip matters when it comes to using wheel packages
175 # workaround of https://github.com/pypa/setuptools/issues/1042
176 pip
--timeout 300 $install 'setuptools >= 0.8,< 36' 'pip >= 7.0' 'wheel >= 0.24' ||
return 1
177 if test $# != 0 ; then
178 pip
--timeout 300 $install $@ ||
return 1
182 function activate_virtualenv
() {
185 local env_dir
=$top_srcdir/install-deps-
$interpreter
187 if ! test -d $env_dir ; then
188 # Make a temporary virtualenv to get a fresh version of virtualenv
189 # because CentOS 7 has a buggy old version (v1.10.1)
190 # https://github.com/pypa/virtualenv/issues/463
191 virtualenv
${env_dir}_tmp
192 ${env_dir}_tmp
/bin
/pip
install --upgrade virtualenv
193 ${env_dir}_tmp
/bin
/virtualenv
--python $interpreter $env_dir
194 rm -rf ${env_dir}_tmp
196 .
$env_dir/bin
/activate
197 if ! populate_wheelhouse
install ; then
202 .
$env_dir/bin
/activate
205 # use pip cache if possible but do not store it outside of the source
207 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
208 mkdir
-p install-deps-cache
210 export XDG_CACHE_HOME
=$top_srcdir/install-deps-cache
211 wip_wheelhouse
=wheelhouse-wip
214 # preload python modules so that tox can run without network access
216 find .
-name tox.ini |
while read ini
; do
219 require
=$
(ls *requirements.txt
2>/dev
/null |
sed -e 's/^/-r /')
220 if test "$require" && ! test -d wheelhouse
; then
221 for interpreter
in python2.7 python3
; do
222 type $interpreter > /dev
/null
2>&1 ||
continue
223 activate_virtualenv
$top_srcdir $interpreter ||
exit 1
224 populate_wheelhouse
"wheel -w $wip_wheelhouse" $require ||
exit 1
226 mv $wip_wheelhouse wheelhouse
231 for interpreter
in python2.7 python3
; do
232 rm -rf $top_srcdir/install-deps-
$interpreter
234 rm -rf $XDG_CACHE_HOME