1diff -Npru kservice-5.51.0.orig/src/sycoca/kbuildservicefactory.cpp kservice-5.51.0/src/sycoca/kbuildservicefactory.cpp
2--- kservice-5.51.0.orig/src/sycoca/kbuildservicefactory.cpp	2018-10-08 10:21:25.000000000 +0200
3+++ kservice-5.51.0/src/sycoca/kbuildservicefactory.cpp	2018-11-04 08:51:59.529451519 +0100
4@@ -93,11 +93,17 @@ KSycocaEntry *KBuildServiceFactory::crea
5         if (QDir::isAbsolutePath(file)) { // vfolder sends us full paths for applications
6             serv = new KService(file);
7         } else { // we get relative paths for services
8+          const QString appImageDesktopFile = QCoreApplication::applicationDirPath() + QLatin1String("/../share/") + QStringLiteral("kservices5/") + file;
9+          if (QFile::exists(appImageDesktopFile)) {
10+            KDesktopFile desktopFile(appImageDesktopFile);
11+            serv = new KService(&desktopFile, appImageDesktopFile);
12+          } else {
13             KDesktopFile desktopFile(QStandardPaths::GenericDataLocation, QStringLiteral("kservices5/") + file);
14             // Note that the second arg below MUST be 'file', unchanged.
15             // If the entry path doesn't match the 'file' parameter to createEntry, reusing old entries
16             // (via time dict, which uses the entry path as key) cannot work.
17             serv = new KService(&desktopFile, file);
18+          }
19         }
20
21         //qCDebug(SYCOCA) << "Creating KService from" << file << "entryPath=" << serv->entryPath();
22diff -Npru kservice-5.51.0.orig/src/sycoca/kbuildsycoca.cpp kservice-5.51.0/src/sycoca/kbuildsycoca.cpp
23--- kservice-5.51.0.orig/src/sycoca/kbuildsycoca.cpp	2018-10-08 10:21:25.000000000 +0200
24+++ kservice-5.51.0/src/sycoca/kbuildsycoca.cpp	2018-11-04 08:53:04.976953937 +0100
25@@ -201,7 +201,11 @@ bool KBuildSycoca::build()
26         m_resource = it1.value();
27
28         QSet<QString> relFiles;
29-        const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, m_resourceSubdir, QStandardPaths::LocateDirectory);
30+        QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, m_resourceSubdir, QStandardPaths::LocateDirectory);
31+        const QString appImageDir = QCoreApplication::applicationDirPath() + QLatin1String("/../share/") + m_resourceSubdir;
32+        if (QFile::exists(appImageDir))
33+          dirs.append(appImageDir);
34+
35         qCDebug(SYCOCA) << "Looking for subdir" << m_resourceSubdir << "=>" << dirs;
36         Q_FOREACH (const QString &dir, dirs) {
37             QDirIterator it(dir, QDirIterator::Subdirectories);
38@@ -626,7 +630,11 @@ quint32 KBuildSycoca::calcResourceHash(c
39     if (!QDir::isRelativePath(filename)) {
40         return updateHash(filename, hash);
41     }
42-    const QStringList files = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, resourceSubDir + QLatin1Char('/') + filename);
43+    QStringList files = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, resourceSubDir + QLatin1Char('/') + filename);
44+    const QString appImageFile = QCoreApplication::applicationDirPath() + QLatin1String("/../share/") + resourceSubDir + QLatin1Char('/') + filename;
45+    if (QFile::exists(appImageFile))
46+      files.append(appImageFile);
47+
48     Q_FOREACH (const QString &file, files) {
49         hash = updateHash(file, hash);
50     }
51diff -Npru kservice-5.51.0.orig/src/sycoca/ksycoca.cpp kservice-5.51.0/src/sycoca/ksycoca.cpp
52--- kservice-5.51.0.orig/src/sycoca/ksycoca.cpp	2018-10-08 10:21:25.000000000 +0200
53+++ kservice-5.51.0/src/sycoca/ksycoca.cpp	2018-11-04 08:56:33.977171556 +0100
54@@ -596,6 +596,14 @@ KSycocaHeader KSycocaPrivate::readSycoca
55
56     str->device()->seek(oldPos);
57
58+    // this clause must be before timeStamp = header.timeStamp
59+    qDebug() << "applications name: " << qAppName();
60+    const QString appImageShare = QCoreApplication::applicationDirPath() + QLatin1String("/../share");
61+    addLocalResourceDir(appImageShare + QLatin1String("/kservices5"));
62+    addLocalResourceDir(appImageShare + QLatin1String("/kservicetypes5"));
63+    addLocalResourceDir(appImageShare + QLatin1String("/mime"));
64+    addLocalResourceDir(appImageShare + QLatin1String("/applications"));
65+
66     timeStamp = header.timeStamp;
67
68     // for the useless public accessors. KF6: remove these two lines, the accessors and the vars.
69