View Issue Details

IDProjectCategoryView StatusLast Update
0015559ScribusBuild Systempublic2019-06-17 13:59
Reporterale Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionduplicate 
Product Version1.5.5.svn 
Summary0015559: appimage needs relative paths for resources
Descriptionprobono made a pull request on gitlib

https://gitlab.com/scribus/scribus/merge_requests/2

the diff is attached.
TagsNo tags attached.
PatchNo

Relationships

duplicate of 0015671 closedjghali Improve AppImage build by allowing relative paths to resource directories 

Activities

ale

2019-01-27 17:25

manager  

appimage-relative-paths.diff (5,498 bytes)   
diff --git a/AppImage-package/AppRun b/AppImage-package/AppRun
index 3bfcc01e5d7bd0769c51f6bf90986506123d96f1..42e5cc90de4f433e0d34e26d58027ec7c982e4cf 100644
--- a/AppImage-package/AppRun
+++ b/AppImage-package/AppRun
@@ -32,12 +32,6 @@ fi
 export PATH="${HERE}"/usr/bin/:"${HERE}"/usr/sbin/:"${HERE}"/usr/games/:"${HERE}"/bin/:"${HERE}"/sbin/:"${PATH}"
 export XDG_DATA_DIRS="${HERE}"/usr/share/:"${XDG_DATA_DIRS}"
 
-############################################################################################
-# Change into bundled usr/ directory
-############################################################################################
-
-cd "${HERE}"/usr # Because Scribus has some hardcoded paths that we patch away; FIXME
-
 ############################################################################################
 # Use bundled Python
 ############################################################################################
diff --git a/AppImage-package/bundle.sh b/AppImage-package/bundle.sh
index da372e889cba996b01e2613753a85f4228d1695f..823f3364d178aeb89225aabadd26db5d53566b3d 100644
--- a/AppImage-package/bundle.sh
+++ b/AppImage-package/bundle.sh
@@ -4,6 +4,14 @@ cat /proc/1/cgroup # Check if we run in Docker; https://github.com/AppImage/AppI
 
 . /opt/qt*/bin/qt*-env.sh || true
 
+########################################################################
+# Action Search
+########################################################################
+
+git clone https://github.com/aoloe/scribus-plugin-actionSearch
+cp -r scribus-plugin-actionSearch/src scribus/plugins/actionSearch
+echo "ADD_SUBDIRECTORY(actionSearch)" >> scribus/plugins/CMakeLists.txt
+
 ########################################################################
 # Build Plaform Theme for Gtk+
 ########################################################################
@@ -72,13 +80,15 @@ rm *deb
 cd -
 
 ########################################################################
-# Patch away absolute paths
-# FIXME: It would be nice if they were relative
+# Work around side effect of bundling everything
 ########################################################################
 
-sed -i -e 's|/usr/share/scribus|././/share/scribus|g' appdir/usr/bin/scribus
-sed -i -e 's|/usr/lib/scribus|././/lib/scribus|g' appdir/usr/bin/scribus
-sed -i -e 's|/usr/share/doc/scribus/|././/share/doc/scribus/|g' appdir/usr/bin/scribus
+# https://github.com/scribusproject/scribus/issues/111#issuecomment-457823282
+# applicationDirPath() is not usr/bin but lib/x86_64-linux-gnu/
+# when AppRun invokes the binary with
+# exec "${HERE}/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" --inhibit-cache --library-path "${LIBRARY_PATH}" "${MAIN}" "$@"
+# hence we add a symlink here to mitigate this
+( cd  appdir/lib/ ; ln -s ../usr/* . )
 
 ########################################################################
 # Also bundle Tcl/Tk, Tkinter (for Calendar script)
diff --git a/scribus/scpaths.cpp b/scribus/scpaths.cpp
index f4bac4d4ddd8fa6b8f1db448beff74a34c3550c3..cfee1b497dee7695edac81cc3d9f336262e387a4 100644
--- a/scribus/scpaths.cpp
+++ b/scribus/scpaths.cpp
@@ -6,6 +6,7 @@ for which a new license (GPL+exception) is in place.
 */
 #include "scpaths.h"
 #include <QApplication>
+#include <QCoreApplication>
 #include <QDebug>
 #include <QDir>
 #include <QProcess>
@@ -66,6 +67,34 @@ ScPaths::ScPaths() :
 	m_shareDir(SHAREDIR),
 	m_templateDir(TEMPLATEDIR)
 {
+
+// Make paths relative to the main executable
+#ifdef Q_OS_LINUX
+	// Set the application name expliticly.
+	QCoreApplication::setApplicationName("scribus");
+	QString pathPtr = QCoreApplication::applicationDirPath() + QString("/..");
+	m_shareDir = QString("%1/share/scribus/").arg(pathPtr);
+	m_docDir = QString("%1/share/doc/scribus/").arg(pathPtr);
+	//m_fontDir = QString("%1/share/scribus/fonts/").arg(pathPtr);
+	m_iconDir = QString("%1/share/scribus/icons/").arg(pathPtr);
+	m_sampleScriptDir = QString("%1/share/scribus/samples/").arg(pathPtr);
+	m_scriptDir = QString("%1/share/scribus/scripts/").arg(pathPtr);
+	m_templateDir = QString("%1/share/scribus/templates/").arg(pathPtr);
+	m_libDir = QString("%1/lib/scribus/").arg(pathPtr);
+	m_pluginDir = QString("%1/lib/scribus/plugins/").arg(pathPtr);
+	m_qmlDir = QString("%1/share/scribus/qml/").arg(pathPtr);
+
+	qDebug() << QString("scpaths: doc dir=%1").arg(m_docDir);
+	qDebug() << QString("scpaths: icon dir=%1").arg(m_iconDir);
+	//qDebug() << QString("scpaths: font dir=%1").arg(m_fontDir);
+	qDebug() << QString("scpaths: sample dir=%1").arg(m_sampleScriptDir);
+	qDebug() << QString("scpaths: script dir=%1").arg(m_scriptDir);
+	qDebug() << QString("scpaths: template dir=%1").arg(m_templateDir);
+	qDebug() << QString("scpaths: lib dir=%1").arg(m_libDir);
+	qDebug() << QString("scpaths: plugins dir=%1").arg(m_pluginDir);
+	qDebug() << QString("scpaths: qml dir=%1").arg(m_qmlDir);
+#endif
+
 // On MacOS/X, override the compile-time settings with a location
 // obtained from the system.
 #ifdef Q_OS_MAC
@@ -94,8 +123,9 @@ ScPaths::ScPaths() :
 	qDebug() << QString("scpaths: plugin dir=%1").arg(m_pluginDir);
 	qDebug() << QString("scpaths: QML dir=%1").arg(m_qmlDir);
 	qDebug() << QString("scpaths: qtplugins=%1").arg(QApplication::libraryPaths().join(":"));
+#endif
 
-#elif defined(_WIN32)
+#ifdef defined(_WIN32)
 	QFileInfo appInfo(qApp->applicationDirPath());
 	QString appPath = qApp->applicationDirPath();
 	QString cleanAppPath = appInfo.canonicalFilePath();
appimage-relative-paths.diff (5,498 bytes)   

jghali

2019-01-27 22:44

administrator   ~0045864

1) QCoreApplication::setApplicationName() should rather be called in main.cpp, before ScribusQApp initilization. Other Qt functions use applicationName(), so it's safer to initialize it as early as possible
2) it is assumed the library directory is called "lib" to initialize m_libDir and m_pluginDir, I've seen cases where it is called lib64 and this is supported by our build system. See WANT_LIB64 in CMakeLists.txt

jghali

2019-01-27 22:53

administrator   ~0045865

See also case where WANT_VERSIONING option is used. In this case, scribus share directory is not
m_shareDir = QString("%1/share/scribus/").arg(pathPtr);

So at this point I cannot commit this patch as it breaks existing build system functionalities.

jghali

2019-01-27 23:00

administrator   ~0045866

If I look at below link it seems lib64 is indeed part of the File Hierarchy Standard, so you indeed cannot assume library directory is called "lib":
https://unix.stackexchange.com/questions/447525/why-there-are-lib-and-lib64-but-only-bin

jghali

2019-06-17 13:58

administrator   ~0046318

Closing as a duplicate of 0015671

Issue History

Date Modified Username Field Change
2019-01-27 17:25 ale New Issue
2019-01-27 17:25 ale File Added: appimage-relative-paths.diff
2019-01-27 22:44 jghali Note Added: 0045864
2019-01-27 22:53 jghali Note Added: 0045865
2019-01-27 23:00 jghali Note Added: 0045866
2019-06-17 13:58 jghali Assigned To => jghali
2019-06-17 13:58 jghali Status new => resolved
2019-06-17 13:58 jghali Resolution open => duplicate
2019-06-17 13:58 jghali Note Added: 0046318
2019-06-17 13:58 jghali Relationship added duplicate of 0015671
2019-06-17 13:59 jghali Status resolved => closed