From 101aa20232e133c4b746f28a47507bad96ab4aa1 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Wed, 25 Jan 2023 15:57:59 +0100 Subject: [PATCH] fix(scripts): fix falco-driver-loader for some debian kernels. Signed-off-by: Federico Di Pierro --- scripts/falco-driver-loader | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/falco-driver-loader b/scripts/falco-driver-loader index 4a1d496a93a..176f1b60281 100755 --- a/scripts/falco-driver-loader +++ b/scripts/falco-driver-loader @@ -134,6 +134,25 @@ get_target_id() { TARGET_ID="amazonlinux" fi ;; + ("debian") + # Workaround: debian kernelreleases might now be actual kernel running; + # instead, they might be the Debian kernel package + # providing the compatible kernel ABI + # See https://lists.debian.org/debian-user/2017/03/msg00485.html + # Real kernel release is embedded inside the kernel version. + # Moreover, kernel arch, when present, is attached to the former, + # therefore make sure to properly take it and attach it to the latter. + TARGET_ID=$(echo "${OS_ID}" | tr '[:upper:]' '[:lower:]') + local ARCH_extra="" + if [[ $KERNEL_RELEASE =~ -(amd64|arm64) ]]; + then + ARCH_extra="-${BASH_REMATCH[1]}" + fi + if [[ $(uname -v) =~ ([0-9]+\.[0-9]+\.[0-9]+\-[0-9]+) ]]; + then + KERNEL_RELEASE="${BASH_REMATCH[1]}${ARCH_extra}" + fi + ;; ("ubuntu") # Extract the flavor from the kernelrelease # Examples: @@ -151,7 +170,7 @@ get_target_id() { TARGET_ID=$(echo "${OS_ID}" | tr '[:upper:]' '[:lower:]') ;; ("minikube") - TARGET_ID="${OS_ID}" + TARGET_ID=$(echo "${OS_ID}" | tr '[:upper:]' '[:lower:]') # Extract the minikube version. Ex. With minikube version equal to "v1.26.0-1655407986-14197" the extracted version # will be "1.26.0" if [[ $(cat ${HOST_ROOT}/etc/VERSION) =~ ([0-9]+(\.[0-9]+){2}) ]]; then @@ -163,7 +182,7 @@ get_target_id() { fi ;; ("bottlerocket") - TARGET_ID="${OS_ID}" + TARGET_ID=$(echo "${OS_ID}" | tr '[:upper:]' '[:lower:]') # variant_id has been sourced from os-release. Get only the first variant part if [[ -n ${VARIANT_ID} ]]; then # take just first part (eg: VARIANT_ID=aws-k8s-1.15 -> aws)