Commit f385076a authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

pkgdep: Make pkgdep.sh to use distro-specific source files



Change-Id: Iee7ba04c489ee1192f6fd65c6647c78536440246
Signed-off-by: default avatarMichal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2508


Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent af8f939e
Loading
Loading
Loading
Loading
+9 −251
Original line number Diff line number Diff line
@@ -118,258 +118,16 @@ trap 'set +e; trap - ERR; echo "Error!"; exit 1;' ERR
scriptsdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $scriptsdir/..)

if [ -s /etc/redhat-release ]; then
	. /etc/os-release
	# Minimal install
	if echo "$ID $VERSION_ID" | grep -E -q 'centos 8'; then
		# Add PowerTools needed for install CUnit-devel in Centos8
		yum install -y yum-utils
		yum config-manager --set-enabled PowerTools
	fi
	yum install -y gcc gcc-c++ make CUnit-devel libaio-devel openssl-devel \
		libuuid-devel libiscsi-devel ncurses-devel
	if echo "$ID $VERSION_ID" | grep -E -q 'centos 8'; then
		yum install -y python36
		#Create hard link to use in SPDK as python
		ln /etc/alternatives/python3 /usr/bin/python || true
	else
		yum install -y python
	fi
	yum install -y python3-pip
	pip3 install ninja
	pip3 install meson
	# Additional dependencies for SPDK CLI - not available in rhel and centos
	if ! echo "$ID $VERSION_ID" | grep -E -q 'rhel 7|centos 7'; then
		yum install -y python3-configshell python3-pexpect
	fi
	# Additional dependencies for ISA-L used in compression
	yum install -y autoconf automake libtool help2man
	# Additional dependencies for DPDK
	yum install -y numactl-devel nasm
	if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
		# Tools for developers
		# Includes Fedora, CentOS 7, RHEL 7
		# Add EPEL repository for CUnit-devel and libunwind-devel
		if echo "$ID $VERSION_ID" | grep -E -q 'rhel 7|centos 7|centos 8'; then
			if ! rpm --quiet -q epel-release; then
				yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
			fi
OS=$(uname -s)

			if [[ $ID = 'rhel' ]]; then
				subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms"
			elif [[ $ID = 'centos' ]]; then
				yum --enablerepo=extras install -y epel-release
			fi
		fi
		if echo "$ID $VERSION_ID" | grep -E -q 'centos 8'; then
			yum install -y python3-pycodestyle
			echo "Centos 8 does not have lcov and ShellCheck dependencies"
		else
			yum install -y python-pycodestyle lcov ShellCheck
		fi
		yum install -y git astyle sg3_utils pciutils
		# Additional (optional) dependencies for showing backtrace in logs
		yum install -y libunwind-devel || true
		install_shfmt
	fi
	if [[ $INSTALL_PMEM == "true" ]]; then
		# Additional dependencies for building pmem based backends
		yum install -y libpmemblk-devel || true
if [[ -e /etc/os-release ]]; then
	source /etc/os-release
fi
	if [[ $INSTALL_FUSE == "true" ]]; then
		# Additional dependencies for FUSE and NVMe-CUSE
		yum install -y fuse3-devel
	fi
	if [[ $INSTALL_RDMA == "true" ]]; then
		# Additional dependencies for RDMA transport in NVMe over Fabrics
		yum install -y libibverbs-devel librdmacm-devel
	fi
	if [[ $INSTALL_DOCS == "true" ]]; then
		# Additional dependencies for building docs
		yum install -y mscgen || echo "Warning: couldn't install mscgen via yum. Please install mscgen manually."
		yum install -y doxygen graphviz
	fi
elif [ -f /etc/debian_version ]; then
	. /etc/os-release
	VERSION_ID_NUM=$(sed 's/\.//g' <<< $VERSION_ID)
	# Includes Ubuntu, Debian
	# Minimal install
	apt-get install -y gcc g++ make libcunit1-dev libaio-dev libssl-dev \
		uuid-dev libiscsi-dev python libncurses5-dev libncursesw5-dev python3-pip
	pip3 install ninja
	pip3 install meson
	# Additional dependencies for SPDK CLI - not available on older Ubuntus
	apt-get install -y python3-configshell-fb python3-pexpect || echo \
		"Note: Some SPDK CLI dependencies could not be installed."

	# Additional dependencies for DPDK
	if [[ $NAME == "Ubuntu" ]] && [[ $VERSION_ID_NUM -lt 1900 ]]; then
		echo "Ubuntu $VERSION_ID needs NASM version 2.13.03 for DPDK but is not in the mainline repository."
		echo "You can install it manually"
	else
		apt-get install -y nasm
	fi
	apt-get install -y libnuma-dev
	# Additional dependencies for ISA-L used in compression
	apt-get install -y autoconf automake libtool help2man
	if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
		# Tools for developers
		apt-get install -y git astyle pep8 lcov clang sg3-utils pciutils shellcheck
		# Additional python style checker not available on ubuntu 16.04 or earlier.
		apt-get install -y pycodestyle || true
		# Additional (optional) dependencies for showing backtrace in logs
		apt-get install -y libunwind-dev || true
		# Additional dependecies for nvmf performance test script
		apt-get install -y python3-paramiko
		install_shfmt
	fi
	if [[ $INSTALL_PMEM == "true" ]]; then
		# Additional dependencies for building pmem based backends
		if [[ $NAME == "Ubuntu" ]] && [[ $VERSION_ID_NUM -gt 1800 ]]; then
			apt-get install -y libpmem-dev
		fi
	fi
	if [[ $INSTALL_FUSE == "true" ]]; then
		# Additional dependencies for FUSE and NVMe-CUSE
		if [[ $NAME == "Ubuntu" ]] && ((VERSION_ID_NUM > 1400 && VERSION_ID_NUM < 1900)); then
			echo "Ubuntu $VERSION_ID does not have libfuse3-dev in mainline repository."
			echo "You can install it manually"
		else
			apt-get install -y libfuse3-dev
		fi
	fi
	if [[ $INSTALL_RDMA == "true" ]]; then
		# Additional dependencies for RDMA transport in NVMe over Fabrics
		apt-get install -y libibverbs-dev librdmacm-dev
	fi
	if [[ $INSTALL_DOCS == "true" ]]; then
		# Additional dependencies for building docs
		apt-get install -y doxygen mscgen graphviz
	fi
elif [ -f /etc/SuSE-release ] || [ -f /etc/SUSE-brand ]; then
	# Minimal install
	zypper install -y gcc gcc-c++ make cunit-devel libaio-devel libopenssl-devel \
		libuuid-devel python-base ncurses-devel ninja meson
	# Additional dependencies for DPDK
	zypper install -y libnuma-devel nasm
	# Additional dependencies for ISA-L used in compression
	zypper install -y autoconf automake libtool help2man
	if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
		# Tools for developers
		zypper install -y git-core lcov python-pycodestyle sg3_utils \
			pciutils ShellCheck
		# Additional (optional) dependencies for showing backtrace in logs
		zypper install libunwind-devel || true
		install_shfmt
	fi
	if [[ $INSTALL_PMEM == "true" ]]; then
		# Additional dependencies for building pmem based backends
		zypper install -y libpmemblk-devel
	fi
	if [[ $INSTALL_FUSE == "true" ]]; then
		# Additional dependencies for FUSE and NVMe-CUSE
		zypper install -y fuse3-devel
	fi
	if [[ $INSTALL_RDMA == "true" ]]; then
		# Additional dependencies for RDMA transport in NVMe over Fabrics
		zypper install -y rdma-core-devel
	fi
	if [[ $INSTALL_DOCS == "true" ]]; then
		# Additional dependencies for building docs
		zypper install -y doxygen mscgen graphviz
	fi
elif [ $(uname -s) = "FreeBSD" ]; then
	# Minimal install
	pkg install -y gmake cunit openssl git bash misc/e2fsprogs-libuuid python \
		ncurses ninja meson
	# Additional dependencies for ISA-L used in compression
	pkg install -y autoconf automake libtool help2man
	if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
		# Tools for developers
		pkg install -y devel/astyle bash py27-pycodestyle \
			misc/e2fsprogs-libuuid sysutils/sg3_utils nasm
		install_shfmt
	fi
	if [[ $INSTALL_DOCS == "true" ]]; then
		# Additional dependencies for building docs
		pkg install -y doxygen mscgen graphviz
	fi
elif [ -f /etc/arch-release ]; then
	# Install main dependencies
	pacman -Sy --needed --noconfirm gcc make cunit libaio openssl \
		libutil-linux libiscsi python ncurses ninja meson
	# Additional dependencies for SPDK CLI
	pacman -Sy --needed --noconfirm python-pexpect python-pip
	pip install configshell_fb
	# Additional dependencies for DPDK
	pacman -Sy --needed --noconfirm numactl nasm
	# Additional dependencies for ISA-L used in compression
	pacman -Sy --needed --noconfirm autoconf automake libtool help2man
	if [[ $INSTALL_DEV_TOOLS == "true" ]]; then
		# Tools for developers
		pacman -Sy --needed --noconfirm git astyle autopep8 \
			clang sg3_utils pciutils shellcheck
		# Additional (optional) dependencies for showing backtrace in logs
		pacman -Sy --needed --noconfirm libunwind
		#fakeroot needed to instal via makepkg
		pacman -Sy --needed --noconfirm fakeroot
		su - $SUDO_USER -c "pushd /tmp;
			git clone https://aur.archlinux.org/perl-perlio-gzip.git;
			cd perl-perlio-gzip;
			yes y | makepkg -si --needed;
			cd ..; rm -rf perl-perlio-gzip
			popd"
		# sed is to modify sources section in PKGBUILD
		# By default it uses git:// which will fail behind proxy, so
		# redirect it to http:// source instead
		su - $SUDO_USER -c "pushd /tmp;
			git clone https://aur.archlinux.org/lcov-git.git;
			cd lcov-git;
			sed -i 's/git:/git+http:/' PKGBUILD;
			makepkg -si --needed --noconfirm;
			cd .. && rm -rf lcov-git;
			popd"
		install_shfmt
	fi
	if [[ $INSTALL_PMEM == "true" ]]; then
		# Additional dependencies for building pmem based backends
		pacman -Sy --needed --noconfirm ndctl pkg-config
		git clone https://github.com/pmem/pmdk.git /tmp/pmdk -b 1.6.1
		make -C /tmp/pmdk -j$(nproc)
		make install prefix=/usr -C /tmp/pmdk
		echo "/usr/local/lib" > /etc/ld.so.conf.d/pmdk.conf
		ldconfig
		rm -rf /tmp/pmdk
	fi
	if [[ $INSTALL_FUSE == "true" ]]; then
		# Additional dependencies for FUSE and NVMe-CUSE
		pacman -Sy --needed --noconfirm fuse3
	fi
	if [[ $INSTALL_RDMA == "true" ]]; then
		# Additional dependencies for RDMA transport in NVMe over Fabrics
		if [[ -n "$http_proxy" ]]; then
			gpg_options=" --keyserver hkp://pgp.mit.edu:11371 --keyserver-options \"http-proxy=$http_proxy\""
		fi
		su - $SUDO_USER -c "gpg $gpg_options --recv-keys 29F0D86B9C1019B1"
		su - $SUDO_USER -c "pushd /tmp;
			git clone https://aur.archlinux.org/rdma-core.git;
			cd rdma-core;
			makepkg -si --needed --noconfirm;
			cd .. && rm -rf rdma-core;
			popd"
	fi
	if [[ $INSTALL_DOCS == "true" ]]; then
		# Additional dependencies for building docs
		pacman -Sy --needed --noconfirm doxygen graphviz
		pacman -S --noconfirm --needed gd ttf-font
		su - $SUDO_USER -c "pushd /tmp;
			git clone https://aur.archlinux.org/mscgen.git;
			cd mscgen;
			makepkg -si --needed --noconfirm;
			cd .. && rm -rf mscgen;
			popd"
	fi
ID=${ID:-$OS} ID=${ID,,}

if [[ -e $scriptsdir/pkgdep/$ID.sh ]]; then
	source "$scriptsdir/pkgdep/$ID.sh"
else
	echo "pkgdep: unknown system type."
	exit 1
	printf 'Not supported platform detected (%s), aborting\n' "$ID" >&2
fi