Fix: Allow alphanumeric characters in SLE version
[lttng-modules.git] / scripts / abi-sle-version.sh
CommitLineData
ce66b486 1#!/bin/sh
6c27a5cc 2# SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1)
ce66b486
MJ
3
4# First argument is the path to the kernel headers.
5KPATH=$1
6
7if [ ! -f "${KPATH}/include/generated/autoconf.h" ]; then
8 echo 0
9 exit 0
10fi
11
12# Check if we are building against a Suse kernel
13SUSE_KERNEL="$(sed -rn 's/^#define CONFIG_SUSE_KERNEL (.*)/\1/p' "${KPATH}/include/generated/autoconf.h")"
14
15if [ "$SUSE_KERNEL" != "1" ]; then
16 echo 0
17 exit 0
18fi
19
20
21if [ ! -f "${KPATH}/include/generated/utsrelease.h" ]; then
22 echo 0
23 exit 0
24fi
25
8fca602a 26SLE_RELEASE="$(sed -rn 's/^#define UTS_RELEASE "(.*)-([0-9a-zA-Z\.]+)-(.*)"/\2/p' "${KPATH}/include/generated/utsrelease.h")"
ce66b486
MJ
27
28SLE_RELEASE_MAJOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)(.*)$/\1/p')"
29SLE_RELEASE_MINOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)(.*)$/\2/p')"
30SLE_RELEASE_PATCH="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$/\3/p')"
31
32# Minor and patch versions can be omitted
33if [ "x$SLE_RELEASE_MINOR" = "x" ]; then
34 SLE_RELEASE_MINOR=0
35fi
36if [ "x$SLE_RELEASE_PATCH" = "x" ]; then
37 SLE_RELEASE_PATCH=0
38fi
39
40# Combine all update numbers into one
41SLE_API_VERSION="$((SLE_RELEASE_MAJOR * 10000 + SLE_RELEASE_MINOR * 100 + SLE_RELEASE_PATCH))"
42
43echo ${SLE_API_VERSION}
This page took 0.027073 seconds and 4 git commands to generate.