┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Potashev <[email protected]>2019-07-15 22:17:03 +0300
committerAlexander Potashev <[email protected]>2019-07-16 15:04:54 +0300
commitf523585f1be5cf2aca70d2e3b13dff7f05ffa2a1 (patch)
tree9edc887e4643247b38b263d96ad5624fe1313799 /src
parentc951c63e14a272d273be2a7556bcf9298e4e7693 (diff)
servicemenuinstaller: Run installation scripts with cwd in their parent directories
Summary: Otherwise, if cwd is set to the unpacked dir root, some service menus fail to install. Test Plan: - Successfully Installed and uninstalled the "Color Folder" service menu from "Configure Dolphin..." -> service menus -> KNewStuff. - ./test_run.rb still passes all its tests. Reviewers: elvisangelaccio, sitter Reviewed By: sitter Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D22466
Diffstat (limited to 'src')
-rw-r--r--src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp20
-rw-r--r--src/settings/services/test/service_menu_deinstallation_test.rb4
2 files changed, 14 insertions, 10 deletions
diff --git a/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp b/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp
index 9c614a8d3..c06a71c23 100644
--- a/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp
+++ b/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp
@@ -157,10 +157,11 @@ QString findRecursive(const QString &dir, const QString &basename)
return QString();
}
-bool runInstallerScriptOnce(const QString &path, const QStringList &args, const QString &dir)
+bool runInstallerScriptOnce(const QString &path, const QStringList &args)
{
QProcess process;
- process.setWorkingDirectory(dir);
+ process.setWorkingDirectory(QFileInfo(path).absolutePath());
+
process.start(path, args, QIODevice::NotOpen);
if (!process.waitForStarted()) {
fail(i18n("Failed to run installer script %1", path));
@@ -182,8 +183,7 @@ bool runInstallerScriptOnce(const QString &path, const QStringList &args, const
// If hasArgVariants is true, run "path".
// If hasArgVariants is false, run "path argVariants[i]" until successful.
-bool runInstallerScript(const QString &path, bool hasArgVariants, const QStringList &argVariants, const QString &dir,
- QString &errorText)
+bool runInstallerScript(const QString &path, bool hasArgVariants, const QStringList &argVariants, QString &errorText)
{
QFile file(path);
if (!file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner)) {
@@ -194,12 +194,12 @@ bool runInstallerScript(const QString &path, bool hasArgVariants, const QStringL
qInfo() << "[servicemenuinstaller]: Trying to run installer/uninstaller" << path;
if (hasArgVariants) {
for (const auto &arg : argVariants) {
- if (runInstallerScriptOnce(path, QStringList{arg}, dir)) {
+ if (runInstallerScriptOnce(path, QStringList{arg})) {
return true;
}
}
} else {
- if (runInstallerScriptOnce(path, QStringList{}, dir)) {
+ if (runInstallerScriptOnce(path, QStringList{})) {
return true;
}
}
@@ -261,7 +261,7 @@ bool cmdInstall(const QString &archive, QString &errorText)
}
if (!installItPath.isEmpty()) {
- return runInstallerScript(installItPath, false, QStringList{}, dir, errorText);
+ return runInstallerScript(installItPath, false, QStringList{}, errorText);
}
// If "install-it" is missing, try "install"
@@ -276,7 +276,7 @@ bool cmdInstall(const QString &archive, QString &errorText)
}
if (!installerPath.isEmpty()) {
- return runInstallerScript(installerPath, true, QStringList{"--local", "--local-install", "--install"}, dir, errorText);
+ return runInstallerScript(installerPath, true, QStringList{"--local", "--local-install", "--install"}, errorText);
}
fail(i18n("Failed to find an installation script in %1", dir));
@@ -311,7 +311,7 @@ bool cmdUninstall(const QString &archive, QString &errorText)
}
if (!deinstallPath.isEmpty()) {
- bool ok = runInstallerScript(deinstallPath, false, QStringList{}, dir, errorText);
+ bool ok = runInstallerScript(deinstallPath, false, QStringList{}, errorText);
if (!ok) {
return ok;
}
@@ -331,7 +331,7 @@ bool cmdUninstall(const QString &archive, QString &errorText)
if (!installerPath.isEmpty()) {
bool ok = runInstallerScript(
- installerPath, true, QStringList{"--remove", "--delete", "--uninstall", "--deinstall"}, dir, errorText);
+ installerPath, true, QStringList{"--remove", "--delete", "--uninstall", "--deinstall"}, errorText);
if (!ok) {
return ok;
}
diff --git a/src/settings/services/test/service_menu_deinstallation_test.rb b/src/settings/services/test/service_menu_deinstallation_test.rb
index 1c9856d94..4017e8ee0 100644
--- a/src/settings/services/test/service_menu_deinstallation_test.rb
+++ b/src/settings/services/test/service_menu_deinstallation_test.rb
@@ -44,10 +44,14 @@ class ServiceMenuDeinstallationTest < Test::Unit::TestCase
FileUtils.mkpath(archive_dir)
File.write("#{archive_dir}/deinstall.sh", <<-DEINSTALL_SH)
#!/bin/sh
+set -e
+cat deinstall.sh
touch #{@tmpdir}/deinstall.sh-run
DEINSTALL_SH
File.write("#{archive_dir}/install.sh", <<-INSTALL_SH)
#!/bin/sh
+set -e
+cat install.sh
touch #{@tmpdir}/install.sh-run
INSTALL_SH