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