aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-08-22 12:10:56 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-08-22 12:10:56 +0200
commit2e8abc421151b81272f7ab988e494fd29eb431ff (patch)
treefdef822fa8c899df5bf1e0e2bf22091a7bf2e0df
parent20aab303a8cd573314c24b8de46a652d094f8e05 (diff)
Better OS detection.
Only take ID_LIKE field if it exists else ID. Doing some stripping also to get a cleaner output variable Change-Id: If5c44bf21c3435bd4739cfd34190a81d28dd10d3 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--cmake/cmake.d/02-variables.cmake11
1 files changed, 6 insertions, 5 deletions
diff --git a/cmake/cmake.d/02-variables.cmake b/cmake/cmake.d/02-variables.cmake
index ec6510f..285648f 100644
--- a/cmake/cmake.d/02-variables.cmake
+++ b/cmake/cmake.d/02-variables.cmake
@@ -51,19 +51,20 @@ set(NPKG_PROJECT_NAME agl-${PROJECT_NAME})
# Get the os type
# Used to package .deb
if(EXISTS "/etc/os-release")
- execute_process(COMMAND grep -E "^ID(=|_LIKE=)" /etc/os-release
+ execute_process(COMMAND bash "-c" "grep -E '^ID(_LIKE)?=' /etc/os-release | tail -n 1"
OUTPUT_VARIABLE TMP_OSRELEASE
)
if (NOT TMP_OSRELEASE STREQUAL "")
- string(REGEX REPLACE ".*=([0-9a-z._-]*)\n" "\\1" OSRELEASE ${TMP_OSRELEASE})
+ string(REGEX REPLACE ".*=\"?([0-9a-z\._-]*)\"?\n" "\\1" OSRELEASE ${TMP_OSRELEASE})
else()
- set(OSRELEASE "NO COMPATIBLE !")
+ set(OSRELEASE "NOT COMPATIBLE !")
endif()
- message(STATUS "Distribution used ${OSRELEASE}")
+
else()
- set(OSRELEASE "NO COMPATIBLE !")
+ set(OSRELEASE "NOT COMPATIBLE ! Missing /etc/os-release file.")
endif()
+message(STATUS "Distribution used ${OSRELEASE}")
if(DEFINED ENV{SDKTARGETSYSROOT})
file(STRINGS $ENV{SDKTARGETSYSROOT}/usr/include/linux/version.h LINUX_VERSION_CODE_LINE REGEX "LINUX_VERSION_CODE")