fix snappy paths

This commit is contained in:
Simon Stürz 2015-09-25 08:23:11 +02:00 committed by Michael Zanetti
parent c45a5a994c
commit 9389c1759d
7 changed files with 72 additions and 41 deletions

15
guh.pro
View File

@ -108,19 +108,28 @@ contains(DEFINES, SNAPPY){
/usr/lib/arm-linux-gnueabihf/libpng12.so.0 \ /usr/lib/arm-linux-gnueabihf/libpng12.so.0 \
/usr/lib/arm-linux-gnueabihf/libharfbuzz.so.0 \ /usr/lib/arm-linux-gnueabihf/libharfbuzz.so.0 \
/usr/lib/arm-linux-gnueabihf/libicudata.so.52 \ /usr/lib/arm-linux-gnueabihf/libicudata.so.52 \
/usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so \ /usr/lib/arm-linux-gnueabihf/libz.so \
/usr/lib/arm-linux-gnueabihf/libicuuc.so.52 \
/usr/lib/arm-linux-gnueabihf/libicui18n.so.52 \
/usr/lib/arm-linux-gnueabihf/libstdc++.so.6 \
/usr/lib/arm-linux-gnueabihf/libsqlite3.so.0 \
/usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so.2.0.0 \ /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so.2.0.0 \
/usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so.2 \ /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so.2 \
/usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so \
/usr/lib/arm-linux-gnueabihf/libfreetype.so.6 \ /usr/lib/arm-linux-gnueabihf/libfreetype.so.6 \
/usr/lib/arm-linux-gnueabihf/libgraphite2.so.3 \ /usr/lib/arm-linux-gnueabihf/libgraphite2.so.3 \
/usr/lib/arm-linux-gnueabihf/libglapi.so.0 /usr/lib/arm-linux-gnueabihf/libglapi.so.0 \
/usr/lib/arm-linux-gnueabihf/libpthread.so \
/usr/lib/arm-linux-gnueabihf/libdl.so \
/usr/lib/arm-linux-gnueabihf/librt.so \
/usr/lib/arm-linux-gnueabihf/libm.so
qtlibs.path = /usr/lib/ qtlibs.path = /usr/lib/
# install guhd.conf # install guhd.conf
guhdconf.files = data/config/guhd.conf guhdconf.files = data/config/guhd.conf
guhdconf.path = $$INSTALLDIR/config/ guhdconf.path = $$INSTALLDIR/config/
INSTALLS += meta wrapper guhdconf qtlibs sqlplugin INSTALLS += wrapper qtlibs sqlplugin
# command to pack libs for snappy package # command to pack libs for snappy package
packlibs.depends = libguh server packlibs.depends = libguh server

View File

@ -50,6 +50,7 @@
#include "guhsettings.h" #include "guhsettings.h"
#include "unistd.h" #include "unistd.h"
#include "loggingcategories.h"
#include <QSettings> #include <QSettings>
#include <QCoreApplication> #include <QCoreApplication>
@ -63,29 +64,30 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent):
{ {
#ifdef SNAPPY #ifdef SNAPPY
QString settingsFilePath = qgetenv("SNAP_APP_DATA_PATH");
QString settingsFile; QString settingsFile;
switch (role) { switch (role) {
case SettingsRoleNone: case SettingsRoleNone:
break; break;
case SettingsRoleDevices: case SettingsRoleDevices:
settingsFile = "config/devices.conf"; settingsFile = settingsFilePath + "/devices.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
qDebug() << "Created device settings" << m_settings->fileName(); //qCDebug(dcApplication) << "Created device settings" << m_settings->fileName();
break; break;
case SettingsRoleRules: case SettingsRoleRules:
settingsFile = "config/rules.conf"; settingsFile = settingsFilePath + "/rules.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
qDebug() << "Created rule settings" << m_settings->fileName(); //qCDebug(dcApplication) << "Created rule settings" << m_settings->fileName();
break; break;
case SettingsRolePlugins: case SettingsRolePlugins:
settingsFile = "config/plugins.conf"; settingsFile = settingsFilePath + "/plugins.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
qDebug() << "Created plugin settings" << m_settings->fileName(); //qCDebug(dcApplication) << "Created plugin settings" << m_settings->fileName();
break; break;
case SettingsRoleGlobal: case SettingsRoleGlobal:
settingsFile = "config/guhd.conf"; settingsFile = settingsFilePath + "/guhd.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
qDebug() << "Created guhd settings" << m_settings->fileName(); //qCDebug(dcApplication) << "Created guhd settings" << m_settings->fileName();
break; break;
default: default:
break; break;
@ -103,12 +105,15 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent):
if (settingsPrefix == "guh-test") { if (settingsPrefix == "guh-test") {
settingsFile = "/tmp/" + settingsPrefix + "/test-devices.conf"; settingsFile = "/tmp/" + settingsPrefix + "/test-devices.conf";
m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);
//qCDebug(dcApplication) << "Created test-devices settings" << m_settings->fileName();
} else if (rootPrivilege) { } else if (rootPrivilege) {
settingsFile = "/etc/" + settingsPrefix + "/devices.conf"; settingsFile = "/etc/" + settingsPrefix + "/devices.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
//qCDebug(dcApplication) << "Created device settings" << m_settings->fileName();
} else { } else {
settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/devices.conf"; settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/devices.conf";
m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);
//qCDebug(dcApplication) << "Created device settings" << m_settings->fileName();
} }
break; break;
case SettingsRoleRules: case SettingsRoleRules:
@ -116,12 +121,15 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent):
if (settingsPrefix == "guh-test") { if (settingsPrefix == "guh-test") {
settingsFile = "/tmp/" + settingsPrefix + "/test-rules.conf"; settingsFile = "/tmp/" + settingsPrefix + "/test-rules.conf";
m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);
//qCDebug(dcApplication) << "Created test-rules settings" << m_settings->fileName();
} else if (rootPrivilege) { } else if (rootPrivilege) {
settingsFile = "/etc/" + settingsPrefix + "/rules.conf"; settingsFile = "/etc/" + settingsPrefix + "/rules.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
//qCDebug(dcApplication) << "Created rule settings" << m_settings->fileName();
} else { } else {
settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/rules.conf"; settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/rules.conf";
m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);
//qCDebug(dcApplication) << "Created rule settings" << m_settings->fileName();
} }
break; break;
case SettingsRolePlugins: case SettingsRolePlugins:
@ -129,18 +137,22 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent):
if (settingsPrefix == "guh-test") { if (settingsPrefix == "guh-test") {
settingsFile = "/tmp/" + settingsPrefix + "/test-plugins.conf"; settingsFile = "/tmp/" + settingsPrefix + "/test-plugins.conf";
m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);
//qCDebug(dcApplication) << "Created test-plugins settings" << m_settings->fileName();
} else if (rootPrivilege) { } else if (rootPrivilege) {
settingsFile = "/etc/" + settingsPrefix + "/plugins.conf"; settingsFile = "/etc/" + settingsPrefix + "/plugins.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
//qCDebug(dcApplication) << "Created plugin settings" << m_settings->fileName();
} else { } else {
settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/plugins.conf"; settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/plugins.conf";
m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this);
//qCDebug(dcApplication) << "Created plugin settings" << m_settings->fileName();
} }
break; break;
case SettingsRoleGlobal: case SettingsRoleGlobal:
// this file schould always be readable and should never be written // this file schould always be readable and should never be written
settingsFile = "/etc/guh/guhd.conf"; settingsFile = "/etc/guh/guhd.conf";
m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); m_settings = new QSettings(settingsFile, QSettings::IniFormat, this);
qCDebug(dcApplication) << "Created test guhd settings" << m_settings->fileName();
break; break;
default: default:
break; break;
@ -178,7 +190,7 @@ QString GuhSettings::logPath()
{ {
QString logPath; QString logPath;
#ifdef SNAPPY #ifdef SNAPPY
logPath = "/var/log/guhd.log"; logPath = qgetenv("SNAP_APP_DATA_PATH") + "/guhd.log";
#else #else
QString organisationName = QCoreApplication::instance()->organizationName(); QString organisationName = QCoreApplication::instance()->organizationName();
@ -281,7 +293,7 @@ void GuhSettings::remove(const QString &key)
/*! Sets the \a value of setting \a key to value. If the \a key already exists, the previous value is overwritten. */ /*! Sets the \a value of setting \a key to value. If the \a key already exists, the previous value is overwritten. */
void GuhSettings::setValue(const QString &key, const QVariant &value) void GuhSettings::setValue(const QString &key, const QVariant &value)
{ {
//Q_ASSERT_X(m_role != GuhSettings::SettingsRoleGlobal, "GuhSettings", "Bad settings usage. The global settings file should be read only."); Q_ASSERT_X(m_role != GuhSettings::SettingsRoleGlobal, "GuhSettings", "Bad settings usage. The global settings file should be read only.");
m_settings->setValue(key, value); m_settings->setValue(key, value);
} }

View File

@ -114,32 +114,32 @@ HEADERS += devicemanager.h \
types/statedescriptor.h \ types/statedescriptor.h \
# install files for libguh-dev # install files for libguh-dev
!snappy {
# install guh-generateplugininfo precompiler
isEmpty(PREFIX) {
INSTALLDIR = /usr/bin
} else {
INSTALLDIR = $$PREFIX/usr/bin
}
generateplugininfo.files = $$top_srcdir/plugins/guh-generateplugininfo
generateplugininfo.path = $$INSTALLDIR
# install guh-generateplugininfo precompiler INSTALLS += generateplugininfo
isEmpty(PREFIX) {
INSTALLDIR = /usr/bin
} else {
INSTALLDIR = $$PREFIX/usr/bin
}
generateplugininfo.files = $$top_srcdir/plugins/guh-generateplugininfo
generateplugininfo.path = $$INSTALLDIR
INSTALLS += generateplugininfo # install header file with relative subdirectory
isEmpty(PREFIX) {
INSTALLDIR = /usr/include
} else {
INSTALLDIR = $$PREFIX/usr/include
}
# install header file with relative subdirectory for(header, HEADERS) {
isEmpty(PREFIX) { path = $$INSTALLDIR/guh/$${dirname(header)}
INSTALLDIR = /usr/include eval(headers_$${path}.files += $${header})
} else { eval(headers_$${path}.path = $${path})
INSTALLDIR = $$PREFIX/usr/include eval(INSTALLS *= headers_$${path})
} }
for(header, HEADERS) {
path = $$INSTALLDIR/guh/$${dirname(header)}
eval(headers_$${path}.files += $${header})
eval(headers_$${path}.path = $${path})
eval(INSTALLS *= headers_$${path})
} }

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
export QT_PLUGIN_PATH=/apps/guh.sideload/current/usr/lib/qt5/plugins export QT_PLUGIN_PATH=$SNAP_APP_PATH/usr/lib/qt5/plugins
export LD_LIBRARY_PATH=/apps/guh.sideload/current/usr/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$SNAP_APP_PATH/usr/lib:$LD_LIBRARY_PATH
/apps/guh.sideload/current/usr/bin/guhd -n $SNAP_APP_PATH/usr/bin/guhd -n -d LogEngine

View File

@ -133,17 +133,19 @@ LogEngine::LogEngine(QObject *parent):
qCDebug(dcLogEngine) << "Set logging dab max size to" << m_dbMaxSize << "for testing."; qCDebug(dcLogEngine) << "Set logging dab max size to" << m_dbMaxSize << "for testing.";
} }
qCDebug(dcLogEngine) << "Opening logging database" << m_db.databaseName();
if (!m_db.isValid()) { if (!m_db.isValid()) {
qCWarning(dcLogEngine) << "Database not valid:" << m_db.lastError().driverText() << m_db.lastError().databaseText(); qCWarning(dcLogEngine) << "Database not valid:" << m_db.lastError().driverText() << m_db.lastError().databaseText();
return; return;
} }
if (!m_db.open()) { if (!m_db.open()) {
qCWarning(dcLogEngine) << "Error opening log database:" << m_db.lastError().driverText() << m_db.lastError().databaseText(); qCWarning(dcLogEngine) << "Error opening log database:" << m_db.lastError().driverText() << m_db.lastError().databaseText();
return; return;
} }
qCDebug(dcLogEngine) << "Opening logging database" << m_db.databaseName();
initDB(); initDB();
} }
@ -349,10 +351,11 @@ void LogEngine::initDB()
m_db.open(); m_db.open();
QSqlQuery query; QSqlQuery query;
if (!m_db.tables().contains("metadata")) { if (!m_db.tables().contains("metadata")) {
qCDebug(dcLogEngine) << "Creating database table...";
query.exec("CREATE TABLE metadata (key varchar(10), data varchar(40));"); query.exec("CREATE TABLE metadata (key varchar(10), data varchar(40));");
query.exec(QString("INSERT INTO metadata (key, data) VALUES('version', '%1');").arg(DB_SCHEMA_VERSION)); query.exec(QString("INSERT INTO metadata (key, data) VALUES('version', '%1');").arg(DB_SCHEMA_VERSION));
qCDebug(dcLogEngine) << "Database table created";
} }
query.exec("SELECT data FROM metadata WHERE key = 'version';"); query.exec("SELECT data FROM metadata WHERE key = 'version';");

View File

@ -195,6 +195,13 @@ int main(int argc, char *argv[])
qCDebug(dcApplication) << "====================================="; qCDebug(dcApplication) << "=====================================";
} }
#ifdef SNAPPY
qCDebug(dcApplication) << "Snappy name :" << qgetenv("SNAP_FULLNAME");
qCDebug(dcApplication) << "Snappy version :" << qgetenv("SNAP_VERSION");
qCDebug(dcApplication) << "Snappy directory:" << qgetenv("SNAP_APP_PATH");
qCDebug(dcApplication) << "Snappy user data:" << qgetenv("SNAP_APP_USER_DATA_PATH");
qCDebug(dcApplication) << "Snappy app data:" << qgetenv("SNAP_APP_DATA_PATH");
#endif
// create core instance // create core instance
GuhCore::instance(); GuhCore::instance();
return application.exec(); return application.exec();

View File

@ -113,7 +113,7 @@ WebServer::WebServer(const QSslConfiguration &sslConfiguration, QObject *parent)
settings.endGroup(); settings.endGroup();
#ifdef SNAPPY #ifdef SNAPPY
m_webinterfaceDir = QDir("/apps/guh.sideload/current/public/"); m_webinterfaceDir = QDir(qgetenv("SNAP_APP_PATH") + "/public/");
#endif #endif
// check public directory // check public directory