Cleanup: move scripts to subdirectory
[deliverable/lttng-modules.git] / scripts / abi-rhel-version.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1)
3
4 # First argument is the path to the kernel headers.
5 KPATH="$1"
6
7 if [ ! -f "${KPATH}/include/generated/uapi/linux/version.h" ]; then
8 echo 0
9 exit 0
10 fi
11
12 # Assuming KPATH is the target kernel headers directory
13 RHEL_RELEASE=$(sed -rn 's/^#define RHEL_RELEASE "(.*)"/\1/p' "${KPATH}/include/generated/uapi/linux/version.h")
14
15 RHEL_RELEASE_MAJOR=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\1/')
16 RHEL_RELEASE_MINOR=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\2/')
17 RHEL_RELEASE_PATCH=$(echo "${RHEL_RELEASE}" | sed -r 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\3/')
18
19 # Combine all update numbers into one
20 RHEL_API_VERSION=$((RHEL_RELEASE_MAJOR * 10000 + RHEL_RELEASE_MINOR * 100 + RHEL_RELEASE_PATCH))
21
22 echo ${RHEL_API_VERSION}
This page took 0.032335 seconds and 5 git commands to generate.