Commit 44a953e8 authored by ck's avatar ck
Browse files

Maemo: Deploy and install packages instead of raw executables.

Reviewed-by: kh1
parent 588884be
......@@ -134,7 +134,7 @@ bool MaemoPackageCreationStep::createPackage()
if (!QFileInfo(projectDir + QLatin1String("/debian")).exists()) {
const QString command = QLatin1String("dh_make -s -n -p ")
% executableFileName() % versionString();
% executableFileName().toLower() % versionString();
if (!runCommand(buildProc, command))
return false;
QFile rulesFile(projectDir + QLatin1String("/debian/rules"));
......@@ -157,8 +157,7 @@ bool MaemoPackageCreationStep::createPackage()
return false;
const QString targetFile(projectDir % QLatin1String("/debian/")
% executableFileName().toLower() % QLatin1String("/usr/bin/")
% executableFileName());
% executableFileName().toLower() % executableFilePathOnTarget());
if (QFile::exists(targetFile)) {
if (!QFile::remove(targetFile)) {
qDebug("Error: Could not remove '%s'", qPrintable(targetFile));
......@@ -245,27 +244,30 @@ QString MaemoPackageCreationStep::targetRoot() const
bool MaemoPackageCreationStep::packagingNeeded() const
{
#if 1
// TODO: When the package contents get user-modifiable, we need
// to check whether files have been added and/or removed and whether
// the newest one is newer than the package.
// For the first check, we should have a switch that the widget sets
// to true when the user has changed the package contents and which
// we set to false after a successful package creation.
QFileInfo packageInfo(packageFilePath(executable()));
QFileInfo packageInfo(packageFilePath());
return !packageInfo.exists()
|| packageInfo.lastModified() <= QFileInfo(executable()).lastModified();
#else
return false;
#endif
}
QString MaemoPackageCreationStep::packageFilePath(const QString &executableFilePath)
QString MaemoPackageCreationStep::packageFilePath() const
{
QFileInfo execInfo(executable());
return execInfo.path() % QDir::separator() % execInfo.fileName().toLower()
% versionString() % QLatin1String("_armel.deb");
}
QString MaemoPackageCreationStep::executableFilePathOnTarget() const
{
return executableFilePath % versionString() % QLatin1String("_armel.deb");
return QLatin1String("/usr/bin/") % executableFileName();
}
QString MaemoPackageCreationStep::versionString()
QString MaemoPackageCreationStep::versionString() const
{
return QLatin1String("_0.1");
}
......
......@@ -56,11 +56,13 @@ class Qt4BuildConfiguration;
class MaemoPackageCreationStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
friend class MaemoPackageCreationFactory;
public:
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig);
static QString packageFilePath(const QString &executableFilePath);
QString packageFilePath() const;
QString executableFilePathOnTarget() const;
private:
MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
MaemoPackageCreationStep *other);
......@@ -80,7 +82,7 @@ private:
QString targetRoot() const;
bool packagingNeeded() const;
static QString versionString();
QString versionString() const;
static const QLatin1String CreatePackageId;
};
......
......@@ -30,6 +30,7 @@
#include "maemoconstants.h"
#include "maemomanager.h"
#include "maemopackagecreationstep.h"
#include "maemorunconfigurationwidget.h"
#include "maemotoolchain.h"
......@@ -39,6 +40,7 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt4project.h>
#include <utils/qtcassert.h>
......@@ -211,7 +213,8 @@ void MaemoRunConfiguration::getDeployTimesFromMap(const QString &key,
bool MaemoRunConfiguration::currentlyNeedsDeployment(const QString &host) const
{
return fileNeedsDeployment(executable(), m_lastDeployed.value(host));
return fileNeedsDeployment(packageStep()->packageFilePath(),
m_lastDeployed.value(host));
}
void MaemoRunConfiguration::wasDeployed(const QString &host)
......@@ -293,6 +296,20 @@ const QString MaemoRunConfiguration::gdbCmd() const
return QString();
}
const MaemoPackageCreationStep *MaemoRunConfiguration::packageStep() const
{
const QList<ProjectExplorer::BuildStep *> &buildSteps
= activeQt4BuildConfiguration()->steps(ProjectExplorer::Build);
for (int i = buildSteps.count() - 1; i >= 0; --i) {
const MaemoPackageCreationStep * const pStep
= qobject_cast<MaemoPackageCreationStep *>(buildSteps.at(i));
if (pStep)
return pStep;
}
Q_ASSERT(!"Impossible: Maemo run configuration without packaging step.");
return 0;
}
QString MaemoRunConfiguration::maddeRoot() const
{
if (const MaemoToolChain *tc = toolchain())
......
......@@ -52,6 +52,7 @@ class Qt4BuildConfiguration;
class Qt4ProFileNode;
class Qt4Target;
class MaemoPackageCreationStep;
class MaemoRunConfigurationFactory;
class MaemoRunConfiguration : public ProjectExplorer::RunConfiguration
......@@ -75,6 +76,8 @@ public:
bool debuggingHelpersNeedDeployment(const QString &host) const;
void debuggingHelpersDeployed(const QString &host);
const MaemoPackageCreationStep *packageStep() const;
QString maddeRoot() const;
QString executable() const;
const QString sysRoot() const;
......
......@@ -33,6 +33,8 @@
****************************************************************************/
#include "maemoruncontrol.h"
#include "maemopackagecreationstep.h"
#include "maemosshthread.h"
#include "maemorunconfiguration.h"
......@@ -122,7 +124,7 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
} else {
m_deployables.clear();
if (m_runConfig->currentlyNeedsDeployment(m_devConfig.host)) {
m_deployables.append(Deployable(executableFileName(),
m_deployables.append(Deployable(packageFileName(),
QFileInfo(executableOnHost()).canonicalPath(),
&MaemoRunConfiguration::wasDeployed));
}
......@@ -181,6 +183,21 @@ bool AbstractMaemoRunControl::isDeploying() const
return m_sshDeployer && m_sshDeployer->isRunning();
}
QString AbstractMaemoRunControl::packageFileName() const
{
return QFileInfo(packageFilePath()).fileName();
}
QString AbstractMaemoRunControl::packageFilePath() const
{
return m_runConfig->packageStep()->packageFilePath();
}
QString AbstractMaemoRunControl::executableFilePathOnTarget() const
{
return m_runConfig->packageStep()->executableFilePathOnTarget();
}
bool AbstractMaemoRunControl::isCleaning() const
{
return m_initialCleaner && m_initialCleaner->isRunning();
......@@ -277,13 +294,6 @@ const QString AbstractMaemoRunControl::executableOnHost() const
return m_runConfig->executable();
}
const QString AbstractMaemoRunControl::sshPort() const
{
return m_devConfig.type == MaemoDeviceConfig::Physical
? QString::number(m_devConfig.sshPort)
: m_runConfig->simulatorSshPort();
}
const QString AbstractMaemoRunControl::executableFileName() const
{
return QFileInfo(executableOnHost()).fileName();
......@@ -294,34 +304,27 @@ const QString AbstractMaemoRunControl::remoteDir() const
return homeDirOnDevice(m_devConfig.uname);
}
const QStringList AbstractMaemoRunControl::options() const
QString AbstractMaemoRunControl::remoteSudo() const
{
const bool usePassword
= m_devConfig.authentication == MaemoDeviceConfig::Password;
const QLatin1String opt("-o");
QStringList optionList;
if (!usePassword)
optionList << QLatin1String("-i") << m_devConfig.keyFile;
return optionList << opt
<< QString::fromLatin1("PasswordAuthentication=%1").
arg(usePassword ? "yes" : "no") << opt
<< QString::fromLatin1("PubkeyAuthentication=%1").
arg(usePassword ? "no" : "yes") << opt
<< QString::fromLatin1("ConnectTimeout=%1").arg(m_devConfig.timeout)
<< opt << QLatin1String("CheckHostIP=no")
<< opt << QLatin1String("StrictHostKeyChecking=no");
return QLatin1String("/usr/lib/mad-developer/devrootsh");
}
const QString AbstractMaemoRunControl::executableOnTarget() const
QString AbstractMaemoRunControl::remoteInstallCommand() const
{
return QString::fromLocal8Bit("%1/%2").arg(remoteDir()).
arg(executableFileName());
return QString::fromLocal8Bit("%1 dpkg -i %2").arg(remoteSudo())
.arg(packageFileName());
}
const QString AbstractMaemoRunControl::targetCmdLinePrefix() const
{
return QString::fromLocal8Bit("chmod u+x %1; source /etc/profile; ").
arg(executableOnTarget());
return QString::fromLocal8Bit("%1 && %2 chmod u+x %3 && source /etc/profile && ")
.arg(remoteInstallCommand()).arg(remoteSudo())
.arg(executableFilePathOnTarget());
}
QString AbstractMaemoRunControl::targetCmdLineSuffix() const
{
return m_runConfig->arguments().join(" ");
}
void AbstractMaemoRunControl::handleError(const QString &errString)
......@@ -348,9 +351,8 @@ void MaemoRunControl::startInternal()
QString MaemoRunControl::remoteCall() const
{
return QString::fromLocal8Bit("%1 %2 %3")
.arg(targetCmdLinePrefix()).arg(executableOnTarget())
.arg(m_runConfig->arguments().join(" "));
return QString::fromLocal8Bit("%1 %2 %3").arg(targetCmdLinePrefix())
.arg(executableFilePathOnTarget()).arg(targetCmdLineSuffix());
}
void MaemoRunControl::stopInternal()
......@@ -407,7 +409,7 @@ QString MaemoDebugRunControl::remoteCall() const
{
return QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4")
.arg(targetCmdLinePrefix()).arg(gdbServerPort())
.arg(executableOnTarget()).arg(m_runConfig->arguments().join(" "));
.arg(executableFilePathOnTarget()).arg(targetCmdLineSuffix());
}
void MaemoDebugRunControl::handleRemoteOutput(const QString &output)
......
......@@ -77,12 +77,14 @@ protected:
void startExecution();
void handleError(const QString &errString);
const QString executableOnHost() const;
const QString executableOnTarget() const;
const QString executableFileName() const;
const QString sshPort() const;
const QString targetCmdLinePrefix() const;
QString targetCmdLineSuffix() const;
const QString remoteDir() const;
const QStringList options() const;
QString packageFileName() const;
QString packageFilePath() const;
QString executableFilePathOnTarget() const;
private slots:
virtual void handleRemoteOutput(const QString &output)=0;
void handleInitialCleanupFinished();
......@@ -98,10 +100,13 @@ private:
virtual void startInternal()=0;
virtual void stopInternal()=0;
virtual QString remoteCall() const=0;
void startInitialCleanup();
void killRemoteProcesses(const QStringList &apps, bool initialCleanup);
bool isCleaning() const;
bool isDeploying() const;
QString remoteSudo() const;
QString remoteInstallCommand() const;
QFutureInterface<void> m_progress;
QScopedPointer<MaemoSshDeployer> m_sshDeployer;
......
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