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