test/integration/lib.sh: fix kernel build dependencies

The yum-builddep utility doesn't always install all the kernel build
dependencies.  Using the --skip-unavailable flag (rhel8+) lets us skip
over packages that it can't find, but continue to install the ones it
can. (Unavailable packages are usually platform-specific or not strictly
necessary for kpatch-build's kernel build invocation.)

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
This commit is contained in:
Joe Lawrence 2022-05-23 08:47:18 -04:00
parent 6b0b482d16
commit e72b876f97
1 changed files with 21 additions and 26 deletions

View File

@ -58,38 +58,33 @@ kpatch_rhel_dependencies()
local kernel_version
local arch
local rhel_major
local py_version
local yum_utils_version
kernel_version=$(uname -r)
arch=$(uname -m)
rhel_major=${VERSION_ID%%.*}
if [ "${rhel_major}" -ge 8 ]; then
py_version="3"
else
py_version="2"
fi
sudo yum install -y git gcc gcc-c++ "kernel-devel-${kernel_version%.*}" elfutils elfutils-devel
sudo yum install -y yum-utils zlib-devel binutils-devel newt-devel \
python${py_version}-devel perl-ExtUtils-Embed audit-libs-devel numactl-devel \
pciutils-devel bison ncurses-devel rpm-build java-devel
sudo yum-builddep -y "kernel-${kernel_version%.*}"
# kpatch-build dependencies
sudo yum install -y \
elfutils \
elfutils-devel \
gcc \
gcc-c++ \
git \
"kernel-devel-${kernel_version%.*}" \
rpm-build \
wget \
yum-utils
sudo debuginfo-install -y "kernel-${kernel_version%.*}"
[[ "$arch" == "ppc64le" ]] && sudo yum install -y gcc-plugin-devel
case "${arch}" in
"x86_64")
sudo yum install -y pesign
;;
"ppc64le")
sudo yum install -y gcc-plugin-devel
if [ "${rhel_major}" -ge 8 ]; then
# yum-builddep doesn't provide everything we need :(
sudo yum install -y flex openssl-devel
# kernel dependencies
yum_utils_version=$(rpm -q --queryformat="%{version}" yum-utils)
if [[ "${yum_utils_version}" = "$(echo -e "${yum_utils_version}\\n4.0.12" | sort -rV | head -n1)" ]]; then
sudo yum-builddep -y --skip-unavailable "kernel-${kernel_version%.*}"
else
sudo yum-builddep -y "kernel-${kernel_version%.*}"
fi
;;
*)
;;
esac
[[ "$arch" == "x86_64" ]] && sudo yum install -y pesign
# ccache
if ! command -v ccache &> /dev/null; then