Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ssu] Add uname-release.contains to boardmapping options
  • Loading branch information
Bernd Wachter committed Apr 26, 2013
1 parent bd4a2b7 commit 2045fb3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion board-mappings.ini
Expand Up @@ -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:
Expand Down
21 changes: 20 additions & 1 deletion libssu/ssudeviceinfo.cpp
Expand Up @@ -9,6 +9,8 @@
#include <QTextStream>
#include <QDir>

#include <sys/utsname.h>

#include "ssudeviceinfo.h"
#include "ssucoreconfig.h"
#include "ssulog.h"
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2045fb3

Please sign in to comment.