]> git.proxmox.com Git - ceph.git/blob - ceph/install-deps.sh
626cbc9e39780637b36b3611ddc3a50e112b7106
[ceph.git] / ceph / install-deps.sh
1 #!/bin/bash -e
2 #
3 # Ceph distributed storage system
4 #
5 # Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
6 #
7 # Author: Loic Dachary <loic@dachary.org>
8 #
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.
13 #
14 DIR=/tmp/install-deps.$$
15 trap "rm -fr $DIR" EXIT
16 mkdir -p $DIR
17 if test $(id -u) != 0 ; then
18 SUDO=sudo
19 fi
20 export LC_ALL=C # the following is vulnerable to i18n
21
22 if [ x`uname`x = xFreeBSDx ]; then
23 $SUDO pkg install -yq \
24 devel/git \
25 devel/gperf \
26 devel/gmake \
27 devel/cmake \
28 devel/yasm \
29 devel/boost-all \
30 devel/boost-python-libs \
31 devel/valgrind \
32 devel/pkgconf \
33 devel/libedit \
34 devel/libtool \
35 devel/google-perftools \
36 lang/cython \
37 devel/py-virtualenv \
38 databases/leveldb \
39 net/openldap24-client \
40 security/nss \
41 security/cryptopp \
42 archivers/snappy \
43 ftp/curl \
44 misc/e2fsprogs-libuuid \
45 misc/getopt \
46 textproc/expat2 \
47 textproc/gsed \
48 textproc/libxml2 \
49 textproc/xmlstarlet \
50 textproc/jq \
51 textproc/sphinx \
52 emulators/fuse \
53 java/junit \
54 lang/python27 \
55 devel/py-pip \
56 devel/py-argparse \
57 devel/py-nose \
58 www/py-flask \
59 www/fcgi \
60 sysutils/flock \
61 sysutils/fusefs-libs \
62
63 # Now use pip to install some extra python modules
64 pip install pecan
65
66 exit
67 else
68 source /etc/os-release
69 case $ID in
70 debian|ubuntu|devuan)
71 echo "Using apt-get to install dependencies"
72 $SUDO apt-get install -y lsb-release devscripts equivs
73 $SUDO apt-get install -y dpkg-dev gcc
74 if ! test -r debian/control ; then
75 echo debian/control is not a readable file
76 exit 1
77 fi
78 touch $DIR/status
79
80 backports=""
81 control="debian/control"
82 case $(lsb_release -sc) in
83 squeeze|wheezy)
84 control="/tmp/control.$$"
85 grep -v babeltrace debian/control > $control
86 backports="-t $(lsb_release -sc)-backports"
87 ;;
88 esac
89
90 # make a metapackage that expresses the build dependencies,
91 # install it, rm the .deb; then uninstall the package as its
92 # work is done
93 $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
94 $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
95 if [ -n "$backports" ] ; then rm $control; fi
96 ;;
97 centos|fedora|rhel|ol|virtuozzo)
98 yumdnf="yum"
99 builddepcmd="yum-builddep -y"
100 if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
101 yumdnf="dnf"
102 builddepcmd="dnf -y builddep --allowerasing"
103 fi
104 echo "Using $yumdnf to install dependencies"
105 $SUDO $yumdnf install -y redhat-lsb-core
106 case $(lsb_release -si) in
107 Fedora)
108 if test $yumdnf = yum; then
109 $SUDO $yumdnf install -y yum-utils
110 fi
111 ;;
112 CentOS|RedHatEnterpriseServer|VirtuozzoLinux)
113 $SUDO yum install -y yum-utils
114 MAJOR_VERSION=$(lsb_release -rs | cut -f1 -d.)
115 if test $(lsb_release -si) = RedHatEnterpriseServer ; then
116 $SUDO yum install subscription-manager
117 $SUDO subscription-manager repos --enable=rhel-$MAJOR_VERSION-server-optional-rpms
118 fi
119 $SUDO yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/$MAJOR_VERSION/x86_64/
120 $SUDO yum install --nogpgcheck -y epel-release
121 $SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
122 $SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
123 if test $(lsb_release -si) = CentOS -a $MAJOR_VERSION = 7 ; then
124 $SUDO yum-config-manager --enable cr
125 fi
126 if test $(lsb_release -si) = VirtuozzoLinux -a $MAJOR_VERSION = 7 ; then
127 $SUDO yum-config-manager --enable cr
128 fi
129 ;;
130 esac
131 sed -e 's/@//g' < ceph.spec.in > $DIR/ceph.spec
132 $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
133 ! grep -q -i error: $DIR/yum-builddep.out || exit 1
134 ;;
135 opensuse|suse|sles)
136 echo "Using zypper to install dependencies"
137 $SUDO zypper --gpg-auto-import-keys --non-interactive install lsb-release systemd-rpm-macros
138 sed -e 's/@//g' < ceph.spec.in > $DIR/ceph.spec
139 $SUDO zypper --non-interactive install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
140 ;;
141 alpine)
142 # for now we need the testing repo for leveldb
143 TESTREPO="http://nl.alpinelinux.org/alpine/edge/testing"
144 if ! grep -qF "$TESTREPO" /etc/apk/repositories ; then
145 $SUDO echo "$TESTREPO" | sudo tee -a /etc/apk/repositories > /dev/null
146 fi
147 source alpine/APKBUILD.in
148 $SUDO apk --update add abuild build-base ccache $makedepends
149 if id -u build >/dev/null 2>&1 ; then
150 $SUDO addgroup build abuild
151 fi
152 ;;
153 *)
154 echo "$ID is unknown, dependencies will have to be installed manually."
155 exit 1
156 ;;
157 esac
158 fi
159
160 function populate_wheelhouse() {
161 local install=$1
162 shift
163
164 # although pip comes with virtualenv, having a recent version
165 # of pip matters when it comes to using wheel packages
166 # workaround of https://github.com/pypa/setuptools/issues/1042
167 pip --timeout 300 $install 'setuptools >= 0.8,< 36' 'pip >= 7.0' 'wheel >= 0.24' || return 1
168 if test $# != 0 ; then
169 pip --timeout 300 $install $@ || return 1
170 fi
171 }
172
173 function activate_virtualenv() {
174 local top_srcdir=$1
175 local interpreter=$2
176 local env_dir=$top_srcdir/install-deps-$interpreter
177
178 if ! test -d $env_dir ; then
179 # Make a temporary virtualenv to get a fresh version of virtualenv
180 # because CentOS 7 has a buggy old version (v1.10.1)
181 # https://github.com/pypa/virtualenv/issues/463
182 virtualenv ${env_dir}_tmp
183 ${env_dir}_tmp/bin/pip install --upgrade virtualenv
184 ${env_dir}_tmp/bin/virtualenv --python $interpreter $env_dir
185 rm -rf ${env_dir}_tmp
186
187 . $env_dir/bin/activate
188 if ! populate_wheelhouse install ; then
189 rm -rf $env_dir
190 return 1
191 fi
192 fi
193 . $env_dir/bin/activate
194 }
195
196 # use pip cache if possible but do not store it outside of the source
197 # tree
198 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
199 mkdir -p install-deps-cache
200 top_srcdir=$(pwd)
201 export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
202 wip_wheelhouse=wheelhouse-wip
203
204 #
205 # preload python modules so that tox can run without network access
206 #
207 find . -name tox.ini | while read ini ; do
208 (
209 cd $(dirname $ini)
210 require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
211 if test "$require" && ! test -d wheelhouse ; then
212 for interpreter in python2.7 python3 ; do
213 type $interpreter > /dev/null 2>&1 || continue
214 activate_virtualenv $top_srcdir $interpreter || exit 1
215 populate_wheelhouse "wheel -w $wip_wheelhouse" $require || exit 1
216 done
217 mv $wip_wheelhouse wheelhouse
218 fi
219 )
220 done
221
222 for interpreter in python2.7 python3 ; do
223 rm -rf $top_srcdir/install-deps-$interpreter
224 done
225 rm -rf $XDG_CACHE_HOME