Maemo: Use devrootsh only on remote systems that have MAD developer.

This commit is contained in:
Christian Kandeler
2011-04-26 12:10:37 +02:00
parent 701742168a
commit b2ef0926e3
18 changed files with 88 additions and 54 deletions

View File

@@ -370,14 +370,6 @@ void AbstractMaemoDeployStep::handleRemoteStderr(const QString &output)
} }
} }
MaemoPortList AbstractMaemoDeployStep::freePorts(const MaemoDeviceConfig::ConstPtr &devConf) const
{
const Qt4BuildConfiguration * const qt4bc = qt4BuildConfiguration();
if (!qt4bc)
return MaemoPortList();
return MaemoGlobal::freePorts(devConf, qt4bc->qtVersion());
}
const Qt4BuildConfiguration *AbstractMaemoDeployStep::qt4BuildConfiguration() const const Qt4BuildConfiguration *AbstractMaemoDeployStep::qt4BuildConfiguration() const
{ {
return static_cast<Qt4BuildConfiguration *>(buildConfiguration()); return static_cast<Qt4BuildConfiguration *>(buildConfiguration());

View File

@@ -93,7 +93,6 @@ protected:
QString deployMountPoint() const; QString deployMountPoint() const;
const Qt4BuildConfiguration *qt4BuildConfiguration() const; const Qt4BuildConfiguration *qt4BuildConfiguration() const;
MaemoPortList freePorts(const QSharedPointer<const MaemoDeviceConfig> &devConfig) const;
QSharedPointer<Utils::SshConnection> connection() const { return m_connection; } QSharedPointer<Utils::SshConnection> connection() const { return m_connection; }
private slots: private slots:

View File

@@ -151,17 +151,20 @@ void MaemoConfigTestDialog::handleGeneralTestResult(int exitStatus)
m_ui->testResultEdit->setPlainText(output); m_ui->testResultEdit->setPlainText(output);
} }
if (m_config->osVersion() == MaemoDeviceConfig::GenericLinux) { switch (m_config->osVersion()) {
case MaemoDeviceConfig::Maemo5:
case MaemoDeviceConfig::Maemo6:
case MaemoDeviceConfig::Meego:
m_currentTest = MadDeveloperTest;
disconnect(m_testProcessRunner.data(),
SIGNAL(processOutputAvailable(QByteArray)), this,
SLOT(processSshOutput(QByteArray)));
m_testProcessRunner->run("test -x "
+ MaemoGlobal::devrootshPath().toUtf8());
break;
default:
testPorts(); testPorts();
return;
} }
m_currentTest = MadDeveloperTest;
disconnect(m_testProcessRunner.data(),
SIGNAL(processOutputAvailable(QByteArray)), this,
SLOT(processSshOutput(QByteArray)));
const QByteArray command = "test -x " + MaemoGlobal::devrootshPath().toUtf8();
m_testProcessRunner->run(command);
} }
void MaemoConfigTestDialog::handleMadDeveloperTestResult(int exitStatus) void MaemoConfigTestDialog::handleMadDeveloperTestResult(int exitStatus)
@@ -208,8 +211,7 @@ void MaemoConfigTestDialog::handlePortListReady()
void MaemoConfigTestDialog::testPorts() void MaemoConfigTestDialog::testPorts()
{ {
if (m_config->freePorts().hasMore()) if (m_config->freePorts().hasMore())
m_portsGatherer->start(m_testProcessRunner->connection(), m_portsGatherer->start(m_testProcessRunner->connection(), m_config);
m_config->freePorts());
else else
finish(); finish();
} }

View File

@@ -153,8 +153,8 @@ void AbstractMaemoDeployByMountStep::handleMountDebugOutput(const QString &outpu
void AbstractMaemoDeployByMountStep::mount() void AbstractMaemoDeployByMountStep::mount()
{ {
m_extendedState = Mounting; m_extendedState = Mounting;
m_mounter->setupMounts(connection(), mountSpecifications(), m_mounter->setupMounts(connection(), helper().cachedDeviceConfig(),
freePorts(helper().cachedDeviceConfig()), qt4BuildConfiguration()); mountSpecifications(), qt4BuildConfiguration());
} }
QString AbstractMaemoDeployByMountStep::deployMountPoint() const QString AbstractMaemoDeployByMountStep::deployMountPoint() const
@@ -259,7 +259,8 @@ void MaemoMountAndInstallDeployStep::deploy()
{ {
const QString remoteFilePath = deployMountPoint() + QLatin1Char('/') const QString remoteFilePath = deployMountPoint() + QLatin1Char('/')
+ QFileInfo(packagingStep()->packageFilePath()).fileName(); + QFileInfo(packagingStep()->packageFilePath()).fileName();
m_installer->installPackage(connection(), remoteFilePath, false); m_installer->installPackage(connection(), helper().cachedDeviceConfig(),
remoteFilePath, false);
} }
void MaemoMountAndInstallDeployStep::cancelInstallation() void MaemoMountAndInstallDeployStep::cancelInstallation()
@@ -365,7 +366,8 @@ QList<MaemoMountSpecification> MaemoMountAndCopyDeployStep::mountSpecifications(
void MaemoMountAndCopyDeployStep::deploy() void MaemoMountAndCopyDeployStep::deploy()
{ {
m_copyFacility->copyFiles(connection(), m_filesToCopy, deployMountPoint()); m_copyFacility->copyFiles(connection(), helper().cachedDeviceConfig(),
m_filesToCopy, deployMountPoint());
} }
void MaemoMountAndCopyDeployStep::handleFileCopied(const MaemoDeployable &deployable) void MaemoMountAndCopyDeployStep::handleFileCopied(const MaemoDeployable &deployable)

View File

@@ -67,15 +67,16 @@ MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent)
} }
void MaemoDeploymentMounter::setupMounts(const SshConnection::Ptr &connection, void MaemoDeploymentMounter::setupMounts(const SshConnection::Ptr &connection,
const MaemoDeviceConfig::ConstPtr &devConf,
const QList<MaemoMountSpecification> &mountSpecs, const QList<MaemoMountSpecification> &mountSpecs,
const MaemoPortList &freePorts, const Qt4BuildConfiguration *bc) const Qt4BuildConfiguration *bc)
{ {
ASSERT_STATE(Inactive); ASSERT_STATE(Inactive);
m_freePorts = freePorts;
m_mountSpecs = mountSpecs; m_mountSpecs = mountSpecs;
m_connection = connection; m_connection = connection;
m_mounter->setConnection(m_connection); m_devConf = devConf;
m_mounter->setConnection(m_connection, m_devConf);
m_buildConfig = bc; m_buildConfig = bc;
connect(m_connection.data(), SIGNAL(error(Utils::SshError)), connect(m_connection.data(), SIGNAL(error(Utils::SshError)),
SLOT(handleConnectionError())); SLOT(handleConnectionError()));
@@ -136,7 +137,7 @@ void MaemoDeploymentMounter::handleUnmounted()
break; break;
case UnmountingCurrentDirs: case UnmountingCurrentDirs:
setState(GatheringPorts); setState(GatheringPorts);
m_portsGatherer->start(m_connection, m_freePorts); m_portsGatherer->start(m_connection, m_devConf);
break; break;
case UnmountingCurrentMounts: case UnmountingCurrentMounts:
setState(Inactive); setState(Inactive);
@@ -166,6 +167,7 @@ void MaemoDeploymentMounter::handlePortListReady()
return; return;
setState(Mounting); setState(Mounting);
m_freePorts = MaemoGlobal::freePorts(m_devConf, m_buildConfig->qtVersion());
m_mounter->mount(&m_freePorts, m_portsGatherer); m_mounter->mount(&m_freePorts, m_portsGatherer);
} }

View File

@@ -45,6 +45,7 @@ namespace Utils { class SshConnection; }
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
class Qt4BuildConfiguration; class Qt4BuildConfiguration;
namespace Internal { namespace Internal {
class MaemoDeviceConfig;
class MaemoRemoteMounter; class MaemoRemoteMounter;
class MaemoUsedPortsGatherer; class MaemoUsedPortsGatherer;
@@ -56,8 +57,9 @@ public:
// Connection must be in connected state. // Connection must be in connected state.
void setupMounts(const QSharedPointer<Utils::SshConnection> &connection, void setupMounts(const QSharedPointer<Utils::SshConnection> &connection,
const QSharedPointer<const MaemoDeviceConfig> &devConf,
const QList<MaemoMountSpecification> &mountSpecs, const QList<MaemoMountSpecification> &mountSpecs,
const MaemoPortList &freePorts, const Qt4BuildConfiguration *bc); const Qt4BuildConfiguration *bc);
void tearDownMounts(); void tearDownMounts();
signals: signals:
@@ -87,6 +89,7 @@ private:
State m_state; State m_state;
QSharedPointer<Utils::SshConnection> m_connection; QSharedPointer<Utils::SshConnection> m_connection;
QSharedPointer<const MaemoDeviceConfig> m_devConf;
MaemoRemoteMounter * const m_mounter; MaemoRemoteMounter * const m_mounter;
MaemoUsedPortsGatherer * const m_portsGatherer; MaemoUsedPortsGatherer * const m_portsGatherer;
MaemoPortList m_freePorts; MaemoPortList m_freePorts;

View File

@@ -127,16 +127,26 @@ QString MaemoGlobal::devrootshPath()
return QLatin1String("/usr/lib/mad-developer/devrootsh"); return QLatin1String("/usr/lib/mad-developer/devrootsh");
} }
QString MaemoGlobal::remoteSudo(const QString &uname) QString MaemoGlobal::remoteSudo(MaemoDeviceConfig::OsVersion osVersion,
const QString &uname)
{ {
return uname == QLatin1String("root") ? QString() : devrootshPath(); if (uname == QLatin1String("root"))
return QString();
switch (osVersion) {
case MaemoDeviceConfig::Maemo5:
case MaemoDeviceConfig::Maemo6:
case MaemoDeviceConfig::Meego:
return devrootshPath();
default:
return QLatin1String("sudo");
}
} }
QString MaemoGlobal::remoteCommandPrefix(MaemoDeviceConfig::OsVersion osVersion, QString MaemoGlobal::remoteCommandPrefix(MaemoDeviceConfig::OsVersion osVersion,
const QString &userName, const QString &commandFilePath) const QString &userName, const QString &commandFilePath)
{ {
QString prefix = QString::fromLocal8Bit("%1 chmod a+x %2; %3; ") QString prefix = QString::fromLocal8Bit("%1 chmod a+x %2; %3; ")
.arg(remoteSudo(userName), commandFilePath, remoteSourceProfilesCommand()); .arg(remoteSudo(osVersion, userName), commandFilePath, remoteSourceProfilesCommand());
if (osVersion != MaemoDeviceConfig::Maemo5 && osVersion != MaemoDeviceConfig::Maemo6) if (osVersion != MaemoDeviceConfig::Maemo5 && osVersion != MaemoDeviceConfig::Maemo6)
prefix += QLatin1String("DISPLAY=:0.0 "); prefix += QLatin1String("DISPLAY=:0.0 ");
return prefix; return prefix;

View File

@@ -83,7 +83,8 @@ public:
static QString homeDirOnDevice(const QString &uname); static QString homeDirOnDevice(const QString &uname);
static QString devrootshPath(); static QString devrootshPath();
static QString remoteSudo(const QString &uname); static QString remoteSudo(MaemoDeviceConfig::OsVersion,
const QString &uname);
static QString remoteCommandPrefix(MaemoDeviceConfig::OsVersion osVersion, static QString remoteCommandPrefix(MaemoDeviceConfig::OsVersion osVersion,
const QString &userName, const QString &commandFilePath); const QString &userName, const QString &commandFilePath);
static QString remoteEnvironment(const QList<Utils::EnvironmentItem> &list); static QString remoteEnvironment(const QList<Utils::EnvironmentItem> &list);

View File

@@ -50,7 +50,8 @@ AbstractMaemoPackageInstaller::AbstractMaemoPackageInstaller(QObject *parent)
AbstractMaemoPackageInstaller::~AbstractMaemoPackageInstaller() {} AbstractMaemoPackageInstaller::~AbstractMaemoPackageInstaller() {}
void AbstractMaemoPackageInstaller::installPackage(const SshConnection::Ptr &connection, void AbstractMaemoPackageInstaller::installPackage(const SshConnection::Ptr &connection,
const QString &packageFilePath, bool removePackageFile) const MaemoDeviceConfig::ConstPtr &devConf, const QString &packageFilePath,
bool removePackageFile)
{ {
Q_ASSERT(connection && connection->state() == SshConnection::Connected); Q_ASSERT(connection && connection->state() == SshConnection::Connected);
Q_ASSERT(!m_isRunning); Q_ASSERT(!m_isRunning);
@@ -69,7 +70,8 @@ void AbstractMaemoPackageInstaller::installPackage(const SshConnection::Ptr &con
const QString space = QLatin1String(" "); const QString space = QLatin1String(" ");
QString cmdLine = QLatin1String("cd ") + workingDirectory() QString cmdLine = QLatin1String("cd ") + workingDirectory()
+ QLatin1String(" && ") + QLatin1String(" && ")
+ MaemoGlobal::remoteSudo(m_installer->connection()->connectionParameters().userName) + MaemoGlobal::remoteSudo(devConf->osVersion(),
m_installer->connection()->connectionParameters().userName)
+ space + installCommand() + space + installCommand()
+ space + installCommandArguments().join(space) + space + space + installCommandArguments().join(space) + space
+ packageFilePath; + packageFilePath;

View File

@@ -45,6 +45,7 @@ class SshRemoteProcessRunner;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
class MaemoDeviceConfig;
class AbstractMaemoPackageInstaller : public QObject class AbstractMaemoPackageInstaller : public QObject
{ {
@@ -53,6 +54,7 @@ public:
~AbstractMaemoPackageInstaller(); ~AbstractMaemoPackageInstaller();
void installPackage(const QSharedPointer<Utils::SshConnection> &connection, void installPackage(const QSharedPointer<Utils::SshConnection> &connection,
const QSharedPointer<const MaemoDeviceConfig> &devConfig,
const QString &packageFilePath, bool removePackageFile); const QString &packageFilePath, bool removePackageFile);
void cancelInstallation(); void cancelInstallation();

View File

@@ -51,11 +51,13 @@ MaemoRemoteCopyFacility::MaemoRemoteCopyFacility(QObject *parent) :
MaemoRemoteCopyFacility::~MaemoRemoteCopyFacility() {} MaemoRemoteCopyFacility::~MaemoRemoteCopyFacility() {}
void MaemoRemoteCopyFacility::copyFiles(const SshConnection::Ptr &connection, void MaemoRemoteCopyFacility::copyFiles(const SshConnection::Ptr &connection,
const MaemoDeviceConfig::ConstPtr &devConf,
const QList<MaemoDeployable> &deployables, const QString &mountPoint) const QList<MaemoDeployable> &deployables, const QString &mountPoint)
{ {
Q_ASSERT(connection->state() == SshConnection::Connected); Q_ASSERT(connection->state() == SshConnection::Connected);
Q_ASSERT(!m_isCopying); Q_ASSERT(!m_isCopying);
m_devConf = devConf;
m_deployables = deployables; m_deployables = deployables;
m_mountPoint = mountPoint; m_mountPoint = mountPoint;
@@ -137,7 +139,8 @@ void MaemoRemoteCopyFacility::copyNextFile()
#endif #endif
QString command = QString::fromLatin1("%1 mkdir -p %3 && %1 cp -r %2 %3") QString command = QString::fromLatin1("%1 mkdir -p %3 && %1 cp -r %2 %3")
.arg(MaemoGlobal::remoteSudo(m_copyRunner->connection()->connectionParameters().userName), .arg(MaemoGlobal::remoteSudo(m_devConf->osVersion(),
m_copyRunner->connection()->connectionParameters().userName),
sourceFilePath, d.remoteDir); sourceFilePath, d.remoteDir);
emit progress(tr("Copying file '%1' to directory '%2' on the device...") emit progress(tr("Copying file '%1' to directory '%2' on the device...")
.arg(d.localFilePath, d.remoteDir)); .arg(d.localFilePath, d.remoteDir));

View File

@@ -47,6 +47,7 @@ class SshRemoteProcessRunner;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
class MaemoDeviceConfig;
class MaemoRemoteCopyFacility : public QObject class MaemoRemoteCopyFacility : public QObject
{ {
@@ -56,6 +57,7 @@ public:
~MaemoRemoteCopyFacility(); ~MaemoRemoteCopyFacility();
void copyFiles(const QSharedPointer<Utils::SshConnection> &connection, void copyFiles(const QSharedPointer<Utils::SshConnection> &connection,
const QSharedPointer<const MaemoDeviceConfig> &devConf,
const QList<MaemoDeployable> &deployables, const QString &mountPoint); const QList<MaemoDeployable> &deployables, const QString &mountPoint);
void cancel(); void cancel();
@@ -77,6 +79,7 @@ private:
void setFinished(); void setFinished();
QSharedPointer<Utils::SshRemoteProcessRunner> m_copyRunner; QSharedPointer<Utils::SshRemoteProcessRunner> m_copyRunner;
QSharedPointer<const MaemoDeviceConfig> m_devConf;
QList<MaemoDeployable> m_deployables; QList<MaemoDeployable> m_deployables;
QString m_mountPoint; QString m_mountPoint;
bool m_isCopying; bool m_isCopying;

View File

@@ -63,10 +63,12 @@ MaemoRemoteMounter::~MaemoRemoteMounter()
killAllUtfsServers(); killAllUtfsServers();
} }
void MaemoRemoteMounter::setConnection(const SshConnection::Ptr &connection) void MaemoRemoteMounter::setConnection(const SshConnection::Ptr &connection,
const MaemoDeviceConfig::ConstPtr &devConf)
{ {
ASSERT_STATE(Inactive); ASSERT_STATE(Inactive);
m_connection = connection; m_connection = connection;
m_devConf = devConf;
} }
void MaemoRemoteMounter::setBuildConfiguration(const Qt4BuildConfiguration *bc) void MaemoRemoteMounter::setBuildConfiguration(const Qt4BuildConfiguration *bc)
@@ -121,10 +123,11 @@ void MaemoRemoteMounter::unmount()
} }
QString remoteCall; QString remoteCall;
const QString remoteSudo = MaemoGlobal::remoteSudo(m_devConf->osVersion(),
m_connection->connectionParameters().userName);
for (int i = 0; i < m_mountSpecs.count(); ++i) { for (int i = 0; i < m_mountSpecs.count(); ++i) {
remoteCall += QString::fromLocal8Bit("%1 umount %2 && %1 rmdir %2;") remoteCall += QString::fromLocal8Bit("%1 umount %2 && %1 rmdir %2;")
.arg(MaemoGlobal::remoteSudo(m_connection->connectionParameters().userName), .arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint);
m_mountSpecs.at(i).mountSpec.remoteMountPoint);
} }
m_umountStderr.clear(); m_umountStderr.clear();
@@ -183,8 +186,8 @@ void MaemoRemoteMounter::stop()
void MaemoRemoteMounter::startUtfsClients() void MaemoRemoteMounter::startUtfsClients()
{ {
const QString userName = m_connection->connectionParameters().userName; const QString userName = m_connection->connectionParameters().userName;
const QString chmodFuse = MaemoGlobal::remoteSudo(userName) const QString chmodFuse = MaemoGlobal::remoteSudo(m_devConf->osVersion(),
+ QLatin1String(" chmod a+r+w /dev/fuse"); userName) + QLatin1String(" chmod a+r+w /dev/fuse");
const QString chmodUtfsClient const QString chmodUtfsClient
= QLatin1String("chmod a+x ") + utfsClientOnDevice(); = QLatin1String("chmod a+x ") + utfsClientOnDevice();
const QLatin1String andOp(" && "); const QLatin1String andOp(" && ");
@@ -199,17 +202,21 @@ void MaemoRemoteMounter::startUtfsClients()
return; return;
} }
const QString remoteSudo
= MaemoGlobal::remoteSudo(m_devConf->osVersion(), userName);
const MaemoMountSpecification &mountSpec = mountInfo.mountSpec; const MaemoMountSpecification &mountSpec = mountInfo.mountSpec;
const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2") const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2")
.arg(MaemoGlobal::remoteSudo(userName), mountSpec.remoteMountPoint); .arg(remoteSudo, mountSpec.remoteMountPoint);
const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2") const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2")
.arg(MaemoGlobal::remoteSudo(userName), mountSpec.remoteMountPoint); .arg(remoteSudo, mountSpec.remoteMountPoint);
QString utfsClient QString utfsClient
= QString::fromLocal8Bit("%1 -l %2 -r %2 -b %2 %4 -o nonempty") = QString::fromLocal8Bit("%1 -l %2 -r %2 -b %2 %4 -o nonempty")
.arg(utfsClientOnDevice()).arg(mountInfo.remotePort) .arg(utfsClientOnDevice()).arg(mountInfo.remotePort)
.arg(mountSpec.remoteMountPoint); .arg(mountSpec.remoteMountPoint);
if (mountInfo.mountAsRoot) if (mountInfo.mountAsRoot) {
utfsClient.prepend(MaemoGlobal::remoteSudo(userName) + QLatin1Char(' ')); utfsClient.prepend(MaemoGlobal::remoteSudo(m_devConf->osVersion(),
userName) + QLatin1Char(' '));
}
QLatin1String seqOp("; "); QLatin1String seqOp("; ");
remoteCall += seqOp + MaemoGlobal::remoteSourceProfilesCommand() remoteCall += seqOp + MaemoGlobal::remoteSourceProfilesCommand()
+ seqOp + mkdir + andOp + chmod + andOp + utfsClient; + seqOp + mkdir + andOp + chmod + andOp + utfsClient;

View File

@@ -53,6 +53,7 @@ class SshRemoteProcess;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
class Qt4BuildConfiguration; class Qt4BuildConfiguration;
namespace Internal { namespace Internal {
class MaemoDeviceConfig;
class MaemoUsedPortsGatherer; class MaemoUsedPortsGatherer;
class MaemoRemoteMounter : public QObject class MaemoRemoteMounter : public QObject
@@ -63,7 +64,8 @@ public:
~MaemoRemoteMounter(); ~MaemoRemoteMounter();
// Must already be connected. // Must already be connected.
void setConnection(const QSharedPointer<Utils::SshConnection> &connection); void setConnection(const QSharedPointer<Utils::SshConnection> &connection,
const QSharedPointer<const MaemoDeviceConfig> &devConf);
void setBuildConfiguration(const Qt4BuildConfiguration *bc); void setBuildConfiguration(const Qt4BuildConfiguration *bc);
void addMountSpecification(const MaemoMountSpecification &mountSpec, void addMountSpecification(const MaemoMountSpecification &mountSpec,
@@ -120,6 +122,7 @@ private:
}; };
QSharedPointer<Utils::SshConnection> m_connection; QSharedPointer<Utils::SshConnection> m_connection;
QSharedPointer<const MaemoDeviceConfig> m_devConf;
QList<MountInfo> m_mountSpecs; QList<MountInfo> m_mountSpecs;
QSharedPointer<Utils::SshRemoteProcess> m_mountProcess; QSharedPointer<Utils::SshRemoteProcess> m_mountProcess;
QSharedPointer<Utils::SshRemoteProcess> m_unmountProcess; QSharedPointer<Utils::SshRemoteProcess> m_unmountProcess;

View File

@@ -208,7 +208,7 @@ void MaemoSshRunner::handleCleanupFinished(int exitStatus)
emitError(tr("Initial cleanup failed: %1") emitError(tr("Initial cleanup failed: %1")
.arg(m_cleaner->errorString())); .arg(m_cleaner->errorString()));
} else { } else {
m_mounter->setConnection(m_connection); m_mounter->setConnection(m_connection, m_devConfig);
unmount(); unmount();
} }
} }
@@ -228,7 +228,7 @@ void MaemoSshRunner::handleUnmounted()
} }
case PreMountUnmounting: case PreMountUnmounting:
setState(GatheringPorts); setState(GatheringPorts);
m_portsGatherer->start(m_connection, m_freePorts); m_portsGatherer->start(m_connection, m_devConfig);
break; break;
case PostRunCleaning: case PostRunCleaning:
case StopRequested: { case StopRequested: {
@@ -307,7 +307,7 @@ bool MaemoSshRunner::isConnectionUsable() const
void MaemoSshRunner::setState(State newState) void MaemoSshRunner::setState(State newState)
{ {
if (newState == Inactive) { if (newState == Inactive) {
m_mounter->setConnection(SshConnection::Ptr()); m_mounter->setConnection(SshConnection::Ptr(), m_devConfig);
m_portsGatherer->stop(); m_portsGatherer->stop();
if (m_connection) { if (m_connection) {
disconnect(m_connection.data(), 0, this, 0); disconnect(m_connection.data(), 0, this, 0);

View File

@@ -155,7 +155,8 @@ void AbstractMaemoUploadAndInstallStep::handleUploadFinished(const QString &erro
+ QFileInfo(packagingStep()->packageFilePath()).fileName(); + QFileInfo(packagingStep()->packageFilePath()).fileName();
m_extendedState = Installing; m_extendedState = Installing;
writeOutput(tr("Installing package to device...")); writeOutput(tr("Installing package to device..."));
m_installer->installPackage(connection(), remoteFilePath, true); m_installer->installPackage(connection(), helper().cachedDeviceConfig(),
remoteFilePath, true);
} }
} }

View File

@@ -48,7 +48,7 @@ MaemoUsedPortsGatherer::MaemoUsedPortsGatherer(QObject *parent) :
MaemoUsedPortsGatherer::~MaemoUsedPortsGatherer() {} MaemoUsedPortsGatherer::~MaemoUsedPortsGatherer() {}
void MaemoUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connection, void MaemoUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connection,
const MaemoPortList &portList) const MaemoDeviceConfig::ConstPtr &devConf)
{ {
if (m_running) if (m_running)
qWarning("Unexpected call of %s in running state", Q_FUNC_INFO); qWarning("Unexpected call of %s in running state", Q_FUNC_INFO);
@@ -64,8 +64,9 @@ void MaemoUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connection,
SLOT(handleRemoteStdOut(QByteArray))); SLOT(handleRemoteStdOut(QByteArray)));
connect(m_procRunner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)), connect(m_procRunner.data(), SIGNAL(processErrorOutputAvailable(QByteArray)),
SLOT(handleRemoteStdErr(QByteArray))); SLOT(handleRemoteStdErr(QByteArray)));
const QString command = MaemoGlobal::remoteSudo(m_procRunner->connection()->connectionParameters().userName) const QString command = MaemoGlobal::remoteSudo(devConf->osVersion(),
+ QLatin1String(" lsof -nPi4tcp:") + portList.toString() m_procRunner->connection()->connectionParameters().userName)
+ QLatin1String(" lsof -nPi4tcp:") + devConf->freePorts().toString()
+ QLatin1String(" -F n |grep '^n' |sed -r 's/[^:]*:([[:digit:]]+).*/\\1/g' |sort -n |uniq"); + QLatin1String(" -F n |grep '^n' |sed -r 's/[^:]*:([[:digit:]]+).*/\\1/g' |sort -n |uniq");
m_procRunner->run(command.toUtf8()); m_procRunner->run(command.toUtf8());
m_running = true; m_running = true;

View File

@@ -46,6 +46,7 @@ class SshRemoteProcessRunner;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
class MaemoDeviceConfig;
class MaemoUsedPortsGatherer : public QObject class MaemoUsedPortsGatherer : public QObject
{ {
@@ -54,7 +55,7 @@ public:
explicit MaemoUsedPortsGatherer(QObject *parent = 0); explicit MaemoUsedPortsGatherer(QObject *parent = 0);
~MaemoUsedPortsGatherer(); ~MaemoUsedPortsGatherer();
void start(const QSharedPointer<Utils::SshConnection> &connection, void start(const QSharedPointer<Utils::SshConnection> &connection,
const MaemoPortList &portList); const QSharedPointer<const MaemoDeviceConfig> &devConf);
void stop(); void stop();
int getNextFreePort(MaemoPortList *freePorts) const; // returns -1 if no more are left int getNextFreePort(MaemoPortList *freePorts) const; // returns -1 if no more are left
QList<int> usedPorts() const { return m_usedPorts; } QList<int> usedPorts() const { return m_usedPorts; }