Commit 1ff13868 authored by ck's avatar ck

Maemo: Add deployment via remote mount.

Only tested on Linux, #ifdef'ed for now.
parent 104f8495
......@@ -42,18 +42,28 @@
#include <QtCore/QPair>
#include <QtCore/QSharedPointer>
// #define DEPLOY_VIA_MOUNT
QT_BEGIN_NAMESPACE
class QEventLoop;
#ifdef DEPLOY_VIA_MOUNT
class QTimer;
#endif
QT_END_NAMESPACE
namespace Core {
#ifndef DEPLOY_VIA_MOUNT
class SftpChannel;
#endif
class SshConnection;
class SshRemoteProcess;
}
namespace Qt4ProjectManager {
namespace Internal {
#ifdef DEPLOY_VIA_MOUNT
class MaemoRemoteMounter;
#endif
class MaemoDeployables;
class MaemoDeviceConfigListModel;
class MaemoPackageCreationStep;
......@@ -81,10 +91,19 @@ private slots:
void stop();
void handleConnected();
void handleConnectionFailure();
#ifdef DEPLOY_VIA_MOUNT
void handleMounted();
void handleUnmounted();
void handleMountError(const QString &errorMsg);
void handleProgressReport(const QString &progressMsg);
void handleCopyProcessFinished(int exitStatus);
void handleCleanupTimeout();
#else
void handleSftpChannelInitialized();
void handleSftpChannelInitializationFailed(const QString &error);
void handleSftpJobFinished(Core::SftpJobId job, const QString &error);
void handleLinkProcessFinished(int exitStatus);
#endif
void handleInstallationFinished(int exitStatus);
void handleInstallerOutput(const QByteArray &output);
void handleInstallerErrorOutput(const QByteArray &output);
......@@ -105,20 +124,39 @@ private:
void addDeployTimesToMap(QVariantMap &map) const;
void getDeployTimesFromMap(const QVariantMap &map);
const MaemoPackageCreationStep *packagingStep() const;
#ifdef DEPLOY_VIA_MOUNT
QString deployMountPoint() const;
void deployNextFile();
#else
bool deploy(const MaemoDeployable &deployable);
#endif
#ifndef DEPLOY_VIA_MOUNT
QString uploadDir() const;
#endif
static const QLatin1String Id;
MaemoDeployables * const m_deployables;
QSharedPointer<Core::SshConnection> m_connection;
#ifdef DEPLOY_VIA_MOUNT
typedef QPair<MaemoDeployable, QSharedPointer<Core::SshRemoteProcess> > DeployAction;
QScopedPointer<DeployAction> m_currentDeployAction;
QList<MaemoDeployable> m_filesToCopy;
MaemoRemoteMounter *m_mounter;
QTimer *m_cleanupTimer;
bool m_canStart;
#else
QSharedPointer<Core::SftpChannel> m_uploader;
QSharedPointer<Core::SshRemoteProcess> m_installer;
typedef QPair<MaemoDeployable, QString> DeployInfo;
QMap<Core::SftpJobId, DeployInfo> m_uploadsInProgress;
QMap<QSharedPointer<Core::SshRemoteProcess>, MaemoDeployable> m_linksInProgress;
bool m_needsInstall;
#endif
QSharedPointer<Core::SshRemoteProcess> m_installer;
bool m_stopped;
bool m_needsInstall;
bool m_connecting;
typedef QPair<MaemoDeployable, QString> DeployablePerHost;
QHash<DeployablePerHost, QDateTime> m_lastDeployed;
MaemoDeviceConfigListModel *m_deviceConfigModel;
......
......@@ -57,15 +57,15 @@ void MaemoRemoteMounter::setConnection(const Core::SshConnection::Ptr &connectio
m_connection = connection;
}
void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec)
void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot)
{
if (mountSpec.isValid())
m_mountSpecs << mountSpec;
m_mountSpecs << MountInfo(mountSpec, mountAsRoot);
}
void MaemoRemoteMounter::mount(const MaemoDeviceConfig &devConfig)
void MaemoRemoteMounter::mount()
{
m_devConfig = devConfig;
m_stop = false;
Q_ASSERT(m_utfsServers.isEmpty());
......@@ -87,7 +87,7 @@ void MaemoRemoteMounter::unmount()
for (int i = 0; i < m_mountSpecs.count(); ++i) {
remoteCall += QString::fromLocal8Bit("%1 umount %2;")
.arg(MaemoGlobal::remoteSudo(),
m_mountSpecs.at(i).remoteMountPoint);
m_mountSpecs.at(i).mountSpec.remoteMountPoint);
}
emit reportProgress(tr("Unmounting remote mount points..."));
......@@ -127,6 +127,7 @@ void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus)
utfsServer->kill();
}
m_mountSpecs.clear();
m_utfsServers.clear();
if (errorMsg.isEmpty()) {
emit reportProgress(tr("Finished unmounting."));
......@@ -222,15 +223,17 @@ void MaemoRemoteMounter::startUtfsClients()
const QLatin1String andOp(" && ");
QString remoteCall = chmodFuse + andOp + chmodUtfsClient;
for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i);
const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i).mountSpec;
const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
const QString utfsClient
QString utfsClient
= QString::fromLocal8Bit("%1 -l %2 -r %2 -b %2 %4")
.arg(utfsClientOnDevice()).arg(mountSpec.remotePort)
.arg(mountSpec.remoteMountPoint);
if (m_mountSpecs.at(i).mountAsRoot)
utfsClient.prepend(MaemoGlobal::remoteSudo() + QLatin1Char(' '));
remoteCall += andOp + mkdir + andOp + chmod + andOp + utfsClient;
}
......@@ -287,14 +290,15 @@ void MaemoRemoteMounter::startUtfsServers()
{
emit reportProgress(tr("Starting UTFS servers..."));
for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i);
const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i).mountSpec;
const ProcPtr utfsServerProc(new QProcess);
const QString port = QString::number(mountSpec.remotePort);
const QString localSecretOpt = QLatin1String("-l");
const QString remoteSecretOpt = QLatin1String("-r");
const QStringList utfsServerArgs = QStringList() << localSecretOpt
<< port << remoteSecretOpt << port << QLatin1String("-c")
<< (m_devConfig.server.host + QLatin1Char(':') + port)
const QStringList utfsServerArgs = QStringList()
<< QLatin1String("--detach") << localSecretOpt << port
<< remoteSecretOpt << port << QLatin1String("-c")
<< (m_connection->connectionParameters().host + QLatin1Char(':') + port)
<< mountSpec.localDir;
utfsServerProc->start(utfsServer(), utfsServerArgs);
if (!utfsServerProc->waitForStarted()) {
......@@ -309,6 +313,7 @@ void MaemoRemoteMounter::startUtfsServers()
emit error(errorMsg);
return;
}
utfsServerProc->waitForFinished();
m_utfsServers << utfsServerProc;
}
......
......@@ -30,7 +30,6 @@
#ifndef MAEMOREMOTEMOUNTER_H
#define MAEMOREMOTEMOUNTER_H
#include "maemodeviceconfigurations.h"
#include "maemomountspecification.h"
#include <coreplugin/ssh/sftpdefs.h>
......@@ -58,8 +57,9 @@ class MaemoRemoteMounter : public QObject
public:
MaemoRemoteMounter(QObject *parent, const MaemoToolChain *toolchain);
~MaemoRemoteMounter();
void addMountSpecification(const MaemoMountSpecification &mountSpec);
void mount(const MaemoDeviceConfig &devConfig);
void addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot);
void mount();
void unmount();
void stop();
......@@ -90,10 +90,16 @@ private:
QString utfsServer() const;
const MaemoToolChain * const m_toolChain;
MaemoDeviceConfig m_devConfig;
struct MountInfo {
MountInfo(const MaemoMountSpecification &m, bool root)
: mountSpec(m), mountAsRoot(root) {}
MaemoMountSpecification mountSpec;
bool mountAsRoot;
};
QSharedPointer<Core::SshConnection> m_connection;
QList<MaemoMountSpecification> m_mountSpecs;
QList<MountInfo> m_mountSpecs;
QSharedPointer<Core::SftpChannel> m_utfsClientUploader;
QSharedPointer<Core::SshRemoteProcess> m_mountProcess;
QSharedPointer<Core::SshRemoteProcess> m_unmountProcess;
......
......@@ -197,14 +197,15 @@ void MaemoSshRunner::handleUnmounted()
const MaemoRemoteMountsModel * const remoteMounts
= m_runConfig->remoteMounts();
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i)
m_mounter->addMountSpecification(remoteMounts->mountSpecificationAt(i));
m_mounter->addMountSpecification(remoteMounts->mountSpecificationAt(i),
false);
if (m_debugging && m_runConfig->useRemoteGdb()) {
m_mounter->addMountSpecification(MaemoMountSpecification(
m_runConfig->localDirToMountForRemoteGdb(),
MaemoGlobal::remoteProjectSourcesMountPoint(),
m_devConfig.debuggingPort));
m_devConfig.debuggingPort), false);
}
m_mounter->mount(m_devConfig);
m_mounter->mount();
}
void MaemoSshRunner::handleMounted()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment