forked from qt-creator/qt-creator
RemoteLinux: Kill remote app before deployment
It's unlikely you want to have two instances running at the same time, and SFTP does not let you overwrite a running executable anyway. Task-number: QTCREATORBUG-19326 Change-Id: Iac48d28f538307fc1764f973ce0c9959ef89af03 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -40,6 +40,8 @@ HEADERS += \
|
||||
genericlinuxdeviceconfigurationwidget.h \
|
||||
remotelinuxcheckforfreediskspaceservice.h \
|
||||
remotelinuxcheckforfreediskspacestep.h \
|
||||
remotelinuxkillappservice.h \
|
||||
remotelinuxkillappstep.h \
|
||||
remotelinuxqmltoolingsupport.h \
|
||||
linuxdeviceprocess.h \
|
||||
remotelinuxcustomrunconfiguration.h \
|
||||
@@ -82,6 +84,8 @@ SOURCES += \
|
||||
genericlinuxdeviceconfigurationwidget.cpp \
|
||||
remotelinuxcheckforfreediskspaceservice.cpp \
|
||||
remotelinuxcheckforfreediskspacestep.cpp \
|
||||
remotelinuxkillappservice.cpp \
|
||||
remotelinuxkillappstep.cpp \
|
||||
remotelinuxqmltoolingsupport.cpp \
|
||||
linuxdeviceprocess.cpp \
|
||||
remotelinuxcustomrunconfiguration.cpp \
|
||||
|
@@ -80,6 +80,10 @@ Project {
|
||||
"remotelinuxenvironmentaspectwidget.h",
|
||||
"remotelinuxenvironmentreader.cpp",
|
||||
"remotelinuxenvironmentreader.h",
|
||||
"remotelinuxkillappservice.cpp",
|
||||
"remotelinuxkillappservice.h",
|
||||
"remotelinuxkillappstep.cpp",
|
||||
"remotelinuxkillappstep.h",
|
||||
"remotelinuxpackageinstaller.cpp",
|
||||
"remotelinuxpackageinstaller.h",
|
||||
"remotelinuxplugin.cpp",
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "genericdirectuploadstep.h"
|
||||
#include "remotelinuxcheckforfreediskspacestep.h"
|
||||
#include "remotelinuxkillappstep.h"
|
||||
#include "remotelinux_constants.h"
|
||||
|
||||
#include <projectexplorer/abi.h>
|
||||
@@ -49,7 +50,8 @@ RemoteLinuxDeployConfiguration::RemoteLinuxDeployConfiguration(Target *target)
|
||||
void RemoteLinuxDeployConfiguration::initialize()
|
||||
{
|
||||
stepList()->insertStep(0, new RemoteLinuxCheckForFreeDiskSpaceStep(stepList()));
|
||||
stepList()->insertStep(1, new GenericDirectUploadStep(stepList()));
|
||||
stepList()->insertStep(1, new RemoteLinuxKillAppStep(stepList()));
|
||||
stepList()->insertStep(2, new GenericDirectUploadStep(stepList()));
|
||||
}
|
||||
|
||||
NamedWidget *RemoteLinuxDeployConfiguration::createConfigWidget()
|
||||
|
101
src/plugins/remotelinux/remotelinuxkillappservice.cpp
Normal file
101
src/plugins/remotelinux/remotelinuxkillappservice.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "remotelinuxkillappservice.h"
|
||||
|
||||
namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
class RemoteLinuxKillAppServicePrivate
|
||||
{
|
||||
public:
|
||||
QString remoteExecutable;
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOp;
|
||||
};
|
||||
} // namespace Internal
|
||||
|
||||
RemoteLinuxKillAppService::RemoteLinuxKillAppService(QObject *parent)
|
||||
: AbstractRemoteLinuxDeployService(parent),
|
||||
d(new Internal::RemoteLinuxKillAppServicePrivate)
|
||||
{
|
||||
}
|
||||
|
||||
RemoteLinuxKillAppService::~RemoteLinuxKillAppService()
|
||||
{
|
||||
cleanup();
|
||||
delete d;
|
||||
}
|
||||
|
||||
void RemoteLinuxKillAppService::setRemoteExecutable(const QString &filePath)
|
||||
{
|
||||
d->remoteExecutable = filePath;
|
||||
}
|
||||
|
||||
bool RemoteLinuxKillAppService::isDeploymentNecessary() const
|
||||
{
|
||||
return !d->remoteExecutable.isEmpty();
|
||||
}
|
||||
|
||||
void RemoteLinuxKillAppService::doDeploy()
|
||||
{
|
||||
d->signalOp = deviceConfiguration()->signalOperation();
|
||||
if (!d->signalOp) {
|
||||
handleDeploymentDone();
|
||||
return;
|
||||
}
|
||||
connect(d->signalOp.data(), &ProjectExplorer::DeviceProcessSignalOperation::finished,
|
||||
this, &RemoteLinuxKillAppService::handleSignalOpFinished);
|
||||
emit progressMessage(tr("Trying to kill \"%1\" on remote device...").arg(d->remoteExecutable));
|
||||
d->signalOp->killProcess(d->remoteExecutable);
|
||||
}
|
||||
|
||||
void RemoteLinuxKillAppService::cleanup()
|
||||
{
|
||||
if (d->signalOp) {
|
||||
disconnect(d->signalOp.data(), nullptr, this, nullptr);
|
||||
d->signalOp.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteLinuxKillAppService::finishDeployment()
|
||||
{
|
||||
cleanup();
|
||||
handleDeploymentDone();
|
||||
}
|
||||
|
||||
void RemoteLinuxKillAppService::stopDeployment()
|
||||
{
|
||||
finishDeployment();
|
||||
}
|
||||
|
||||
void RemoteLinuxKillAppService::handleSignalOpFinished(const QString &errorMessage)
|
||||
{
|
||||
if (errorMessage.isEmpty())
|
||||
emit progressMessage(tr("Remote application killed."));
|
||||
else
|
||||
emit progressMessage(tr("Failed to kill remote application. Assuming it was not running."));
|
||||
finishDeployment();
|
||||
}
|
||||
|
||||
} // namespace RemoteLinux
|
60
src/plugins/remotelinux/remotelinuxkillappservice.h
Normal file
60
src/plugins/remotelinux/remotelinuxkillappservice.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
|
||||
namespace RemoteLinux {
|
||||
namespace Internal { class RemoteLinuxKillAppServicePrivate; }
|
||||
|
||||
class REMOTELINUX_EXPORT RemoteLinuxKillAppService : public AbstractRemoteLinuxDeployService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RemoteLinuxKillAppService(QObject *parent = nullptr);
|
||||
~RemoteLinuxKillAppService() override;
|
||||
|
||||
void setRemoteExecutable(const QString &filePath);
|
||||
|
||||
private:
|
||||
void handleStdErr();
|
||||
void handleProcessFinished();
|
||||
|
||||
bool isDeploymentNecessary() const override;
|
||||
void doDeviceSetup() override { handleDeviceSetupDone(true); }
|
||||
void stopDeviceSetup() override { handleDeviceSetupDone(false); }
|
||||
|
||||
void doDeploy() override;
|
||||
void stopDeployment() override;
|
||||
|
||||
void handleSignalOpFinished(const QString &errorMessage);
|
||||
void cleanup();
|
||||
void finishDeployment();
|
||||
|
||||
Internal::RemoteLinuxKillAppServicePrivate * const d;
|
||||
};
|
||||
|
||||
} // namespace RemoteLinux
|
80
src/plugins/remotelinux/remotelinuxkillappstep.cpp
Normal file
80
src/plugins/remotelinux/remotelinuxkillappstep.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "remotelinuxkillappstep.h"
|
||||
|
||||
#include "remotelinuxkillappservice.h"
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/runnables.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QString>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace RemoteLinux {
|
||||
|
||||
RemoteLinuxKillAppStep::RemoteLinuxKillAppStep(BuildStepList *bsl, Core::Id id)
|
||||
: AbstractRemoteLinuxDeployStep(bsl, id), m_service(new RemoteLinuxKillAppService(this))
|
||||
{
|
||||
setDefaultDisplayName(displayName());
|
||||
}
|
||||
|
||||
BuildStepConfigWidget *RemoteLinuxKillAppStep::createConfigWidget()
|
||||
{
|
||||
return new SimpleBuildStepConfigWidget(this);
|
||||
}
|
||||
|
||||
bool RemoteLinuxKillAppStep::initInternal(QString *error)
|
||||
{
|
||||
Q_UNUSED(error);
|
||||
Target * const theTarget = target();
|
||||
QTC_ASSERT(theTarget, return false);
|
||||
RunConfiguration * const rc = theTarget->activeRunConfiguration();
|
||||
const QString remoteExe = rc && rc->runnable().is<StandardRunnable>()
|
||||
? rc->runnable().as<StandardRunnable>().executable
|
||||
: QString();
|
||||
m_service->setRemoteExecutable(remoteExe);
|
||||
return true;
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployService *RemoteLinuxKillAppStep::deployService() const
|
||||
{
|
||||
return m_service;
|
||||
}
|
||||
|
||||
Core::Id RemoteLinuxKillAppStep::stepId()
|
||||
{
|
||||
return "RemoteLinux.KillAppStep";
|
||||
}
|
||||
|
||||
QString RemoteLinuxKillAppStep::displayName()
|
||||
{
|
||||
return tr("Kill current application instance");
|
||||
}
|
||||
|
||||
} // namespace RemoteLinux
|
52
src/plugins/remotelinux/remotelinuxkillappstep.h
Normal file
52
src/plugins/remotelinux/remotelinuxkillappstep.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
|
||||
namespace RemoteLinux {
|
||||
class RemoteLinuxKillAppService;
|
||||
|
||||
class REMOTELINUX_EXPORT RemoteLinuxKillAppStep : public AbstractRemoteLinuxDeployStep
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RemoteLinuxKillAppStep(ProjectExplorer::BuildStepList *bsl,
|
||||
Core::Id id = stepId());
|
||||
|
||||
static Core::Id stepId();
|
||||
static QString displayName();
|
||||
|
||||
private:
|
||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
|
||||
|
||||
bool initInternal(QString *error) override;
|
||||
AbstractRemoteLinuxDeployService *deployService() const override;
|
||||
|
||||
RemoteLinuxKillAppService * const m_service;
|
||||
};
|
||||
|
||||
} // namespace RemoteLinux
|
@@ -38,6 +38,7 @@
|
||||
#include "remotelinuxcheckforfreediskspacestep.h"
|
||||
#include "remotelinuxdeployconfiguration.h"
|
||||
#include "remotelinuxcustomcommanddeploymentstep.h"
|
||||
#include "remotelinuxkillappstep.h"
|
||||
#include "tarpackagecreationstep.h"
|
||||
#include "uploadandinstalltarpackagestep.h"
|
||||
|
||||
@@ -94,6 +95,7 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
|
||||
addAutoReleasedObject(new GenericLinuxDeployStepFactory
|
||||
<GenericRemoteLinuxCustomCommandDeploymentStep>);
|
||||
addAutoReleasedObject(new GenericLinuxDeployStepFactory<RemoteLinuxCheckForFreeDiskSpaceStep>);
|
||||
addAutoReleasedObject(new GenericLinuxDeployStepFactory<RemoteLinuxKillAppStep>);
|
||||
|
||||
addAutoReleasedObject(new EmbeddedLinuxQtVersionFactory);
|
||||
|
||||
|
Reference in New Issue
Block a user