2 # -*- mode:sh; tab-width:8; indent-tabs-mode:t -*-
4 # Ceph distributed storage system
6 # Copyright (C) 2014, 2015 Red Hat <contact@redhat.com>
8 # Author: Loic Dachary <loic@dachary.org>
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public
12 # License as published by the Free Software Foundation; either
13 # version 2.1 of the License, or (at your option) any later version.
16 DIR
=/tmp
/install-deps.$$
17 trap "rm -fr $DIR" EXIT
19 if test $
(id
-u) != 0 ; then
22 export LC_ALL
=C
# the following is vulnerable to i18n
26 function munge_ceph_spec_in
{
31 local for_make_check
=$1
34 sed -e 's/@//g' < ceph.spec.
in > $OUTFILE
35 # http://rpm.org/user_doc/conditional_builds.html
36 if $with_seastar; then
37 sed -i -e 's/%bcond_with seastar/%bcond_without seastar/g' $OUTFILE
40 sed -i -e 's/%bcond_with jaeger/%bcond_without jaeger/g' $OUTFILE
43 sed -i -e 's/%bcond_with zbd/%bcond_without zbd/g' $OUTFILE
45 if $for_make_check; then
46 sed -i -e 's/%bcond_with make_check/%bcond_without make_check/g' $OUTFILE
50 function munge_debian_control
{
55 local for_make_check
=$1
60 control
="/tmp/control.$$"
61 grep -v babeltrace debian
/control
> $control
64 if $with_seastar; then
65 sed -i -e 's/^# Crimson[[:space:]]//g' $control
68 sed -i -e 's/^# Jaeger[[:space:]]//g' $control
69 sed -i -e 's/^# Crimson libyaml-cpp-dev,/d' $control
71 if $for_make_check; then
72 sed -i 's/^# Make-Check[[:space:]]/ /g' $control
77 function ensure_decent_gcc_on_ubuntu
{
78 # point gcc to the one offered by g++-7 if the used one is not
80 local old
=$
(gcc
-dumpfullversion -dumpversion)
83 if dpkg
--compare-versions $old ge
${new}.0; then
87 if [ ! -f /usr
/bin
/g
++-${new} ]; then
88 $SUDO tee /etc
/apt
/sources.list.d
/ubuntu-toolchain-r.list
<<EOF
89 deb [lang=none] http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu $codename main
90 deb [arch=amd64 lang=none] http://mirror.nullivex.com/ppa/ubuntu-toolchain-r-test $codename main
92 # import PPA's signing key into APT's keyring
93 cat << ENDOFKEY | $SUDO apt-key add -
94 -----BEGIN PGP PUBLIC KEY BLOCK-----
96 Comment: Hostname: keyserver.ubuntu.com
98 mI0ESuBvRwEEAMi4cDba7xlKaaoXjO1n1HX8RKrkW+HEIl79nSOSJyvzysajs7zUow/OzCQp
99 9NswqrDmNuH1+lPTTRNAGtK8r2ouq2rnXT1mTl23dpgHZ9spseR73s4ZBGw/ag4bpU5dNUSt
100 vfmHhIjVCuiSpNn7cyy1JSSvSs3N2mxteKjXLBf7ABEBAAG0GkxhdW5jaHBhZCBUb29sY2hh
101 aW4gYnVpbGRziLYEEwECACAFAkrgb0cCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAe
102 k3eiup7yfzGKA/4xzUqNACSlB+k+DxFFHqkwKa/ziFiAlkLQyyhm+iqz80htRZr7Ls/ZRYZl
103 0aSU56/hLe0V+TviJ1s8qdN2lamkKdXIAFfavA04nOnTzyIBJ82EAUT3Nh45skMxo4z4iZMN
104 msyaQpNl/m/lNtOLhR64v5ZybofB2EWkMxUzX8D/FQ==
106 -----END PGP PUBLIC KEY BLOCK-----
108 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get update
-y || true
109 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
install -y g
++-${new}
120 $SUDO update-alternatives
--remove-all gcc || true
121 $SUDO update-alternatives \
122 --install /usr
/bin
/gcc gcc
/usr
/bin
/gcc-
${new} 20 \
123 --slave /usr
/bin
/g
++ g
++ /usr
/bin
/g
++-${new}
125 if [ -f /usr
/bin
/g
++-${old} ]; then
126 $SUDO update-alternatives \
127 --install /usr
/bin
/gcc gcc
/usr
/bin
/gcc-
${old} 10 \
128 --slave /usr
/bin
/g
++ g
++ /usr
/bin
/g
++-${old}
131 $SUDO update-alternatives
--auto gcc
133 # cmake uses the latter by default
134 $SUDO ln -nsf /usr
/bin
/gcc
/usr
/bin
/${ARCH}-linux-gnu-gcc
135 $SUDO ln -nsf /usr
/bin
/g
++ /usr
/bin
/${ARCH}-linux-gnu-g++
138 function ensure_python3_sphinx_on_ubuntu
{
139 local sphinx_command
=/usr
/bin
/sphinx-build
140 # python-sphinx points $sphinx_command to
141 # ../share/sphinx/scripts/python2/sphinx-build when it's installed
142 # let's "correct" this
143 if test -e $sphinx_command && head -n1 $sphinx_command |
grep -q python$
; then
144 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
-y remove python-sphinx
148 function install_pkg_on_ubuntu
{
159 if [ $force = "force" ]; then
163 if ! apt
-qq list
$pkg 2>/dev
/null |
grep -q installed
; then
164 missing_pkgs
+=" $pkg"
168 if test -n "$missing_pkgs"; then
169 local shaman_url
="https://shaman.ceph.com/api/repos/${project}/master/${sha1}/ubuntu/${codename}/repo"
170 $SUDO curl
--silent --location $shaman_url --output /etc
/apt
/sources.list.d
/$project.list
171 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get update
-y -o Acquire
::Languages
=none
-o Acquire
::Translation
=none || true
172 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
install --allow-unauthenticated -y $missing_pkgs
176 function install_boost_on_ubuntu
{
178 local installed_ver
=$
(apt
-qq list
--installed ceph-libboost
*-dev 2>/dev
/null |
179 grep -e 'libboost[0-9].[0-9]\+-dev' |
182 if test -n "$installed_ver"; then
183 if echo "$installed_ver" |
grep -q "^$ver"; then
186 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
-y remove
"ceph-libboost.*${installed_ver}.*"
187 $SUDO rm -f /etc
/apt
/sources.list.d
/ceph-libboost
${installed_ver}.list
191 local project
=libboost
192 local sha1
=7aba8a1882670522ee1d1ee1bba0ea170b292dec
193 install_pkg_on_ubuntu \
198 ceph-libboost-atomic
$ver-dev \
199 ceph-libboost-chrono
$ver-dev \
200 ceph-libboost-container
$ver-dev \
201 ceph-libboost-context
$ver-dev \
202 ceph-libboost-coroutine
$ver-dev \
203 ceph-libboost-date-time
$ver-dev \
204 ceph-libboost-filesystem
$ver-dev \
205 ceph-libboost-iostreams
$ver-dev \
206 ceph-libboost-program-options
$ver-dev \
207 ceph-libboost-python
$ver-dev \
208 ceph-libboost-random
$ver-dev \
209 ceph-libboost-regex
$ver-dev \
210 ceph-libboost-system
$ver-dev \
211 ceph-libboost-test
$ver-dev \
212 ceph-libboost-thread
$ver-dev \
213 ceph-libboost-timer
$ver-dev
216 function install_libzbd_on_ubuntu
{
219 local sha1
=1fadde94b08fab574b17637c2bebd2b1e7f9127b
220 install_pkg_on_ubuntu \
228 function version_lt
{
229 test $1 != $
(echo -e "$1\n$2" |
sort -rV |
head -n 1)
236 elif [ $FOR_MAKE_CHECK ]; then
242 if [ x$
(uname
)x
= xFreeBSDx
]; then
243 $SUDO pkg
install -yq \
252 devel
/boost-python-libs \
257 devel
/google-perftools \
259 devel
/py-virtualenv \
261 net
/openldap24-client \
265 misc
/e2fsprogs-libuuid \
272 textproc
/xmlstarlet \
283 devel
/py-prettytable \
291 security
/oath-toolkit \
293 sysutils
/fusefs-libs \
295 # Now use pip to install some extra python modules
300 [ $WITH_SEASTAR ] && with_seastar
=true || with_seastar
=false
301 [ $WITH_JAEGER ] && with_jaeger
=true || with_jaeger
=false
302 [ $WITH_ZBD ] && with_zbd
=true || with_zbd
=false
303 source /etc
/os-release
305 debian|ubuntu|devuan|elementary
)
306 echo "Using apt-get to install dependencies"
307 $SUDO apt-get
install -y devscripts equivs
308 $SUDO apt-get
install -y dpkg-dev
309 ensure_python3_sphinx_on_ubuntu
312 ensure_decent_gcc_on_ubuntu
9 bionic
313 [ ! $NO_BOOST_PKGS ] && install_boost_on_ubuntu bionic
314 $with_zbd && install_libzbd_on_ubuntu bionic
317 $SUDO apt-get
install -y gcc
320 if ! test -r debian
/control
; then
321 echo debian
/control is not a readable
file
327 control
=$
(munge_debian_control
"$VERSION" "$with_seastar" "$for_make_check" "debian/control")
330 backports
="-t $codename-backports"
334 # make a metapackage that expresses the build dependencies,
335 # install it, rm the .deb; then uninstall the package as its
337 $SUDO env DEBIAN_FRONTEND
=noninteractive mk-build-deps
--install --remove --tool="apt-get -y --no-install-recommends $backports" $control ||
exit 1
338 $SUDO env DEBIAN_FRONTEND
=noninteractive apt-get
-y remove ceph-build-deps
339 if [ "$control" != "debian/control" ] ; then rm $control; fi
341 centos|fedora|rhel|ol|virtuozzo
)
342 builddepcmd
="dnf -y builddep --allowerasing"
343 echo "Using dnf to install dependencies"
346 $SUDO dnf
install -y dnf-utils
348 centos|rhel|ol|virtuozzo
)
349 MAJOR_VERSION
="$(echo $VERSION_ID | cut -d. -f1)"
350 $SUDO dnf
install -y dnf-utils
351 rpm
--quiet --query epel-release || \
352 $SUDO dnf
-y install --nogpgcheck https
://dl.fedoraproject.org
/pub
/epel
/epel-release-latest-
$MAJOR_VERSION.noarch.rpm
353 $SUDO rpm
--import /etc
/pki
/rpm-gpg
/RPM-GPG-KEY-EPEL-
$MAJOR_VERSION
354 $SUDO rm -f /etc
/yum.repos.d
/dl.fedoraproject.org
*
355 if test $ID = centos
-a $MAJOR_VERSION = 8 ; then
356 # Enable 'powertools' or 'PowerTools' repo
357 $SUDO dnf config-manager
--set-enabled $
(dnf repolist
--all 2>/dev
/null|gawk
'tolower($0) ~ /^powertools\s/{print $1}')
358 # before EPEL8 and PowerTools provide all dependencies, we use sepia for the dependencies
359 $SUDO dnf config-manager
--add-repo http
://apt-mirror.front.sepia.ceph.com
/lab-extras
/8/
360 $SUDO dnf config-manager
--setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck
=0 --save
361 elif test $ID = rhel
-a $MAJOR_VERSION = 8 ; then
362 $SUDO subscription-manager repos
--enable "codeready-builder-for-rhel-8-${ARCH}-rpms"
363 $SUDO dnf config-manager
--add-repo http
://apt-mirror.front.sepia.ceph.com
/lab-extras
/8/
364 $SUDO dnf config-manager
--setopt=apt-mirror.front.sepia.ceph.com_lab-extras_8_.gpgcheck
=0 --save
368 munge_ceph_spec_in
$with_seastar $with_zbd $for_make_check $DIR/ceph.spec
369 # for python3_pkgversion macro defined by python-srpm-macros, which is required by python3-devel
370 $SUDO dnf
install -y python3-devel
371 $SUDO $builddepcmd $DIR/ceph.spec
2>&1 |
tee $DIR/yum-builddep.out
372 [ ${PIPESTATUS[0]} -ne 0 ] && exit 1
373 IGNORE_YUM_BUILDEP_ERRORS
="ValueError: SELinux policy is not managed or store cannot be accessed."
374 sed "/$IGNORE_YUM_BUILDEP_ERRORS/d" $DIR/yum-builddep.out |
grep -qi "error:" && exit 1
377 echo "Using zypper to install dependencies"
378 zypp_install
="zypper --gpg-auto-import-keys --non-interactive install --no-recommends"
379 $SUDO $zypp_install systemd-rpm-macros rpm-build ||
exit 1
380 munge_ceph_spec_in
$with_seastar false
$for_make_check $DIR/ceph.spec
381 $SUDO $zypp_install $
(rpmspec
-q --buildrequires $DIR/ceph.spec
) ||
exit 1
384 echo "$ID is unknown, dependencies will have to be installed manually."
390 function populate_wheelhouse
() {
394 # although pip comes with virtualenv, having a recent version
395 # of pip matters when it comes to using wheel packages
396 PIP_OPTS
="--timeout 300 --exists-action i"
397 pip
$PIP_OPTS $install \
398 'setuptools >= 0.8' 'pip >= 7.0' 'wheel >= 0.24' 'tox >= 2.9.1' ||
return 1
399 if test $# != 0 ; then
400 pip
$PIP_OPTS $install $@ ||
return 1
404 function activate_virtualenv
() {
406 local env_dir
=$top_srcdir/install-deps-python3
408 if ! test -d $env_dir ; then
409 virtualenv
--python=python3
${env_dir}
410 .
$env_dir/bin
/activate
411 if ! populate_wheelhouse
install ; then
416 .
$env_dir/bin
/activate
419 function preload_wheels_for_tox
() {
424 local require_files
=$
(ls *requirements
*.txt
2>/dev
/null
) || true
425 local constraint_files
=$
(ls *constraints
*.txt
2>/dev
/null
) || true
426 local require
=$
(echo -n "$require_files" |
sed -e 's/^/-r /')
427 local constraint
=$
(echo -n "$constraint_files" |
sed -e 's/^/-c /')
428 local md5
=wheelhouse
/md5
429 if test "$require"; then
430 if ! test -f $md5 ||
! md5sum -c $md5 > /dev
/null
; then
434 if test "$require" && ! test -d wheelhouse
; then
435 type python3
> /dev
/null
2>&1 ||
continue
436 activate_virtualenv
$top_srcdir ||
exit 1
437 populate_wheelhouse
"wheel -w $wip_wheelhouse" $require $constraint ||
exit 1
438 mv $wip_wheelhouse wheelhouse
439 md5sum $require_files $constraint_files > $md5
444 # use pip cache if possible but do not store it outside of the source
446 # see https://pip.pypa.io/en/stable/reference/pip_install.html#caching
447 if $for_make_check; then
448 mkdir
-p install-deps-cache
450 export XDG_CACHE_HOME
=$top_srcdir/install-deps-cache
451 wip_wheelhouse
=wheelhouse-wip
453 # preload python modules so that tox can run without network access
455 find .
-name tox.ini |
while read ini
; do
456 preload_wheels_for_tox
$ini
458 rm -rf $top_srcdir/install-deps-python3
459 rm -rf $XDG_CACHE_HOME
460 type git
> /dev
/null ||
(echo "Dashboard uses git to pull dependencies." ; false
)