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