forked from qt-creator/qt-creator
Utils: Better prerequisites check for DeviceShell
Check the existence of all commands used by the DeviceShell script before trying to start it. Change-Id: I7a69957a979f8eb021c45e54615ad8d38353d28b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -240,9 +240,9 @@ bool DeviceShell::start()
|
|||||||
|
|
||||||
bool DeviceShell::checkCommand(const QByteArray &command)
|
bool DeviceShell::checkCommand(const QByteArray &command)
|
||||||
{
|
{
|
||||||
const QByteArray checkBase64Cmd = "(which base64 || echo '<missing>')\n";
|
const QByteArray checkCmd = "(which " + command + " || echo '<missing>')\n";
|
||||||
|
|
||||||
m_shellProcess->writeRaw(checkBase64Cmd);
|
m_shellProcess->writeRaw(checkCmd);
|
||||||
if (!m_shellProcess->waitForReadyRead()) {
|
if (!m_shellProcess->waitForReadyRead()) {
|
||||||
qCWarning(deviceShellLog) << "Timeout while trying to check for" << command;
|
qCWarning(deviceShellLog) << "Timeout while trying to check for" << command;
|
||||||
return false;
|
return false;
|
||||||
@@ -265,8 +265,11 @@ bool DeviceShell::installShellScript()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkCommand("base64")) {
|
static const QList<QByteArray> requiredCommands
|
||||||
m_shellScriptState = State::NoScript;
|
= {"base64", "cat", "echo", "kill", "mkfifo", "mktemp", "rm"};
|
||||||
|
|
||||||
|
for (const QByteArray &command : requiredCommands) {
|
||||||
|
if (!checkCommand(command))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user