From 90fa6e2d6f79adfb38ae4fcdf0aca3e6dc96a88a Mon Sep 17 00:00:00 2001 From: Wardenjohn Date: Tue, 12 Dec 2023 11:18:27 +0800 Subject: [PATCH] fix the bug of wrong shell condition and contains more distro This commit fix the fowlling problem: 1. move SUPPORTED_DISTRO to SUPPORTED_RPM_DISTROS 2. fix the wrong ID of "Anolis" to "anolis" in SUPPORTED_RPM_DISTROS 3. change distro in function to local variable 4. rename is_supported_distro to is_supported_rpm_distro; print_supported_distro to print_supported_rpm_distro 5. fix the bug of return value of is_supported_rpm_distro 6. contains ubuntu and debian release in print_supported_rpm_distro, and adjust the vmlinux search logic at the same time. --- kpatch-build/kpatch-build | 51 +++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/kpatch-build/kpatch-build b/kpatch-build/kpatch-build index 9913abe8c..eac405c7a 100755 --- a/kpatch-build/kpatch-build +++ b/kpatch-build/kpatch-build @@ -65,13 +65,15 @@ LLD="${CROSS_COMPILE:-}ld.lld" READELF="${CROSS_COMPILE:-}readelf" OBJCOPY="${CROSS_COMPILE:-}objcopy" -SUPPORTED_DISTRO=" +SUPPORTED_RPM_DISTROS=" fedora rhel centos openEuler photon - Anolis + anolis + ubuntu + debian " warn() { @@ -658,17 +660,17 @@ module_name_string() { echo "${1//[^a-zA-Z0-9_-]/-}" | cut -c 1-55 } -is_supported_distro(){ - distro=$1 - for each_distro in ${SUPPORTED_DISTRO[@]}; do +is_supported_rpm_distro(){ + local distro=$1 + for each_distro in ${SUPPORTED_RPM_DISTROS[@]}; do if [[ $distro == $each_distro ]]; then - return 1; + return 0 fi - done; - return 0 + done + return 1 } -print_supported_distro(){ +print_supported_rpm_distro(){ [[ "$DISTRO" = fedora ]] && echo "Fedora distribution detected" [[ "$DISTRO" = rhel ]] && echo "RHEL distribution detected" [[ "$DISTRO" = ol ]] && echo "Oracle Linux distribution detected" @@ -676,6 +678,8 @@ print_supported_distro(){ [[ "$DISTRO" = openEuler ]] && echo "OpenEuler distribution detected" [[ "$DISTRO" = photon ]] && echo "Photon OS distribution detected" [[ "$DISTRO" = anolis ]] && echo "Anolis OS distribution detected" + [[ "$DISTRO" = ubuntu ]] && echo "Ubuntu OS distribution detected" + [[ "$DISTRO" = debian ]] && echo "Debian OS distribution detected" } usage() { @@ -894,24 +898,23 @@ fi [[ -z "$TARGETS" ]] && TARGETS="vmlinux modules" -if is_supported_distro "$DISTRO"; then +if is_supported_rpm_distro "$DISTRO"; then - [[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux" - [[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed" + if [[ "$DISTRO" = ubuntu ]] || [[ "$DISTRO" = debian ]]; then + [[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/boot/vmlinux-$ARCHVERSION" - export PATH="/usr/lib64/ccache:$PATH" - -elif [[ "$DISTRO" = ubuntu ]] || [[ "$DISTRO" = debian ]]; then - [[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/boot/vmlinux-$ARCHVERSION" + if [[ "$DISTRO" = ubuntu ]]; then + [[ -e "$VMLINUX" ]] || die "linux-image-$ARCHVERSION-dbgsym not installed" - if [[ "$DISTRO" = ubuntu ]]; then - [[ -e "$VMLINUX" ]] || die "linux-image-$ARCHVERSION-dbgsym not installed" + elif [[ "$DISTRO" = debian ]]; then + [[ -e "$VMLINUX" ]] || die "linux-image-$ARCHVERSION-dbg not installed" + fi + else + [[ -z "$VMLINUX" ]] && VMLINUX="/usr/lib/debug/lib/modules/$ARCHVERSION/vmlinux" + [[ -e "$VMLINUX" ]] || die "kernel-debuginfo-$ARCHVERSION not installed" - elif [[ "$DISTRO" = debian ]]; then - [[ -e "$VMLINUX" ]] || die "linux-image-$ARCHVERSION-dbg not installed" + export PATH="/usr/lib64/ccache:$PATH" fi - - export PATH="/usr/lib/ccache:$PATH" fi save_env @@ -933,9 +936,9 @@ elif [[ -e "$KERNEL_SRCDIR"/.config ]] && [[ -e "$VERSIONFILE" ]] && [[ "$(cat " echo "Using cache at $KERNEL_SRCDIR" else - if is_supported_distro "$DISTRO"; then + if is_supported_rpm_distro "$DISTRO"; then - print_supported_distro "$DISTRO" + print_supported_rpm_distro "$DISTRO" clean_cache