-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aea5f4c
Showing
25 changed files
with
1,521 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
TEMPLATE = app | ||
TARGET = patchmanager-daemon | ||
|
||
QT = core dbus network | ||
CONFIG += link_pkgconfig | ||
PKGCONFIG += nemonotifications-qt5 | ||
PKGCONFIG += libsystemd-journal | ||
PKGCONFIG += rpm | ||
|
||
isEmpty(PROJECT_PACKAGE_VERSION) { | ||
BUILD_VERSION = "4.99.99" | ||
} else { | ||
BUILD_VERSION = $$PROJECT_PACKAGE_VERSION | ||
} | ||
message("Version: $$BUILD_VERSION") | ||
|
||
DEFINES += BUILD_VERSION=\\\"$$BUILD_VERSION\\\" | ||
|
||
#HEADERS += \ | ||
# src/patchmanager_include.h | ||
|
||
SOURCES += \ | ||
src/main.cpp \ | ||
src/patchmanager.cpp | ||
|
||
target.path = /usr/sbin | ||
INSTALLS += target | ||
|
||
# DBus service | ||
dbusService.files = dbus/org.coderus.patchmanager.service | ||
dbusService.path = /usr/share/dbus-1/system-services/ | ||
INSTALLS += dbusService | ||
|
||
# DBus interface | ||
dbusInterface.files = dbus/org.coderus.patchmanager.xml | ||
dbusInterface.path = /usr/share/dbus-1/interfaces/ | ||
INSTALLS += dbusInterface | ||
|
||
# DBus config | ||
dbusConf.files = dbus/org.coderus.patchmanager.conf | ||
dbusConf.path = /etc/dbus-1/system.d/ | ||
INSTALLS += dbusConf | ||
|
||
# Systemd | ||
systemd.files = \ | ||
systemd/patchmanager.service \ | ||
systemd/checkForUpdates-patchmanager.service \ | ||
systemd/checkForUpdates-patchmanager.timer | ||
systemd.path = /lib/systemd/system/ | ||
INSTALLS += systemd | ||
|
||
# user environment | ||
env.files = environment/01-dbus.conf | ||
env.path = /var/lib/environment/patchmanager/ | ||
INSTALLS += env | ||
|
||
# dbus interface | ||
pm_dbus_adaptor.files = dbus/org.coderus.patchmanager.xml | ||
pm_dbus_adaptor.source_flags = -c PatchManagerAdaptor | ||
pm_dbus_adaptor.header_flags = -c PatchManagerAdaptor# -i patchmanager_include.h | ||
DBUS_ADAPTORS += pm_dbus_adaptor | ||
|
||
INCLUDEPATH += /usr/include/ | ||
|
||
HEADERS += \ | ||
src/patchmanager.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE busconfig PUBLIC | ||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> | ||
|
||
<busconfig> | ||
<policy user="root"> | ||
<allow own="org.coderus.patchmanager"/> | ||
</policy> | ||
|
||
<policy context="default"> | ||
<allow send_destination="org.coderus.patchmanager" send_interface="org.SfietKonstantin.patchmanager"/> | ||
<allow send_destination="org.coderus.patchmanager" send_interface="org.freedesktop.DBus.Introspectable"/> | ||
<allow send_destination="org.coderus.patchmanager" send_interface="org.freedesktop.DBus.Peer"/> | ||
<allow send_destination="org.coderus.patchmanager" send_interface="org.freedesktop.DBus.Properties"/> | ||
</policy> | ||
</busconfig> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[D-BUS Service] | ||
Name=org.coderus.patchmanager | ||
Exec=/bin/false | ||
User=root | ||
SystemdService=patchmanager.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | ||
<node> | ||
<interface name="org.coderus.patchmanager"> | ||
<method name="listPatches"> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantList"/> | ||
<arg name="result" type="a(v)" direction="out" /> | ||
</method> | ||
<method name="listVersions"> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | ||
<arg name="result" type="a{sv}" direction="out" /> | ||
</method> | ||
<method name="isPatchApplied"> | ||
<arg name="patch" type="s" direction="in" /> | ||
<arg name="applied" type="b" direction="out" /> | ||
</method> | ||
<method name="applyPatch"> | ||
<arg name="patch" type="s" direction="in" /> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | ||
<arg name="result" type="a{sv}" direction="out" /> | ||
</method> | ||
<method name="unapplyPatch"> | ||
<arg name="patch" type="s" direction="in" /> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | ||
<arg name="result" type="a{sv}" direction="out" /> | ||
</method> | ||
<method name="installPatch"> | ||
<arg name="patch" type="s" direction="in" /> | ||
<arg name="version" type="s" direction="in" /> | ||
<arg name="url" type="s" direction="in" /> | ||
<arg name="ok" type="b" direction="out" /> | ||
</method> | ||
<method name="uninstallPatch"> | ||
<arg name="patch" type="s" direction="in" /> | ||
<arg name="ok" type="b" direction="out" /> | ||
</method> | ||
<method name="resetState"> | ||
<arg name="patch" type="s" direction="in" /> | ||
<arg name="ok" type="b" direction="out" /> | ||
</method> | ||
<method name="unapplyAllPatches"> | ||
<arg name="ok" type="b" direction="out" /> | ||
</method> | ||
<method name="votePatch"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
<arg name="patch" type="s" direction="in" /> | ||
<arg name="action" type="i" direction="in" /> | ||
</method> | ||
<method name="checkVote"> | ||
<arg name="patch" type="s" direction="in" /> | ||
<arg name="vote" type="i" direction="out" /> | ||
</method> | ||
<method name="putSettings"> | ||
<arg name="name" type="s" direction="in" /> | ||
<arg name="value" type="v" direction="in" /> | ||
<arg name="result" type="b" direction="out" /> | ||
</method> | ||
<method name="getSettings"> | ||
<arg name="name" type="s" direction="in" /> | ||
<arg name="def" type="v" direction="in" /> | ||
<arg name="value" type="v" direction="out" /> | ||
</method> | ||
<method name="checkEaster"> | ||
<arg name="easter" type="s" direction="out" /> | ||
</method> | ||
<method name="getSsuVersion"> | ||
<arg name="version" type="s" direction="out" /> | ||
</method> | ||
<method name="getPatchmanagerVersion"> | ||
<arg name="version" type="s" direction="out" /> | ||
</method> | ||
<method name="downloadCatalog"> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/> | ||
<arg name="params" type="a{sv}" direction="in" /> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantList"/> | ||
<arg name="json" type="a(v)" direction="out" /> | ||
</method> | ||
<method name="downloadPatchInfo"> | ||
<arg name="name" type="s" direction="in" /> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | ||
<arg name="data" type="a{sv}" direction="out" /> | ||
</method> | ||
<method name="getUpdates"> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | ||
<arg name="updates" type="a{sv}" direction="out" /> | ||
</method> | ||
<method name="restartServices"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
</method> | ||
<method name="patchToggleService"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
<arg name="patch" type="s" direction="in" /> | ||
<arg name="activate" type="b" direction="in" /> | ||
</method> | ||
<method name="getToggleServices"> | ||
<arg name="toggle" type="b" direction="out" /> | ||
</method> | ||
<method name="getFailure"> | ||
<arg name="failure" type="b" direction="out" /> | ||
</method> | ||
<method name="getLoaded"> | ||
<arg name="loaded" type="b" direction="out" /> | ||
</method> | ||
<method name="resolveFailure"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
</method> | ||
<method name="loadRequest"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
<arg name="apply" type="b" direction="in" /> | ||
</method> | ||
<method name="checkForUpdates"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
</method> | ||
<method name="quit"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
</method> | ||
<method name="lipstickChanged"> | ||
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/> | ||
<arg name="state" type="s" direction="in" /> | ||
</method> | ||
<signal name="applyPatchFinished"> | ||
<arg name="patch" type="s"/> | ||
</signal> | ||
<signal name="unapplyPatchFinished"> | ||
<arg name="patch" type="s"/> | ||
</signal> | ||
<signal name="updatesAvailable"> | ||
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | ||
<arg name="updates" type="a{sv}"/> | ||
</signal> | ||
<signal name="toggleServicesChanged"> | ||
<arg name="toggle" type="b"/> | ||
</signal> | ||
<signal name="patchAltered"> | ||
<arg name="patch" type="s"/> | ||
<arg name="installed" type="b"/> | ||
</signal> | ||
<signal name="listPatchesChanged" /> | ||
<signal name="unapplyAllPatchesFinished" /> | ||
<signal name="failureChanged"> | ||
<arg name="failure" type="b"/> | ||
</signal> | ||
<signal name="loadedChanged"> | ||
<arg name="loaded" type="b"/> | ||
</signal> | ||
<signal name="autoApplyingStarted"> | ||
<arg name="count" type="i"/> | ||
</signal> | ||
<signal name="autoApplyingPatch"> | ||
<arg name="name" type="s"/> | ||
</signal> | ||
<signal name="autoApplyingFailed"> | ||
<arg name="name" type="s"/> | ||
</signal> | ||
<signal name="autoApplyingFinished"> | ||
<arg name="success" type="b"/> | ||
</signal> | ||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/100000/dbus/user_bus_socket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include <QDebug> | ||
|
||
#include <QCoreApplication> | ||
#include <QFile> | ||
#include <QFileInfo> | ||
#include <QTranslator> | ||
|
||
#include <unistd.h> | ||
|
||
static const QString s_newConfigLocation = QStringLiteral("/etc/patchmanager2.conf"); | ||
static const QString s_oldConfigLocation = QStringLiteral("/home/nemo/.config/patchmanager2.conf"); | ||
|
||
QString getLang() | ||
{ | ||
QString lang = QStringLiteral("en_US.utf8"); | ||
|
||
QFile localeConfig(QStringLiteral("/var/lib/environment/nemo/locale.conf")); | ||
|
||
if (!localeConfig.exists() || !localeConfig.open(QFile::ReadOnly)) { | ||
return lang; | ||
} | ||
|
||
while (!localeConfig.atEnd()) { | ||
QString line = localeConfig.readLine().trimmed(); | ||
if (line.startsWith(QStringLiteral("LANG="))) { | ||
lang = line.mid(5); | ||
break; | ||
} | ||
} | ||
|
||
return lang; | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
if (getuid() != 0) { | ||
qWarning() << "Not running as root, exiting"; | ||
return 2; | ||
} | ||
|
||
qputenv("NO_PM_PRELOAD", "1"); | ||
|
||
QCoreApplication app(argc, argv); | ||
#ifdef BUILD_VERSION | ||
const QString version = QStringLiteral(BUILD_VERSION); | ||
app.setApplicationVersion(version); | ||
#else | ||
qDebug() << Q_FUNC_INFO << "Patchmanager version unknown!"; | ||
app.setApplicationVersion(QStringLiteral("3.9.9")); | ||
#endif | ||
|
||
qDebug() << Q_FUNC_INFO << "Patchmanager:" << qApp->applicationVersion(); | ||
|
||
const QString lang = getLang(); | ||
qDebug() << Q_FUNC_INFO << "Language:" << lang; | ||
|
||
QTranslator translator; | ||
qDebug() << Q_FUNC_INFO << "Translator loaded:" << | ||
translator.load(QLocale(lang), | ||
QStringLiteral("settings-patchmanager"), | ||
QStringLiteral("-"), | ||
QStringLiteral("/usr/share/translations/"), | ||
QStringLiteral(".qm")); | ||
|
||
qDebug() << Q_FUNC_INFO << "Translator installed:" << | ||
app.installTranslator(&translator); | ||
|
||
QFile preload(QStringLiteral("/etc/ld.so.preload")); | ||
if (preload.exists()) { | ||
qDebug() << Q_FUNC_INFO << "ld.so.preload:"; | ||
if (!preload.open(QFile::ReadOnly)) { | ||
qWarning() << "Can't open ld.so.preload!"; | ||
} | ||
qDebug().noquote() << preload.readAll(); | ||
} else { | ||
qWarning() << Q_FUNC_INFO << "ld.so.preload does not exists!"; | ||
} | ||
|
||
if (!QFileInfo::exists(s_newConfigLocation) && QFileInfo::exists(s_oldConfigLocation)) { | ||
QFile::copy(s_oldConfigLocation, s_newConfigLocation); | ||
} | ||
|
||
if (Q_UNLIKELY(qEnvironmentVariableIsEmpty("DBUS_SESSION_BUS_ADDRESS"))) { | ||
qDebug() << Q_FUNC_INFO << "Injecting DBUS_SESSION_BUS_ADDRESS..." << | ||
qputenv("DBUS_SESSION_BUS_ADDRESS", QByteArrayLiteral("unix:path=/run/user/100000/dbus/user_bus_socket")); | ||
} | ||
|
||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <QDebug> | ||
|
||
#include "patchmanager.h" | ||
|
||
static PatchManager* s_pm = nullptr; | ||
|
||
static const QString s_patchFolder = QStringLiteral("/usr/share/patchmanager/patches"); | ||
static const QString s_patchBackup = QStringLiteral("/tmp/patchmanager/patches"); | ||
|
||
static const QString s_scriptApply = QStringLiteral("/usr/libexec/pm-apply"); | ||
static const QString s_scriptUnapply = QStringLiteral("/usr/libexec/pm-unapply"); | ||
|
||
static const QString s_configLocation = QStringLiteral("/etc/patchmanager.conf"); | ||
|
||
static const QString s_sessionBusConnection = QStringLiteral("patchmanagerconnection"); | ||
|
||
|
||
#define NAME(x) #x | ||
|
||
PatchManager *PatchManager::GetInstance() | ||
{ | ||
if (!s_pm) { | ||
s_pm = new PatchManager(); | ||
} | ||
return s_pm; | ||
} | ||
|
||
QString PatchManager::patchFolder() | ||
{ | ||
return s_patchFolder; | ||
} | ||
|
||
PatchManager::PatchManager(QObject *parent) | ||
: QObject(parent) | ||
{ | ||
|
||
} | ||
|
||
bool PatchManager::isReady() const | ||
{ | ||
return m_ready; | ||
} | ||
|
||
void PatchManager::refreshPatchList() | ||
{ | ||
qDebug() << Q_FUNC_INFO; | ||
QMetaObject::invokeMethod(this, NAME(doRefreshPatchList), Qt::QueuedConnection); | ||
} | ||
|
||
void PatchManager::doRefreshPatchList() | ||
{ | ||
|
||
} |
Oops, something went wrong.