1 From ca8ff6e6d527ee968300cce5e8cd148f6a4d256b Mon Sep 17 00:00:00 2001
2 From: Thomas Tuegel <ttuegel@mailbox.org>
3 Date: Sun, 25 Apr 2021 08:00:10 -0500
4 Subject: [PATCH 1/3] akonadi paths
7 src/akonadicontrol/agentmanager.cpp | 4 ++--
8 src/akonadicontrol/agentprocessinstance.cpp | 2 +-
9 src/server/storage/dbconfigmysql.cpp | 26 ++++-----------------
10 src/server/storage/dbconfigpostgresql.cpp | 19 +++------------
11 4 files changed, 11 insertions(+), 40 deletions(-)
13 diff --git a/src/akonadicontrol/agentmanager.cpp b/src/akonadicontrol/agentmanager.cpp
14 index 44ceec5..eb5fa50 100644
15 --- a/src/akonadicontrol/agentmanager.cpp
16 +++ b/src/akonadicontrol/agentmanager.cpp
17 @@ -47,7 +47,7 @@ public:
18 connect(this, &Akonadi::ProcessControl::unableToStart, this, []() {
19 QCoreApplication::instance()->exit(255);
21 - start(QStringLiteral("akonadiserver"), args, RestartOnCrash);
22 + start(QStringLiteral(NIX_OUT "/bin/akonadiserver"), args, RestartOnCrash);
25 ~StorageProcessControl() override
26 @@ -69,7 +69,7 @@ public:
27 connect(this, &Akonadi::ProcessControl::unableToStart, this, []() {
28 qCCritical(AKONADICONTROL_LOG) << "Failed to start AgentServer!";
30 - start(QStringLiteral("akonadi_agent_server"), args, RestartOnCrash);
31 + start(QStringLiteral(NIX_OUT "/bin/akonadi_agent_server"), args, RestartOnCrash);
34 ~AgentServerProcessControl() override
35 diff --git a/src/akonadicontrol/agentprocessinstance.cpp b/src/akonadicontrol/agentprocessinstance.cpp
36 index 8e92e08..f98dfd8 100644
37 --- a/src/akonadicontrol/agentprocessinstance.cpp
38 +++ b/src/akonadicontrol/agentprocessinstance.cpp
39 @@ -47,7 +47,7 @@ bool AgentProcessInstance::start(const AgentType &agentInfo)
41 Q_ASSERT(agentInfo.launchMethod == AgentType::Launcher);
42 const QStringList arguments = QStringList() << executable << identifier();
43 - const QString agentLauncherExec = Akonadi::StandardDirs::findExecutable(QStringLiteral("akonadi_agent_launcher"));
44 + const QString agentLauncherExec = QLatin1String(NIX_OUT "/bin/akonadi_agent_launcher");
45 mController->start(agentLauncherExec, arguments);
48 diff --git a/src/server/storage/dbconfigmysql.cpp b/src/server/storage/dbconfigmysql.cpp
49 index 1a437ac..3550f9d 100644
50 --- a/src/server/storage/dbconfigmysql.cpp
51 +++ b/src/server/storage/dbconfigmysql.cpp
52 @@ -72,7 +72,6 @@ bool DbConfigMysql::init(QSettings &settings, bool storeSettings)
53 // determine default settings depending on the driver
54 QString defaultHostName;
55 QString defaultOptions;
56 - QString defaultServerPath;
57 QString defaultCleanShutdownCommand;
60 @@ -80,16 +79,7 @@ bool DbConfigMysql::init(QSettings &settings, bool storeSettings)
63 const bool defaultInternalServer = true;
64 -#ifdef MYSQLD_EXECUTABLE
65 - if (QFile::exists(QStringLiteral(MYSQLD_EXECUTABLE))) {
66 - defaultServerPath = QStringLiteral(MYSQLD_EXECUTABLE);
69 - if (defaultServerPath.isEmpty()) {
70 - defaultServerPath = findExecutable(QStringLiteral("mysqld"));
73 - const QString mysqladminPath = findExecutable(QStringLiteral("mysqladmin"));
74 + const QString mysqladminPath = QLatin1String(NIXPKGS_MYSQL_MYSQLADMIN);
75 if (!mysqladminPath.isEmpty()) {
77 defaultCleanShutdownCommand = QStringLiteral("%1 --defaults-file=%2/mysql.conf --socket=%3/%4 shutdown")
78 @@ -99,10 +89,10 @@ bool DbConfigMysql::init(QSettings &settings, bool storeSettings)
82 - mMysqlInstallDbPath = findExecutable(QStringLiteral("mysql_install_db"));
83 + mMysqlInstallDbPath = QLatin1String(NIXPKGS_MYSQL_MYSQL_INSTALL_DB);
84 qCDebug(AKONADISERVER_LOG) << "Found mysql_install_db: " << mMysqlInstallDbPath;
86 - mMysqlCheckPath = findExecutable(QStringLiteral("mysqlcheck"));
87 + mMysqlCheckPath = QLatin1String(NIXPKGS_MYSQL_MYSQLCHECK);
88 qCDebug(AKONADISERVER_LOG) << "Found mysqlcheck: " << mMysqlCheckPath;
90 mInternalServer = settings.value(QStringLiteral("QMYSQL/StartServer"), defaultInternalServer).toBool();
91 @@ -119,7 +109,7 @@ bool DbConfigMysql::init(QSettings &settings, bool storeSettings)
92 mUserName = settings.value(QStringLiteral("User")).toString();
93 mPassword = settings.value(QStringLiteral("Password")).toString();
94 mConnectionOptions = settings.value(QStringLiteral("Options"), defaultOptions).toString();
95 - mMysqldPath = settings.value(QStringLiteral("ServerPath"), defaultServerPath).toString();
96 + mMysqldPath = QLatin1String(NIXPKGS_MYSQL_MYSQLD);
97 mCleanServerShutdownCommand = settings.value(QStringLiteral("CleanServerShutdownCommand"), defaultCleanShutdownCommand).toString();
100 @@ -129,9 +119,6 @@ bool DbConfigMysql::init(QSettings &settings, bool storeSettings)
101 // intentionally not namespaced as we are the only one in this db instance when using internal mode
102 mDatabaseName = QStringLiteral("akonadi");
104 - if (mInternalServer && (mMysqldPath.isEmpty() || !QFile::exists(mMysqldPath))) {
105 - mMysqldPath = defaultServerPath;
108 qCDebug(AKONADISERVER_LOG) << "Using mysqld:" << mMysqldPath;
110 @@ -141,9 +128,6 @@ bool DbConfigMysql::init(QSettings &settings, bool storeSettings)
111 settings.setValue(QStringLiteral("Name"), mDatabaseName);
112 settings.setValue(QStringLiteral("Host"), mHostName);
113 settings.setValue(QStringLiteral("Options"), mConnectionOptions);
114 - if (!mMysqldPath.isEmpty()) {
115 - settings.setValue(QStringLiteral("ServerPath"), mMysqldPath);
117 settings.setValue(QStringLiteral("StartServer"), mInternalServer);
120 @@ -215,7 +199,7 @@ bool DbConfigMysql::startInternalServer()
123 // generate config file
124 - const QString globalConfig = StandardDirs::locateResourceFile("config", QStringLiteral("mysql-global.conf"));
125 + const QString globalConfig = QLatin1String(NIX_OUT "/etc/xdg/akonadi/mysql-global.conf");
126 const QString localConfig = StandardDirs::locateResourceFile("config", QStringLiteral("mysql-local.conf"));
127 const QString actualConfig = StandardDirs::saveDir("data") + QLatin1String("/mysql.conf");
128 if (globalConfig.isEmpty()) {
129 diff --git a/src/server/storage/dbconfigpostgresql.cpp b/src/server/storage/dbconfigpostgresql.cpp
130 index 4df61da..e3469c4 100644
131 --- a/src/server/storage/dbconfigpostgresql.cpp
132 +++ b/src/server/storage/dbconfigpostgresql.cpp
133 @@ -125,9 +125,7 @@ bool DbConfigPostgresql::init(QSettings &settings, bool storeSettings)
134 // determine default settings depending on the driver
135 QString defaultHostName;
136 QString defaultOptions;
137 - QString defaultServerPath;
138 QString defaultInitDbPath;
139 - QString defaultPgUpgradePath;
140 QString defaultPgData;
142 #ifndef Q_WS_WIN // We assume that PostgreSQL is running as service on Windows
143 @@ -138,12 +136,8 @@ bool DbConfigPostgresql::init(QSettings &settings, bool storeSettings)
145 mInternalServer = settings.value(QStringLiteral("QPSQL/StartServer"), defaultInternalServer).toBool();
146 if (mInternalServer) {
147 - const auto paths = postgresSearchPaths(QStringLiteral("/usr/lib/postgresql"));
149 - defaultServerPath = QStandardPaths::findExecutable(QStringLiteral("pg_ctl"), paths);
150 - defaultInitDbPath = QStandardPaths::findExecutable(QStringLiteral("initdb"), paths);
151 + defaultInitDbPath = QLatin1String(NIXPKGS_POSTGRES_INITDB);
152 defaultHostName = Utils::preferredSocketDirectory(StandardDirs::saveDir("data", QStringLiteral("db_misc")));
153 - defaultPgUpgradePath = QStandardPaths::findExecutable(QStringLiteral("pg_upgrade"), paths);
154 defaultPgData = StandardDirs::saveDir("data", QStringLiteral("db_data"));
157 @@ -162,20 +156,14 @@ bool DbConfigPostgresql::init(QSettings &settings, bool storeSettings)
158 mUserName = settings.value(QStringLiteral("User")).toString();
159 mPassword = settings.value(QStringLiteral("Password")).toString();
160 mConnectionOptions = settings.value(QStringLiteral("Options"), defaultOptions).toString();
161 - mServerPath = settings.value(QStringLiteral("ServerPath"), defaultServerPath).toString();
162 - if (mInternalServer && mServerPath.isEmpty()) {
163 - mServerPath = defaultServerPath;
165 + mServerPath = QLatin1String(NIXPKGS_POSTGRES_PG_CTL);
166 qCDebug(AKONADISERVER_LOG) << "Found pg_ctl:" << mServerPath;
167 mInitDbPath = settings.value(QStringLiteral("InitDbPath"), defaultInitDbPath).toString();
168 if (mInternalServer && mInitDbPath.isEmpty()) {
169 mInitDbPath = defaultInitDbPath;
171 qCDebug(AKONADISERVER_LOG) << "Found initdb:" << mServerPath;
172 - mPgUpgradePath = settings.value(QStringLiteral("UpgradePath"), defaultPgUpgradePath).toString();
173 - if (mInternalServer && mPgUpgradePath.isEmpty()) {
174 - mPgUpgradePath = defaultPgUpgradePath;
176 + mPgUpgradePath = QLatin1String(NIXPKGS_POSTGRES_PG_UPGRADE);
177 qCDebug(AKONADISERVER_LOG) << "Found pg_upgrade:" << mPgUpgradePath;
178 mPgData = settings.value(QStringLiteral("PgData"), defaultPgData).toString();
179 if (mPgData.isEmpty()) {
180 @@ -192,7 +180,6 @@ bool DbConfigPostgresql::init(QSettings &settings, bool storeSettings)
181 settings.setValue(QStringLiteral("Port"), mHostPort);
183 settings.setValue(QStringLiteral("Options"), mConnectionOptions);
184 - settings.setValue(QStringLiteral("ServerPath"), mServerPath);
185 settings.setValue(QStringLiteral("InitDbPath"), mInitDbPath);
186 settings.setValue(QStringLiteral("StartServer"), mInternalServer);