X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=scripts%2Frt-patch-version.sh;fp=scripts%2Frt-patch-version.sh;h=270496570b4c672ec3af6404a6284e056f0f294d;hb=6c27a5ccba05b088fbfcf8cd982c25649838298d;hp=0000000000000000000000000000000000000000;hpb=1c124020c743254923d8e76ab5dcd1f69709982e;p=lttng-modules.git diff --git a/scripts/rt-patch-version.sh b/scripts/rt-patch-version.sh new file mode 100755 index 00000000..27049657 --- /dev/null +++ b/scripts/rt-patch-version.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + +# First argument is the path to the kernel headers. +KPATH="$1" + +VERSIONFILE="" + +if [ -f "${KPATH}/localversion-rt" ]; then + VERSIONFILE="${KPATH}/localversion-rt" + +elif [ -f "${KPATH}/source/localversion-rt" ]; then + VERSIONFILE="${KPATH}/source/localversion-rt" +else + echo 0 + exit 0 +fi + +RT_PATCH_VERSION=$(sed -rn 's/^-rt([0-9]+)$/\1/p' "${VERSIONFILE}") + +if [ "x${RT_PATCH_VERSION}" = "x" ]; then + echo 0 + exit 0 +fi + +echo "${RT_PATCH_VERSION}"