xref: /spdk/scripts/pkgdep/rhel.sh (revision 9bff828f99403ad2f3ac3b8b29b62acb83b24145)
1#!/usr/bin/env bash
2
3disclaimer() {
4	case "$ID" in
5		rhel)
6			cat <<- WARN
7
8				WARNING: $PRETTY_NAME system detected.
9
10				Please, note that the support for this platform is considered to be "best-effort",
11				as in, access to some packages may be limited and/or missing. Review your repo
12				setup to make sure installation of all dependencies is possible.
13
14			WARN
15
16			# Don't trigger errexit, simply install what's available. This is default
17			# behavior of older yum versions (e.g. the one present on RHEL 7.x) anyway.
18			yum() { "$(type -P yum)" --skip-broken "$@"; }
19			# For systems which are not registered, subscription-manager will most likely
20			# fail on most calls so simply ignore its failures.
21			sub() { subscription-manager "$@" || :; }
22			;;
23
24		*) ;;
25	esac
26}
27
28is_repo() { yum repolist --all | grep -q "^$1"; }
29
30disclaimer
31
32# First, add extra EPEL, ELRepo, Ceph repos to have a chance of covering most of the packages
33# on the enterprise systems, like RHEL.
34if [[ $ID == centos || $ID == rhel ]]; then
35	repos=() enable=("epel" "elrepo" "elrepo-testing")
36	[[ $ID == centos ]] && enable+=("extras")
37	if [[ $VERSION_ID == 7* ]]; then
38		repos+=("https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm")
39		repos+=("https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm")
40		[[ $ID == centos ]] && repos+=("centos-release-ceph-nautilus.noarch")
41		[[ $ID == centos ]] && repos+=("centos-release-scl-rh")
42		# Disable liburing, see https://github.com/spdk/spdk/issues/1564
43		if [[ $INSTALL_LIBURING == true ]]; then
44			echo "Liburing not supported on ${ID}$VERSION_ID, disabling"
45			INSTALL_LIBURING=false
46		fi
47	fi
48	if [[ $VERSION_ID == 8* ]]; then
49		repos+=("https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm")
50		repos+=("https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm")
51		[[ $ID == centos ]] && repos+=("https://download.ceph.com/rpm-nautilus/el8/noarch/ceph-release-1-1.el8.noarch.rpm")
52		# Add PowerTools needed for install CUnit-devel in Centos8
53		if [[ $ID == centos ]]; then
54			is_repo "PowerTools" && enable+=("PowerTools")
55			is_repo "powertools" && enable+=("powertools")
56		fi
57	fi
58	if ((${#repos[@]} > 0)); then
59		yum install -y "${repos[@]}" yum-utils
60		yum-config-manager --enable "${enable[@]}"
61	fi
62	# Potential dependencies can be needed from other RHEL repos, enable them
63	if [[ $ID == rhel ]]; then
64		[[ $VERSION_ID == 7* ]] && sub repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms"
65		[[ $VERSION_ID == 8* ]] && sub repos --enable codeready-builder-for-rhel-8-x86_64-rpms
66	fi
67fi
68
69# Minimal install
70# workaround for arm: ninja fails with dep on skbuild python module
71if [ "$(uname -m)" = "aarch64" ]; then
72	pip3 install scikit-build
73	if echo "$ID $VERSION_ID" | grep -E -q 'centos 7'; then
74		# by default centos 7.x uses cmake 2.8 while ninja requires 3.6 or higher
75		yum install -y cmake3
76		# cmake3 is installed as /usr/bin/cmake3 while ninja directly calls `cmake`. Create a soft link
77		# as a workaround
78		mkdir -p /tmp/bin/
79		ln -s /usr/bin/cmake3 /tmp/bin/cmake > /dev/null 2>&1 || true
80		export PATH=/tmp/bin:$PATH
81	fi
82fi
83
84yum install -y gcc gcc-c++ make cmake CUnit-devel libaio-devel openssl-devel \
85	libuuid-devel libiscsi-devel ncurses-devel json-c-devel libcmocka-devel
86if echo "$ID $VERSION_ID" | grep -E -q 'centos 8|rhel 8'; then
87	yum install -y python36 python36-devel
88	#Create hard link to use in SPDK as python
89	if [[ ! -e /usr/bin/python && -e /etc/alternatives/python3 ]]; then
90		ln -s /etc/alternatives/python3 /usr/bin/python
91	fi
92else
93	yum install -y python python3-devel
94fi
95yum install -y python3-pip
96pip3 install ninja
97pip3 install meson
98pip3 install pyelftools
99pip3 install ijson
100pip3 install python-magic
101
102# Additional dependencies for SPDK CLI - not available in rhel and centos
103if ! echo "$ID $VERSION_ID" | grep -E -q 'rhel 7|centos 7'; then
104	yum install -y python3-configshell python3-pexpect
105fi
106# Additional dependencies for ISA-L used in compression
107yum install -y autoconf automake libtool help2man
108# Additional dependencies for DPDK
109yum install -y numactl-devel nasm
110# Additional dependencies for USDT
111yum install -y systemtap-sdt-devel
112if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
113	# Tools for developers
114	if echo "$ID $VERSION_ID" | grep -E -q 'centos 8'; then
115		yum install -y python3-pycodestyle
116		echo "Centos 8 does not have lcov and ShellCheck dependencies"
117	else
118		yum install -y python-pycodestyle lcov ShellCheck
119	fi
120	yum install -y git astyle sg3_utils pciutils libabigail bash-completion ruby-devel
121fi
122if [[ $INSTALL_PMEM == "true" ]]; then
123	# Additional dependencies for building pmem based backends
124	yum install -y libpmemblk-devel || true
125	yum install -y libpmemobj-devel || true
126fi
127if [[ $INSTALL_FUSE == "true" ]]; then
128	# Additional dependencies for FUSE and NVMe-CUSE
129	yum install -y fuse3-devel
130fi
131if [[ $INSTALL_RDMA == "true" ]]; then
132	# Additional dependencies for RDMA transport in NVMe over Fabrics
133	yum install -y libibverbs-devel librdmacm-devel
134fi
135if [[ $INSTALL_DOCS == "true" ]]; then
136	# Additional dependencies for building docs
137	yum install -y mscgen || echo "Warning: couldn't install mscgen via yum. Please install mscgen manually."
138	yum install -y doxygen graphviz
139fi
140