Maemo: Refactor upload + install deployment step.

This commit is contained in:
Christian Kandeler
2011-04-07 11:44:11 +02:00
parent 482bf10c09
commit f653fedaaf
8 changed files with 208 additions and 60 deletions

View File

@@ -177,11 +177,6 @@ void AbstractMaemoDeployStep::getDeployTimesFromMap(const QVariantMap &map)
}
}
const AbstractMaemoPackageCreationStep *AbstractMaemoDeployStep::packagingStep() const
{
return MaemoGlobal::earlierBuildStep<AbstractMaemoPackageCreationStep>(maemoDeployConfig(), this);
}
void AbstractMaemoDeployStep::raiseError(const QString &errorString)
{
emit addTask(Task(Task::Error, errorString, QString(), -1,

View File

@@ -92,7 +92,9 @@ protected:
void writeOutput(const QString &text, OutputFormat format = MessageOutput,
OutputNewlineSetting newlineSetting = DoAppendNewline);
void setDeploymentFinished();
const AbstractMaemoPackageCreationStep *packagingStep() const;
virtual const AbstractMaemoPackageCreationStep *packagingStep() const=0;
QString deployMountPoint() const;
const Qt4BuildConfiguration *qt4BuildConfiguration() const;
QSharedPointer<Utils::SshConnection> connection() const { return m_connection; }

View File

@@ -225,10 +225,15 @@ void MaemoMountAndInstallDeployStep::ctor()
SLOT(handleInstallationFinished(QString)));
}
const AbstractMaemoPackageCreationStep *MaemoMountAndInstallDeployStep::packagingStep() const
{
return MaemoGlobal::earlierBuildStep<MaemoDebianPackageCreationStep>(maemoDeployConfig(), this);
}
bool MaemoMountAndInstallDeployStep::isDeploymentPossibleInternal(QString &whyNot) const
{
if (!packagingStep()) {
whyNot = tr("No packaging step found.");
whyNot = tr("No matching packaging step found.");
return false;
}
return true;

View File

@@ -97,6 +97,7 @@ public:
static const QString Id;
static const QString DisplayName;
private:
virtual const AbstractMaemoPackageCreationStep *packagingStep() const;
virtual bool isDeploymentPossibleInternal(QString &whynot) const;
virtual bool isDeploymentNeeded(const QString &hostName) const;
@@ -122,6 +123,7 @@ public:
static const QString Id;
static const QString DisplayName;
private:
virtual const AbstractMaemoPackageCreationStep *packagingStep() const { return 0; }
virtual bool isDeploymentPossibleInternal(QString &whynot) const;
virtual bool isDeploymentNeeded(const QString &hostName) const;

View File

@@ -67,14 +67,16 @@ QStringList MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent)
return QStringList();
QStringList ids;
if (qobject_cast<Qt4BaseTarget *>(parent->target()))
ids << MaemoUploadAndInstallDeployStep::Id;
if (qobject_cast<AbstractQt4MaemoTarget *>(parent->target()))
ids << MaemoCopyToSysrootStep::Id;
if (qobject_cast<AbstractDebBasedQt4MaemoTarget *>(parent->target()))
if (qobject_cast<AbstractDebBasedQt4MaemoTarget *>(parent->target())) {
ids << MaemoInstallDebianPackageToSysrootStep::Id;
else if (qobject_cast<AbstractRpmBasedQt4MaemoTarget *>(parent->target()))
ids << MaemoUploadAndInstallDpkgPackageStep::Id;
}
else if (qobject_cast<AbstractRpmBasedQt4MaemoTarget *>(parent->target())) {
ids << MaemoInstallRpmPackageToSysrootStep::Id;
ids << MaemoUploadAndInstallRpmPackageStep::Id;
}
if (qobject_cast<Qt4Maemo5Target *>(parent->target())) {
ids << MaemoMountAndInstallDeployStep::Id
<< MaemoMountAndCopyDeployStep::Id;
@@ -89,8 +91,12 @@ QString MaemoDeployStepFactory::displayNameForId(const QString &id) const
return MaemoMountAndInstallDeployStep::DisplayName;
else if (id == MaemoMountAndCopyDeployStep::Id)
return MaemoMountAndCopyDeployStep::DisplayName;
else if (id == MaemoUploadAndInstallDeployStep::Id)
return MaemoUploadAndInstallDeployStep::DisplayName;
else if (id == MaemoUploadAndInstallDpkgPackageStep::Id)
return MaemoUploadAndInstallDpkgPackageStep::DisplayName;
else if (id == MaemoUploadAndInstallRpmPackageStep::Id)
return MaemoUploadAndInstallRpmPackageStep::DisplayName;
else if (id == MaemoUploadAndInstallTarPackageStep::Id)
return MaemoUploadAndInstallTarPackageStep::DisplayName;
else if (id == MaemoInstallDebianPackageToSysrootStep::Id)
return MaemoInstallDebianPackageToSysrootStep::DisplayName;
else if (id == MaemoInstallRpmPackageToSysrootStep::Id)
@@ -120,11 +126,16 @@ BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const QString &
return new MaemoMountAndInstallDeployStep(parent);
} else if (id == MaemoMountAndCopyDeployStep::Id) {
return new MaemoMountAndCopyDeployStep(parent);
} else if (id == MaemoUploadAndInstallDeployStep::Id
|| (id == OldMaemoDeployStepId && (qobject_cast<const Qt4HarmattanTarget *>(t)
|| qobject_cast<const Qt4MeegoTarget *>(t)))) {
return new MaemoUploadAndInstallDeployStep(parent);
} else if (id == MaemoUploadAndInstallDpkgPackageStep::Id
|| (id == OldMaemoDeployStepId && (qobject_cast<const Qt4HarmattanTarget *>(t)))) {
return new MaemoUploadAndInstallDpkgPackageStep(parent);
} else if (id == MaemoUploadAndInstallRpmPackageStep::Id
|| (id == OldMaemoDeployStepId && (qobject_cast<const Qt4MeegoTarget *>(t)))) {
return new MaemoUploadAndInstallRpmPackageStep(parent);
} else if (id == MaemoUploadAndInstallTarPackageStep::Id) {
return new MaemoUploadAndInstallTarPackageStep(parent);
}
return 0;
}
@@ -159,9 +170,15 @@ BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *produ
} else if (product->id() == MaemoMountAndCopyDeployStep::Id) {
return new MaemoMountAndCopyDeployStep(parent,
qobject_cast<MaemoMountAndCopyDeployStep *>(product));
} else if (product->id() == MaemoUploadAndInstallDeployStep::Id) {
return new MaemoUploadAndInstallDeployStep(parent,
qobject_cast<MaemoUploadAndInstallDeployStep*>(product));
} else if (product->id() == MaemoUploadAndInstallDpkgPackageStep::Id) {
return new MaemoUploadAndInstallDpkgPackageStep(parent,
qobject_cast<MaemoUploadAndInstallDpkgPackageStep*>(product));
} else if (product->id() == MaemoUploadAndInstallRpmPackageStep::Id) {
return new MaemoUploadAndInstallRpmPackageStep(parent,
qobject_cast<MaemoUploadAndInstallRpmPackageStep*>(product));
} else if (product->id() == MaemoUploadAndInstallTarPackageStep::Id) {
return new MaemoUploadAndInstallTarPackageStep(parent,
qobject_cast<MaemoUploadAndInstallTarPackageStep*>(product));
} else if (product->id() == MaemoInstallDebianPackageToSysrootStep::Id) {
return new MaemoInstallDebianPackageToSysrootStep(parent,
qobject_cast<MaemoInstallDebianPackageToSysrootStep *>(product));

View File

@@ -37,6 +37,7 @@
#include "maemopackagecreationstep.h"
#include "maemopackageinstaller.h"
#include "maemopackageuploader.h"
#include "qt4maemodeployconfiguration.h"
#include "qt4maemotarget.h"
#include <qt4projectmanager/qt4buildconfiguration.h>
@@ -52,23 +53,22 @@ using namespace Utils;
namespace Qt4ProjectManager {
namespace Internal {
MaemoUploadAndInstallDeployStep::MaemoUploadAndInstallDeployStep(BuildStepList *parent)
: AbstractMaemoDeployStep(parent, Id)
AbstractMaemoUploadAndInstallStep::AbstractMaemoUploadAndInstallStep(BuildStepList *parent, const QString &id)
: AbstractMaemoDeployStep(parent, id)
{
ctor();
}
MaemoUploadAndInstallDeployStep::MaemoUploadAndInstallDeployStep(BuildStepList *parent,
MaemoUploadAndInstallDeployStep *other)
AbstractMaemoUploadAndInstallStep::AbstractMaemoUploadAndInstallStep(BuildStepList *parent,
AbstractMaemoUploadAndInstallStep *other)
: AbstractMaemoDeployStep(parent, other)
{
ctor();
}
void MaemoUploadAndInstallDeployStep::ctor()
void AbstractMaemoUploadAndInstallStep::finishInitialization(const QString &displayName,
AbstractMaemoPackageInstaller *installer)
{
setDefaultDisplayName(DisplayName);
setDefaultDisplayName(displayName);
m_installer = installer;
m_extendedState = Inactive;
m_uploader = new MaemoPackageUploader(this);
@@ -76,13 +76,6 @@ void MaemoUploadAndInstallDeployStep::ctor()
SLOT(handleProgressReport(QString)));
connect(m_uploader, SIGNAL(uploadFinished(QString)),
SLOT(handleUploadFinished(QString)));
if (qobject_cast<AbstractDebBasedQt4MaemoTarget *>(target()))
m_installer = new MaemoDebianPackageInstaller(this);
else if (qobject_cast<AbstractRpmBasedQt4MaemoTarget *>(target()))
m_installer = new MaemoRpmPackageInstaller(this);
else
m_installer = new MaemoTarPackageInstaller(this);
connect(m_installer, SIGNAL(stdoutData(QString)),
SLOT(handleRemoteStdout(QString)));
connect(m_installer, SIGNAL(stderrData(QString)),
@@ -91,16 +84,16 @@ void MaemoUploadAndInstallDeployStep::ctor()
SLOT(handleInstallationFinished(QString)));
}
bool MaemoUploadAndInstallDeployStep::isDeploymentPossibleInternal(QString &whyNot) const
bool AbstractMaemoUploadAndInstallStep::isDeploymentPossibleInternal(QString &whyNot) const
{
if (!packagingStep()) {
whyNot = tr("No packaging step found.");
whyNot = tr("No matching packaging step found.");
return false;
}
return true;
}
bool MaemoUploadAndInstallDeployStep::isDeploymentNeeded(const QString &hostName) const
bool AbstractMaemoUploadAndInstallStep::isDeploymentNeeded(const QString &hostName) const
{
const AbstractMaemoPackageCreationStep * const pStep = packagingStep();
Q_ASSERT(pStep);
@@ -108,14 +101,14 @@ bool MaemoUploadAndInstallDeployStep::isDeploymentNeeded(const QString &hostName
return currentlyNeedsDeployment(hostName, d);
}
void MaemoUploadAndInstallDeployStep::startInternal()
void AbstractMaemoUploadAndInstallStep::startInternal()
{
Q_ASSERT(m_extendedState == Inactive);
upload();
}
void MaemoUploadAndInstallDeployStep::stopInternal()
void AbstractMaemoUploadAndInstallStep::stopInternal()
{
ASSERT_BASE_STATE(StopRequested);
ASSERT_STATE(QList<ExtendedState>() << Uploading << Installing);
@@ -136,7 +129,7 @@ void MaemoUploadAndInstallDeployStep::stopInternal()
setFinished();
}
void MaemoUploadAndInstallDeployStep::upload()
void AbstractMaemoUploadAndInstallStep::upload()
{
m_extendedState = Uploading;
const QString localFilePath = packagingStep()->packageFilePath();
@@ -145,7 +138,7 @@ void MaemoUploadAndInstallDeployStep::upload()
m_uploader->uploadPackage(connection(), localFilePath, remoteFilePath);
}
void MaemoUploadAndInstallDeployStep::handleUploadFinished(const QString &errorMsg)
void AbstractMaemoUploadAndInstallStep::handleUploadFinished(const QString &errorMsg)
{
ASSERT_BASE_STATE(QList<BaseState>() << Deploying << StopRequested);
ASSERT_STATE(QList<ExtendedState>() << Uploading << Inactive);
@@ -166,7 +159,7 @@ void MaemoUploadAndInstallDeployStep::handleUploadFinished(const QString &errorM
}
}
void MaemoUploadAndInstallDeployStep::handleInstallationFinished(const QString &errorMsg)
void AbstractMaemoUploadAndInstallStep::handleInstallationFinished(const QString &errorMsg)
{
ASSERT_BASE_STATE(QList<BaseState>() << Deploying << StopRequested);
ASSERT_STATE(QList<ExtendedState>() << Installing << Inactive);
@@ -184,20 +177,102 @@ void MaemoUploadAndInstallDeployStep::handleInstallationFinished(const QString &
setFinished();
}
void MaemoUploadAndInstallDeployStep::setFinished()
void AbstractMaemoUploadAndInstallStep::setFinished()
{
m_extendedState = Inactive;
setDeploymentFinished();
}
QString MaemoUploadAndInstallDeployStep::uploadDir() const
QString AbstractMaemoUploadAndInstallStep::uploadDir() const
{
return MaemoGlobal::homeDirOnDevice(connection()->connectionParameters().userName);
}
const QString MaemoUploadAndInstallDeployStep::Id("MaemoUploadAndInstallDeployStep");
const QString MaemoUploadAndInstallDeployStep::DisplayName
= tr("Deploy package via SFTP upload");
MaemoUploadAndInstallDpkgPackageStep::MaemoUploadAndInstallDpkgPackageStep(ProjectExplorer::BuildStepList *bc)
: AbstractMaemoUploadAndInstallStep(bc, Id)
{
ctor();
}
MaemoUploadAndInstallDpkgPackageStep::MaemoUploadAndInstallDpkgPackageStep(ProjectExplorer::BuildStepList *bc,
MaemoUploadAndInstallDpkgPackageStep *other)
: AbstractMaemoUploadAndInstallStep(bc, other)
{
ctor();
}
void MaemoUploadAndInstallDpkgPackageStep::ctor()
{
finishInitialization(DisplayName, new MaemoDebianPackageInstaller(this));
}
const AbstractMaemoPackageCreationStep *MaemoUploadAndInstallDpkgPackageStep::packagingStep() const
{
return MaemoGlobal::earlierBuildStep<MaemoDebianPackageCreationStep>(maemoDeployConfig(), this);
}
const QString MaemoUploadAndInstallDpkgPackageStep::Id("MaemoUploadAndInstallDpkgPackageStep");
const QString MaemoUploadAndInstallDpkgPackageStep::DisplayName
= tr("Deploy Debian package via SFTP upload");
MaemoUploadAndInstallRpmPackageStep::MaemoUploadAndInstallRpmPackageStep(ProjectExplorer::BuildStepList *bc)
: AbstractMaemoUploadAndInstallStep(bc, Id)
{
ctor();
}
MaemoUploadAndInstallRpmPackageStep::MaemoUploadAndInstallRpmPackageStep(ProjectExplorer::BuildStepList *bc,
MaemoUploadAndInstallRpmPackageStep *other)
: AbstractMaemoUploadAndInstallStep(bc, other)
{
ctor();
}
void MaemoUploadAndInstallRpmPackageStep::ctor()
{
finishInitialization(DisplayName, new MaemoRpmPackageInstaller(this));
}
const AbstractMaemoPackageCreationStep *MaemoUploadAndInstallRpmPackageStep::packagingStep() const
{
return MaemoGlobal::earlierBuildStep<MaemoRpmPackageCreationStep>(maemoDeployConfig(), this);
}
const QString MaemoUploadAndInstallRpmPackageStep::Id("MaemoUploadAndInstallRpmPackageStep");
const QString MaemoUploadAndInstallRpmPackageStep::DisplayName
= tr("Deploy RPM package via SFTP upload");
MaemoUploadAndInstallTarPackageStep::MaemoUploadAndInstallTarPackageStep(ProjectExplorer::BuildStepList *bc)
: AbstractMaemoUploadAndInstallStep(bc, Id)
{
ctor();
}
MaemoUploadAndInstallTarPackageStep::MaemoUploadAndInstallTarPackageStep(ProjectExplorer::BuildStepList *bc,
MaemoUploadAndInstallTarPackageStep *other)
: AbstractMaemoUploadAndInstallStep(bc, other)
{
ctor();
}
const AbstractMaemoPackageCreationStep *MaemoUploadAndInstallTarPackageStep::packagingStep() const
{
return MaemoGlobal::earlierBuildStep<MaemoTarPackageCreationStep>(maemoDeployConfig(), this);
}
void MaemoUploadAndInstallTarPackageStep::ctor()
{
finishInitialization(DisplayName, new MaemoTarPackageInstaller(this));
}
const QString MaemoUploadAndInstallTarPackageStep::Id("MaemoUploadAndInstallTarPackageStep");
const QString MaemoUploadAndInstallTarPackageStep::DisplayName
= tr("Deploy tar package via SFTP upload");
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -41,16 +41,17 @@ namespace Internal {
class AbstractMaemoPackageInstaller;
class MaemoPackageUploader;
class MaemoUploadAndInstallDeployStep : public AbstractMaemoDeployStep
class AbstractMaemoUploadAndInstallStep : public AbstractMaemoDeployStep
{
Q_OBJECT
public:
MaemoUploadAndInstallDeployStep(ProjectExplorer::BuildStepList *bc);
MaemoUploadAndInstallDeployStep(ProjectExplorer::BuildStepList *bc,
MaemoUploadAndInstallDeployStep *other);
protected:
AbstractMaemoUploadAndInstallStep(ProjectExplorer::BuildStepList *bc,
const QString &id);
AbstractMaemoUploadAndInstallStep(ProjectExplorer::BuildStepList *bc,
AbstractMaemoUploadAndInstallStep *other);
static const QString Id;
static const QString DisplayName;
void finishInitialization(const QString &displayName,
AbstractMaemoPackageInstaller *installer);
private slots:
void handleUploadFinished(const QString &errorMsg);
@@ -64,7 +65,6 @@ private:
virtual void startInternal();
virtual void stopInternal();
void ctor();
void upload();
void setFinished();
QString uploadDir() const;
@@ -74,6 +74,58 @@ private:
ExtendedState m_extendedState;
};
class MaemoUploadAndInstallDpkgPackageStep : public AbstractMaemoUploadAndInstallStep
{
Q_OBJECT
public:
MaemoUploadAndInstallDpkgPackageStep(ProjectExplorer::BuildStepList *bc);
MaemoUploadAndInstallDpkgPackageStep(ProjectExplorer::BuildStepList *bc,
MaemoUploadAndInstallDpkgPackageStep *other);
static const QString Id;
static const QString DisplayName;
private:
void ctor();
virtual const AbstractMaemoPackageCreationStep *packagingStep() const;
};
class MaemoUploadAndInstallRpmPackageStep : public AbstractMaemoUploadAndInstallStep
{
Q_OBJECT
public:
MaemoUploadAndInstallRpmPackageStep(ProjectExplorer::BuildStepList *bc);
MaemoUploadAndInstallRpmPackageStep(ProjectExplorer::BuildStepList *bc,
MaemoUploadAndInstallRpmPackageStep *other);
static const QString Id;
static const QString DisplayName;
private:
void ctor();
virtual const AbstractMaemoPackageCreationStep *packagingStep() const;
};
class MaemoUploadAndInstallTarPackageStep : public AbstractMaemoUploadAndInstallStep
{
Q_OBJECT
public:
MaemoUploadAndInstallTarPackageStep(ProjectExplorer::BuildStepList *bc);
MaemoUploadAndInstallTarPackageStep(ProjectExplorer::BuildStepList *bc,
MaemoUploadAndInstallTarPackageStep *other);
static const QString Id;
static const QString DisplayName;
private:
void ctor();
virtual const AbstractMaemoPackageCreationStep *packagingStep() const;
};
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -166,14 +166,14 @@ DeployConfiguration *Qt4MaemoDeployConfigurationFactory::create(Target *parent,
} else if (id == Qt4MaemoDeployConfiguration::HarmattanId) {
dc->stepList()->insertStep(0, new MaemoDebianPackageCreationStep(dc->stepList()));
dc->stepList()->insertStep(1, new MaemoInstallDebianPackageToSysrootStep(dc->stepList()));
dc->stepList()->insertStep(2, new MaemoUploadAndInstallDeployStep(dc->stepList()));
dc->stepList()->insertStep(2, new MaemoUploadAndInstallDpkgPackageStep(dc->stepList()));
} else if (id == Qt4MaemoDeployConfiguration::MeegoId) {
dc->stepList()->insertStep(0, new MaemoRpmPackageCreationStep(dc->stepList()));
dc->stepList()->insertStep(1, new MaemoInstallRpmPackageToSysrootStep(dc->stepList()));
dc->stepList()->insertStep(2, new MaemoUploadAndInstallDeployStep(dc->stepList()));
dc->stepList()->insertStep(2, new MaemoUploadAndInstallRpmPackageStep(dc->stepList()));
} else if (id == Qt4MaemoDeployConfiguration::GenericLinuxId) {
dc->stepList()->insertStep(0, new MaemoTarPackageCreationStep(dc->stepList()));
dc->stepList()->insertStep(1, new MaemoUploadAndInstallDeployStep(dc->stepList()));
dc->stepList()->insertStep(1, new MaemoUploadAndInstallTarPackageStep(dc->stepList()));
}
return dc;
}