mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Merge branch 'release/20.04'
This commit is contained in:
commit
8fa3e7c145
|
@ -37,7 +37,7 @@ Q_NORETURN void fail(const QString &str)
|
||||||
qCritical() << str;
|
qCritical() << str;
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
auto args = QStringList{"--passivepopup", i18n("Dolphin service menu installation failed"), "15"};
|
const QStringList args = {"--passivepopup", i18n("Dolphin service menu installation failed"), "15"};
|
||||||
process.start("kdialog", args, QIODevice::ReadOnly);
|
process.start("kdialog", args, QIODevice::ReadOnly);
|
||||||
if (!process.waitForStarted()) {
|
if (!process.waitForStarted()) {
|
||||||
qFatal("Failed to run kdialog");
|
qFatal("Failed to run kdialog");
|
||||||
|
@ -59,34 +59,34 @@ struct UncompressCommand
|
||||||
QStringList args2;
|
QStringList args2;
|
||||||
};
|
};
|
||||||
|
|
||||||
void runUncompress(const QString &inputPath, const QString &outputPath) {
|
void runUncompress(const QString &inputPath, const QString &outputPath)
|
||||||
|
{
|
||||||
QVector<QPair<QStringList, UncompressCommand>> mimeTypeToCommand;
|
QVector<QPair<QStringList, UncompressCommand>> mimeTypeToCommand;
|
||||||
mimeTypeToCommand.append({QStringList{"application/x-tar", "application/tar", "application/x-gtar",
|
mimeTypeToCommand.append({{"application/x-tar", "application/tar", "application/x-gtar", "multipart/x-tar"},
|
||||||
"multipart/x-tar"},
|
UncompressCommand({"tar", {"-xf"}, {"-C"}})});
|
||||||
UncompressCommand{"tar", QStringList() << "-xf", QStringList() << "-C"}});
|
mimeTypeToCommand.append({{"application/x-gzip", "application/gzip",
|
||||||
mimeTypeToCommand.append({QStringList{"application/x-gzip", "application/gzip",
|
"application/x-gzip-compressed-tar", "application/gzip-compressed-tar",
|
||||||
"application/x-gzip-compressed-tar", "application/gzip-compressed-tar",
|
"application/x-gzip-compressed", "application/gzip-compressed",
|
||||||
"application/x-gzip-compressed", "application/gzip-compressed",
|
"application/tgz", "application/x-compressed-tar",
|
||||||
"application/tgz", "application/x-compressed-tar",
|
"application/x-compressed-gtar", "file/tgz",
|
||||||
"application/x-compressed-gtar", "file/tgz",
|
"multipart/x-tar-gz", "application/x-gunzip", "application/gzipped",
|
||||||
"multipart/x-tar-gz", "application/x-gunzip", "application/gzipped",
|
"gzip/document"},
|
||||||
"gzip/document"},
|
UncompressCommand({"tar", {"-zxf"}, {"-C"}})});
|
||||||
UncompressCommand{"tar", QStringList{"-zxf"}, QStringList{"-C"}}});
|
mimeTypeToCommand.append({{"application/bzip", "application/bzip2", "application/x-bzip",
|
||||||
mimeTypeToCommand.append({QStringList{"application/bzip", "application/bzip2", "application/x-bzip",
|
"application/x-bzip2", "application/bzip-compressed",
|
||||||
"application/x-bzip2", "application/bzip-compressed",
|
"application/bzip2-compressed", "application/x-bzip-compressed",
|
||||||
"application/bzip2-compressed", "application/x-bzip-compressed",
|
"application/x-bzip2-compressed", "application/bzip-compressed-tar",
|
||||||
"application/x-bzip2-compressed", "application/bzip-compressed-tar",
|
"application/bzip2-compressed-tar", "application/x-bzip-compressed-tar",
|
||||||
"application/bzip2-compressed-tar", "application/x-bzip-compressed-tar",
|
"application/x-bzip2-compressed-tar", "application/x-bz2"},
|
||||||
"application/x-bzip2-compressed-tar", "application/x-bz2"},
|
UncompressCommand({"tar", {"-jxf"}, {"-C"}})});
|
||||||
UncompressCommand{"tar", QStringList{"-jxf"}, QStringList{"-C"}}});
|
mimeTypeToCommand.append({{"application/zip", "application/x-zip", "application/x-zip-compressed",
|
||||||
mimeTypeToCommand.append({QStringList{"application/zip", "application/x-zip", "application/x-zip-compressed",
|
"multipart/x-zip"},
|
||||||
"multipart/x-zip"},
|
UncompressCommand({"unzip", {}, {"-d"}})});
|
||||||
UncompressCommand{"unzip", QStringList{}, QStringList{"-d"}}});
|
|
||||||
|
|
||||||
const auto mime = QMimeDatabase().mimeTypeForFile(inputPath).name();
|
const auto mime = QMimeDatabase().mimeTypeForFile(inputPath).name();
|
||||||
|
|
||||||
UncompressCommand command{};
|
UncompressCommand command{};
|
||||||
for (const auto &pair : mimeTypeToCommand) {
|
for (const auto &pair : qAsConst(mimeTypeToCommand)) {
|
||||||
if (pair.first.contains(mime)) {
|
if (pair.first.contains(mime)) {
|
||||||
command = pair.second;
|
command = pair.second;
|
||||||
break;
|
break;
|
||||||
|
@ -163,14 +163,12 @@ bool runInstallerScript(const QString &path, bool hasArgVariants, const QStringL
|
||||||
qInfo() << "[servicemenuinstaller]: Trying to run installer/uninstaller" << path;
|
qInfo() << "[servicemenuinstaller]: Trying to run installer/uninstaller" << path;
|
||||||
if (hasArgVariants) {
|
if (hasArgVariants) {
|
||||||
for (const auto &arg : argVariants) {
|
for (const auto &arg : argVariants) {
|
||||||
if (runInstallerScriptOnce(path, QStringList{arg})) {
|
if (runInstallerScriptOnce(path, {arg})) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (runInstallerScriptOnce(path, {})) {
|
||||||
if (runInstallerScriptOnce(path, QStringList{})) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errorText = i18nc(
|
errorText = i18nc(
|
||||||
|
@ -224,8 +222,8 @@ bool cmdInstall(const QString &archive, QString &errorText)
|
||||||
|
|
||||||
// Try "install-it" first
|
// Try "install-it" first
|
||||||
QString installItPath;
|
QString installItPath;
|
||||||
const auto basenames1 = QStringList{"install-it.sh", "install-it"};
|
const QStringList basenames1 = {"install-it.sh", "install-it"};
|
||||||
for (const auto &basename : qAsConst(basenames1)) {
|
for (const auto &basename : basenames1) {
|
||||||
const auto path = findRecursive(dir, basename);
|
const auto path = findRecursive(dir, basename);
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
installItPath = path;
|
installItPath = path;
|
||||||
|
@ -239,8 +237,8 @@ bool cmdInstall(const QString &archive, QString &errorText)
|
||||||
|
|
||||||
// If "install-it" is missing, try "install"
|
// If "install-it" is missing, try "install"
|
||||||
QString installerPath;
|
QString installerPath;
|
||||||
const auto basenames2 = QStringList{"installKDE4.sh", "installKDE4", "install.sh", "install"};
|
const QStringList basenames2 = {"installKDE4.sh", "installKDE4", "install.sh", "install"};
|
||||||
for (const auto &basename : qAsConst(basenames2)) {
|
for (const auto &basename : basenames2) {
|
||||||
const auto path = findRecursive(dir, basename);
|
const auto path = findRecursive(dir, basename);
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
installerPath = path;
|
installerPath = path;
|
||||||
|
@ -249,7 +247,7 @@ bool cmdInstall(const QString &archive, QString &errorText)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!installerPath.isEmpty()) {
|
if (!installerPath.isEmpty()) {
|
||||||
return runInstallerScript(installerPath, true, QStringList{"--local", "--local-install", "--install"}, errorText);
|
return runInstallerScript(installerPath, true, {"--local", "--local-install", "--install"}, errorText);
|
||||||
}
|
}
|
||||||
|
|
||||||
fail(i18n("Failed to find an installation script in %1", dir));
|
fail(i18n("Failed to find an installation script in %1", dir));
|
||||||
|
@ -274,8 +272,8 @@ bool cmdUninstall(const QString &archive, QString &errorText)
|
||||||
|
|
||||||
// Try "deinstall" first
|
// Try "deinstall" first
|
||||||
QString deinstallPath;
|
QString deinstallPath;
|
||||||
const auto basenames1 = QStringList{"deinstall.sh", "deinstall"};
|
const QStringList basenames1 = {"deinstall.sh", "deinstall"};
|
||||||
for (const auto &basename : qAsConst(basenames1)) {
|
for (const auto &basename : basenames1) {
|
||||||
const auto path = findRecursive(dir, basename);
|
const auto path = findRecursive(dir, basename);
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
deinstallPath = path;
|
deinstallPath = path;
|
||||||
|
@ -284,17 +282,16 @@ bool cmdUninstall(const QString &archive, QString &errorText)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!deinstallPath.isEmpty()) {
|
if (!deinstallPath.isEmpty()) {
|
||||||
bool ok = runInstallerScript(deinstallPath, false, QStringList{}, errorText);
|
const bool ok = runInstallerScript(deinstallPath, false, {}, errorText);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If "deinstall" is missing, try "install --uninstall"
|
// If "deinstall" is missing, try "install --uninstall"
|
||||||
|
|
||||||
QString installerPath;
|
QString installerPath;
|
||||||
const auto basenames2 = QStringList{"install-it.sh", "install-it", "installKDE4.sh",
|
const QStringList basenames2 = {"install-it.sh", "install-it", "installKDE4.sh",
|
||||||
"installKDE4", "install.sh", "install"};
|
"installKDE4", "install.sh", "install"};
|
||||||
for (const auto &basename : qAsConst(basenames2)) {
|
for (const auto &basename : basenames2) {
|
||||||
const auto path = findRecursive(dir, basename);
|
const auto path = findRecursive(dir, basename);
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
installerPath = path;
|
installerPath = path;
|
||||||
|
@ -303,8 +300,8 @@ bool cmdUninstall(const QString &archive, QString &errorText)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!installerPath.isEmpty()) {
|
if (!installerPath.isEmpty()) {
|
||||||
bool ok = runInstallerScript(
|
const bool ok = runInstallerScript(installerPath, true,
|
||||||
installerPath, true, QStringList{"--remove", "--delete", "--uninstall", "--deinstall"}, errorText);
|
{"--remove", "--delete", "--uninstall", "--deinstall"}, errorText);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -344,11 +341,11 @@ int main(int argc, char *argv[])
|
||||||
const QString archive = args[1];
|
const QString archive = args[1];
|
||||||
|
|
||||||
QString errorText;
|
QString errorText;
|
||||||
if (cmd == "install") {
|
if (cmd == QLatin1String("install")) {
|
||||||
if (!cmdInstall(archive, errorText)) {
|
if (!cmdInstall(archive, errorText)) {
|
||||||
fail(errorText);
|
fail(errorText);
|
||||||
}
|
}
|
||||||
} else if (cmd == "uninstall") {
|
} else if (cmd == QLatin1String("uninstall")) {
|
||||||
if (!cmdUninstall(archive, errorText)) {
|
if (!cmdUninstall(archive, errorText)) {
|
||||||
fail(errorText);
|
fail(errorText);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue