xref: /spdk/scripts/pkgdep/rhel.sh (revision b4ba6cdf0ad14da86fe0ca1b53f6a3f7b09560de)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2020 Intel Corporation
4#  All rights reserved.
5#  Copyright (c) 2022 Dell Inc, or its subsidiaries.
6#
7
8disclaimer() {
9	case "$ID" in
10		rhel)
11			cat <<- WARN
12
13				WARNING: $PRETTY_NAME system detected.
14
15				Please, note that the support for this platform is considered to be "best-effort",
16				as in, access to some packages may be limited and/or missing. Review your repo
17				setup to make sure installation of all dependencies is possible.
18
19			WARN
20
21			# Don't trigger errexit, simply install what's available. This is default
22			# behavior of older yum versions (e.g. the one present on RHEL 7.x) anyway.
23			yum() { "$(type -P yum)" --skip-broken "$@"; }
24			# For systems which are not registered, subscription-manager will most likely
25			# fail on most calls so simply ignore its failures.
26			sub() { subscription-manager "$@" || :; }
27			;;
28
29		*) ;;
30	esac
31}
32
33is_repo() { yum repolist --all | grep -q "^$1"; }
34
35disclaimer
36
37# First, add extra EPEL, ELRepo, Ceph repos to have a chance of covering most of the packages
38# on the enterprise systems, like RHEL.
39if [[ $ID == centos || $ID == rhel || $ID == rocky ]]; then
40	repos=() enable=("epel" "elrepo" "elrepo-testing") add=()
41	[[ $ID == centos || $ID == rocky ]] && enable+=("extras")
42	if [[ $VERSION_ID == 7* ]]; then
43		repos+=("https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm")
44		repos+=("https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm")
45		[[ $ID == centos ]] && repos+=("centos-release-ceph-nautilus.noarch")
46		[[ $ID == centos ]] && repos+=("centos-release-scl-rh")
47		# Disable liburing, see https://github.com/spdk/spdk/issues/1564
48		if [[ $INSTALL_LIBURING == true ]]; then
49			echo "Liburing not supported on ${ID}$VERSION_ID, disabling"
50			INSTALL_LIBURING=false
51		fi
52		add+=("https://packages.daos.io/v2.0/CentOS7/packages/x86_64/daos_packages.repo")
53		enable+=("daos-packages")
54	fi
55	if [[ $VERSION_ID == 8* ]]; then
56		repos+=("https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm")
57		repos+=("https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm")
58		add+=("https://packages.daos.io/v2.0/EL8/packages/x86_64/daos_packages.repo")
59		enable+=("daos-packages")
60	fi
61
62	if [[ $VERSION_ID == 9* ]]; then
63		repos+=("https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm")
64		repos+=("https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm")
65		[[ $ID != rhel ]] && enable+=("crb")
66	fi
67
68	# Add PowerTools needed for install CUnit-devel
69	if [[ ($ID == centos || $ID == rocky) && $VERSION_ID =~ ^[89].* ]]; then
70		is_repo "PowerTools" && enable+=("PowerTools")
71		is_repo "powertools" && enable+=("powertools")
72		repos+=("centos-release-ceph-pacific.noarch")
73		enable+=("centos-ceph-pacific")
74	fi
75
76	[[ $ID == rhel && $VERSION_ID == 8* ]] && repos+=("https://download.ceph.com/rpm-pacific/el8/noarch/ceph-release-1-1.el8.noarch.rpm")
77	[[ $ID == rhel && $VERSION_ID == 9* ]] && repos+=("https://download.ceph.com/rpm-reef/el9/noarch/ceph-release-1-1.el9.noarch.rpm")
78
79	if [[ $ID == rocky ]]; then
80		enable+=("devel")
81	fi
82
83	if ((${#add[@]} > 0)); then
84		for _repo in "${add[@]}"; do
85			yum-config-manager --add-repo "$_repo"
86		done
87	fi
88
89	if ((${#repos[@]} > 0)); then
90		yum install -y "${repos[@]}" yum-utils
91		yum-config-manager --enable "${enable[@]}"
92	fi
93	# Potential dependencies can be needed from other RHEL repos, enable them
94	if [[ $ID == rhel ]]; then
95		[[ $VERSION_ID == 7* ]] && sub repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms"
96		[[ $VERSION_ID == 8* ]] && sub repos --enable codeready-builder-for-rhel-8-x86_64-rpms
97		[[ $VERSION_ID == 9* ]] && sub repos --enable codeready-builder-for-rhel-9-x86_64-rpms
98	fi
99fi
100
101yum install -y gcc gcc-c++ make CUnit-devel libaio-devel openssl-devel \
102	libuuid-devel libiscsi-devel ncurses-devel json-c-devel libcmocka-devel \
103	clang clang-devel python3-pip unzip keyutils keyutils-libs-devel fuse3-devel patchelf
104
105# Minimal install
106# workaround for arm: ninja fails with dep on skbuild python module
107if [ "$(uname -m)" = "aarch64" ]; then
108	pip3 install scikit-build
109	if echo "$ID $VERSION_ID" | grep -E -q 'centos 7'; then
110		# by default centos 7.x uses cmake 2.8 while ninja requires 3.6 or higher
111		yum install -y cmake3
112		# cmake3 is installed as /usr/bin/cmake3 while ninja directly calls `cmake`. Create a soft link
113		# as a workaround
114		mkdir -p /tmp/bin/
115		ln -s /usr/bin/cmake3 /tmp/bin/cmake > /dev/null 2>&1 || true
116		export PATH=/tmp/bin:$PATH
117	fi
118fi
119
120# for rhel and centos7 OpenSSL 1.1 should be installed via EPEL
121if echo "$ID $VERSION_ID" | grep -E -q 'centos 7|rhel 7'; then
122	yum install -y openssl11-devel
123fi
124if echo "$ID $VERSION_ID" | grep -E -q 'centos 8|rhel 8|rocky 8'; then
125	yum install -y python36 python36-devel
126	#Create hard link to use in SPDK as python
127	if [[ ! -e /usr/bin/python && -e /etc/alternatives/python3 ]]; then
128		ln -s /etc/alternatives/python3 /usr/bin/python
129	fi
130	# pip3, which is shipped with centos8 and rocky8, is currently providing faulty ninja binary
131	# which segfaults at each run. To workaround it, upgrade pip itself and then use it for each
132	# package - new pip will provide ninja at the same version but with the actually working
133	# binary.
134	pip3 install --upgrade pip
135	pip3() { /usr/local/bin/pip "$@"; }
136else
137	yum install -y python python3-devel
138fi
139pip3 install ninja
140pip3 install meson
141pip3 install pyelftools
142pip3 install ijson
143pip3 install python-magic
144pip3 install Jinja2
145pip3 install pandas
146pip3 install tabulate
147if ! [[ $ID == centos && $VERSION_ID == 7 ]]; then
148	# Problem with modules compilation on Centos7
149	pip3 install grpcio
150	pip3 install grpcio-tools
151fi
152pip3 install pyyaml
153
154# Additional dependencies for SPDK CLI - not available in rhel and centos
155if ! echo "$ID $VERSION_ID" | grep -E -q 'rhel 7|centos 7'; then
156	yum install -y python3-configshell python3-pexpect
157fi
158# Additional dependencies for ISA-L used in compression
159yum install -y autoconf automake libtool help2man
160# Additional dependencies for DPDK
161yum install -y numactl-devel nasm
162# Additional dependencies for USDT
163yum install -y systemtap-sdt-devel
164if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
165	# Tools for developers
166	devtool_pkgs=(git sg3_utils pciutils libabigail bash-completion ruby-devel)
167
168	if echo "$ID $VERSION_ID" | grep -E -q 'centos 8|rocky 8'; then
169		devtool_pkgs+=(python3-pycodestyle astyle)
170		echo "Centos 8 and Rocky 8 do not have lcov and ShellCheck dependencies"
171	elif [[ $ID == openeuler ]]; then
172		devtool_pkgs+=(python3-pycodestyle)
173		echo "openEuler does not have astyle, lcov and ShellCheck dependencies"
174	else
175		devtool_pkgs+=(python-pycodestyle astyle lcov ShellCheck)
176	fi
177
178	yum install -y "${devtool_pkgs[@]}"
179fi
180if [[ $INSTALL_PMEM == "true" ]]; then
181	# Additional dependencies for building pmem based backends
182	yum install -y libpmemobj-devel || true
183fi
184if [[ $INSTALL_RBD == "true" ]]; then
185	# Additional dependencies for RBD bdev in NVMe over Fabrics
186	yum install -y librados-devel librbd-devel
187fi
188if [[ $INSTALL_RDMA == "true" ]]; then
189	# Additional dependencies for RDMA transport in NVMe over Fabrics
190	yum install -y libibverbs-devel librdmacm-devel
191fi
192if [[ $INSTALL_DOCS == "true" ]]; then
193	# Additional dependencies for building docs
194	yum install -y mscgen || echo "Warning: couldn't install mscgen via yum. Please install mscgen manually."
195	yum install -y doxygen graphviz
196fi
197if [[ $INSTALL_DAOS == "true" ]]; then
198	if [[ ($ID == centos || $ID == rocky) && $VERSION_ID =~ ^[78].* ]]; then
199		yum install -y daos-devel
200	else
201		echo "Skipping installation of DAOS bdev dependencies. Supported only under centos, rocky (variants 7-8)."
202	fi
203fi
204# Additional dependencies for Avahi
205if [[ $INSTALL_AVAHI == "true" ]]; then
206	# Additional dependencies for Avahi
207	yum install -y avahi-devel
208fi
209