]>
Commit | Line | Data |
---|---|---|
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 | # | |
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 | ||
c07f9fc5 FG |
22 | function munge_ceph_spec_in { |
23 | local OUTFILE=$1 | |
24 | sed -e 's/@//g' -e 's/%bcond_with make_check/%bcond_without make_check/g' < ceph.spec.in > $OUTFILE | |
25 | } | |
26 | ||
7c673cae FG |
27 | if [ x`uname`x = xFreeBSDx ]; then |
28 | $SUDO pkg install -yq \ | |
c07f9fc5 | 29 | devel/babeltrace \ |
7c673cae | 30 | devel/git \ |
31f18b77 | 31 | devel/gperf \ |
7c673cae FG |
32 | devel/gmake \ |
33 | devel/cmake \ | |
34 | devel/yasm \ | |
35 | devel/boost-all \ | |
36 | devel/boost-python-libs \ | |
37 | devel/valgrind \ | |
38 | devel/pkgconf \ | |
7c673cae FG |
39 | devel/libedit \ |
40 | devel/libtool \ | |
41 | devel/google-perftools \ | |
42 | lang/cython \ | |
43 | devel/py-virtualenv \ | |
44 | databases/leveldb \ | |
c07f9fc5 | 45 | net/openldap-client \ |
7c673cae FG |
46 | security/nss \ |
47 | security/cryptopp \ | |
48 | archivers/snappy \ | |
49 | ftp/curl \ | |
50 | misc/e2fsprogs-libuuid \ | |
51 | misc/getopt \ | |
224ce89b | 52 | net/socat \ |
7c673cae FG |
53 | textproc/expat2 \ |
54 | textproc/gsed \ | |
55 | textproc/libxml2 \ | |
56 | textproc/xmlstarlet \ | |
c07f9fc5 FG |
57 | textproc/jq \ |
58 | textproc/py-sphinx \ | |
7c673cae FG |
59 | emulators/fuse \ |
60 | java/junit \ | |
c07f9fc5 | 61 | lang/python \ |
7c673cae | 62 | lang/python27 \ |
c07f9fc5 | 63 | devel/py-pip \ |
7c673cae FG |
64 | devel/py-argparse \ |
65 | devel/py-nose \ | |
c07f9fc5 | 66 | devel/py-prettytable \ |
7c673cae FG |
67 | www/py-flask \ |
68 | www/fcgi \ | |
69 | sysutils/flock \ | |
70 | sysutils/fusefs-libs \ | |
71 | ||
31f18b77 FG |
72 | # Now use pip to install some extra python modules |
73 | pip install pecan | |
74 | ||
7c673cae FG |
75 | exit |
76 | else | |
77 | source /etc/os-release | |
78 | case $ID in | |
79 | debian|ubuntu|devuan) | |
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 | |
85 | exit 1 | |
86 | fi | |
87 | touch $DIR/status | |
88 | ||
89 | backports="" | |
90 | control="debian/control" | |
91 | case $(lsb_release -sc) in | |
92 | squeeze|wheezy) | |
93 | control="/tmp/control.$$" | |
94 | grep -v babeltrace debian/control > $control | |
95 | backports="-t $(lsb_release -sc)-backports" | |
96 | ;; | |
97 | esac | |
98 | ||
99 | # make a metapackage that expresses the build dependencies, | |
100 | # install it, rm the .deb; then uninstall the package as its | |
101 | # work is done | |
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 | |
105 | ;; | |
106 | centos|fedora|rhel|ol|virtuozzo) | |
107 | yumdnf="yum" | |
108 | builddepcmd="yum-builddep -y" | |
109 | if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then | |
110 | yumdnf="dnf" | |
111 | builddepcmd="dnf -y builddep --allowerasing" | |
112 | fi | |
113 | echo "Using $yumdnf to install dependencies" | |
114 | $SUDO $yumdnf install -y redhat-lsb-core | |
115 | case $(lsb_release -si) in | |
116 | Fedora) | |
117 | if test $yumdnf = yum; then | |
118 | $SUDO $yumdnf install -y yum-utils | |
119 | fi | |
120 | ;; | |
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 | |
127 | fi | |
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 | |
134 | fi | |
135 | if test $(lsb_release -si) = VirtuozzoLinux -a $MAJOR_VERSION = 7 ; then | |
136 | $SUDO yum-config-manager --enable cr | |
137 | fi | |
138 | ;; | |
139 | esac | |
c07f9fc5 | 140 | munge_ceph_spec_in $DIR/ceph.spec |
7c673cae FG |
141 | $SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out |
142 | ! grep -q -i error: $DIR/yum-builddep.out || exit 1 | |
143 | ;; | |
144 | opensuse|suse|sles) | |
145 | echo "Using zypper to install dependencies" | |
146 | $SUDO zypper --gpg-auto-import-keys --non-interactive install lsb-release systemd-rpm-macros | |
c07f9fc5 | 147 | munge_ceph_spec_in $DIR/ceph.spec |
7c673cae FG |
148 | $SUDO zypper --non-interactive install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1 |
149 | ;; | |
150 | alpine) | |
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 | |
155 | fi | |
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 | |
160 | fi | |
161 | ;; | |
162 | *) | |
163 | echo "$ID is unknown, dependencies will have to be installed manually." | |
164 | exit 1 | |
165 | ;; | |
166 | esac | |
167 | fi | |
168 | ||
169 | function populate_wheelhouse() { | |
170 | local install=$1 | |
171 | shift | |
172 | ||
173 | # although pip comes with virtualenv, having a recent version | |
174 | # of pip matters when it comes to using wheel packages | |
31f18b77 FG |
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 | |
7c673cae FG |
177 | if test $# != 0 ; then |
178 | pip --timeout 300 $install $@ || return 1 | |
179 | fi | |
180 | } | |
181 | ||
182 | function activate_virtualenv() { | |
183 | local top_srcdir=$1 | |
184 | local interpreter=$2 | |
185 | local env_dir=$top_srcdir/install-deps-$interpreter | |
186 | ||
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 | |
195 | ||
196 | . $env_dir/bin/activate | |
197 | if ! populate_wheelhouse install ; then | |
198 | rm -rf $env_dir | |
199 | return 1 | |
200 | fi | |
201 | fi | |
202 | . $env_dir/bin/activate | |
203 | } | |
204 | ||
205 | # use pip cache if possible but do not store it outside of the source | |
206 | # tree | |
207 | # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching | |
208 | mkdir -p install-deps-cache | |
209 | top_srcdir=$(pwd) | |
210 | export XDG_CACHE_HOME=$top_srcdir/install-deps-cache | |
211 | wip_wheelhouse=wheelhouse-wip | |
212 | ||
213 | # | |
214 | # preload python modules so that tox can run without network access | |
215 | # | |
216 | find . -name tox.ini | while read ini ; do | |
217 | ( | |
218 | cd $(dirname $ini) | |
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 | |
225 | done | |
226 | mv $wip_wheelhouse wheelhouse | |
227 | fi | |
228 | ) | |
229 | done | |
230 | ||
231 | for interpreter in python2.7 python3 ; do | |
232 | rm -rf $top_srcdir/install-deps-$interpreter | |
233 | done | |
234 | rm -rf $XDG_CACHE_HOME |