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

pkgdep/helpers: Move helper functions to dedicated helpers.sh



This is done to make sure all other pieces, not only common.sh,
have access to these functions.

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


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 5f5c5275
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ trap 'set +e; trap - ERR; echo "Error!"; exit 1;' ERR
scriptsdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $scriptsdir/..)
source "$rootdir/scripts/common.sh"
source "$scriptsdir/pkgdep/helpers.sh"

OS=$(uname -s)

+0 −25
Original line number Diff line number Diff line
@@ -237,31 +237,6 @@ install_golangci_lint() {
	pkgdep_toolpath golangci_lint "${golangcidir}"
}

pkgdep_toolpath() {
	# Usage: pkgdep_toolpath TOOL DIR
	#
	# Regenerates /etc/opt/spdk-pkgdep/paths to ensure that
	# TOOL in DIR will be in PATH before other versions
	# of the TOOL installed in the system.
	local toolname="$1"
	local toolpath="$2"
	local toolpath_dir="/etc/opt/spdk-pkgdep/paths"
	local toolpath_file="${toolpath_dir}/${toolname}.path"
	local export_file="${toolpath_dir}/export.sh"
	mkdir -p "$(dirname "${toolpath_file}")"
	echo "${toolpath}" > "${toolpath_file}" || {
		echo "cannot write toolpath ${toolpath} to ${toolpath_file}"
		return 1
	}
	echo "# generated, source this file in shell" > "${export_file}"
	for pathfile in "${toolpath_dir}"/*.path; do
		echo "PATH=$(< ${pathfile}):\$PATH" >> "${export_file}"
	done
	echo "export PATH" >> "${export_file}"
	echo "echo \$PATH" >> "${export_file}"
	chmod a+x "${export_file}"
}

if [[ $INSTALL_DEV_TOOLS == true ]]; then
	install_shfmt
	install_spdk_bash_completion
+30 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
#  SPDX-License-Identifier: BSD-3-Clause
#  Copyright (C) 2024 Intel Corporation
#  All rights reserved.
#

pkgdep_toolpath() {
	# Usage: pkgdep_toolpath TOOL DIR
	#
	# Regenerates /etc/opt/spdk-pkgdep/paths to ensure that
	# TOOL in DIR will be in PATH before other versions
	# of the TOOL installed in the system.
	local toolname="$1"
	local toolpath="$2"
	local toolpath_dir="/etc/opt/spdk-pkgdep/paths"
	local toolpath_file="${toolpath_dir}/${toolname}.path"
	local export_file="${toolpath_dir}/export.sh"
	mkdir -p "$(dirname "${toolpath_file}")"
	echo "${toolpath}" > "${toolpath_file}" || {
		echo "cannot write toolpath ${toolpath} to ${toolpath_file}"
		return 1
	}
	echo "# generated, source this file in shell" > "${export_file}"
	for pathfile in "${toolpath_dir}"/*.path; do
		echo "PATH=$(< ${pathfile}):\$PATH" >> "${export_file}"
	done
	echo "export PATH" >> "${export_file}"
	echo "echo \$PATH" >> "${export_file}"
	chmod a+x "${export_file}"
}