View Issue Details

IDProjectCategoryView StatusLast Update
0015671ScribusBuild Systempublic2019-07-30 21:27
Reporterale Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version1.5.5.svn 
Target VersionFixed in Version1.5.5.svn 
Summary0015671: Improve AppImage build by allowing relative paths to resource directories
Descriptionhttps://gitlab.com/impagina/scribus-patched/compare/master...appimage

- add an optional "RELATIVE_PATH" to the CMakeLists.txt file
- compiling in a build directory
- only use the gtk2 theme in gnome (other DE can be added)
- a bit of clean up in the bundle.sh file
TagsNo tags attached.
PatchNo

Relationships

has duplicate 0015559 closedjghali appimage needs relative paths for resources 

Activities

ale

2019-05-04 08:46

manager  

appimage.diff (10,381 bytes)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c12e24904..f80200630 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -25,4 +25,4 @@ appimage:linux:
   artifacts:
     expire_in: 14 days
     paths:
-      - ./Scribus*.AppImage*
\ No newline at end of file
+      - ./build-appimage/Scribus*.AppImage*
diff --git a/AppImage-package/AppRun b/AppImage-package/AppRun
index 3bfcc01e5..fd1e6aa44 100644
--- a/AppImage-package/AppRun
+++ b/AppImage-package/AppRun
@@ -56,7 +56,10 @@ export TK_LIBRARY="${HERE}"/usr/share/tcltk/tk8.6:$TK_LIBRARY:$TCL_LIBRARY
 # Make it look more native on Gtk+ based systems
 ############################################################################################
 
-export QT_QPA_PLATFORMTHEME=gtk2
+case "${XDG_CURRENT_DESKTOP}" in
+    *GNOME*|*gnome*)
+        export QT_QPA_PLATFORMTHEME=gtk2
+esac
 
 ############################################################################################
 # Run experimental bundle that bundles everything if a private ld-linux-x86-64.so.2 is there
diff --git a/AppImage-package/bundle.sh b/AppImage-package/bundle.sh
index da372e889..ee7b01f44 100644
--- a/AppImage-package/bundle.sh
+++ b/AppImage-package/bundle.sh
@@ -1,29 +1,16 @@
 #!/bin/bash
 
-cat /proc/1/cgroup # Check if we run in Docker; https://github.com/AppImage/AppImageKit/issues/912
+mkdir build-appimage
+cd build-appimage
 
+# for docker images:
+# if qt is not in the standard path, load its environment variables
+# /opt/qt*/bin/qt*-env.sh
 . /opt/qt*/bin/qt*-env.sh || true
 
-########################################################################
-# Build Plaform Theme for Gtk+
-########################################################################
-
-find /opt/qt*/| grep platform 
-#apt-get update
-#apt-get -y install libgtk-3-dev libnotify-dev qt5113d
-#git clone https://github.com/CrimsonAS/gtkplatform
-#cd gtkplatform
-#qmake
-#make -j$(nproc)
-#sudo make install 
-#cd -
 
 ########################################################################
-# https://askubuntu.com/a/910143
-# https://askubuntu.com/a/748186
-# Deploy with linuxdeployqt using
-# -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
-# At runtime, export QT_QPA_PLATFORMTHEME=gtk2 (Xfce does this itself)
+# Build Plaform Theme for Gtk+
 ########################################################################
 
 git clone http://code.qt.io/qt/qtstyleplugins.git
@@ -37,12 +24,27 @@ cd -
 # Build Scribus and install to appdir/
 ########################################################################
 
-cmake . -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=/usr -DWANT_HUNSPELL=1 -DWITH_PODOFO=1 -DWANT_GRAPHICSMAGICK=1 -DWANT_DEBUG=0 -DWANT_SVNVERSION=0 -DWANT_GUI_LANG=en_US
+cmake .. -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
+    -DCMAKE_C_COMPILER_LAUNCHER=ccache \
+    -DCMAKE_INSTALL_PREFIX=/usr \
+    -DWANT_RELATIVE_PATH="." \
+    -DWANT_HUNSPELL=1 \
+    -DWITH_PODOFO=1 \
+    -DWANT_GRAPHICSMAGICK=1 \
+    -DWANT_DEBUG=0 \
+    -DWANT_SVNVERSION=0 \
+    -DWANT_GUI_LANG="en_US;de;fr;it"
 make -j$(nproc)
-make DESTDIR=appdir -j$(nproc) install ; find appdir/
-cp AppImage-package/AppRun appdir/ ; chmod +x appdir/AppRun
+
+make DESTDIR=appdir -j$(nproc) install
+
+
+# TODO: make sure that the appdir directory exits
+cp ../AppImage-package/AppRun appdir/
+chmod +x appdir/AppRun
 cp ./appdir/usr/share/icons/hicolor/256x256/apps/scribus.png ./appdir/
-sed -i -e 's|^Icon=.*|Icon=scribus|g' ./appdir/usr/share/applications/scribus.desktop # Needed?
+# TODO: is this needed?
+sed -i -e 's|^Icon=.*|Icon=scribus|g' ./appdir/usr/share/applications/scribus.desktop
 
 ########################################################################
 # Bundle everyhting
@@ -51,7 +53,8 @@ sed -i -e 's|^Icon=.*|Icon=scribus|g' ./appdir/usr/share/applications/scribus.de
 
 cd appdir/
 
-# Bundle all of glibc; this should eventually be done by linuxdeployqt
+# Bundle all of glibc
+# (this should eventually be done by linuxdeployqt)
 apt-get update -q
 apt-get download libc6
 find *.deb -exec dpkg-deb -x {} . \;
@@ -71,26 +74,15 @@ find *.deb -exec dpkg-deb -x {} . \;
 rm *deb
 cd -
 
-########################################################################
-# Patch away absolute paths
-# FIXME: It would be nice if they were relative
-########################################################################
-
-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
-
-########################################################################
-# Also bundle Tcl/Tk, Tkinter (for Calendar script)
-########################################################################
-
+# Bundle Tcl/Tk, Tkinter (for hte Calendar script)
 mkdir -p appdir/usr/lib appdir/usr/share
 cp /usr/li*/python2.7/lib-dynload/_tkinter.so appdir/usr/ # It is indeed picked up here because we cd there at runtime
 cp -r /usr/lib/tcltk appdir/usr/lib/
 cp -r /usr/share/tcltk appdir/usr/share/
 
 ########################################################################
-# Create extra qt.conf in a strange location; FIXME: why is this needed?
+# Create extra qt.conf in a strange location
+# TODO: why is this needed?
 ########################################################################
 
 mkdir -p appdir/lib/x86_64-linux-gnu/
@@ -112,4 +104,4 @@ wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/contin
 chmod a+x linuxdeployqt-continuous-x86_64.AppImage
 ARCH=x86_64 ./linuxdeployqt-continuous-x86_64.AppImage --appimage-extract-and-run appdir/usr/share/applications/scribus.desktop \
 -appimage -unsupported-bundle-everything \
--executable=appdir/usr/bin/python2.7 -executable=appdir/usr/_tkinter.so -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
\ No newline at end of file
+-executable=appdir/usr/bin/python2.7 -executable=appdir/usr/_tkinter.so -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 305e11b06..fb6647423 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -283,7 +283,9 @@ if(WANT_VERSIONING)
 else()
 	set(SHAREDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}/")
 endif()
-if(NOT IS_ABSOLUTE ${SHAREDIR})
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DSHAREDIR="${WANT_RELATIVE_PATH}/${SHAREDIR}")
+elseif(NOT IS_ABSOLUTE ${SHAREDIR})
 	add_definitions(-DSHAREDIR="${CMAKE_INSTALL_PREFIX}/${SHAREDIR}")
 else()
 	add_definitions(-DSHAREDIR="${SHAREDIR}")
@@ -303,7 +305,9 @@ else()
 		endif()
 	endif()
 endif()
-if(NOT IS_ABSOLUTE ${DOCDIR})
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DDOCDIR="${WANT_RELATIVE_PATH}/${DOCDIR}")
+elseif(NOT IS_ABSOLUTE ${DOCDIR})
 	add_definitions(-DDOCDIR="${CMAKE_INSTALL_PREFIX}/${DOCDIR}")
 else()
 	add_definitions(-DDOCDIR="${DOCDIR}")
@@ -315,7 +319,9 @@ if(WIN32)
 else()
 	set(ICONDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
 endif()
-if(NOT IS_ABSOLUTE ${ICONDIR})
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DICONDIR="${WANT_RELATIVE_PATH}/${ICONDIR}")
+elseif(NOT IS_ABSOLUTE ${ICONDIR})
 	add_definitions(-DICONDIR="${CMAKE_INSTALL_PREFIX}/${ICONDIR}")
 else()
 	add_definitions(-DICONDIR="${ICONDIR}")
@@ -323,7 +329,9 @@ endif()
 
 #SAMPLES
 set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
-if(NOT IS_ABSOLUTE ${SAMPLESDIR})
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DSAMPLESDIR="${WANT_RELATIVE_PATH}/${SAMPLESDIR}")
+elseif(NOT IS_ABSOLUTE ${SAMPLESDIR})
 	add_definitions(-DSAMPLESDIR="${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}")
 else()
 	add_definitions(-DSAMPLESDIR="${SAMPLESDIR}")
@@ -331,7 +339,9 @@ endif()
 
 #SCRIPTS
 set(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
-if(NOT IS_ABSOLUTE ${SCRIPTSDIR})
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DSCRIPTSDIR="${WANT_RELATIVE_PATH}/${SCRIPTSDIR}")
+elseif(NOT IS_ABSOLUTE ${SCRIPTSDIR})
 	add_definitions(-DSCRIPTSDIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}")
 else()
 	add_definitions(-DSCRIPTSDIR="${SCRIPTSDIR}")
@@ -343,7 +353,10 @@ if(WIN32)
 else()
 	set(TEMPLATEDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
 endif()
-if(NOT IS_ABSOLUTE ${TEMPLATEDIR})
+
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DTEMPLATEDIR="${WANT_RELATIVE_PATH}/${TEMPLATEDIR}")
+elseif(NOT IS_ABSOLUTE ${TEMPLATEDIR})
 	add_definitions(-DTEMPLATEDIR="${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}")
 else()
 	add_definitions(-DTEMPLATEDIR="${TEMPLATEDIR}")
@@ -359,7 +372,9 @@ add_definitions(-DQMLDIR="${CMAKE_INSTALL_PREFIX}/${QMLDIR}")
 
 #DESKTOP
 set(DESKTOPDIR "${CMAKE_INSTALL_DATAROOTDIR}/applications/")
-if(NOT IS_ABSOLUTE ${DESKTOPDIR})
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DDESKTOPDIR="${WANT_RELATIVE_PATH}/${DESKTOPDIR}")
+elseif(NOT IS_ABSOLUTE ${DESKTOPDIR})
 	add_definitions(-DDESKTOPDIR="${CMAKE_INSTALL_PREFIX}/${DESKTOPDIR}")
 else()
 	add_definitions(-DDESKTOPDIR="${DESKTOPDIR}")
@@ -368,7 +383,9 @@ endif()
 #APPDATA
 
 set(APPDATADIR "${CMAKE_INSTALL_DATAROOTDIR}/metainfo/")
-if(NOT IS_ABSOLUTE ${APPDATADIRR})
+if(DEFINED WANT_RELATIVE_PATH)
+	add_definitions(-DAPPDATADIR="${WANT_RELATIVE_PATH}/${APPDATADIRR}")
+elseif(NOT IS_ABSOLUTE ${APPDATADIRR})
 	add_definitions(-DAPPDATADIR="${CMAKE_INSTALL_PREFIX}/${APPDATADIR}")
 else()
 	add_definitions(-DAPPDATADIR="${APPDATADIR}")
@@ -407,7 +424,11 @@ if (APPLEBUNDLE)
 else()
 	set(LIBDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/")
 endif()
-add_definitions(-DLIBDIR="${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
+if(DEFINED WANT_RELATIVE_PATH)
+    add_definitions(-DLIBDIR="${WANT_RELATIVE_PATH}/${LIBDIR}")
+else()
+    add_definitions(-DLIBDIR="${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
+endif()
 
 #PLUGINS
 if(WIN32)
@@ -419,7 +440,11 @@ else()
 		set(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
 	endif()
 endif()
-add_definitions(-DPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}")
+if(DEFINED WANT_RELATIVE_PATH)
+    add_definitions(-DPLUGINDIR="${WANT_RELATIVE_PATH}/${PLUGINDIR}")
+else()
+    add_definitions(-DPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}")
+endif()
 
 
 #INCLUDE
appimage.diff (10,381 bytes)

ale

2019-05-04 08:47

manager   ~0046179

probono wrote that it looks ok for him...

jghali

2019-05-23 14:37

administrator   ~0046254

I had a look at this patch and I have a concern: with this patch, the plugin directory will basically depends on the working directory... which means that i may be possible to execute arbitrary code by writing a proper command line and using a specially crafted working directory. So from a security point of view, it's probably not fine.

I tried to do it in a different way by somewhat mixing this approach and the approach used in 0015559. The attached patch add a WANT_RELOCATABLE option to cmake command line. When using this option, the resources and plugins directories will be defined relative to the executable path. Please test.

15671_allow_relative_paths.patch (16,693 bytes)
Index: AppImage-package/AppRun
===================================================================
--- AppImage-package/AppRun	(revision 22988)
+++ AppImage-package/AppRun	(working copy)
@@ -56,7 +56,10 @@
 # Make it look more native on Gtk+ based systems
 ############################################################################################
 
-export QT_QPA_PLATFORMTHEME=gtk2
+case "${XDG_CURRENT_DESKTOP}" in
+    *GNOME*|*gnome*)
+        export QT_QPA_PLATFORMTHEME=gtk2
+esac
 
 ############################################################################################
 # Run experimental bundle that bundles everything if a private ld-linux-x86-64.so.2 is there
Index: AppImage-package/bundle.sh
===================================================================
--- AppImage-package/bundle.sh	(revision 22988)
+++ AppImage-package/bundle.sh	(working copy)
@@ -2,23 +2,12 @@
 
 cat /proc/1/cgroup # Check if we run in Docker; https://github.com/AppImage/AppImageKit/issues/912
 
+# for docker images:
+# if qt is not in the standard path, load its environment variables
 . /opt/qt*/bin/qt*-env.sh || true
 
 ########################################################################
 # Build Plaform Theme for Gtk+
-########################################################################
-
-find /opt/qt*/| grep platform 
-#apt-get update
-#apt-get -y install libgtk-3-dev libnotify-dev qt5113d
-#git clone https://github.com/CrimsonAS/gtkplatform
-#cd gtkplatform
-#qmake
-#make -j$(nproc)
-#sudo make install 
-#cd -
-
-########################################################################
 # https://askubuntu.com/a/910143
 # https://askubuntu.com/a/748186
 # Deploy with linuxdeployqt using
@@ -37,13 +26,30 @@
 # Build Scribus and install to appdir/
 ########################################################################
 
-cmake . -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=/usr -DWANT_HUNSPELL=1 -DWITH_PODOFO=1 -DWANT_GRAPHICSMAGICK=1 -DWANT_DEBUG=0 -DWANT_SVNVERSION=0 -DWANT_GUI_LANG=en_US
+cmake . -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
+    -DCMAKE_C_COMPILER_LAUNCHER=ccache \
+    -DCMAKE_INSTALL_PREFIX=/usr \
+    -DWANT_RELOCATABLE=1 \
+    -DWANT_HUNSPELL=1 \
+    -DWITH_PODOFO=1 \
+    -DWANT_GRAPHICSMAGICK=1 \
+    -DWANT_DEBUG=0 \
+    -DWANT_SVNVERSION=0 \
+    -DWANT_GUI_LANG=en_US;de;fr;it \
 make -j$(nproc)
-make DESTDIR=appdir -j$(nproc) install ; find appdir/
-cp AppImage-package/AppRun appdir/ ; chmod +x appdir/AppRun
+
+make DESTDIR=appdir -j$(nproc) install
+find appdir/
+
+# TODO: make sure that the appdir directory exits
+cp AppImage-package/AppRun appdir/
+chmod +x appdir/AppRun
+
 cp ./appdir/usr/share/icons/hicolor/256x256/apps/scribus.png ./appdir/
-sed -i -e 's|^Icon=.*|Icon=scribus|g' ./appdir/usr/share/applications/scribus.desktop # Needed?
 
+# TODO: is this needed?
+sed -i -e 's|^Icon=.*|Icon=scribus|g' ./appdir/usr/share/applications/scribus.desktop
+
 ########################################################################
 # Bundle everyhting
 # to allow the AppImage to run on older systems as well
@@ -72,13 +78,17 @@
 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/* .
+cd -
 
 ########################################################################
 # Also bundle Tcl/Tk, Tkinter (for Calendar script)
@@ -90,7 +100,8 @@
 cp -r /usr/share/tcltk appdir/usr/share/
 
 ########################################################################
-# Create extra qt.conf in a strange location; FIXME: why is this needed?
+# Create extra qt.conf in a strange location;
+# FIXME: why is this needed?
 ########################################################################
 
 mkdir -p appdir/lib/x86_64-linux-gnu/
@@ -112,4 +123,4 @@
 chmod a+x linuxdeployqt-continuous-x86_64.AppImage
 ARCH=x86_64 ./linuxdeployqt-continuous-x86_64.AppImage --appimage-extract-and-run appdir/usr/share/applications/scribus.desktop \
 -appimage -unsupported-bundle-everything \
--executable=appdir/usr/bin/python2.7 -executable=appdir/usr/_tkinter.so -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
\ No newline at end of file
+-executable=appdir/usr/bin/python2.7 -executable=appdir/usr/_tkinter.so -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 22988)
+++ CMakeLists.txt	(working copy)
@@ -216,6 +216,20 @@
 message(STATUS "Building for target ${MACHINE}")
 
 ##############################################################################################################
+########## Relocatability                                                                           ##########
+
+if (APPLEBUNDLE OR WIN32)
+	if (WANT_RELOCATABLE)
+		message(STATUS "Ignoring relocatable option on Win32 or OSX when building bundle")
+		set(WANT_RELOCATABLE 0)
+	endif()
+endif()
+
+if (WANT_RELOCATABLE)
+	add_definitions(-DWANT_RELOCATABLE)
+endif()
+
+##############################################################################################################
 ########## Versioning Setup                                                                         ##########
 
 #On Apple, we ignore the versioning tag so all items are "scribus" not "scribus-version"
@@ -259,7 +273,7 @@
 ########## Install/Directory Setup                                                                  ##########
 
 if (APPLEBUNDLE)
-set (APPLE_APP_DIR "${CMAKE_INSTALL_PREFIX}")
+	set (APPLE_APP_DIR "${CMAKE_INSTALL_PREFIX}")
 	if ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/Contents/?$")
 		# all ok
 	else()
@@ -283,7 +297,10 @@
 else()
 	set(SHAREDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}/")
 endif()
-if(NOT IS_ABSOLUTE ${SHAREDIR})
+
+if(IS_ABSOLUTE ${SHAREDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: SHAREDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${SHAREDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DSHAREDIR="${CMAKE_INSTALL_PREFIX}/${SHAREDIR}")
 else()
 	add_definitions(-DSHAREDIR="${SHAREDIR}")
@@ -292,18 +309,17 @@
 #SHARE - use the default on Apple as TAG_VERSION is empty
 if(WIN32 OR OS2)
 	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/")
+elseif(TAG_VERSION OR BUILD_OSX_BUNDLE)
+	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
+elseif(NOT WANT_VERSIONING)
+	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}/")
 else()
-	if(TAG_VERSION OR BUILD_OSX_BUNDLE)
-		set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
-	else()
-		if(NOT WANT_VERSIONING)
-			set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}/")
-		else()
-			set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}-${VERSION}/")
-		endif()
-	endif()
+	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}-${VERSION}/")
 endif()
-if(NOT IS_ABSOLUTE ${DOCDIR})
+
+if(IS_ABSOLUTE ${DOCDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: DOCDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${DOCDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DDOCDIR="${CMAKE_INSTALL_PREFIX}/${DOCDIR}")
 else()
 	add_definitions(-DDOCDIR="${DOCDIR}")
@@ -315,7 +331,10 @@
 else()
 	set(ICONDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
 endif()
-if(NOT IS_ABSOLUTE ${ICONDIR})
+
+if(IS_ABSOLUTE ${ICONDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: ICONDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${ICONDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DICONDIR="${CMAKE_INSTALL_PREFIX}/${ICONDIR}")
 else()
 	add_definitions(-DICONDIR="${ICONDIR}")
@@ -322,8 +341,15 @@
 endif()
 
 #SAMPLES
-set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
-if(NOT IS_ABSOLUTE ${SAMPLESDIR})
+if(WIN32)
+	set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/samples/")
+else()
+	set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
+endif()
+
+if(IS_ABSOLUTE ${SAMPLESDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: SAMPLESDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${SAMPLESDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DSAMPLESDIR="${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}")
 else()
 	add_definitions(-DSAMPLESDIR="${SAMPLESDIR}")
@@ -330,8 +356,15 @@
 endif()
 
 #SCRIPTS
-set(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
-if(NOT IS_ABSOLUTE ${SCRIPTSDIR})
+if(WIN32)
+	set(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/scripts/")
+else()
+	set(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
+endif()
+
+if(IS_ABSOLUTE ${SCRIPTSDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: SCRIPTSDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${SCRIPTSDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DSCRIPTSDIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}")
 else()
 	add_definitions(-DSCRIPTSDIR="${SCRIPTSDIR}")
@@ -343,7 +376,10 @@
 else()
 	set(TEMPLATEDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
 endif()
-if(NOT IS_ABSOLUTE ${TEMPLATEDIR})
+
+if(IS_ABSOLUTE ${TEMPLATEDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: TEMPLATEDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${TEMPLATEDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DTEMPLATEDIR="${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}")
 else()
 	add_definitions(-DTEMPLATEDIR="${TEMPLATEDIR}")
@@ -355,11 +391,21 @@
 else()
 	set(QMLDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/qml/")
 endif()
-add_definitions(-DQMLDIR="${CMAKE_INSTALL_PREFIX}/${QMLDIR}")
 
+if(IS_ABSOLUTE ${QMLDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: QMLDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${QMLDIR} AND NOT WANT_RELOCATABLE)
+	add_definitions(-DQMLDIR="${CMAKE_INSTALL_PREFIX}/${QMLDIR}")
+else()
+	add_definitions(-DQMLDIR="${QMLDIR}")
+endif()
+
 #DESKTOP
 set(DESKTOPDIR "${CMAKE_INSTALL_DATAROOTDIR}/applications/")
-if(NOT IS_ABSOLUTE ${DESKTOPDIR})
+
+if(IS_ABSOLUTE ${DESKTOPDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: DESKTOPDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${DESKTOPDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DDESKTOPDIR="${CMAKE_INSTALL_PREFIX}/${DESKTOPDIR}")
 else()
 	add_definitions(-DDESKTOPDIR="${DESKTOPDIR}")
@@ -366,9 +412,11 @@
 endif()
 
 #APPDATA
+set(APPDATADIR "${CMAKE_INSTALL_DATAROOTDIR}/metainfo/")
 
-set(APPDATADIR "${CMAKE_INSTALL_DATAROOTDIR}/metainfo/")
-if(NOT IS_ABSOLUTE ${APPDATADIRR})
+if(IS_ABSOLUTE ${APPDATADIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: APPDATADIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${APPDATADIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DAPPDATADIR="${CMAKE_INSTALL_PREFIX}/${APPDATADIR}")
 else()
 	add_definitions(-DAPPDATADIR="${APPDATADIR}")
@@ -380,17 +428,17 @@
 # Example: I want to use special ~/.scribus135svn config directory for my trunk
 #          cmake -DAPPLICATION_DATA_DIR=.scribus135svn ...
 if (APPLICATION_DATA_DIR)
-    message(STATUS "Using ApplicationDataDir ${APPLICATION_DATA_DIR} instead of the platform default.")
+	message(STATUS "Using ApplicationDataDir ${APPLICATION_DATA_DIR} instead of the platform default.")
 	add_definitions(-DAPPLICATION_DATA_DIR="${APPLICATION_DATA_DIR}")
 else()
-    message(STATUS "Using standard ApplicationDataDir. You can change it with -DAPPLICATION_DATA_DIR")
+	message(STATUS "Using standard ApplicationDataDir. You can change it with -DAPPLICATION_DATA_DIR")
 endif()
 
 if (APPLICATION_CONFIG_DIR)
-    message(STATUS "Using ApplicationConfigDir ${APPLICATION_CONFIG_DIR} instead of the platform default.")
+	message(STATUS "Using ApplicationConfigDir ${APPLICATION_CONFIG_DIR} instead of the platform default.")
 	add_definitions(-DAPPLICATION_CONFIG_DIR="${APPLICATION_CONFIG_DIR}")
 else()
-    message(STATUS "Using standard ApplicationConfigDir. You can change it with -DAPPLICATION_CONFIG_DIR")
+	message(STATUS "Using standard ApplicationConfigDir. You can change it with -DAPPLICATION_CONFIG_DIR")
 endif()
 
 #LIB LOCATION - lib or lib64 normally
@@ -399,8 +447,9 @@
 	if(NOT ARCH_X86_64)
 		message(STATUS "WARNING: BUILDING 64 Bit build on non 64 bit architecture")
 	endif()
-	 set(LIB_SUFFIX "64" CACHE TYPE STRING)
+	set(LIB_SUFFIX "64" CACHE TYPE STRING)
 endif()
+
 set(LIB_DIR_NAME "lib${LIB_SUFFIX}")
 if (APPLEBUNDLE)
 	set(LIBDIR "lib/")
@@ -407,21 +456,33 @@
 else()
 	set(LIBDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/")
 endif()
-add_definitions(-DLIBDIR="${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
 
+if(IS_ABSOLUTE ${LIBDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: LIBDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${LIBDIR} AND NOT WANT_RELOCATABLE)
+	add_definitions(-DLIBDIR="${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
+else()
+	add_definitions(-DLIBDIR="${LIBDIR}")
+endif()
+
 #PLUGINS
 if(WIN32)
 	set(PLUGINDIR "plugins")
+elseif (APPLEBUNDLE)
+	set(PLUGINDIR "${LIBDIR}")
 else()
-	if (APPLEBUNDLE)
-		set(PLUGINDIR "${LIBDIR}")
-	else()
-		set(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
-	endif()
+	set(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
 endif()
-add_definitions(-DPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}")
 
+if(IS_ABSOLUTE ${PLUGINDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: PLUGINDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${PLUGINDIR} AND NOT WANT_RELOCATABLE)
+	add_definitions(-DPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}")
+else()
+	add_definitions(-DPLUGINDIR="${PLUGINDIR}")
+endif()
 
+
 #INCLUDE
 set(INCLUDEDIR "include/${MAIN_DIR_NAME}${TAG_VERSION}/")
 #NO ADD DEFINITIONS, WE ONLY INSTALL WITH IT
Index: scribus/scpaths.cpp
===================================================================
--- scribus/scpaths.cpp	(revision 22988)
+++ scribus/scpaths.cpp	(working copy)
@@ -52,20 +52,33 @@
 }
 
 // Protected "real" constructor
-// All paths are initialized to compile-time defaults passed in
+ScPaths::ScPaths()
+{
+// On *nix, all paths are initialized to compile-time defaults passed in
 // as preprocessor macros and set by autoconf.
-ScPaths::ScPaths() :
-	m_docDir(DOCDIR),
-	m_fontDir(),
-	m_iconDir(ICONDIR),
-	m_libDir(LIBDIR),
-	m_pluginDir(PLUGINDIR),
-	m_qmlDir(QMLDIR),
-	m_sampleScriptDir(SAMPLESDIR),
-	m_scriptDir(SCRIPTSDIR),
-	m_shareDir(SHAREDIR),
-	m_templateDir(TEMPLATEDIR)
-{
+#if !defined(Q_OS_MAC) && !defined(_WIN32) && defined(WANT_RELOCATABLE)
+	QString appPath = qApp->applicationDirPath();
+	m_docDir = appPath + "/../" + QString(DOCDIR);
+	m_iconDir = appPath + "/../" + QString(ICONDIR);
+	m_libDir = appPath + "/../" + QString(LIBDIR);
+	m_pluginDir = appPath + "/../" + QString(PLUGINDIR);
+	m_qmlDir = appPath + "/../" + QString(QMLDIR);
+	m_sampleScriptDir = appPath + "/../" + QString(SAMPLESDIR);
+	m_scriptDir = appPath + "/../" + QString(SCRIPTSDIR);
+	m_shareDir = appPath + "/../" + QString(SHAREDIR);
+	m_templateDir = appPath + "/../" + QString(TEMPLATEDIR);
+#elif !defined(Q_OS_MAC) && !defined(_WIN32)
+	m_docDir = QString(DOCDIR);
+	m_iconDir = QString(ICONDIR);
+	m_libDir = QString(LIBDIR);
+	m_pluginDir = QString(PLUGINDIR);
+	m_qmlDir = QString(QMLDIR);
+	m_sampleScriptDir = QString(SAMPLESDIR);
+	m_scriptDir = QString(SCRIPTSDIR);
+	m_shareDir = QString(SHAREDIR);
+	m_templateDir = QString(TEMPLATEDIR);
+#endif
+
 // On MacOS/X, override the compile-time settings with a location
 // obtained from the system.
 #ifdef Q_OS_MAC

ale

2019-05-23 15:46

manager   ~0046255

- you removed the "build" directory... that should not be a big issue...
- "-DWANT_GUI_LANG=en_US;de;fr;it \" the backslash at the end is probably wrong
- you have left in a "find appdir/" that i'm not sure is doing anything (maybe giving a visual confirmation that everything is ok?)
- the "if(IS_ABSOLUTE ${SHAREDIR} AND WANT_RELOCATABLE) ... elseif()" conditions seem a bit too complex to me. i would only check for the sane combinations and do a default action otherwise (basically: remove the first if...) but it should work as you did it...

i will try to put your patch on gitlab and see how it behaves...

Issue History

Date Modified Username Field Change
2019-05-04 08:46 ale New Issue
2019-05-04 08:46 ale File Added: appimage.diff
2019-05-04 08:47 ale Note Added: 0046179
2019-05-23 14:37 jghali File Added: 15671_allow_relative_paths.patch
2019-05-23 14:37 jghali Note Added: 0046254
2019-05-23 15:46 ale Note Added: 0046255
2019-06-17 13:57 jghali Summary allow relative paths when making && improve the appimage build => Improve AppImage build by allowing relative paths
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 => fixed
2019-06-17 13:58 jghali Fixed in Version => 1.5.5.svn
2019-06-17 13:58 jghali Relationship added has duplicate 0015559
2019-06-17 15:00 jghali Summary Improve AppImage build by allowing relative paths => Improve AppImage build by allowing relative paths to resource directories
2019-07-30 21:27 cbradney Status resolved => closed