From kde-commits Sat Sep 22 17:49:02 2018 From: =?utf-8?q?=C5=81ukasz_Wojni=C5=82owicz?= Date: Sat, 22 Sep 2018 17:49:02 +0000 To: kde-commits Subject: [kmymoney] /: Adjust some standard paths for AppImage Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=153764195931007 Git commit a27d1f322e80186aeceb2f9e8723e29fd56847a7 by =C5=81ukasz Wojni=C5= =82owicz. Committed on 22/09/2018 at 17:48. Pushed by wojnilowicz into branch 'master'. Adjust some standard paths for AppImage Differential Revision: https://phabricator.kde.org/D15604 M +2 -0 config-kmymoney.h.cmake M +31 -6 kmymoney/kmymoney.cpp M +8 -4 packaging/linux/appimage/build-image.sh M +1 -12 packaging/linux/appimage/build-kmymoney.sh https://commits.kde.org/kmymoney/a27d1f322e80186aeceb2f9e8723e29fd56847a7 diff --git a/config-kmymoney.h.cmake b/config-kmymoney.h.cmake index 8611c59aa..23689530c 100644 --- a/config-kmymoney.h.cmake +++ b/config-kmymoney.h.cmake @@ -20,3 +20,5 @@ #cmakedefine ENABLE_SQLCIPHER 1 = #cmakedefine ENABLE_GPG 1 + +#cmakedefine IS_APPIMAGE 1 diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp index fba59a4c6..4a54ca3c1 100644 --- a/kmymoney/kmymoney.cpp +++ b/kmymoney/kmymoney.cpp @@ -1160,9 +1160,26 @@ KMyMoneyApp::KMyMoneyApp(QWidget* parent) : layout->setSpacing(6); = { +#ifndef IS_APPIMAGE // find where our custom icons were installed based on an custom icon = that we know should exist after installation const auto customIconRelativePath =3D QString(QStringLiteral("icons/hi= color/16x16/actions/account-add.png")); auto customIconAbsolutePath =3D QStandardPaths::locate(QStandardPaths:= :AppDataLocation, customIconRelativePath); + if (customIconAbsolutePath.isEmpty()) { + qWarning("Custom icons were not found in any of the following QStand= ardPaths::AppDataLocation:"); + for (const auto &standardPath : QStandardPaths::standardLocations(QS= tandardPaths::AppDataLocation)) + qWarning() << standardPath; + } +#else + // according to https://docs.appimage.org/packaging-guide/ingredients.= html#open-source-applications + // QStandardPaths::AppDataLocation is unreliable on AppImages, so appl= y workaround here in case we fail to find icons + const auto appImageAppDataLocation =3D QCoreApplication::applicationDi= rPath() + QLatin1String("/../share/kmymoney/") + customIconRelativePath; + if (QFile::exists(appImageAppDataLocation )) { + customIconAbsolutePath =3D appImageAppDataLocation ; + } else { + qWarning("Custom icons were not found in the following location:"); + qWarning() << appImageAppDataLocation ; + } +#endif = // add our custom icons path to icons search path if (!customIconAbsolutePath.isEmpty()) { @@ -1171,10 +1188,6 @@ KMyMoneyApp::KMyMoneyApp(QWidget* parent) : auto paths =3D QIcon::themeSearchPaths(); paths.append(customIconAbsolutePath); QIcon::setThemeSearchPaths(paths); - } else { - qWarning("Custom icons were not found in any of the following QStand= ardPaths::AppDataLocation:"); - for (const auto &standardPath : QStandardPaths::standardLocations(QS= tandardPaths::AppDataLocation)) - qWarning() << standardPath; } = #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) @@ -2921,9 +2934,21 @@ void KMyMoneyApp::Private::saveConsistencyCheckResul= ts() void KMyMoneyApp::Private::setThemedCSS() { const QStringList CSSnames {QStringLiteral("kmymoney.css"), QStringLiter= al("welcome.css")}; - const QString rcDir("/html/"); - const QStringList defaultCSSDirs =3D QStandardPaths::locateAll(QStandard= Paths::AppDataLocation, rcDir, QStandardPaths::LocateDirectory); + QStringList defaultCSSDirs; +#ifndef IS_APPIMAGE + defaultCSSDirs =3D QStandardPaths::locateAll(QStandardPaths::AppDataLoca= tion, rcDir, QStandardPaths::LocateDirectory); +#else + // according to https://docs.appimage.org/packaging-guide/ingredients.ht= ml#open-source-applications + // QStandardPaths::AppDataLocation is unreliable on AppImages, so apply = workaround here in case we fail to find icons + const auto appImageAppDataLocation =3D QCoreApplication::applicationDirP= ath() + QLatin1String("/../share/kmymoney") + rcDir; + if (QFile::exists(appImageAppDataLocation + CSSnames.first())) { + defaultCSSDirs.append(appImageAppDataLocation); + } else { + qWarning("CSS file was not found in the following location:"); + qWarning() << appImageAppDataLocation; + } +#endif = // scan the list of directories to find the ones that really // contains all files we look for diff --git a/packaging/linux/appimage/build-image.sh b/packaging/linux/appi= mage/build-image.sh index 548c3a337..55c48391a 100755 --- a/packaging/linux/appimage/build-image.sh +++ b/packaging/linux/appimage/build-image.sh @@ -49,18 +49,22 @@ cp -r $DEPS_INSTALL_PREFIX/translations $APPDIR/usr/ mv $APPDIR/usr/lib/x86_64-linux-gnu/* $APPDIR/usr/lib rm -rf $APPDIR/usr/lib/x86_64-linux-gnu/ = -# Step 3: Update the rpath in the various plugins we have to make sure the= y'll be loadable in an Appimage context -for lib in $PLUGINS/*.so*; do +# Step 3: Move plugins to loadable location +mv $PLUGINS $APPDIR/usr/plugins + +# Step 4: Update the rpath in the various plugins we have to make sure the= y'll be loadable in an Appimage context +for lib in $APPDIR/usr/plugins/kmymoney/*.so*; do patchelf --set-rpath '$ORIGIN/..' $lib; done = -# Step 4: Build the image!!! +# Step 5: Build the image!!! linuxdeployqt $APPDIR/usr/share/applications/org.kde.kmymoney.desktop \ -executable=3D$APPDIR/usr/bin/kmymoney \ -qmldir=3D$DEPS_INSTALL_PREFIX/qml \ -verbose=3D2 \ -bundle-non-qt-libs \ - -appimage + -appimage \ + -exclude-libs=3Dlibnss3.so,libnssutil3.so = # Step 5: Find out what version of KMyMoney we built and give the Appimage= a proper name cd $BUILD_PREFIX/kmymoney-build diff --git a/packaging/linux/appimage/build-kmymoney.sh b/packaging/linux/a= ppimage/build-kmymoney.sh index 894e2a55a..6f167b483 100755 --- a/packaging/linux/appimage/build-kmymoney.sh +++ b/packaging/linux/appimage/build-kmymoney.sh @@ -40,18 +40,7 @@ cmake $KMYMONEY_SOURCES \ -DCMAKE_BUILD_TYPE=3DRelWithDebInfo \ -DBUILD_TESTING=3DFALSE \ -DENABLE_WEBENGINE=3DTRUE \ - -DENABLE_SQLCIPHER=3DFALSE \ - -DENABLE_SQLSTORAGE=3DFALSE \ - -DENABLE_KBANKING=3DFALSE \ - -DENABLE_ONLINEJOBOUTBOXVIEW=3DFALSE \ - -DENABLE_OFXIMPORTER=3DFALSE \ - -DENABLE_ADDRESSBOOK=3DFALSE \ - -DENABLE_HOLIDAYS=3DFALSE \ - -DENABLE_ACTIVITIES=3DFALSE \ - -DENABLE_FORECASTVIEW=3DFALSE \ - -DENABLE_REPORTSVIEW=3DFALSE \ - -DENABLE_BUDGETVIEW=3DFALSE \ - -DENABLE_GPG=3DFALSE + -DIS_APPIMAGE=3DTRUE = # Build and Install KMyMoney (ready for the next phase) make -j$CPU_COUNT install