From 9389c1759d2aeafd1e54775cd60ddc2a1f5c0d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 25 Sep 2015 08:23:11 +0200 Subject: [PATCH] fix snappy paths --- guh.pro | 15 +++++++++--- libguh/guhsettings.cpp | 32 ++++++++++++++++++-------- libguh/libguh.pro | 44 ++++++++++++++++++------------------ meta/guhd-wrapper.sh | 6 ++--- server/logging/logengine.cpp | 7 ++++-- server/main.cpp | 7 ++++++ server/webserver.cpp | 2 +- 7 files changed, 72 insertions(+), 41 deletions(-) diff --git a/guh.pro b/guh.pro index 7fd69df6..8fa909c3 100644 --- a/guh.pro +++ b/guh.pro @@ -108,19 +108,28 @@ contains(DEFINES, SNAPPY){ /usr/lib/arm-linux-gnueabihf/libpng12.so.0 \ /usr/lib/arm-linux-gnueabihf/libharfbuzz.so.0 \ /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 \ + /usr/lib/arm-linux-gnueabihf/mesa-egl/libGLESv2.so \ /usr/lib/arm-linux-gnueabihf/libfreetype.so.6 \ /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/ # install guhd.conf guhdconf.files = data/config/guhd.conf guhdconf.path = $$INSTALLDIR/config/ - INSTALLS += meta wrapper guhdconf qtlibs sqlplugin + INSTALLS += wrapper qtlibs sqlplugin # command to pack libs for snappy package packlibs.depends = libguh server diff --git a/libguh/guhsettings.cpp b/libguh/guhsettings.cpp index 8cd17289..7e5b5e0f 100644 --- a/libguh/guhsettings.cpp +++ b/libguh/guhsettings.cpp @@ -50,6 +50,7 @@ #include "guhsettings.h" #include "unistd.h" +#include "loggingcategories.h" #include #include @@ -63,29 +64,30 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): { #ifdef SNAPPY + QString settingsFilePath = qgetenv("SNAP_APP_DATA_PATH"); QString settingsFile; switch (role) { case SettingsRoleNone: break; case SettingsRoleDevices: - settingsFile = "config/devices.conf"; + settingsFile = settingsFilePath + "/devices.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); - qDebug() << "Created device settings" << m_settings->fileName(); + //qCDebug(dcApplication) << "Created device settings" << m_settings->fileName(); break; case SettingsRoleRules: - settingsFile = "config/rules.conf"; + settingsFile = settingsFilePath + "/rules.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); - qDebug() << "Created rule settings" << m_settings->fileName(); + //qCDebug(dcApplication) << "Created rule settings" << m_settings->fileName(); break; case SettingsRolePlugins: - settingsFile = "config/plugins.conf"; + settingsFile = settingsFilePath + "/plugins.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); - qDebug() << "Created plugin settings" << m_settings->fileName(); + //qCDebug(dcApplication) << "Created plugin settings" << m_settings->fileName(); break; case SettingsRoleGlobal: - settingsFile = "config/guhd.conf"; + settingsFile = settingsFilePath + "/guhd.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); - qDebug() << "Created guhd settings" << m_settings->fileName(); + //qCDebug(dcApplication) << "Created guhd settings" << m_settings->fileName(); break; default: break; @@ -103,12 +105,15 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): if (settingsPrefix == "guh-test") { settingsFile = "/tmp/" + settingsPrefix + "/test-devices.conf"; m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); + //qCDebug(dcApplication) << "Created test-devices settings" << m_settings->fileName(); } else if (rootPrivilege) { settingsFile = "/etc/" + settingsPrefix + "/devices.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + //qCDebug(dcApplication) << "Created device settings" << m_settings->fileName(); } else { settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/devices.conf"; m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); + //qCDebug(dcApplication) << "Created device settings" << m_settings->fileName(); } break; case SettingsRoleRules: @@ -116,12 +121,15 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): if (settingsPrefix == "guh-test") { settingsFile = "/tmp/" + settingsPrefix + "/test-rules.conf"; m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); + //qCDebug(dcApplication) << "Created test-rules settings" << m_settings->fileName(); } else if (rootPrivilege) { settingsFile = "/etc/" + settingsPrefix + "/rules.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + //qCDebug(dcApplication) << "Created rule settings" << m_settings->fileName(); } else { settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/rules.conf"; m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); + //qCDebug(dcApplication) << "Created rule settings" << m_settings->fileName(); } break; case SettingsRolePlugins: @@ -129,18 +137,22 @@ GuhSettings::GuhSettings(const SettingsRole &role, QObject *parent): if (settingsPrefix == "guh-test") { settingsFile = "/tmp/" + settingsPrefix + "/test-plugins.conf"; m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); + //qCDebug(dcApplication) << "Created test-plugins settings" << m_settings->fileName(); } else if (rootPrivilege) { settingsFile = "/etc/" + settingsPrefix + "/plugins.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + //qCDebug(dcApplication) << "Created plugin settings" << m_settings->fileName(); } else { settingsFile = QDir::homePath() + "/.config/" + settingsPrefix + "/plugins.conf"; m_settings = new QSettings(settingsFile, QSettings::NativeFormat, this); + //qCDebug(dcApplication) << "Created plugin settings" << m_settings->fileName(); } break; case SettingsRoleGlobal: // this file schould always be readable and should never be written settingsFile = "/etc/guh/guhd.conf"; m_settings = new QSettings(settingsFile, QSettings::IniFormat, this); + qCDebug(dcApplication) << "Created test guhd settings" << m_settings->fileName(); break; default: break; @@ -178,7 +190,7 @@ QString GuhSettings::logPath() { QString logPath; #ifdef SNAPPY - logPath = "/var/log/guhd.log"; + logPath = qgetenv("SNAP_APP_DATA_PATH") + "/guhd.log"; #else 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. */ 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); } diff --git a/libguh/libguh.pro b/libguh/libguh.pro index b53c434c..0e250b14 100644 --- a/libguh/libguh.pro +++ b/libguh/libguh.pro @@ -114,32 +114,32 @@ HEADERS += devicemanager.h \ types/statedescriptor.h \ # 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 -isEmpty(PREFIX) { - INSTALLDIR = /usr/bin -} else { - INSTALLDIR = $$PREFIX/usr/bin -} -generateplugininfo.files = $$top_srcdir/plugins/guh-generateplugininfo -generateplugininfo.path = $$INSTALLDIR + INSTALLS += generateplugininfo -INSTALLS += generateplugininfo + # install header file with relative subdirectory + isEmpty(PREFIX) { + INSTALLDIR = /usr/include + } else { + INSTALLDIR = $$PREFIX/usr/include + } -# install header file with relative subdirectory -isEmpty(PREFIX) { - INSTALLDIR = /usr/include -} else { - INSTALLDIR = $$PREFIX/usr/include -} - -for(header, HEADERS) { - path = $$INSTALLDIR/guh/$${dirname(header)} - eval(headers_$${path}.files += $${header}) - eval(headers_$${path}.path = $${path}) - 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}) + } } - diff --git a/meta/guhd-wrapper.sh b/meta/guhd-wrapper.sh index ec2ef342..ea1ced7c 100755 --- a/meta/guhd-wrapper.sh +++ b/meta/guhd-wrapper.sh @@ -1,5 +1,5 @@ #!/bin/sh -export QT_PLUGIN_PATH=/apps/guh.sideload/current/usr/lib/qt5/plugins -export LD_LIBRARY_PATH=/apps/guh.sideload/current/usr/lib:$LD_LIBRARY_PATH -/apps/guh.sideload/current/usr/bin/guhd -n +export QT_PLUGIN_PATH=$SNAP_APP_PATH/usr/lib/qt5/plugins +export LD_LIBRARY_PATH=$SNAP_APP_PATH/usr/lib:$LD_LIBRARY_PATH +$SNAP_APP_PATH/usr/bin/guhd -n -d LogEngine diff --git a/server/logging/logengine.cpp b/server/logging/logengine.cpp index 321fb480..276d5260 100644 --- a/server/logging/logengine.cpp +++ b/server/logging/logengine.cpp @@ -133,17 +133,19 @@ LogEngine::LogEngine(QObject *parent): qCDebug(dcLogEngine) << "Set logging dab max size to" << m_dbMaxSize << "for testing."; } - qCDebug(dcLogEngine) << "Opening logging database" << m_db.databaseName(); if (!m_db.isValid()) { qCWarning(dcLogEngine) << "Database not valid:" << m_db.lastError().driverText() << m_db.lastError().databaseText(); return; } + if (!m_db.open()) { qCWarning(dcLogEngine) << "Error opening log database:" << m_db.lastError().driverText() << m_db.lastError().databaseText(); return; } + qCDebug(dcLogEngine) << "Opening logging database" << m_db.databaseName(); + initDB(); } @@ -349,10 +351,11 @@ void LogEngine::initDB() m_db.open(); QSqlQuery query; - if (!m_db.tables().contains("metadata")) { + qCDebug(dcLogEngine) << "Creating database table..."; 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)); + qCDebug(dcLogEngine) << "Database table created"; } query.exec("SELECT data FROM metadata WHERE key = 'version';"); diff --git a/server/main.cpp b/server/main.cpp index fce576ac..2f67509b 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -195,6 +195,13 @@ int main(int argc, char *argv[]) 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 GuhCore::instance(); return application.exec(); diff --git a/server/webserver.cpp b/server/webserver.cpp index bdc7f009..0c2f1490 100644 --- a/server/webserver.cpp +++ b/server/webserver.cpp @@ -113,7 +113,7 @@ WebServer::WebServer(const QSslConfiguration &sslConfiguration, QObject *parent) settings.endGroup(); #ifdef SNAPPY - m_webinterfaceDir = QDir("/apps/guh.sideload/current/public/"); + m_webinterfaceDir = QDir(qgetenv("SNAP_APP_PATH") + "/public/"); #endif // check public directory