Commit 66bb5d46 authored by Michal Berger's avatar Michal Berger Committed by Konrad Sztyber
Browse files

pkgdep/git: Support iRDMA installation under ubuntu



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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 63e0c25d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ sudo() {
}

set -e
shopt -s extglob
shopt -s extglob nullglob

UPGRADE=false
INSTALL=false
+66 −34
Original line number Diff line number Diff line
@@ -311,14 +311,31 @@ function install_igb_uio() {
function install_irdma() {
	local RDMA_CORE_VERSION=51.0
	local RDMA_CORE=https://github.com/linux-rdma/rdma-core/releases/download/v$RDMA_CORE_VERSION/rdma-core-$RDMA_CORE_VERSION.tar.gz

	if [[ $ID != fedora ]]; then
		echo "Installation of the irdma can be attempted only on Fedora"
	local packages=() hint=""

	case "$ID" in
		fedora)
			install \
				ninja-build \
				pandoc \
				perl-generators \
				valgrind-devel \
				python-docutils \
				libnl3 \
				libnl3-devel \
				python3-Cython
				;;
		debian | ubuntu)
			install \
				debhelper \
				dh-python \
				python3-docutils
			;;
		*)
			echo "irdma installation not supported under $ID" >&2
			return 0
	fi

	# Install extra dependencies needed by the rdma-core
	install ninja-build pandoc perl-generators valgrind-devel python-docutils libnl3 libnl3-devel python3-Cython
			;;
	esac

	rm -rf "$GIT_REPOS/irdma-$IRDMA_VERSION"
	rm -rf "$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION"
@@ -346,13 +363,17 @@ function install_irdma() {
	patch --dir="$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION" -p2 \
		< "$GIT_REPOS/irdma-$IRDMA_VERSION/libirdma-$RDMA_CORE_VERSION.patch"

	# Note that paths and the name of the package are hardcoded into .spec, hence they need to stay like this.
	case "$ID" in
		fedora)
			[[ -e $GIT_REPOS/rdma-core-$RDMA_CORE_VERSION/redhat/rdma-core.spec ]]
			# Note that paths and the name of the package are hardcoded into .spec, hence they need
			# to stay like this.
			mkdir -p "$HOME/rpmbuild/"{SOURCES,SPECS}
			cp "$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION/redhat/rdma-core.spec" "$HOME/rpmbuild/SPECS"

			# Re-package the source
	tar -czf "$HOME/rpmbuild/SOURCES/rdma-core-$RDMA_CORE_VERSION.tar.gz" -C "$GIT_REPOS" "rdma-core-$RDMA_CORE_VERSION"
			tar -czf "$HOME/rpmbuild/SOURCES/rdma-core-$RDMA_CORE_VERSION.tar.gz" \
				-C "$GIT_REPOS" "rdma-core-$RDMA_CORE_VERSION"

			# Build the rpms
			(
@@ -361,29 +382,40 @@ function install_irdma() {
				PATH="/usr/bin:$PATH" rpmbuild -ba rdma-core.spec
			)

	# Now, don't install the packages since this will, most likely, conflict with packages already installed
	# in the system. Instead, simply inform user what the next step is and note what potential issues it may
	# have with the installation.
			packages=("$HOME/rpmbuild/RPMS/x86_64/"*.rpm)
			hint="$package_manager install [--allowerasing] $HOME/rpmbuild/RPMS/x86_64/*.rpm"
			;;
		debian | ubuntu)
			[[ -e $GIT_REPOS/rdma-core-$RDMA_CORE_VERSION/debian/control ]]

			# Build the debs
			(
				cd "$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION"
				dh clean --with python3,systemd --builddirectory=build-deb
				dh build --with systemd --builddirectory=build-deb
				dh binary --with systemd --builddirectory=build-deb
			)

			packages=("$GIT_REPOS/"*.deb)
			hint="dpkg --install $GIT_REPOS/*.deb"
			;;
	esac

	shopt -s nullglob
	local rpms=("$HOME/rpmbuild/RPMS/x86_64/"*.rpm)
	shopt -u nullglob
	((${#rpms[@]} > 0))
	((${#packages[@]} > 0)) || return 1

	cat <<-EOF

		INFO: rdma-core-$RDMA_CORE_VERSION was successfully built, following packages are
		available for installation:

		$(printf '  - %s\n' "${rpms[@]##*/}")
		$(printf '  - %s\n' "${packages[@]##*/}")

		Note that installing the above packages may raise conflicts with their
		potentially newer versions already installed on the system. Dependent
		packages may be uninstalled during the process as well. Please, run the
		following command to finish the installation:

		  $package_manager install [--allowerasing] $HOME/rpmbuild/RPMS/x86_64/*.rpm

		  $hint
	EOF
}