1#!/usr/bin/env bash 2# Please run this script as root. 3 4set -e 5 6function usage() 7{ 8 echo "" 9 echo "This script is intended to automate the installation of package dependencies to build SPDK." 10 echo "Please run this script as root user." 11 echo "" 12 echo "$0" 13 echo " -h --help" 14 echo "" 15 exit 0 16} 17 18INSTALL_CRYPTO=false 19 20while getopts 'hi-:' optchar; do 21 case "$optchar" in 22 -) 23 case "$OPTARG" in 24 help) usage;; 25 *) echo "Invalid argument '$OPTARG'" 26 usage;; 27 esac 28 ;; 29 h) usage;; 30 *) echo "Invalid argument '$OPTARG'" 31 usage;; 32 esac 33done 34 35trap 'set +e; trap - ERR; echo "Error!"; exit 1;' ERR 36 37scriptsdir=$(readlink -f $(dirname $0)) 38rootdir=$(readlink -f $scriptsdir/..) 39 40if [ -s /etc/redhat-release ]; then 41 . /etc/os-release 42 43 # Includes Fedora, CentOS 7, RHEL 7 44 # Add EPEL repository for CUnit-devel and libunwind-devel 45 if echo "$ID $VERSION_ID" | egrep -q 'rhel 7|centos 7'; then 46 if ! rpm --quiet -q epel-release; then 47 yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 48 fi 49 50 if [ $ID = 'rhel' ]; then 51 subscription-manager repos --enable "rhel-*-optional-rpms" --enable "rhel-*-extras-rpms" 52 elif [ $ID = 'centos' ]; then 53 yum --enablerepo=extras install -y epel-release 54 fi 55 fi 56 57 yum install -y gcc gcc-c++ make CUnit-devel libaio-devel openssl-devel \ 58 git astyle python-pycodestyle lcov python clang-analyzer libuuid-devel \ 59 sg3_utils libiscsi-devel pciutils 60 # Additional (optional) dependencies for showing backtrace in logs 61 yum install -y libunwind-devel || true 62 # Additional dependencies for NVMe over Fabrics 63 yum install -y libibverbs-devel librdmacm-devel 64 # Additional dependencies for DPDK 65 yum install -y numactl-devel nasm 66 # Additional dependencies for building docs 67 yum install -y doxygen mscgen graphviz 68 # Additional dependencies for building pmem based backends 69 yum install -y libpmemblk-devel || true 70 # Additional dependencies for SPDK CLI - not available in rhel and centos 71 if ! echo "$ID $VERSION_ID" | egrep -q 'rhel 7|centos 7'; then 72 yum install -y python3-configshell python3-pexpect 73 fi 74 # Additional dependencies for ISA-L used in compression 75 yum install -y autoconf automake libtool help2man 76elif [ -f /etc/debian_version ]; then 77 # Includes Ubuntu, Debian 78 apt-get install -y gcc g++ make libcunit1-dev libaio-dev libssl-dev \ 79 git astyle pep8 lcov clang uuid-dev sg3-utils libiscsi-dev pciutils 80 # Additional python style checker not available on ubuntu 16.04 or earlier. 81 apt-get install -y pycodestyle || true 82 # Additional (optional) dependencies for showing backtrace in logs 83 apt-get install -y libunwind-dev || true 84 # Additional dependencies for NVMe over Fabrics 85 apt-get install -y libibverbs-dev librdmacm-dev 86 # Additional dependencies for DPDK 87 apt-get install -y libnuma-dev nasm 88 # Additional dependencies for building docs 89 apt-get install -y doxygen mscgen graphviz 90 # Additional dependencies for SPDK CLI - not available on older Ubuntus 91 apt-get install -y python3-configshell-fb python3-pexpect || echo \ 92 "Note: Some SPDK CLI dependencies could not be installed." 93 # Additional dependencies for ISA-L used in compression 94 apt-get install -y autoconf automake libtool help2man 95elif [ -f /etc/SuSE-release ] || [ -f /etc/SUSE-brand ]; then 96 zypper install -y gcc gcc-c++ make cunit-devel libaio-devel libopenssl-devel \ 97 git-core lcov python-base python-pycodestyle libuuid-devel sg3_utils pciutils 98 # Additional (optional) dependencies for showing backtrace in logs 99 zypper install libunwind-devel || true 100 # Additional dependencies for NVMe over Fabrics 101 zypper install -y rdma-core-devel 102 # Additional dependencies for DPDK 103 zypper install -y libnuma-devel nasm 104 # Additional dependencies for building pmem based backends 105 zypper install -y libpmemblk-devel 106 # Additional dependencies for building docs 107 zypper install -y doxygen mscgen graphviz 108 # Additional dependencies for ISA-L used in compression 109 zypper install -y autoconf automake libtool help2man 110elif [ $(uname -s) = "FreeBSD" ] ; then 111 pkg install -y gmake cunit openssl git devel/astyle bash py27-pycodestyle \ 112 python misc/e2fsprogs-libuuid sysutils/sg3_utils nasm 113 # Additional dependencies for building docs 114 pkg install -y doxygen mscgen graphviz 115 # Additional dependencies for ISA-L used in compression 116 pkg install -y autoconf automake libtool help2man 117else 118 echo "pkgdep: unknown system type." 119 exit 1 120fi 121