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)
|
||||
{
|
||||
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()) {
|
||||
qCWarning(deviceShellLog) << "Timeout while trying to check for" << command;
|
||||
return false;
|
||||
@@ -265,9 +265,12 @@ bool DeviceShell::installShellScript()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkCommand("base64")) {
|
||||
m_shellScriptState = State::NoScript;
|
||||
return false;
|
||||
static const QList<QByteArray> requiredCommands
|
||||
= {"base64", "cat", "echo", "kill", "mkfifo", "mktemp", "rm"};
|
||||
|
||||
for (const QByteArray &command : requiredCommands) {
|
||||
if (!checkCommand(command))
|
||||
return false;
|
||||
}
|
||||
|
||||
const static QByteArray shellScriptBase64 = FilePath(":/utils/scripts/deviceshell.sh")
|
||||
|
Reference in New Issue
Block a user