fix(scripts/falco-driver-loader): fixed ubuntu kernel version

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
This commit is contained in:
Roberto Scolaro 2023-06-12 15:27:50 +00:00 committed by poiana
parent e7534d9455
commit c2af4c3a21

View File

@ -165,14 +165,26 @@ get_target_id() {
("ubuntu") ("ubuntu")
# Extract the flavor from the kernelrelease # Extract the flavor from the kernelrelease
# Examples: # Examples:
# 5.0.0-1028-aws-5.0 -> ubuntu-aws-5.0 # 5.0.0-1028-aws-5.0 -> ubuntu-aws
# 5.15.0-1009-aws -> ubuntu-aws # 5.15.0-1009-aws -> ubuntu-aws
if [[ $KERNEL_RELEASE =~ -([a-zA-Z]+)(-.*)?$ ]]; if [[ $KERNEL_RELEASE =~ -([a-zA-Z]+)(-.*)?$ ]];
then then
TARGET_ID="ubuntu-${BASH_REMATCH[1]}${BASH_REMATCH[2]}" TARGET_ID="ubuntu-${BASH_REMATCH[1]}"
else else
TARGET_ID="ubuntu-generic" TARGET_ID="ubuntu-generic"
fi fi
# In the case that the kernelversion isn't just a number
# we keep also the remaining part excluding `-Ubuntu`.
# E.g.:
# from the following `uname -v` result
# `#26~22.04.1-Ubuntu SMP Mon Apr 24 01:58:15 UTC 2023`
# we obtain the kernelversion`26~22.04.1`
if [[ $(uname -v) =~ (^\#[0-9]+\~[^-]*-Ubuntu .*$) ]];
then
KERNEL_VERSION=$(uname -v | sed 's/#\([^-\\ ]*\).*/\1/g')
fi
;; ;;
("flatcar") ("flatcar")
KERNEL_RELEASE="${VERSION_ID}" KERNEL_RELEASE="${VERSION_ID}"