2015-05-08 07:19:44 +00:00
|
|
|
#!/bin/bash -e
|
2014-11-25 16:25:26 +00:00
|
|
|
#
|
|
|
|
# Ceph distributed storage system
|
|
|
|
#
|
2015-05-02 13:59:12 +00:00
|
|
|
# Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
|
2014-11-25 16:25:26 +00:00
|
|
|
#
|
|
|
|
# Author: Loic Dachary <loic@dachary.org>
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
DIR=/tmp/install-deps.$$
|
|
|
|
trap "rm -fr $DIR" EXIT
|
|
|
|
mkdir -p $DIR
|
2014-12-20 17:57:59 +00:00
|
|
|
if test $(id -u) != 0 ; then
|
|
|
|
SUDO=sudo
|
|
|
|
fi
|
2015-01-25 19:45:48 +00:00
|
|
|
export LC_ALL=C # the following is vulnerable to i18n
|
2015-02-03 15:26:17 +00:00
|
|
|
|
2016-03-24 11:48:20 +00:00
|
|
|
if [ x`uname`x = xFreeBSDx ]; then
|
|
|
|
$SUDO pkg install -yq \
|
|
|
|
devel/git \
|
|
|
|
devel/gmake \
|
2016-10-16 20:10:03 +00:00
|
|
|
devel/cmake \
|
2016-03-24 11:48:20 +00:00
|
|
|
devel/yasm \
|
|
|
|
devel/boost-all \
|
2016-10-16 20:10:03 +00:00
|
|
|
devel/boost-python-libs \
|
2016-03-24 11:48:20 +00:00
|
|
|
devel/valgrind \
|
|
|
|
devel/pkgconf \
|
|
|
|
devel/libatomic_ops \
|
|
|
|
devel/libedit \
|
|
|
|
devel/libtool \
|
|
|
|
devel/google-perftools \
|
|
|
|
lang/cython \
|
|
|
|
devel/py-virtualenv \
|
|
|
|
databases/leveldb \
|
|
|
|
net/openldap24-client \
|
|
|
|
security/nss \
|
|
|
|
security/cryptopp \
|
|
|
|
archivers/snappy \
|
|
|
|
ftp/curl \
|
|
|
|
misc/e2fsprogs-libuuid \
|
2016-10-18 09:33:09 +00:00
|
|
|
misc/getopt \
|
2016-03-24 11:48:20 +00:00
|
|
|
textproc/expat2 \
|
2017-03-09 12:42:34 +00:00
|
|
|
textproc/gsed \
|
2016-03-24 11:48:20 +00:00
|
|
|
textproc/libxml2 \
|
|
|
|
textproc/xmlstarlet \
|
2016-11-19 19:10:51 +00:00
|
|
|
textproc/jq \
|
2017-02-01 22:04:48 +00:00
|
|
|
textproc/sphinx \
|
2016-03-24 11:48:20 +00:00
|
|
|
emulators/fuse \
|
|
|
|
java/junit \
|
|
|
|
lang/python27 \
|
|
|
|
devel/py-argparse \
|
|
|
|
devel/py-nose \
|
|
|
|
www/py-flask \
|
|
|
|
www/fcgi \
|
|
|
|
sysutils/flock \
|
2017-04-02 00:08:51 +00:00
|
|
|
sysutils/fusefs-libs \
|
2016-03-24 11:48:20 +00:00
|
|
|
|
|
|
|
exit
|
2016-06-29 07:40:07 +00:00
|
|
|
else
|
2016-09-05 13:40:33 +00:00
|
|
|
source /etc/os-release
|
|
|
|
case $ID in
|
2016-06-29 07:40:07 +00:00
|
|
|
debian|ubuntu|devuan)
|
|
|
|
echo "Using apt-get to install dependencies"
|
|
|
|
$SUDO apt-get install -y lsb-release devscripts equivs
|
2016-04-25 15:11:45 +00:00
|
|
|
$SUDO apt-get install -y dpkg-dev gcc
|
2015-02-05 13:46:41 +00:00
|
|
|
if ! test -r debian/control ; then
|
|
|
|
echo debian/control is not a readable file
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-11-25 16:25:26 +00:00
|
|
|
touch $DIR/status
|
2016-03-24 00:43:53 +00:00
|
|
|
|
|
|
|
backports=""
|
|
|
|
control="debian/control"
|
2014-11-25 16:25:26 +00:00
|
|
|
case $(lsb_release -sc) in
|
2015-02-03 16:40:41 +00:00
|
|
|
squeeze|wheezy)
|
2016-03-24 00:43:53 +00:00
|
|
|
control="/tmp/control.$$"
|
|
|
|
grep -v babeltrace debian/control > $control
|
2015-04-10 07:26:14 +00:00
|
|
|
backports="-t $(lsb_release -sc)-backports"
|
2014-11-25 16:25:26 +00:00
|
|
|
;;
|
|
|
|
esac
|
2016-03-24 00:43:53 +00:00
|
|
|
|
|
|
|
# make a metapackage that expresses the build dependencies,
|
|
|
|
# install it, rm the .deb; then uninstall the package as its
|
|
|
|
# work is done
|
|
|
|
$SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
|
|
|
|
$SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
|
|
|
|
if [ -n "$backports" ] ; then rm $control; fi
|
2014-11-25 16:25:26 +00:00
|
|
|
;;
|
2017-04-03 13:35:49 +00:00
|
|
|
centos|fedora|rhel|ol|virtuozzo)
|
2016-09-16 04:29:15 +00:00
|
|
|
yumdnf="yum"
|
|
|
|
builddepcmd="yum-builddep -y"
|
|
|
|
if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then
|
|
|
|
yumdnf="dnf"
|
|
|
|
builddepcmd="dnf -y builddep --allowerasing"
|
|
|
|
fi
|
|
|
|
echo "Using $yumdnf to install dependencies"
|
|
|
|
$SUDO $yumdnf install -y redhat-lsb-core
|
2014-11-25 16:25:26 +00:00
|
|
|
case $(lsb_release -si) in
|
2015-03-04 12:47:37 +00:00
|
|
|
Fedora)
|
2016-09-16 04:29:15 +00:00
|
|
|
if test $yumdnf = yum; then
|
|
|
|
$SUDO $yumdnf install -y yum-utils
|
|
|
|
fi
|
2014-11-25 16:25:26 +00:00
|
|
|
;;
|
2017-04-03 13:35:49 +00:00
|
|
|
CentOS|RedHatEnterpriseServer|VirtuozzoLinux)
|
2015-03-04 12:47:37 +00:00
|
|
|
$SUDO yum install -y yum-utils
|
|
|
|
MAJOR_VERSION=$(lsb_release -rs | cut -f1 -d.)
|
2015-12-08 07:02:56 +00:00
|
|
|
if test $(lsb_release -si) = RedHatEnterpriseServer ; then
|
2015-03-04 12:47:37 +00:00
|
|
|
$SUDO yum install subscription-manager
|
|
|
|
$SUDO subscription-manager repos --enable=rhel-$MAJOR_VERSION-server-optional-rpms
|
|
|
|
fi
|
2016-04-20 20:23:55 +00:00
|
|
|
$SUDO yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/$MAJOR_VERSION/x86_64/
|
2015-03-04 12:47:37 +00:00
|
|
|
$SUDO yum install --nogpgcheck -y epel-release
|
|
|
|
$SUDO rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$MAJOR_VERSION
|
|
|
|
$SUDO rm -f /etc/yum.repos.d/dl.fedoraproject.org*
|
2015-12-08 07:02:56 +00:00
|
|
|
if test $(lsb_release -si) = CentOS -a $MAJOR_VERSION = 7 ; then
|
|
|
|
$SUDO yum-config-manager --enable cr
|
|
|
|
fi
|
2017-04-03 13:35:49 +00:00
|
|
|
if test $(lsb_release -si) = VirtuozzoLinux -a $MAJOR_VERSION = 7 ; then
|
|
|
|
$SUDO yum-config-manager --enable cr
|
|
|
|
fi
|
2015-03-04 12:47:37 +00:00
|
|
|
;;
|
2014-11-25 16:25:26 +00:00
|
|
|
esac
|
|
|
|
sed -e 's/@//g' < ceph.spec.in > $DIR/ceph.spec
|
2016-09-16 04:29:15 +00:00
|
|
|
$SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
|
2015-06-06 10:28:03 +00:00
|
|
|
! grep -q -i error: $DIR/yum-builddep.out || exit 1
|
2014-11-25 16:25:26 +00:00
|
|
|
;;
|
2016-10-31 18:46:13 +00:00
|
|
|
opensuse|suse|sles)
|
2016-06-29 07:40:07 +00:00
|
|
|
echo "Using zypper to install dependencies"
|
|
|
|
$SUDO zypper --gpg-auto-import-keys --non-interactive install lsb-release systemd-rpm-macros
|
2015-10-03 08:46:06 +00:00
|
|
|
sed -e 's/@//g' < ceph.spec.in > $DIR/ceph.spec
|
2015-05-08 07:19:44 +00:00
|
|
|
$SUDO zypper --non-interactive install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
|
2015-03-23 20:28:20 +00:00
|
|
|
;;
|
2016-06-29 07:40:07 +00:00
|
|
|
*)
|
2016-09-05 13:40:33 +00:00
|
|
|
echo "$ID is unknown, dependencies will have to be installed manually."
|
2016-08-31 21:29:30 +00:00
|
|
|
exit 1
|
2014-11-25 16:25:26 +00:00
|
|
|
;;
|
2016-06-29 07:40:07 +00:00
|
|
|
esac
|
|
|
|
fi
|
2015-05-02 13:59:12 +00:00
|
|
|
|
2015-06-04 08:00:45 +00:00
|
|
|
function populate_wheelhouse() {
|
2015-05-28 23:34:45 +00:00
|
|
|
local install=$1
|
2015-06-04 03:45:55 +00:00
|
|
|
shift
|
2015-05-28 23:34:45 +00:00
|
|
|
|
|
|
|
# although pip comes with virtualenv, having a recent version
|
|
|
|
# of pip matters when it comes to using wheel packages
|
|
|
|
pip --timeout 300 $install 'setuptools >= 0.8' 'pip >= 7.0' 'wheel >= 0.24' || return 1
|
2015-06-04 03:45:55 +00:00
|
|
|
if test $# != 0 ; then
|
|
|
|
pip --timeout 300 $install $@ || return 1
|
|
|
|
fi
|
2015-05-28 23:34:45 +00:00
|
|
|
}
|
|
|
|
|
2015-06-04 05:44:00 +00:00
|
|
|
function activate_virtualenv() {
|
|
|
|
local top_srcdir=$1
|
|
|
|
local interpreter=$2
|
|
|
|
local env_dir=$top_srcdir/install-deps-$interpreter
|
|
|
|
|
|
|
|
if ! test -d $env_dir ; then
|
2016-07-13 22:06:51 +00:00
|
|
|
# Make a temporary virtualenv to get a fresh version of virtualenv
|
|
|
|
# because CentOS 7 has a buggy old version (v1.10.1)
|
|
|
|
# https://github.com/pypa/virtualenv/issues/463
|
|
|
|
virtualenv ${env_dir}_tmp
|
|
|
|
${env_dir}_tmp/bin/pip install --upgrade virtualenv
|
|
|
|
${env_dir}_tmp/bin/virtualenv --python $interpreter $env_dir
|
|
|
|
rm -rf ${env_dir}_tmp
|
|
|
|
|
2015-06-04 05:44:00 +00:00
|
|
|
. $env_dir/bin/activate
|
2015-06-04 08:00:45 +00:00
|
|
|
if ! populate_wheelhouse install ; then
|
2015-06-04 05:44:00 +00:00
|
|
|
rm -rf $env_dir
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
. $env_dir/bin/activate
|
|
|
|
}
|
|
|
|
|
2015-05-30 08:53:51 +00:00
|
|
|
# use pip cache if possible but do not store it outside of the source
|
|
|
|
# tree
|
|
|
|
# see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
|
|
|
|
mkdir -p install-deps-cache
|
|
|
|
top_srcdir=$(pwd)
|
|
|
|
export XDG_CACHE_HOME=$top_srcdir/install-deps-cache
|
2015-06-04 03:53:55 +00:00
|
|
|
wip_wheelhouse=wheelhouse-wip
|
2015-05-30 08:53:51 +00:00
|
|
|
|
2015-05-02 13:59:12 +00:00
|
|
|
#
|
|
|
|
# preload python modules so that tox can run without network access
|
|
|
|
#
|
2015-05-08 18:53:54 +00:00
|
|
|
find . -name tox.ini | while read ini ; do
|
|
|
|
(
|
|
|
|
cd $(dirname $ini)
|
|
|
|
require=$(ls *requirements.txt 2>/dev/null | sed -e 's/^/-r /')
|
|
|
|
if test "$require" && ! test -d wheelhouse ; then
|
2015-09-18 10:59:09 +00:00
|
|
|
for interpreter in python2.7 python3 ; do
|
2015-05-08 18:53:54 +00:00
|
|
|
type $interpreter > /dev/null 2>&1 || continue
|
2015-06-04 05:44:00 +00:00
|
|
|
activate_virtualenv $top_srcdir $interpreter || exit 1
|
2015-06-04 08:00:45 +00:00
|
|
|
populate_wheelhouse "wheel -w $wip_wheelhouse" $require || exit 1
|
2015-05-08 18:53:54 +00:00
|
|
|
done
|
2015-06-04 03:53:55 +00:00
|
|
|
mv $wip_wheelhouse wheelhouse
|
2015-05-08 18:53:54 +00:00
|
|
|
fi
|
|
|
|
)
|
2015-05-02 13:59:12 +00:00
|
|
|
done
|
2015-06-03 14:05:28 +00:00
|
|
|
|
2015-09-18 10:59:09 +00:00
|
|
|
for interpreter in python2.7 python3 ; do
|
2015-06-03 14:05:28 +00:00
|
|
|
rm -rf $top_srcdir/install-deps-$interpreter
|
|
|
|
done
|
|
|
|
rm -rf $XDG_CACHE_HOME
|