mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: require shared-mime-info v0.91+
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d1ab8476eb
commit
2193402c44
3 changed files with 4 additions and 74 deletions
|
@ -64,7 +64,7 @@ set_package_properties(ZLIB PROPERTIES
|
|||
PURPOSE "Required by the core KDE libraries and some critical kioslaves"
|
||||
)
|
||||
|
||||
find_package(SharedMimeInfo 0.70)
|
||||
find_package(SharedMimeInfo 0.91)
|
||||
set_package_properties(SharedMimeInfo PROPERTIES
|
||||
DESCRIPTION "Shared Mime Info"
|
||||
URL "http://freedesktop.org/wiki/Software/shared-mime-info"
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
# UPDATE_MIME_DATABASE_EXECUTABLE - the update-mime-database executable
|
||||
#
|
||||
# The minimum required version of SharedMimeInfo can be specified using the
|
||||
# standard syntax, e.g. find_package(SharedMimeInfo 0.20)
|
||||
# standard syntax, e.g. find_package(SharedMimeInfo 0.91)
|
||||
#
|
||||
# For backward compatibility, the following two variables are also supported:
|
||||
# SHARED_MIME_INFO_MINIMUM_VERSION - set to the minimum version you need, default is 0.18.
|
||||
# SHARED_MIME_INFO_MINIMUM_VERSION - set to the minimum version you need, default is 0.91.
|
||||
# When both are used, i.e. the version is set in the find_package() call and
|
||||
# SHARED_MIME_INFO_MINIMUM_VERSION is set, the version specified in the find_package()
|
||||
# call takes precedence.
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
# the minimum version of shared-mime-database we require
|
||||
if(NOT SharedMimeInfo_FIND_VERSION)
|
||||
set(SharedMimeInfo_FIND_VERSION "0.18")
|
||||
set(SharedMimeInfo_FIND_VERSION "0.91")
|
||||
endif()
|
||||
|
||||
find_program (UPDATE_MIME_DATABASE_EXECUTABLE NAMES update-mime-database)
|
||||
|
|
|
@ -49,76 +49,6 @@ static int mimeDataBaseVersion()
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Remove the #idef'ed code below once the issue is fixed
|
||||
// in QProcess or when we require s-m-i >= 0.91
|
||||
#ifdef Q_OS_UNIX
|
||||
// Try to read the version number from the shared-mime-info.pc file
|
||||
QStringList paths;
|
||||
const QByteArray pkgConfigPath = qgetenv("PKG_CONFIG_PATH");
|
||||
if (!pkgConfigPath.isEmpty()) {
|
||||
paths << QFile::decodeName(pkgConfigPath).split(QLatin1Char(':'), QString::SkipEmptyParts);
|
||||
}
|
||||
|
||||
// Add platform specific hard-coded default paths to the list...
|
||||
paths << QLatin1String("/share/pkgconfig");
|
||||
paths << QLatin1String("/lib/pkgconfig");
|
||||
paths << QLatin1String("/lib32/pkgconfig");
|
||||
paths << QLatin1String("/lib64/pkgconfig");
|
||||
paths << QLatin1String("/usr/share/pkgconfig");
|
||||
paths << QLatin1String("/usr/lib/pkgconfig");
|
||||
paths << QLatin1String("/usr/lib32/pkgconfig");
|
||||
paths << QLatin1String("/usr/lib64/pkgconfig");
|
||||
paths << QLatin1String(KDEDIR "/share/pkgconfig");
|
||||
paths << QLatin1String(KDEDIR "/lib/pkgconfig");
|
||||
paths << QLatin1String(KDEDIR "/lib32/pkgconfig");
|
||||
paths << QLatin1String(KDEDIR "/lib64/pkgconfig");
|
||||
|
||||
Q_FOREACH(const QString& path, paths) {
|
||||
const QString fileName = path + QLatin1String("/shared-mime-info.pc");
|
||||
if (!QFile::exists(fileName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QFile file (fileName);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
break;
|
||||
}
|
||||
|
||||
while (!file.atEnd()) {
|
||||
const QByteArray line = file.readLine().simplified();
|
||||
if (!line.startsWith("Version")) { // krazy:exclude=strings
|
||||
continue;
|
||||
}
|
||||
QRegExp versionRe(QString::fromLatin1("Version: (\\d+)\\.(\\d+)(\\.(\\d+))?"));
|
||||
if (versionRe.indexIn(QString::fromLocal8Bit(line)) > -1) {
|
||||
return KDE_MAKE_VERSION(versionRe.cap(1).toInt(), versionRe.cap(2).toInt(), versionRe.cap(4).toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Execute "update-mime-database -v" to determine version number.
|
||||
// NOTE: On *nix, the code below is known to cause freezes/hangs in apps
|
||||
// that block signals. See https://bugs.kde.org/show_bug.cgi?id=260719.
|
||||
const QString umd = KStandardDirs::findExe(QString::fromLatin1("update-mime-database"));
|
||||
if (umd.isEmpty()) {
|
||||
kWarning(servicesDebugArea()) << "update-mime-database not found!";
|
||||
return -1;
|
||||
}
|
||||
|
||||
QProcess smi;
|
||||
smi.start(umd, QStringList() << QString::fromLatin1("-v"));
|
||||
if (smi.waitForStarted() && smi.waitForFinished()) {
|
||||
const QString out = QString::fromLocal8Bit(smi.readAllStandardError());
|
||||
QRegExp versionRe(QString::fromLatin1("update-mime-database \\(shared-mime-info\\) (\\d+)\\.(\\d+)(\\.(\\d+))?"));
|
||||
if (versionRe.indexIn(out) > -1) {
|
||||
return KDE_MAKE_VERSION(versionRe.cap(1).toInt(), versionRe.cap(2).toInt(), versionRe.cap(4).toInt());
|
||||
}
|
||||
kWarning(servicesDebugArea()) << "Unexpected version scheme from update-mime-database -v: got" << out;
|
||||
} else {
|
||||
kWarning(servicesDebugArea()) << "Error running update-mime-database -v";
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue