2018-10-01 18:47:23 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-11-02 15:49:40 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2017 Intel Corporation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2017-11-15 22:15:06 +00:00
|
|
|
|
|
|
|
# The purpose of this script is to provide a simple procedure for spinning up a new
|
2023-02-24 00:19:14 +00:00
|
|
|
# test environment capable of running our whole test suite. This script will install
|
|
|
|
# all of the necessary dependencies to run almost the complete test suite.
|
2017-11-15 22:15:06 +00:00
|
|
|
|
2020-06-02 09:24:58 +00:00
|
|
|
sudo() {
|
|
|
|
"$(type -P sudo)" -E "$@"
|
|
|
|
}
|
|
|
|
|
2017-11-15 22:15:06 +00:00
|
|
|
set -e
|
2020-07-27 06:43:00 +00:00
|
|
|
shopt -s extglob
|
2017-11-15 22:15:06 +00:00
|
|
|
|
2018-06-26 20:47:41 +00:00
|
|
|
UPGRADE=false
|
|
|
|
INSTALL=false
|
2021-08-06 10:09:31 +00:00
|
|
|
CONF="rocksdb,fio,flamegraph,tsocks,qemu,libiscsi,nvmecli,qat,spdk,refspdk,vagrant,igb_uio,ice"
|
2020-07-27 06:43:00 +00:00
|
|
|
package_manager=
|
2018-12-04 19:27:57 +00:00
|
|
|
|
2020-09-11 13:48:03 +00:00
|
|
|
function pre_install() { :; }
|
|
|
|
function install() { :; }
|
|
|
|
function upgrade() { :; }
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function usage() {
|
|
|
|
echo "This script is intended to automate the environment setup for a linux virtual machine."
|
|
|
|
echo "Please run this script as your regular user. The script will make calls to sudo as needed."
|
|
|
|
echo ""
|
|
|
|
echo "./vm_setup.sh"
|
|
|
|
echo " -h --help"
|
2020-06-25 07:35:13 +00:00
|
|
|
echo " -u --upgrade Run $package_manager upgrade"
|
|
|
|
echo " -i --install-deps Install $package_manager based dependencies"
|
2022-07-08 08:20:40 +00:00
|
|
|
echo " -t --test-conf List of test configurations to enable (${CONF},irdma,lcov,bpftrace)"
|
2020-05-07 11:27:06 +00:00
|
|
|
echo " -c --conf-path Path to configuration file"
|
2020-06-02 08:48:47 +00:00
|
|
|
echo " -d --dir-git Path to where git sources should be saved"
|
2020-06-05 15:22:50 +00:00
|
|
|
echo " -s --disable-tsocks Disable use of tsocks"
|
2020-07-27 06:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function error() {
|
|
|
|
printf "%s\n\n" "$1" >&2
|
2023-02-24 00:19:14 +00:00
|
|
|
usage
|
|
|
|
return 1
|
2020-07-27 06:43:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_os_id_version() {
|
|
|
|
if [[ -f /etc/os-release ]]; then
|
|
|
|
source /etc/os-release
|
|
|
|
elif [[ -f /usr/local/etc/os-release ]]; then
|
|
|
|
# On FreeBSD file is located under /usr/local if etc_os-release package is installed
|
|
|
|
source /usr/local/etc/os-release
|
2020-09-16 08:30:13 +00:00
|
|
|
elif [[ $(uname -s) == FreeBSD ]]; then
|
|
|
|
ID=freebsd
|
|
|
|
VERSION_ID=$(freebsd-version)
|
|
|
|
VERSION_ID=${VERSION_ID//.*/}
|
2020-07-27 06:43:00 +00:00
|
|
|
else
|
|
|
|
echo "File os-release not found" >&2
|
2023-02-24 00:19:14 +00:00
|
|
|
return 1
|
2020-07-27 06:43:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
OSID=$ID
|
|
|
|
OSVERSION=$VERSION_ID
|
|
|
|
|
|
|
|
echo "OS-ID: $OSID | OS-Version: $OSVERSION"
|
|
|
|
}
|
|
|
|
|
|
|
|
function detect_package_manager() {
|
|
|
|
local manager_scripts
|
|
|
|
manager_scripts=("$vmsetupdir/pkgdep/"!(git))
|
|
|
|
|
|
|
|
local package_manager_lib
|
|
|
|
for package_manager_lib in "${manager_scripts[@]}"; do
|
|
|
|
package_manager=${package_manager_lib##*/}
|
|
|
|
if hash "${package_manager}" &> /dev/null; then
|
|
|
|
source "${package_manager_lib}"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
2018-06-26 20:47:41 +00:00
|
|
|
}
|
|
|
|
|
2020-05-18 15:20:37 +00:00
|
|
|
vmsetupdir=$(readlink -f "$(dirname "$0")")
|
|
|
|
rootdir=$(readlink -f "$vmsetupdir/../../../")
|
2020-10-22 15:28:43 +00:00
|
|
|
source "$rootdir/scripts/common.sh"
|
2020-05-18 15:20:37 +00:00
|
|
|
|
2020-07-27 06:43:00 +00:00
|
|
|
set_os_id_version
|
2023-02-24 00:19:14 +00:00
|
|
|
source "$vmsetupdir/pkgdep/git"
|
2020-07-27 06:43:00 +00:00
|
|
|
detect_package_manager
|
2018-12-04 19:27:57 +00:00
|
|
|
|
config/pkgdep: Allow for sourcing OS-based routines
vm_setup.sh currently depends on package managers to determine which
SPDK dependencies must be installed, however, this may cause issues on
systems which provide more than one package manager, e.g., dnf and
yum. Due to that fact, some packages were missing since they were
bound to a specific package manager instead of the distribution, case
and point, nbd. Also, some OS-dependent steps had to be duplicated,
like repo refresh on Centos8, since either of the managers could be
in use.
To address the above, allow for souring of OS-based routines to
overwrite defaults set based on given package manager.
Change-Id: I0d8d88dea4521e9c76b187c69743e4e09aa724e6
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4017
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
2020-09-01 12:41:45 +00:00
|
|
|
if [[ -e $vmsetupdir/pkgdep/os/$OSID ]]; then
|
|
|
|
source "$vmsetupdir/pkgdep/os/$OSID"
|
|
|
|
fi
|
|
|
|
|
2018-12-04 19:27:57 +00:00
|
|
|
# Parse input arguments #
|
2020-06-05 15:22:50 +00:00
|
|
|
while getopts 'd:siuht:c:-:' optchar; do
|
2020-05-07 11:27:06 +00:00
|
|
|
case "$optchar" in
|
|
|
|
-)
|
|
|
|
case "$OPTARG" in
|
2023-02-24 00:19:14 +00:00
|
|
|
help)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2020-05-07 11:27:06 +00:00
|
|
|
upgrade) UPGRADE=true ;;
|
|
|
|
install-deps) INSTALL=true ;;
|
|
|
|
test-conf=*) CONF="${OPTARG#*=}" ;;
|
|
|
|
conf-path=*) CONF_PATH="${OPTARG#*=}" ;;
|
2020-06-02 08:48:47 +00:00
|
|
|
dir-git=*) GIT_REPOS="${OPTARG#*=}" ;;
|
2020-06-05 15:22:50 +00:00
|
|
|
disable-tsocks) NO_TSOCKS=true ;;
|
2020-07-27 06:43:00 +00:00
|
|
|
*) error "Invalid argument '$OPTARG'" ;;
|
2020-05-07 11:27:06 +00:00
|
|
|
esac
|
|
|
|
;;
|
2023-02-24 00:19:14 +00:00
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2020-05-07 11:27:06 +00:00
|
|
|
u) UPGRADE=true ;;
|
|
|
|
i) INSTALL=true ;;
|
|
|
|
t) CONF="$OPTARG" ;;
|
|
|
|
c) CONF_PATH="$OPTARG" ;;
|
2020-06-02 08:48:47 +00:00
|
|
|
d) GIT_REPOS="$OPTARG" ;;
|
2020-06-05 15:22:50 +00:00
|
|
|
s) NO_TSOCKS=true ;;
|
2020-07-27 06:43:00 +00:00
|
|
|
*) error "Invalid argument '$OPTARG'" ;;
|
2020-05-07 11:27:06 +00:00
|
|
|
esac
|
2018-06-26 20:47:41 +00:00
|
|
|
done
|
|
|
|
|
2023-02-24 00:19:14 +00:00
|
|
|
if [[ -z $package_manager ]]; then
|
2020-06-25 09:01:02 +00:00
|
|
|
echo "Supported package manager not found. Script supports:"
|
2020-07-27 06:43:00 +00:00
|
|
|
printf " * %s\n" "${manager_scripts[@]##*/}"
|
2020-06-25 09:01:02 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-07-27 06:43:00 +00:00
|
|
|
if [[ -n $CONF_PATH ]]; then
|
2023-02-24 00:19:14 +00:00
|
|
|
if [[ ! -f $CONF_PATH ]]; then
|
2020-07-27 06:43:00 +00:00
|
|
|
error "Configuration file does not exist: '$CONF_PATH'"
|
2020-05-07 11:27:06 +00:00
|
|
|
fi
|
2023-02-24 00:19:14 +00:00
|
|
|
source "$CONF_PATH"
|
2018-06-22 17:57:00 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-26 20:47:41 +00:00
|
|
|
if $UPGRADE; then
|
2020-05-18 15:20:37 +00:00
|
|
|
upgrade
|
2018-06-26 20:47:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if $INSTALL; then
|
2020-05-18 15:20:37 +00:00
|
|
|
sudo "$rootdir/scripts/pkgdep.sh" --all
|
|
|
|
pre_install
|
|
|
|
install "${packages[@]}"
|
2020-04-23 05:57:53 +00:00
|
|
|
fi
|
|
|
|
|
2021-02-08 13:10:17 +00:00
|
|
|
install_sources
|