Author: jghali
Date: Mon Jun 17 13:57:22 2019
New Revision: 23028

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23028
Log:
#15671: Improve AppImage build by allowing relative paths

Modified:
    trunk/Scribus/AppImage-package/AppRun
    trunk/Scribus/AppImage-package/bundle.sh
    trunk/Scribus/CMakeLists.txt
    trunk/Scribus/scribus/scpaths.cpp

Modified: trunk/Scribus/AppImage-package/AppRun
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23028&path=/trunk/Scribus/AppImage-package/AppRun
==============================================================================
--- trunk/Scribus/AppImage-package/AppRun       (original)
+++ trunk/Scribus/AppImage-package/AppRun       Mon Jun 17 13:57:22 2019
@@ -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

Modified: trunk/Scribus/AppImage-package/bundle.sh
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23028&path=/trunk/Scribus/AppImage-package/bundle.sh
==============================================================================
--- trunk/Scribus/AppImage-package/bundle.sh    (original)
+++ trunk/Scribus/AppImage-package/bundle.sh    Mon Jun 17 13:57:22 2019
@@ -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,12 +26,29 @@
 # 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
@@ -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
+-executable=appdir/usr/bin/python2.7 -executable=appdir/usr/_tkinter.so 
-extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so

Modified: trunk/Scribus/CMakeLists.txt
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23028&path=/trunk/Scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/CMakeLists.txt        (original)
+++ trunk/Scribus/CMakeLists.txt        Mon Jun 17 13:57:22 2019
@@ -220,6 +220,21 @@
 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)
+    message(STATUS "Enabling relocatable binaries")
+       add_definitions(-DWANT_RELOCATABLE)
+endif()
+
+##############################################################################################################
 ########## Versioning Setup                                                    
                     ##########
 
 #On Apple, we ignore the versioning tag so all items are "scribus" not 
"scribus-version"
@@ -287,7 +302,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}")
@@ -296,18 +314,17 @@
 #SHARE - use the default on Apple as TAG_VERSION is empty
 if(WIN32 OR OS2)
        set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/")
-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()
-endif()
-if(NOT IS_ABSOLUTE ${DOCDIR})
+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()
+       set(DOCDIR 
"${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}-${VERSION}/")
+endif()
+
+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}")
@@ -319,23 +336,40 @@
 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}")
 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}")
 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}")
@@ -347,7 +381,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}")
@@ -359,20 +396,32 @@
 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}")
 endif()
 
 #APPDATA
-
 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}")
@@ -412,19 +461,31 @@
 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")
-else()
-       if (APPLEBUNDLE)
-               set(PLUGINDIR "${LIBDIR}")
-       else()
-               set(PLUGINDIR 
"${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
-       endif()
-endif()
-add_definitions(-DPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}")
+elseif (APPLEBUNDLE)
+       set(PLUGINDIR "${LIBDIR}")
+else()
+       set(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
+endif()
+
+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

Modified: trunk/Scribus/scribus/scpaths.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=23028&path=/trunk/Scribus/scribus/scpaths.cpp
==============================================================================
--- trunk/Scribus/scribus/scpaths.cpp   (original)
+++ trunk/Scribus/scribus/scpaths.cpp   Mon Jun 17 13:57:22 2019
@@ -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


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to