From c091cf7b2cb7d54f3326dc4645dcd4f55a709da5 Mon Sep 17 00:00:00 2001 From: Arun-Prasad-V Date: Tue, 13 Aug 2024 16:30:35 +0530 Subject: [PATCH] updated manual patch script for ubuntu 24 support --- scripts/patch-realsense-ubuntu-lts-hwe.sh | 5 +++-- scripts/patch-utils-hwe.sh | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/patch-realsense-ubuntu-lts-hwe.sh b/scripts/patch-realsense-ubuntu-lts-hwe.sh index da42db9830..820d5ec3b2 100755 --- a/scripts/patch-realsense-ubuntu-lts-hwe.sh +++ b/scripts/patch-realsense-ubuntu-lts-hwe.sh @@ -71,7 +71,7 @@ source ./scripts/patch-utils-hwe.sh LINUX_BRANCH=${LINUX_BRANCH:-$(uname -r)} # Get the required tools and headers to build the kernel -sudo apt-get install linux-headers-generic linux-headers-$LINUX_BRANCH build-essential git bc -y +sudo apt-get install linux-headers-$LINUX_BRANCH build-essential git bc -y #Packages to build the patched modules require_package libusb-1.0-0-dev require_package libssl-dev @@ -137,7 +137,7 @@ if [ $rebuild_ko -eq 0 ]; then #Search the repository for the tag that matches the mmaj.min.patch-build of Ubuntu kernel kernel_full_num=$(echo $LINUX_BRANCH | cut -d '-' -f 1,2) - if [ "${ubuntu_codename}" != "jammy" ]; + if [[ "${ubuntu_codename}" != "jammy" && "${ubuntu_codename}" != "noble" ]]; then kernel_git_tag=$(git ls-remote --tags origin | grep "${kernel_full_num}\." | grep '[^^{}]$' | tail -n 1 | awk -F/ '{print $NF}') else @@ -330,6 +330,7 @@ fi # As a precausion start with unloading the core uvcvideo: try_unload_module uvcvideo try_unload_module videobuf2_v4l2 +[ ${k_maj_min} -ge 608 ] && try_unload_module videobuf2_memops [ ${k_maj_min} -ge 500 ] && try_unload_module videobuf2_common [ ${k_maj_min} -ge 605 ] && try_unload_module uvc try_unload_module videodev diff --git a/scripts/patch-utils-hwe.sh b/scripts/patch-utils-hwe.sh index b1ff9412b1..e96d89a39d 100644 --- a/scripts/patch-utils-hwe.sh +++ b/scripts/patch-utils-hwe.sh @@ -157,7 +157,7 @@ function choose_kernel_branch { ;; esac else - echo -e "\e[31mUnsupported distribution $2, kernel version $1 . The patches are maintained for Ubuntu 16/18/20/22/24 LTS\e[0m" >&2 + echo -e "\e[31mUnsupported distribution $2, kernel version $1 . The patches are maintained for Ubuntu 20/22/24 LTS\e[0m" >&2 exit 1 fi } @@ -232,7 +232,10 @@ function try_module_insert { fi # backup the existing module (if available) for recovery - if [ -f ${tgt_ko} ]; + if [ -f ${tgt_ko}.zst ]; + then + sudo cp ${tgt_ko}.zst ${tgt_ko}.zst.bckup + elif [ -f ${tgt_ko} ]; then sudo cp ${tgt_ko} ${tgt_ko}.bckup else @@ -254,7 +257,12 @@ function try_module_insert { echo -e "\e[31mVerify that the current kernel version is aligned to the patched module version\e[0m" if [ ${backup_available} -ne 0 ]; then - sudo cp ${tgt_ko}.bckup ${tgt_ko} + if [ -f ${tgt_ko}.zst.bckup ]; + then + sudo cp ${tgt_ko}.zst.bckup ${tgt_ko}.zst + else + sudo cp ${tgt_ko}.bckup ${tgt_ko} + fi sudo modprobe ${module_name} printf "\e[34mThe original \e[33m %s \e[34m module was reloaded\n\e[0m" ${module_name} fi @@ -262,7 +270,8 @@ function try_module_insert { else # Everything went OK, delete backup printf "\e[32m succeeded\e[0m" - sudo rm ${tgt_ko}.bckup + sudo rm -f ${tgt_ko}.zst.bckup + sudo rm -f ${tgt_ko}.bckup fi # Reload all dependent modules recursively