Skip to content

Commit

Permalink
kpatch-build: add support for OpenCloudOS
Browse files Browse the repository at this point in the history
OpenCloudOS is a centos-like Linux distribution.
I test kpatch in OpenCloudOS V8 and V9.
It works well in V9. But v8 itself has two problems:
1. no available epol repo, so kpatch can't install ccache.
2. executing 'uname -r' can't get an accurate kernel version.

Both problems have been notified to the OpenCloudOS community.
After they fix these problems, kpatch will work well in all versions.

Signed-off-by: Longjun Luo <[email protected]>
  • Loading branch information
anatasluo committed Jan 16, 2024
1 parent 032c8d2 commit 493849c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kpatch-build/kpatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ fi

if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] ||
[[ "$DISTRO" = centos ]] || [[ "$DISTRO" = openEuler ]] ||
[[ "$DISTRO" = photon ]]; then
[[ "$DISTRO" = photon ]] || [[ "$DISTRO" = opencloudos ]]; then

[[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux"
[[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed"
Expand Down Expand Up @@ -910,14 +910,16 @@ elif [[ -e "$KERNEL_SRCDIR"/.config ]] && [[ -e "$VERSIONFILE" ]] && [[ "$(cat "
echo "Using cache at $KERNEL_SRCDIR"

else
if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]] || [[ "$DISTRO" = openEuler ]] || [[ "$DISTRO" = photon ]]; then
if [[ "$DISTRO" = fedora ]] || [[ "$DISTRO" = rhel ]] || [[ "$DISTRO" = ol ]] || [[ "$DISTRO" = centos ]] ||
[[ "$DISTRO" = openEuler ]] || [[ "$DISTRO" = photon ]] || [[ "$DISTRO" = opencloudos ]]; then

[[ "$DISTRO" = fedora ]] && echo "Fedora distribution detected"
[[ "$DISTRO" = rhel ]] && echo "RHEL distribution detected"
[[ "$DISTRO" = ol ]] && echo "Oracle Linux distribution detected"
[[ "$DISTRO" = centos ]] && echo "CentOS distribution detected"
[[ "$DISTRO" = openEuler ]] && echo "OpenEuler distribution detected"
[[ "$DISTRO" = photon ]] && echo "Photon OS distribution detected"
[[ "$DISTRO" = opencloudos ]] && echo "opencloudos distribution detected"

clean_cache

Expand Down Expand Up @@ -982,6 +984,8 @@ else
cp "$RPMTOPDIR"/SOURCES/"$SRC_CFG" "$RPMTOPDIR"/BUILD/linux-"$KVER" | logger || die
fi
mv "$RPMTOPDIR"/BUILD/linux-"$KVER" "$KERNEL_SRCDIR" 2>&1 | logger || die
elif [[ "$DISTRO" = opencloudos ]]; then
mv "$RPMTOPDIR"/BUILD/kernel-*/kernel-* "$KERNEL_SRCDIR" 2>&1 | logger || die
else
mv "$RPMTOPDIR"/BUILD/kernel-*/linux-* "$KERNEL_SRCDIR" 2>&1 | logger || die
fi
Expand All @@ -995,7 +999,7 @@ else

echo "$ARCHVERSION" > "$VERSIONFILE" || die

if [[ "$DISTRO" = openEuler ]]; then
if [[ "$DISTRO" = openEuler ]] || [[ "$DISTRO" = opencloudos ]]; then
[[ -z "$CONFIGFILE" ]] && CONFIGFILE="/boot/config-${ARCHVERSION}"
elif [[ "$DISTRO" = photon ]]; then
[[ -z "$CONFIGFILE" ]] && CONFIGFILE="$KERNEL_SRCDIR/$SRC_CFG"
Expand Down
13 changes: 13 additions & 0 deletions test/integration/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ kpatch_photon_dependencies()
fi
}

kpatch_opencloudos_dependencies()
{
local kernel_version
local arch
kernel_version=$(uname -r)
arch=$(uname -m)

sudo yum install -y elfutils elfutils-devel gcc gcc-c++ git ccache \
rpm-build wget dnf-utils "kernel-devel-${kernel_version}*"
sudo debuginfo-install -y "kernel-${kernel_version}*"
sudo yum-builddep -y "kernel-${kernel_version}*"
}

kpatch_dependencies()
{
# shellcheck disable=SC1091
Expand Down

0 comments on commit 493849c

Please sign in to comment.