[education/rkward] /: Improve support for running from non-standard paths on Linux
Thomas Friedrichsmeier
null at kde.org
Mon Jul 17 16:42:19 BST 2023
Git commit 201b2cba2ab3620b297edf3a4b5a05524077ffc9 by Thomas Friedrichsmeier.
Committed on 17/07/2023 at 15:42.
Pushed by tfry into branch 'master'.
Improve support for running from non-standard paths on Linux
CCBUG: 469926
M +2 -0 ChangeLog
M +4 -1 rkward/CMakeLists.txt
M +10 -2 rkward/main.cpp
https://invent.kde.org/education/rkward/-/commit/201b2cba2ab3620b297edf3a4b5a05524077ffc9
diff --git a/ChangeLog b/ChangeLog
index bcf76bde1..b3f878154 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+- Fixed: Better support for running from non-standard paths on Linux (e.g. user-local installation in home dir)
+- Fixed: Added REUSE license information where missing
- Fixed: Handling of carriage returns in R Console window (used in progress bars, importantly)
- Fixed: Crash when renaming top level object from context menu
diff --git a/rkward/CMakeLists.txt b/rkward/CMakeLists.txt
index 12d81a41c..6258401a2 100644
--- a/rkward/CMakeLists.txt
+++ b/rkward/CMakeLists.txt
@@ -57,7 +57,10 @@ ADD_EXECUTABLE(rkward main.cpp)
# NOTE: These definitions are needed for the startup procedure (main.cpp), only.
# We should switch with to target_compile_definitions once we require CMAKE 2.6+
-ADD_DEFINITIONS(-DINSTALL_PATH="${CMAKE_INSTALL_PREFIX}")
+TARGET_COMPILE_DEFINITIONS(rkward PUBLIC -DINSTALL_PATH="${CMAKE_INSTALL_PREFIX}")
+FILE(RELATIVE_PATH RelPathToData /${BIN_INSTALL_DIR} /${DATA_INSTALL_DIR})
+TARGET_COMPILE_DEFINITIONS(rkward PUBLIC -DREL_PATH_TO_DATA="${RelPathToData}")
+
SET_TARGET_PROPERTIES(rkward PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "RKWard")
diff --git a/rkward/main.cpp b/rkward/main.cpp
index 5e67844fb..d609eb60f 100644
--- a/rkward/main.cpp
+++ b/rkward/main.cpp
@@ -1,6 +1,6 @@
/*
main.cpp - This file is part of RKWard (https://rkward.kde.org). Created: Tue Oct 29 2002
-SPDX-FileCopyrightText: 2002-2020 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2002-2023 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -331,7 +331,7 @@ int main (int argc, char *argv[]) {
RKSettingsModuleGeneral::setStartupOption("quirkmode", parser.isSet("quirkmode"));
// MacOS may need some path adjustments, first
-#ifdef Q_OS_MACOS
+#if defined(Q_OS_MACOS)
QString oldpath = qgetenv ("PATH");
if (!oldpath.contains (INSTALL_PATH)) {
//ensure that PATH is set to include what we deliver with the bundle
@@ -342,6 +342,14 @@ int main (int argc, char *argv[]) {
// try to ensure that DBus is running before trying to connect
QProcess::execute ("launchctl", QStringList () << "load" << "/Library/LaunchAgents/org.freedesktop.dbus-session.plist");
}
+#elif defined(Q_OS_UNIX)
+ QStringList data_dirs = QString(qgetenv("XDG_DATA_DIRS")).split(PATH_VAR_SEP);;
+ QString reldatadir = QDir::cleanPath(QDir(app.applicationDirPath()).absoluteFilePath(REL_PATH_TO_DATA));
+ if (!data_dirs.contains(reldatadir)) {
+ RK_DEBUG(APP, DL_WARNING, "Running from non-standard path? Adding %s to XDG_DATA_DIRS", qPrintable(reldatadir));
+ data_dirs.prepend(reldatadir);
+ qputenv("XDG_DATA_DIRS", data_dirs.join(PATH_VAR_SEP).toLocal8Bit());
+ }
#endif
// This is _not_ the same path adjustment as above: Make sure to add the current dir to the path, before launching R and backend.
QStringList syspaths = QString(qgetenv("PATH")).split(PATH_VAR_SEP);
More information about the rkward-tracker
mailing list