From 2045fb3aa18c0a369b504daf0b35873947d3dff3 Mon Sep 17 00:00:00 2001 From: Bernd Wachter Date: Fri, 26 Apr 2013 23:52:59 +0300 Subject: [PATCH] [ssu] Add uname-release.contains to boardmapping options --- board-mappings.ini | 5 ++++- libssu/ssudeviceinfo.cpp | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/board-mappings.ini b/board-mappings.ini index 4bf91df..b7fb83c 100644 --- a/board-mappings.ini +++ b/board-mappings.ini @@ -19,10 +19,13 @@ # pull in the whole X11 stack, and on Mer/Nemo does cpuinfo # matching only anyway, which ssu can do better already. # - cpuinfo.contains -- searches /proc/cpuinfo for a string +# - uname-release.contains -- searches the kernels release string for +# a string (uname -r) # - arch.equals -- compares with zyppers arch (like i586) # # Resolve order is: -# file.exists -> systeminfo.equals -> cpuinfo.contains -> arch.equals +# file.exists -> systeminfo.equals -> cpuinfo.contains +# -> uname-release.contains -> arch.equals # # The found model (after resolving variants) will be used as category. The # following keys are valid there: diff --git a/libssu/ssudeviceinfo.cpp b/libssu/ssudeviceinfo.cpp index a481d3f..ec7dfc1 100644 --- a/libssu/ssudeviceinfo.cpp +++ b/libssu/ssudeviceinfo.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include "ssudeviceinfo.h" #include "ssucoreconfig.h" #include "ssulog.h" @@ -184,8 +186,25 @@ QString SsuDeviceInfo::deviceModel(){ } if (!cachedModel.isEmpty()) return cachedModel; + // check if the device can be identified by the kernel version string + struct utsname buf; + if (!uname(&buf)){ + QString utsRelease(buf.release); + boardMappings->beginGroup("uname-release.contains"); + keys = boardMappings->allKeys(); + + foreach (const QString &key, keys){ + QString value = boardMappings->value(key).toString(); + if (utsRelease.contains(value)){ + cachedModel = key; + break; + } + } + boardMappings->endGroup(); + } + if (!cachedModel.isEmpty()) return cachedModel; - // check if there's a match on arch ofr generic fallback. This probably + // check if there's a match on arch of generic fallback. This probably // only makes sense for x86 boardMappings->beginGroup("arch.equals"); keys = boardMappings->allKeys();