| 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: (GPL-2.0-only OR LGPL-2.1-only) |
| 3 | # SPDX-FileCopyrightText: 2016-2021 EfficiOS Inc. |
| 4 | |
| 5 | # First argument is the path to the kernel headers. |
| 6 | KPATH=$1 |
| 7 | |
| 8 | if [ ! -f "${KPATH}/include/generated/autoconf.h" ]; then |
| 9 | echo 0 |
| 10 | exit 0 |
| 11 | fi |
| 12 | |
| 13 | # Check if we are building against a Suse kernel |
| 14 | SUSE_KERNEL="$(sed -rn 's/^#define CONFIG_SUSE_KERNEL (.*)/\1/p' "${KPATH}/include/generated/autoconf.h")" |
| 15 | |
| 16 | if [ "$SUSE_KERNEL" != "1" ]; then |
| 17 | echo 0 |
| 18 | exit 0 |
| 19 | fi |
| 20 | |
| 21 | |
| 22 | if [ ! -f "${KPATH}/include/generated/utsrelease.h" ]; then |
| 23 | echo 0 |
| 24 | exit 0 |
| 25 | fi |
| 26 | |
| 27 | SLE_RELEASE="$(sed -rn 's/^#define UTS_RELEASE "(.*)-([0-9a-zA-Z\.]+)-(.*)"/\2/p' "${KPATH}/include/generated/utsrelease.h")" |
| 28 | |
| 29 | SLE_RELEASE_MAJOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)(.*)$/\1/p')" |
| 30 | SLE_RELEASE_MINOR="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)(.*)$/\2/p')" |
| 31 | SLE_RELEASE_PATCH="$(echo "${SLE_RELEASE}" | sed -rn 's/^([0-9]+)\.([0-9]+)\.([0-9]+)(.*)$/\3/p')" |
| 32 | |
| 33 | # Minor and patch versions can be omitted |
| 34 | if [ "x$SLE_RELEASE_MINOR" = "x" ]; then |
| 35 | SLE_RELEASE_MINOR=0 |
| 36 | fi |
| 37 | if [ "x$SLE_RELEASE_PATCH" = "x" ]; then |
| 38 | SLE_RELEASE_PATCH=0 |
| 39 | fi |
| 40 | |
| 41 | echo "${SLE_RELEASE_MAJOR} ${SLE_RELEASE_MINOR} ${SLE_RELEASE_PATCH}" |