forked from qt-creator/qt-creator
RemoteLinux: Introduce abstract packaging step.
This removes the dependency of the tar packaging step on Maemo-specific code. Change-Id: I863b13e643a5028edaf2f571f63b1a52d229812b Reviewed-on: http://codereview.qt.nokia.com/1709 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
159
src/plugins/remotelinux/abstractpackagingstep.cpp
Normal file
159
src/plugins/remotelinux/abstractpackagingstep.cpp
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** This file may be used under the terms of the GNU Lesser General Public
|
||||||
|
** License version 2.1 as published by the Free Software Foundation and
|
||||||
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||||
|
** Please review the following information to ensure the GNU Lesser General
|
||||||
|
** Public License version 2.1 requirements will be met:
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** Other Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used in accordance with the terms and
|
||||||
|
** conditions contained in a signed written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at info@qt.nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
#include "abstractpackagingstep.h"
|
||||||
|
|
||||||
|
#include "deploymentinfo.h"
|
||||||
|
#include "remotelinuxdeployconfiguration.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
|
namespace RemoteLinux {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class AbstractPackagingStepPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractPackagingStepPrivate() : currentBuildConfiguration(0), running(false) { }
|
||||||
|
|
||||||
|
BuildConfiguration *currentBuildConfiguration;
|
||||||
|
bool running;
|
||||||
|
QString cachedPackageDirectory;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
AbstractPackagingStep::AbstractPackagingStep(BuildStepList *bsl, const QString &id)
|
||||||
|
: BuildStep(bsl, id)
|
||||||
|
{
|
||||||
|
ctor();
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractPackagingStep::AbstractPackagingStep(BuildStepList *bsl, AbstractPackagingStep *other)
|
||||||
|
: BuildStep(bsl, other)
|
||||||
|
{
|
||||||
|
ctor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractPackagingStep::ctor()
|
||||||
|
{
|
||||||
|
m_d = new Internal::AbstractPackagingStepPrivate;
|
||||||
|
connect(target(), SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
||||||
|
SLOT(handleBuildConfigurationChanged()));
|
||||||
|
handleBuildConfigurationChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractPackagingStep::~AbstractPackagingStep()
|
||||||
|
{
|
||||||
|
delete m_d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractPackagingStep::handleBuildConfigurationChanged()
|
||||||
|
{
|
||||||
|
if (m_d->currentBuildConfiguration)
|
||||||
|
disconnect(m_d->currentBuildConfiguration, 0, this, 0);
|
||||||
|
m_d->currentBuildConfiguration = target()->activeBuildConfiguration();
|
||||||
|
if (m_d->currentBuildConfiguration) {
|
||||||
|
connect(m_d->currentBuildConfiguration, SIGNAL(buildDirectoryChanged()), this,
|
||||||
|
SIGNAL(packageFilePathChanged()));
|
||||||
|
}
|
||||||
|
emit packageFilePathChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AbstractPackagingStep::packageFilePath() const
|
||||||
|
{
|
||||||
|
if (packageDirectory().isEmpty())
|
||||||
|
return QString();
|
||||||
|
return packageDirectory() + QLatin1Char('/') + packageFileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AbstractPackagingStep::packageDirectory() const
|
||||||
|
{
|
||||||
|
if (m_d->running)
|
||||||
|
return m_d->cachedPackageDirectory;
|
||||||
|
return m_d->currentBuildConfiguration
|
||||||
|
? m_d->currentBuildConfiguration->buildDirectory() : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoteLinuxDeployConfiguration *AbstractPackagingStep::deployConfiguration() const
|
||||||
|
{
|
||||||
|
return qobject_cast<RemoteLinuxDeployConfiguration *>(parent()->parent());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AbstractPackagingStep::isPackagingNeeded() const
|
||||||
|
{
|
||||||
|
const QSharedPointer<DeploymentInfo> &deploymentInfo = deployConfiguration()->deploymentInfo();
|
||||||
|
QFileInfo packageInfo(packageFilePath());
|
||||||
|
if (!packageInfo.exists() || deploymentInfo->isModified())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const int deployableCount = deploymentInfo->deployableCount();
|
||||||
|
for (int i = 0; i < deployableCount; ++i) {
|
||||||
|
if (Utils::FileUtils::isFileNewerThan(deploymentInfo->deployableAt(i).localFilePath,
|
||||||
|
packageInfo.lastModified()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AbstractPackagingStep::init()
|
||||||
|
{
|
||||||
|
m_d->cachedPackageDirectory = packageDirectory();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractPackagingStep::setPackagingStarted()
|
||||||
|
{
|
||||||
|
m_d->running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractPackagingStep::setPackagingFinished(bool success)
|
||||||
|
{
|
||||||
|
m_d->running = false;
|
||||||
|
if (success)
|
||||||
|
deployConfiguration()->deploymentInfo()->setUnmodified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractPackagingStep::raiseError(const QString &errorMessage)
|
||||||
|
{
|
||||||
|
emit addOutput(errorMessage, BuildStep::ErrorOutput);
|
||||||
|
emit addTask(Task(Task::Error, errorMessage, QString(), -1,
|
||||||
|
Constants::TASK_CATEGORY_BUILDSYSTEM));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace RemoteLinux
|
||||||
82
src/plugins/remotelinux/abstractpackagingstep.h
Normal file
82
src/plugins/remotelinux/abstractpackagingstep.h
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** This file may be used under the terms of the GNU Lesser General Public
|
||||||
|
** License version 2.1 as published by the Free Software Foundation and
|
||||||
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||||
|
** Please review the following information to ensure the GNU Lesser General
|
||||||
|
** Public License version 2.1 requirements will be met:
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** Other Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used in accordance with the terms and
|
||||||
|
** conditions contained in a signed written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at info@qt.nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
#ifndef ABSTRACTPACKAGINGSTEP_H
|
||||||
|
#define ABSTRACTPACKAGINGSTEP_H
|
||||||
|
|
||||||
|
#include "remotelinux_export.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/buildstep.h>
|
||||||
|
|
||||||
|
namespace RemoteLinux {
|
||||||
|
class RemoteLinuxDeployConfiguration;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
class AbstractPackagingStepPrivate;
|
||||||
|
}
|
||||||
|
|
||||||
|
class REMOTELINUX_EXPORT AbstractPackagingStep : public ProjectExplorer::BuildStep
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AbstractPackagingStep(ProjectExplorer::BuildStepList *bsl, const QString &id);
|
||||||
|
AbstractPackagingStep(ProjectExplorer::BuildStepList *bsl, AbstractPackagingStep *other);
|
||||||
|
~AbstractPackagingStep();
|
||||||
|
|
||||||
|
QString packageFilePath() const;
|
||||||
|
bool init();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void packageFilePathChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setPackagingStarted();
|
||||||
|
void setPackagingFinished(bool success);
|
||||||
|
|
||||||
|
void raiseError(const QString &errorMessage);
|
||||||
|
RemoteLinuxDeployConfiguration *deployConfiguration() const;
|
||||||
|
QString packageDirectory() const;
|
||||||
|
|
||||||
|
virtual bool isPackagingNeeded() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleBuildConfigurationChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual QString packageFileName() const=0;
|
||||||
|
|
||||||
|
void ctor();
|
||||||
|
|
||||||
|
Internal::AbstractPackagingStepPrivate *m_d;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace RemoteLinux
|
||||||
|
|
||||||
|
#endif // ABSTRACTPACKAGINGSTEP_H
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "abstractremotelinuxdeployservice.h"
|
#include "abstractremotelinuxdeployservice.h"
|
||||||
#include "maemodeploystepwidget.h"
|
#include "maemodeploystepwidget.h"
|
||||||
#include "qt4maemodeployconfiguration.h"
|
#include "remotelinuxdeployconfiguration.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <qt4projectmanager/qt4buildconfiguration.h>
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class AbstractMaemoPackageCreationStep;
|
|
||||||
class AbstractMaemoPackageInstaller;
|
class AbstractMaemoPackageInstaller;
|
||||||
class AbstractUploadAndInstallPackageServicePrivate;
|
class AbstractUploadAndInstallPackageServicePrivate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
#include "genericremotelinuxdeploystepfactory.h"
|
#include "genericremotelinuxdeploystepfactory.h"
|
||||||
|
|
||||||
#include "genericdirectuploadstep.h"
|
#include "genericdirectuploadstep.h"
|
||||||
#include "maemopackagecreationstep.h"
|
|
||||||
#include "remotelinuxdeployconfigurationfactory.h"
|
#include "remotelinuxdeployconfigurationfactory.h"
|
||||||
|
#include "tarpackagecreationstep.h"
|
||||||
#include "uploadandinstalltarpackagestep.h"
|
#include "uploadandinstalltarpackagestep.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
@@ -55,15 +55,15 @@ QStringList GenericRemoteLinuxDeployStepFactory::availableCreationIds(BuildStepL
|
|||||||
const DeployConfiguration * const dc = qobject_cast<DeployConfiguration *>(parent->parent());
|
const DeployConfiguration * const dc = qobject_cast<DeployConfiguration *>(parent->parent());
|
||||||
if (!dc || dc->id() != RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId())
|
if (!dc || dc->id() != RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId())
|
||||||
return ids;
|
return ids;
|
||||||
ids << MaemoTarPackageCreationStep::CreatePackageId << UploadAndInstallTarPackageStep::stepId()
|
ids << TarPackageCreationStep::stepId() << UploadAndInstallTarPackageStep::stepId()
|
||||||
<< GenericDirectUploadStep::stepId();
|
<< GenericDirectUploadStep::stepId();
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GenericRemoteLinuxDeployStepFactory::displayNameForId(const QString &id) const
|
QString GenericRemoteLinuxDeployStepFactory::displayNameForId(const QString &id) const
|
||||||
{
|
{
|
||||||
if (id == MaemoTarPackageCreationStep::CreatePackageId)
|
if (id == TarPackageCreationStep::stepId())
|
||||||
return tr("Create tarball");
|
return TarPackageCreationStep::displayName();
|
||||||
if (id == UploadAndInstallTarPackageStep::stepId())
|
if (id == UploadAndInstallTarPackageStep::stepId())
|
||||||
return UploadAndInstallTarPackageStep::displayName();
|
return UploadAndInstallTarPackageStep::displayName();
|
||||||
if (id == GenericDirectUploadStep::stepId())
|
if (id == GenericDirectUploadStep::stepId())
|
||||||
@@ -80,8 +80,8 @@ BuildStep *GenericRemoteLinuxDeployStepFactory::create(BuildStepList *parent, co
|
|||||||
{
|
{
|
||||||
Q_ASSERT(canCreate(parent, id));
|
Q_ASSERT(canCreate(parent, id));
|
||||||
|
|
||||||
if (id == MaemoTarPackageCreationStep::CreatePackageId)
|
if (id == TarPackageCreationStep::stepId())
|
||||||
return new MaemoTarPackageCreationStep(parent);
|
return new TarPackageCreationStep(parent);
|
||||||
if (id == UploadAndInstallTarPackageStep::stepId())
|
if (id == UploadAndInstallTarPackageStep::stepId())
|
||||||
return new UploadAndInstallTarPackageStep(parent);
|
return new UploadAndInstallTarPackageStep(parent);
|
||||||
if (id == GenericDirectUploadStep::stepId())
|
if (id == GenericDirectUploadStep::stepId())
|
||||||
@@ -115,8 +115,8 @@ bool GenericRemoteLinuxDeployStepFactory::canClone(BuildStepList *parent, BuildS
|
|||||||
|
|
||||||
BuildStep *GenericRemoteLinuxDeployStepFactory::clone(BuildStepList *parent, BuildStep *product)
|
BuildStep *GenericRemoteLinuxDeployStepFactory::clone(BuildStepList *parent, BuildStep *product)
|
||||||
{
|
{
|
||||||
if (MaemoTarPackageCreationStep * const other = qobject_cast<MaemoTarPackageCreationStep *>(product))
|
if (TarPackageCreationStep * const other = qobject_cast<TarPackageCreationStep *>(product))
|
||||||
return new MaemoTarPackageCreationStep(parent, other);
|
return new TarPackageCreationStep(parent, other);
|
||||||
if (UploadAndInstallTarPackageStep * const other = qobject_cast<UploadAndInstallTarPackageStep*>(product))
|
if (UploadAndInstallTarPackageStep * const other = qobject_cast<UploadAndInstallTarPackageStep*>(product))
|
||||||
return new UploadAndInstallTarPackageStep(parent, other);
|
return new UploadAndInstallTarPackageStep(parent, other);
|
||||||
if (GenericDirectUploadStep * const other = qobject_cast<GenericDirectUploadStep *>(product))
|
if (GenericDirectUploadStep * const other = qobject_cast<GenericDirectUploadStep *>(product))
|
||||||
|
|||||||
@@ -31,14 +31,11 @@
|
|||||||
|
|
||||||
#include "maemopackagecreationstep.h"
|
#include "maemopackagecreationstep.h"
|
||||||
|
|
||||||
#include "deploymentinfo.h"
|
|
||||||
#include "maemoconstants.h"
|
#include "maemoconstants.h"
|
||||||
#include "maemoglobal.h"
|
#include "maemoglobal.h"
|
||||||
#include "maemopackagecreationwidget.h"
|
#include "maemopackagecreationwidget.h"
|
||||||
#include "qt4maemotarget.h"
|
#include "qt4maemotarget.h"
|
||||||
#include "remotelinuxdeployconfiguration.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/buildsteplist.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <qt4projectmanager/qt4buildconfiguration.h>
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||||
#include <qt4projectmanager/qt4project.h>
|
#include <qt4projectmanager/qt4project.h>
|
||||||
@@ -49,8 +46,6 @@
|
|||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QProcess>
|
#include <QtCore/QProcess>
|
||||||
#include <QtCore/QRegExp>
|
#include <QtCore/QRegExp>
|
||||||
#include <QtCore/QStringBuilder>
|
|
||||||
#include <QtGui/QWidget>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const QLatin1String MagicFileName(".qtcreator");
|
const QLatin1String MagicFileName(".qtcreator");
|
||||||
@@ -68,44 +63,28 @@ namespace Internal {
|
|||||||
const QLatin1String AbstractMaemoPackageCreationStep::DefaultVersionNumber("0.0.1");
|
const QLatin1String AbstractMaemoPackageCreationStep::DefaultVersionNumber("0.0.1");
|
||||||
|
|
||||||
AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl,
|
AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl,
|
||||||
const QString &id)
|
const QString &id) : AbstractPackagingStep(bsl, id)
|
||||||
: ProjectExplorer::BuildStep(bsl, id)
|
|
||||||
{
|
{
|
||||||
ctor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl,
|
AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl,
|
||||||
AbstractMaemoPackageCreationStep *other) : BuildStep(bsl, other)
|
AbstractMaemoPackageCreationStep *other) : AbstractPackagingStep(bsl, other)
|
||||||
{
|
{
|
||||||
ctor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractMaemoPackageCreationStep::~AbstractMaemoPackageCreationStep()
|
AbstractMaemoPackageCreationStep::~AbstractMaemoPackageCreationStep()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractMaemoPackageCreationStep::ctor()
|
|
||||||
{
|
|
||||||
m_lastBuildConfig = qt4BuildConfiguration();
|
|
||||||
connect(target(),
|
|
||||||
SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
||||||
this, SLOT(handleBuildConfigChanged()));
|
|
||||||
handleBuildConfigChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AbstractMaemoPackageCreationStep::init()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AbstractMaemoPackageCreationStep::run(QFutureInterface<bool> &fi)
|
void AbstractMaemoPackageCreationStep::run(QFutureInterface<bool> &fi)
|
||||||
{
|
{
|
||||||
if (!packagingNeeded()) {
|
if (!isPackagingNeeded()) {
|
||||||
emit addOutput(tr("Package up to date."), MessageOutput);
|
emit addOutput(tr("Package up to date."), MessageOutput);
|
||||||
fi.reportResult(true);
|
fi.reportResult(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setPackagingStarted();
|
||||||
// TODO: Make the build process asynchronous; i.e. no waitFor()-functions etc.
|
// TODO: Make the build process asynchronous; i.e. no waitFor()-functions etc.
|
||||||
QProcess * const buildProc = new QProcess;
|
QProcess * const buildProc = new QProcess;
|
||||||
connect(buildProc, SIGNAL(readyReadStandardOutput()), this,
|
connect(buildProc, SIGNAL(readyReadStandardOutput()), this,
|
||||||
@@ -116,10 +95,9 @@ void AbstractMaemoPackageCreationStep::run(QFutureInterface<bool> &fi)
|
|||||||
const bool success = createPackage(buildProc, fi);
|
const bool success = createPackage(buildProc, fi);
|
||||||
disconnect(buildProc, 0, this, 0);
|
disconnect(buildProc, 0, this, 0);
|
||||||
buildProc->deleteLater();
|
buildProc->deleteLater();
|
||||||
if (success) {
|
if (success)
|
||||||
emit addOutput(tr("Package created."), BuildStep::MessageOutput);
|
emit addOutput(tr("Package created."), BuildStep::MessageOutput);
|
||||||
deployConfig()->deploymentInfo()->setUnmodified();
|
setPackagingFinished(success);
|
||||||
}
|
|
||||||
fi.reportResult(success);
|
fi.reportResult(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,19 +124,6 @@ void AbstractMaemoPackageCreationStep::handleBuildOutput()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractMaemoPackageCreationStep::handleBuildConfigChanged()
|
|
||||||
{
|
|
||||||
if (m_lastBuildConfig)
|
|
||||||
disconnect(m_lastBuildConfig, 0, this, 0);
|
|
||||||
m_lastBuildConfig = qt4BuildConfiguration();
|
|
||||||
connect(m_lastBuildConfig, SIGNAL(qtVersionChanged()), this,
|
|
||||||
SIGNAL(qtVersionChanged()));
|
|
||||||
connect(m_lastBuildConfig, SIGNAL(buildDirectoryChanged()), this,
|
|
||||||
SIGNAL(packageFilePathChanged()));
|
|
||||||
emit qtVersionChanged();
|
|
||||||
emit packageFilePathChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
const Qt4BuildConfiguration *AbstractMaemoPackageCreationStep::qt4BuildConfiguration() const
|
const Qt4BuildConfiguration *AbstractMaemoPackageCreationStep::qt4BuildConfiguration() const
|
||||||
{
|
{
|
||||||
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
||||||
@@ -179,41 +144,20 @@ AbstractRpmBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::rpmBasedMaemoT
|
|||||||
return qobject_cast<AbstractRpmBasedQt4MaemoTarget*>(buildConfiguration()->target());
|
return qobject_cast<AbstractRpmBasedQt4MaemoTarget*>(buildConfiguration()->target());
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteLinuxDeployConfiguration *AbstractMaemoPackageCreationStep::deployConfig() const
|
|
||||||
{
|
|
||||||
return qobject_cast<RemoteLinuxDeployConfiguration *>(parent()->parent());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AbstractMaemoPackageCreationStep::buildDirectory() const
|
|
||||||
{
|
|
||||||
return qt4BuildConfiguration()->buildDirectory();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AbstractMaemoPackageCreationStep::projectName() const
|
QString AbstractMaemoPackageCreationStep::projectName() const
|
||||||
{
|
{
|
||||||
return qt4BuildConfiguration()->qt4Target()->qt4Project()
|
return qt4BuildConfiguration()->qt4Target()->qt4Project()
|
||||||
->rootProjectNode()->displayName().toLower();
|
->rootProjectNode()->displayName().toLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractMaemoPackageCreationStep::packagingNeeded() const
|
bool AbstractMaemoPackageCreationStep::isPackagingNeeded() const
|
||||||
{
|
{
|
||||||
const QSharedPointer<DeploymentInfo> &deploymentInfo
|
if (AbstractPackagingStep::isPackagingNeeded())
|
||||||
= deployConfig()->deploymentInfo();
|
|
||||||
QFileInfo packageInfo(packageFilePath());
|
|
||||||
if (!packageInfo.exists() || deploymentInfo->isModified())
|
|
||||||
return true;
|
return true;
|
||||||
|
return isMetaDataNewerThan(QFileInfo(packageFilePath()).lastModified());
|
||||||
const int deployableCount = deploymentInfo->deployableCount();
|
|
||||||
for (int i = 0; i < deployableCount; ++i) {
|
|
||||||
if (Utils::FileUtils::isFileNewerThan(deploymentInfo->deployableAt(i).localFilePath,
|
|
||||||
packageInfo.lastModified()))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isMetaDataNewerThan(packageInfo.lastModified());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AbstractMaemoPackageCreationStep::packageFilePath() const
|
QString AbstractMaemoPackageCreationStep::packageFileName() const
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
const QString &version = versionString(&error);
|
const QString &version = versionString(&error);
|
||||||
@@ -221,8 +165,7 @@ QString AbstractMaemoPackageCreationStep::packageFilePath() const
|
|||||||
return QString();
|
return QString();
|
||||||
QFileInfo fi(maemoTarget()->packageFileName());
|
QFileInfo fi(maemoTarget()->packageFileName());
|
||||||
const QString baseName = replaceDots(fi.completeBaseName());
|
const QString baseName = replaceDots(fi.completeBaseName());
|
||||||
return buildDirectory() + QLatin1Char('/') + baseName
|
return baseName + QLatin1Char('.') + fi.suffix();
|
||||||
+ QLatin1Char('.') + fi.suffix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AbstractMaemoPackageCreationStep::versionString(QString *error) const
|
QString AbstractMaemoPackageCreationStep::versionString(QString *error) const
|
||||||
@@ -230,8 +173,7 @@ QString AbstractMaemoPackageCreationStep::versionString(QString *error) const
|
|||||||
return maemoTarget()->projectVersion(error);
|
return maemoTarget()->projectVersion(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractMaemoPackageCreationStep::setVersionString(const QString &version,
|
bool AbstractMaemoPackageCreationStep::setVersionString(const QString &version, QString *error)
|
||||||
QString *error)
|
|
||||||
{
|
{
|
||||||
const bool success = maemoTarget()->setProjectVersion(version, error);
|
const bool success = maemoTarget()->setProjectVersion(version, error);
|
||||||
if (success)
|
if (success)
|
||||||
@@ -244,21 +186,13 @@ QString AbstractMaemoPackageCreationStep::nativePath(const QFile &file)
|
|||||||
return QDir::toNativeSeparators(QFileInfo(file).filePath());
|
return QDir::toNativeSeparators(QFileInfo(file).filePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractMaemoPackageCreationStep::raiseError(const QString &shortMsg,
|
|
||||||
const QString &detailedMsg)
|
|
||||||
{
|
|
||||||
emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg, BuildStep::ErrorOutput);
|
|
||||||
emit addTask(Task(Task::Error, shortMsg, QString(), -1,
|
|
||||||
TASK_CATEGORY_BUILDSYSTEM));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AbstractMaemoPackageCreationStep::callPackagingCommand(QProcess *proc,
|
bool AbstractMaemoPackageCreationStep::callPackagingCommand(QProcess *proc,
|
||||||
const QStringList &arguments)
|
const QStringList &arguments)
|
||||||
{
|
{
|
||||||
preparePackagingProcess(proc, qt4BuildConfiguration(), buildDirectory());
|
preparePackagingProcess(proc, qt4BuildConfiguration(), packageDirectory());
|
||||||
const QtSupport::BaseQtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion();
|
const QtSupport::BaseQtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion();
|
||||||
if (!qtVersion) {
|
if (!qtVersion) {
|
||||||
raiseError(tr("Packaging failed."), tr("Packaging error: No Qt version."));
|
raiseError(tr("Packaging failed: No Qt version."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const QString madCommand = MaemoGlobal::madCommand(qtVersion->qmakeCommand());
|
const QString madCommand = MaemoGlobal::madCommand(qtVersion->qmakeCommand());
|
||||||
@@ -268,8 +202,7 @@ bool AbstractMaemoPackageCreationStep::callPackagingCommand(QProcess *proc,
|
|||||||
BuildStep::MessageOutput);
|
BuildStep::MessageOutput);
|
||||||
MaemoGlobal::callMad(*proc, arguments, qtVersion->qmakeCommand(), true);
|
MaemoGlobal::callMad(*proc, arguments, qtVersion->qmakeCommand(), true);
|
||||||
if (!proc->waitForStarted()) {
|
if (!proc->waitForStarted()) {
|
||||||
raiseError(tr("Packaging failed."),
|
raiseError(tr("Packaging failed: Could not start command '%1'. Reason: %2")
|
||||||
tr("Packaging error: Could not start command '%1'. Reason: %2")
|
|
||||||
.arg(cmdLine, proc->errorString()));
|
.arg(cmdLine, proc->errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -333,10 +266,8 @@ bool MaemoDebianPackageCreationStep::createPackage(QProcess *buildProc,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(fi);
|
Q_UNUSED(fi);
|
||||||
checkProjectName();
|
checkProjectName();
|
||||||
const QString projectDir
|
const QString projectDir = buildConfiguration()->target()->project()->projectDirectory();
|
||||||
= buildConfiguration()->target()->project()->projectDirectory();
|
const bool inSourceBuild = QFileInfo(packageDirectory()) == QFileInfo(projectDir);
|
||||||
const bool inSourceBuild
|
|
||||||
= QFileInfo(buildDirectory()) == QFileInfo(projectDir);
|
|
||||||
if (!copyDebianFiles(inSourceBuild))
|
if (!copyDebianFiles(inSourceBuild))
|
||||||
return false;
|
return false;
|
||||||
const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage")
|
const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage")
|
||||||
@@ -347,36 +278,32 @@ bool MaemoDebianPackageCreationStep::createPackage(QProcess *buildProc,
|
|||||||
QFile::remove(packageFilePath());
|
QFile::remove(packageFilePath());
|
||||||
|
|
||||||
// Workaround for non-working dh_builddeb --destdir=.
|
// Workaround for non-working dh_builddeb --destdir=.
|
||||||
if (!QDir(buildDirectory()).isRoot()) {
|
if (!QDir(packageDirectory()).isRoot()) {
|
||||||
const AbstractQt4MaemoTarget * const target = maemoTarget();
|
const AbstractQt4MaemoTarget * const target = maemoTarget();
|
||||||
QString error;
|
QString error;
|
||||||
const QString pkgFileName = target->packageFileName();
|
const QString pkgFileName = target->packageFileName();
|
||||||
if (!error.isEmpty())
|
if (!error.isEmpty())
|
||||||
raiseError(tr("Packaging failed."), "Failed to get package name.");
|
raiseError(tr("Packaging failed: Could not get package name."));
|
||||||
const QString changesSourceFileName = QFileInfo(pkgFileName).completeBaseName()
|
const QString changesSourceFileName = QFileInfo(pkgFileName).completeBaseName()
|
||||||
+ QLatin1String(".changes");
|
+ QLatin1String(".changes");
|
||||||
const QString changesTargetFileName = replaceDots(QFileInfo(pkgFileName).completeBaseName())
|
const QString changesTargetFileName = replaceDots(QFileInfo(pkgFileName).completeBaseName())
|
||||||
+ QLatin1String(".changes");
|
+ QLatin1String(".changes");
|
||||||
const QString packageSourceDir = buildDirectory() + QLatin1String("/../");
|
const QString packageSourceDir = packageDirectory() + QLatin1String("/../");
|
||||||
const QString packageSourceFilePath
|
const QString packageSourceFilePath = packageSourceDir + pkgFileName;
|
||||||
= packageSourceDir + pkgFileName;
|
const QString changesSourceFilePath = packageSourceDir + changesSourceFileName;
|
||||||
const QString changesSourceFilePath
|
|
||||||
= packageSourceDir + changesSourceFileName;
|
|
||||||
const QString changesTargetFilePath
|
const QString changesTargetFilePath
|
||||||
= buildDirectory() + QLatin1Char('/') + changesTargetFileName;
|
= packageDirectory() + QLatin1Char('/') + changesTargetFileName;
|
||||||
QFile::remove(changesTargetFilePath);
|
QFile::remove(changesTargetFilePath);
|
||||||
if (!QFile::rename(packageSourceFilePath, packageFilePath())
|
if (!QFile::rename(packageSourceFilePath, packageFilePath())
|
||||||
|| !QFile::rename(changesSourceFilePath, changesTargetFilePath)) {
|
|| !QFile::rename(changesSourceFilePath, changesTargetFilePath)) {
|
||||||
raiseError(tr("Packaging failed."),
|
raiseError(tr("Packaging failed: Could not move package files from '%1'' to '%2'.")
|
||||||
tr("Could not move package files from %1 to %2.")
|
.arg(packageSourceDir, packageDirectory()));
|
||||||
.arg(packageSourceDir, buildDirectory()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inSourceBuild) {
|
if (inSourceBuild) {
|
||||||
buildProc->start(packagingCommand(qt4BuildConfiguration(),
|
buildProc->start(packagingCommand(qt4BuildConfiguration(), QLatin1String("dh_clean")));
|
||||||
QLatin1String("dh_clean")));
|
|
||||||
buildProc->waitForFinished();
|
buildProc->waitForFinished();
|
||||||
buildProc->terminate();
|
buildProc->terminate();
|
||||||
}
|
}
|
||||||
@@ -390,8 +317,7 @@ bool MaemoDebianPackageCreationStep::isMetaDataNewerThan(const QDateTime &packag
|
|||||||
return true;
|
return true;
|
||||||
const QStringList debianFiles = debBasedMaemoTarget()->debianFiles();
|
const QStringList debianFiles = debBasedMaemoTarget()->debianFiles();
|
||||||
foreach (const QString &debianFile, debianFiles) {
|
foreach (const QString &debianFile, debianFiles) {
|
||||||
const QString absFilePath
|
const QString absFilePath = debianPath + QLatin1Char('/') + debianFile;
|
||||||
= debianPath + QLatin1Char('/') + debianFile;
|
|
||||||
if (packageDate <= QFileInfo(absFilePath).lastModified())
|
if (packageDate <= QFileInfo(absFilePath).lastModified())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -413,29 +339,27 @@ void MaemoDebianPackageCreationStep::checkProjectName()
|
|||||||
|
|
||||||
bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild)
|
bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild)
|
||||||
{
|
{
|
||||||
const QString debianDirPath = buildDirectory() + QLatin1String("/debian");
|
const QString debianDirPath = packageDirectory() + QLatin1String("/debian");
|
||||||
const QString magicFilePath
|
const QString magicFilePath
|
||||||
= debianDirPath + QLatin1Char('/') + MagicFileName;
|
= debianDirPath + QLatin1Char('/') + MagicFileName;
|
||||||
if (inSourceBuild && QFileInfo(debianDirPath).isDir()
|
if (inSourceBuild && QFileInfo(debianDirPath).isDir()
|
||||||
&& !QFileInfo(magicFilePath).exists()) {
|
&& !QFileInfo(magicFilePath).exists()) {
|
||||||
raiseError(tr("Packaging failed: Foreign debian directory detected."),
|
raiseError(tr("Packaging failed: Foreign debian directory detected. "
|
||||||
tr("You are not using a shadow build and there is a debian "
|
"You are not using a shadow build and there is a debian "
|
||||||
"directory in your project root ('%1'). Qt Creator will not "
|
"directory in your project root ('%1'). Qt Creator will not "
|
||||||
"overwrite that directory. Please remove it or use the "
|
"overwrite that directory. Please remove it or use the "
|
||||||
"shadow build feature.")
|
"shadow build feature.").arg(QDir::toNativeSeparators(debianDirPath)));
|
||||||
.arg(QDir::toNativeSeparators(debianDirPath)));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QString error;
|
QString error;
|
||||||
if (!Utils::FileUtils::removeRecursively(debianDirPath, &error)) {
|
if (!Utils::FileUtils::removeRecursively(debianDirPath, &error)) {
|
||||||
raiseError(tr("Packaging failed."),
|
raiseError(tr("Packaging failed: Could not remove directory '%1': %2")
|
||||||
tr("Could not remove directory '%1': %2").arg(debianDirPath, error));
|
.arg(debianDirPath, error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QDir buildDir(buildDirectory());
|
QDir buildDir(packageDirectory());
|
||||||
if (!buildDir.mkdir("debian")) {
|
if (!buildDir.mkdir("debian")) {
|
||||||
raiseError(tr("Could not create Debian directory '%1'.")
|
raiseError(tr("Could not create Debian directory '%1'.").arg(debianDirPath));
|
||||||
.arg(debianDirPath));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const QString templatesDirPath = debBasedMaemoTarget()->debianDirPath();
|
const QString templatesDirPath = debBasedMaemoTarget()->debianDirPath();
|
||||||
@@ -457,8 +381,7 @@ bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild)
|
|||||||
return false;
|
return false;
|
||||||
} else if (!QFile::copy(srcFile, destFile)) {
|
} else if (!QFile::copy(srcFile, destFile)) {
|
||||||
raiseError(tr("Could not copy file '%1' to '%2'")
|
raiseError(tr("Could not copy file '%1' to '%2'")
|
||||||
.arg(QDir::toNativeSeparators(srcFile),
|
.arg(QDir::toNativeSeparators(srcFile), QDir::toNativeSeparators(destFile)));
|
||||||
QDir::toNativeSeparators(destFile)));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -545,17 +468,18 @@ void MaemoRpmPackageCreationStep::ctor()
|
|||||||
bool MaemoRpmPackageCreationStep::createPackage(QProcess *buildProc,
|
bool MaemoRpmPackageCreationStep::createPackage(QProcess *buildProc,
|
||||||
const QFutureInterface<bool> &fi)
|
const QFutureInterface<bool> &fi)
|
||||||
{
|
{
|
||||||
|
setPackagingStarted();
|
||||||
|
|
||||||
Q_UNUSED(fi);
|
Q_UNUSED(fi);
|
||||||
const QStringList args = QStringList() << QLatin1String("rrpmbuild")
|
const QStringList args = QStringList() << QLatin1String("rrpmbuild")
|
||||||
<< QLatin1String("-bb") << rpmBasedMaemoTarget()->specFilePath();
|
<< QLatin1String("-bb") << rpmBasedMaemoTarget()->specFilePath();
|
||||||
if (!callPackagingCommand(buildProc, args))
|
if (!callPackagingCommand(buildProc, args))
|
||||||
return false;
|
return false;
|
||||||
QFile::remove(packageFilePath());
|
QFile::remove(packageFilePath());
|
||||||
const QString packageSourceFilePath = rpmBuildDir(qt4BuildConfiguration())
|
const QString packageSourceFilePath = rpmBuildDir() + QLatin1Char('/')
|
||||||
+ QLatin1Char('/') + rpmBasedMaemoTarget()->packageFileName();
|
+ rpmBasedMaemoTarget()->packageFileName();
|
||||||
if (!QFile::rename(packageSourceFilePath, packageFilePath())) {
|
if (!QFile::rename(packageSourceFilePath, packageFilePath())) {
|
||||||
raiseError(tr("Packaging failed."),
|
raiseError(tr("Packaging failed: Could not move package file from %1 to %2.")
|
||||||
tr("Could not move package file from %1 to %2.")
|
|
||||||
.arg(packageSourceFilePath, packageFilePath()));
|
.arg(packageSourceFilePath, packageFilePath()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -570,267 +494,13 @@ bool MaemoRpmPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDa
|
|||||||
return packageDate <= specFileChangeDate;
|
return packageDate <= specFileChangeDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaemoRpmPackageCreationStep::rpmBuildDir(const Qt4BuildConfiguration *bc)
|
QString MaemoRpmPackageCreationStep::rpmBuildDir() const
|
||||||
{
|
{
|
||||||
return bc->buildDirectory() + QLatin1String("/rrpmbuild");
|
return packageDirectory() + QLatin1String("/rrpmbuild");
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString MaemoRpmPackageCreationStep::CreatePackageId
|
const QString MaemoRpmPackageCreationStep::CreatePackageId
|
||||||
= QLatin1String("MaemoRpmPackageCreationStep");
|
= QLatin1String("MaemoRpmPackageCreationStep");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CreateTarStepWidget : public BuildStepConfigWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
CreateTarStepWidget(MaemoTarPackageCreationStep *step) : m_step(step)
|
|
||||||
{
|
|
||||||
connect(m_step, SIGNAL(packageFilePathChanged()),
|
|
||||||
SIGNAL(updateSummary()));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QString summaryText() const
|
|
||||||
{
|
|
||||||
return QLatin1String("<b>") + tr("Create tarball:")
|
|
||||||
+ QLatin1String("</b> ") + m_step->packageFilePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QString displayName() const { return QString(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const MaemoTarPackageCreationStep * const m_step;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
const int TarBlockSize = 512;
|
|
||||||
struct TarFileHeader {
|
|
||||||
char fileName[100];
|
|
||||||
char fileMode[8];
|
|
||||||
char uid[8];
|
|
||||||
char gid[8];
|
|
||||||
char length[12];
|
|
||||||
char mtime[12];
|
|
||||||
char chksum[8];
|
|
||||||
char typeflag;
|
|
||||||
char linkname[100];
|
|
||||||
char magic[6];
|
|
||||||
char version[2];
|
|
||||||
char uname[32];
|
|
||||||
char gname[32];
|
|
||||||
char devmajor[8];
|
|
||||||
char devminor[8];
|
|
||||||
char fileNamePrefix[155];
|
|
||||||
char padding[12];
|
|
||||||
};
|
|
||||||
} // Anonymous namespace.
|
|
||||||
|
|
||||||
MaemoTarPackageCreationStep::MaemoTarPackageCreationStep(BuildStepList *bsl)
|
|
||||||
: AbstractMaemoPackageCreationStep(bsl, CreatePackageId)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
MaemoTarPackageCreationStep::MaemoTarPackageCreationStep(BuildStepList *buildConfig,
|
|
||||||
MaemoTarPackageCreationStep *other)
|
|
||||||
: AbstractMaemoPackageCreationStep(buildConfig, other)
|
|
||||||
{
|
|
||||||
ctor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoTarPackageCreationStep::ctor()
|
|
||||||
{
|
|
||||||
setDefaultDisplayName(tr("Create tarball"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MaemoTarPackageCreationStep::createPackage(QProcess *buildProc,
|
|
||||||
const QFutureInterface<bool> &fi)
|
|
||||||
{
|
|
||||||
Q_UNUSED(buildProc);
|
|
||||||
|
|
||||||
// TODO: Optimization: Only package changed files (needs refactoring in upper level; worth the effort?)
|
|
||||||
QFile tarFile(packageFilePath());
|
|
||||||
if (!tarFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
|
||||||
raiseError(tr("Error: tar file %1 cannot be opened (%2).")
|
|
||||||
.arg(QDir::toNativeSeparators(packageFilePath()),
|
|
||||||
tarFile.errorString()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const QSharedPointer<DeploymentInfo> deploymentInfo = deployConfig()->deploymentInfo();
|
|
||||||
for (int i = 0; i < deploymentInfo->deployableCount(); ++i) {
|
|
||||||
const DeployableFile &d = deploymentInfo->deployableAt(i);
|
|
||||||
QFileInfo fileInfo(d.localFilePath);
|
|
||||||
if (!appendFile(tarFile, fileInfo, d.remoteDir + QLatin1Char('/')
|
|
||||||
+ fileInfo.fileName(), fi)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QByteArray eofIndicator(2*sizeof(TarFileHeader), 0);
|
|
||||||
if (tarFile.write(eofIndicator) != eofIndicator.length()) {
|
|
||||||
raiseError(tr("Error writing tar file '%1': %2.")
|
|
||||||
.arg(QDir::toNativeSeparators(tarFile.fileName()),
|
|
||||||
tarFile.errorString()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MaemoTarPackageCreationStep::appendFile(QFile &tarFile,
|
|
||||||
const QFileInfo &fileInfo, const QString &remoteFilePath,
|
|
||||||
const QFutureInterface<bool> &fi)
|
|
||||||
{
|
|
||||||
if (!writeHeader(tarFile, fileInfo, remoteFilePath))
|
|
||||||
return false;
|
|
||||||
if (fileInfo.isDir()) {
|
|
||||||
QDir dir(fileInfo.absoluteFilePath());
|
|
||||||
foreach (const QString &fileName,
|
|
||||||
dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
|
|
||||||
const QString thisLocalFilePath
|
|
||||||
= dir.path() + QLatin1Char('/') + fileName;
|
|
||||||
const QString thisRemoteFilePath = remoteFilePath
|
|
||||||
+ QLatin1Char('/') + fileName;
|
|
||||||
if (!appendFile(tarFile, QFileInfo(thisLocalFilePath),
|
|
||||||
thisRemoteFilePath, fi)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const QString nativePath
|
|
||||||
= QDir::toNativeSeparators(fileInfo.filePath());
|
|
||||||
QFile file(fileInfo.filePath());
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
|
||||||
raiseError(tr("Error reading file '%1': %2.")
|
|
||||||
.arg(nativePath, file.errorString()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int chunkSize = 1024*1024;
|
|
||||||
|
|
||||||
// TODO: Wasteful. Work with fixed-size buffer.
|
|
||||||
while (!file.atEnd() && !file.error() != QFile::NoError
|
|
||||||
&& !tarFile.error() != QFile::NoError) {
|
|
||||||
const QByteArray data = file.read(chunkSize);
|
|
||||||
tarFile.write(data);
|
|
||||||
if (fi.isCanceled())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (file.error() != QFile::NoError) {
|
|
||||||
raiseError(tr("Error reading file '%1': %2.")
|
|
||||||
.arg(nativePath, file.errorString()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int blockModulo = file.size() % TarBlockSize;
|
|
||||||
if (blockModulo != 0) {
|
|
||||||
tarFile.write(QByteArray(TarBlockSize - blockModulo, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tarFile.error() != QFile::NoError) {
|
|
||||||
raiseError(tr("Error writing tar file '%1': %2.")
|
|
||||||
.arg(QDir::toNativeSeparators(tarFile.fileName()),
|
|
||||||
tarFile.errorString()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MaemoTarPackageCreationStep::writeHeader(QFile &tarFile,
|
|
||||||
const QFileInfo &fileInfo, const QString &remoteFilePath)
|
|
||||||
{
|
|
||||||
TarFileHeader header;
|
|
||||||
qMemSet(&header, '\0', sizeof header);
|
|
||||||
const QByteArray &filePath = remoteFilePath.toUtf8();
|
|
||||||
const int maxFilePathLength = sizeof header.fileNamePrefix
|
|
||||||
+ sizeof header.fileName;
|
|
||||||
if (filePath.count() > maxFilePathLength) {
|
|
||||||
raiseError(tr("Cannot add file '%1' to tar-archive: path too long.")
|
|
||||||
.arg(QDir::toNativeSeparators(filePath)));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int fileNameBytesToWrite
|
|
||||||
= qMin<int>(filePath.length(), sizeof header.fileName);
|
|
||||||
const int fileNameOffset = filePath.length() - fileNameBytesToWrite;
|
|
||||||
qMemCopy(&header.fileName, filePath.data() + fileNameOffset,
|
|
||||||
fileNameBytesToWrite);
|
|
||||||
if (fileNameOffset > 0)
|
|
||||||
qMemCopy(&header.fileNamePrefix, filePath.data(), fileNameOffset);
|
|
||||||
int permissions = (0400 * fileInfo.permission(QFile::ReadOwner))
|
|
||||||
| (0200 * fileInfo.permission(QFile::WriteOwner))
|
|
||||||
| (0100 * fileInfo.permission(QFile::ExeOwner))
|
|
||||||
| (040 * fileInfo.permission(QFile::ReadGroup))
|
|
||||||
| (020 * fileInfo.permission(QFile::WriteGroup))
|
|
||||||
| (010 * fileInfo.permission(QFile::ExeGroup))
|
|
||||||
| (04 * fileInfo.permission(QFile::ReadOther))
|
|
||||||
| (02 * fileInfo.permission(QFile::WriteOther))
|
|
||||||
| (01 * fileInfo.permission(QFile::ExeOther));
|
|
||||||
const QByteArray permissionString = QString("%1").arg(permissions,
|
|
||||||
sizeof header.fileMode - 1, 8, QLatin1Char('0')).toAscii();
|
|
||||||
qMemCopy(&header.fileMode, permissionString.data(),
|
|
||||||
permissionString.length());
|
|
||||||
const QByteArray uidString = QString("%1").arg(fileInfo.ownerId(),
|
|
||||||
sizeof header.uid - 1, 8, QLatin1Char('0')).toAscii();
|
|
||||||
qMemCopy(&header.uid, uidString.data(), uidString.length());
|
|
||||||
const QByteArray gidString = QString("%1").arg(fileInfo.groupId(),
|
|
||||||
sizeof header.gid - 1, 8, QLatin1Char('0')).toAscii();
|
|
||||||
qMemCopy(&header.gid, gidString.data(), gidString.length());
|
|
||||||
const QByteArray sizeString = QString("%1").arg(fileInfo.size(),
|
|
||||||
sizeof header.length - 1, 8, QLatin1Char('0')).toAscii();
|
|
||||||
qMemCopy(&header.length, sizeString.data(), sizeString.length());
|
|
||||||
const QByteArray mtimeString = QString("%1").arg(fileInfo.lastModified().toTime_t(),
|
|
||||||
sizeof header.mtime - 1, 8, QLatin1Char('0')).toAscii();
|
|
||||||
qMemCopy(&header.mtime, mtimeString.data(), mtimeString.length());
|
|
||||||
if (fileInfo.isDir())
|
|
||||||
header.typeflag = '5';
|
|
||||||
qMemCopy(&header.magic, "ustar", sizeof "ustar");
|
|
||||||
qMemCopy(&header.version, "00", 2);
|
|
||||||
const QByteArray &owner = fileInfo.owner().toUtf8();
|
|
||||||
qMemCopy(&header.uname, owner.data(),
|
|
||||||
qMin<int>(owner.length(), sizeof header.uname - 1));
|
|
||||||
const QByteArray &group = fileInfo.group().toUtf8();
|
|
||||||
qMemCopy(&header.gname, group.data(),
|
|
||||||
qMin<int>(group.length(), sizeof header.gname - 1));
|
|
||||||
qMemSet(&header.chksum, ' ', sizeof header.chksum);
|
|
||||||
quint64 checksum = 0;
|
|
||||||
for (size_t i = 0; i < sizeof header; ++i)
|
|
||||||
checksum += reinterpret_cast<char *>(&header)[i];
|
|
||||||
const QByteArray checksumString = QString("%1").arg(checksum,
|
|
||||||
sizeof header.chksum - 1, 8, QLatin1Char('0')).toAscii();
|
|
||||||
qMemCopy(&header.chksum, checksumString.data(), checksumString.length());
|
|
||||||
header.chksum[sizeof header.chksum-1] = 0;
|
|
||||||
if (!tarFile.write(reinterpret_cast<char *>(&header), sizeof header)) {
|
|
||||||
raiseError(tr("Error writing tar file '%1': %2")
|
|
||||||
.arg(QDir::toNativeSeparators(packageFilePath()),
|
|
||||||
tarFile.errorString()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MaemoTarPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(packageDate);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MaemoTarPackageCreationStep::packageFilePath() const
|
|
||||||
{
|
|
||||||
return buildDirectory() + QLatin1Char('/') + projectName()
|
|
||||||
+ QLatin1String(".tar");
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildStepConfigWidget *MaemoTarPackageCreationStep::createConfigWidget()
|
|
||||||
{
|
|
||||||
return new CreateTarStepWidget(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString MaemoTarPackageCreationStep::CreatePackageId
|
|
||||||
= QLatin1String("MaemoTarPackageCreationStep");
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace RemoteLinux
|
} // namespace RemoteLinux
|
||||||
|
|
||||||
#include "maemopackagecreationstep.moc"
|
|
||||||
|
|||||||
@@ -32,12 +32,11 @@
|
|||||||
#ifndef MAEMOPACKAGECREATIONSTEP_H
|
#ifndef MAEMOPACKAGECREATIONSTEP_H
|
||||||
#define MAEMOPACKAGECREATIONSTEP_H
|
#define MAEMOPACKAGECREATIONSTEP_H
|
||||||
|
|
||||||
#include <projectexplorer/buildstep.h>
|
#include<remotelinux/abstractpackagingstep.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QDateTime;
|
class QDateTime;
|
||||||
class QFile;
|
class QFile;
|
||||||
class QFileInfo;
|
|
||||||
class QProcess;
|
class QProcess;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@@ -51,14 +50,12 @@ class AbstractQt4MaemoTarget;
|
|||||||
class AbstractDebBasedQt4MaemoTarget;
|
class AbstractDebBasedQt4MaemoTarget;
|
||||||
class AbstractRpmBasedQt4MaemoTarget;
|
class AbstractRpmBasedQt4MaemoTarget;
|
||||||
|
|
||||||
class AbstractMaemoPackageCreationStep : public ProjectExplorer::BuildStep
|
class AbstractMaemoPackageCreationStep : public RemoteLinux::AbstractPackagingStep
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
virtual ~AbstractMaemoPackageCreationStep();
|
virtual ~AbstractMaemoPackageCreationStep();
|
||||||
|
|
||||||
virtual QString packageFilePath() const;
|
|
||||||
|
|
||||||
QString versionString(QString *error) const;
|
QString versionString(QString *error) const;
|
||||||
bool setVersionString(const QString &version, QString *error);
|
bool setVersionString(const QString &version, QString *error);
|
||||||
|
|
||||||
@@ -66,18 +63,13 @@ public:
|
|||||||
const Qt4ProjectManager::Qt4BuildConfiguration *bc,
|
const Qt4ProjectManager::Qt4BuildConfiguration *bc,
|
||||||
const QString &workingDir);
|
const QString &workingDir);
|
||||||
|
|
||||||
QString projectName() const;
|
|
||||||
const Qt4ProjectManager::Qt4BuildConfiguration *qt4BuildConfiguration() const;
|
const Qt4ProjectManager::Qt4BuildConfiguration *qt4BuildConfiguration() const;
|
||||||
AbstractQt4MaemoTarget *maemoTarget() const;
|
AbstractQt4MaemoTarget *maemoTarget() const;
|
||||||
AbstractDebBasedQt4MaemoTarget *debBasedMaemoTarget() const;
|
AbstractDebBasedQt4MaemoTarget *debBasedMaemoTarget() const;
|
||||||
AbstractRpmBasedQt4MaemoTarget *rpmBasedMaemoTarget() const;
|
AbstractRpmBasedQt4MaemoTarget *rpmBasedMaemoTarget() const;
|
||||||
RemoteLinuxDeployConfiguration *deployConfig() const;
|
|
||||||
|
|
||||||
static const QLatin1String DefaultVersionNumber;
|
static const QLatin1String DefaultVersionNumber;
|
||||||
|
|
||||||
signals:
|
|
||||||
void packageFilePathChanged();
|
|
||||||
void qtVersionChanged();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *bsl,
|
AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *bsl,
|
||||||
@@ -85,27 +77,24 @@ protected:
|
|||||||
AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig,
|
AbstractMaemoPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig,
|
||||||
AbstractMaemoPackageCreationStep *other);
|
AbstractMaemoPackageCreationStep *other);
|
||||||
|
|
||||||
void raiseError(const QString &shortMsg,
|
|
||||||
const QString &detailedMsg = QString());
|
|
||||||
bool callPackagingCommand(QProcess *proc, const QStringList &arguments);
|
bool callPackagingCommand(QProcess *proc, const QStringList &arguments);
|
||||||
static QString replaceDots(const QString &name);
|
static QString replaceDots(const QString &name);
|
||||||
QString buildDirectory() const;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleBuildOutput();
|
void handleBuildOutput();
|
||||||
void handleBuildConfigChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ctor();
|
|
||||||
virtual bool init();
|
|
||||||
virtual void run(QFutureInterface<bool> &fi);
|
virtual void run(QFutureInterface<bool> &fi);
|
||||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||||
|
|
||||||
|
virtual QString packageFileName() const;
|
||||||
|
|
||||||
virtual bool createPackage(QProcess *buildProc, const QFutureInterface<bool> &fi)=0;
|
virtual bool createPackage(QProcess *buildProc, const QFutureInterface<bool> &fi)=0;
|
||||||
virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const=0;
|
virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const=0;
|
||||||
|
|
||||||
|
QString projectName() const;
|
||||||
static QString nativePath(const QFile &file);
|
static QString nativePath(const QFile &file);
|
||||||
bool packagingNeeded() const;
|
bool isPackagingNeeded() const;
|
||||||
|
|
||||||
const Qt4ProjectManager::Qt4BuildConfiguration *m_lastBuildConfig;
|
const Qt4ProjectManager::Qt4BuildConfiguration *m_lastBuildConfig;
|
||||||
};
|
};
|
||||||
@@ -152,34 +141,11 @@ private:
|
|||||||
MaemoRpmPackageCreationStep *other);
|
MaemoRpmPackageCreationStep *other);
|
||||||
|
|
||||||
void ctor();
|
void ctor();
|
||||||
static QString rpmBuildDir(const Qt4ProjectManager::Qt4BuildConfiguration *bc);
|
QString rpmBuildDir() const;
|
||||||
|
|
||||||
static const QString CreatePackageId;
|
static const QString CreatePackageId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MaemoTarPackageCreationStep : public AbstractMaemoPackageCreationStep
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
MaemoTarPackageCreationStep(ProjectExplorer::BuildStepList *bsl);
|
|
||||||
MaemoTarPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig,
|
|
||||||
MaemoTarPackageCreationStep *other);
|
|
||||||
|
|
||||||
virtual QString packageFilePath() const;
|
|
||||||
|
|
||||||
static const QString CreatePackageId;
|
|
||||||
private:
|
|
||||||
virtual bool createPackage(QProcess *buildProc, const QFutureInterface<bool> &fi);
|
|
||||||
virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const;
|
|
||||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
|
||||||
|
|
||||||
void ctor();
|
|
||||||
bool appendFile(QFile &tarFile, const QFileInfo &fileInfo,
|
|
||||||
const QString &remoteFilePath, const QFutureInterface<bool> &fi);
|
|
||||||
bool writeHeader(QFile &tarFile, const QFileInfo &fileInfo,
|
|
||||||
const QString &remoteFilePath);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace RemoteLinux
|
} // namespace RemoteLinux
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ HEADERS += \
|
|||||||
genericdirectuploadservice.h \
|
genericdirectuploadservice.h \
|
||||||
remotelinuxdeployconfiguration.h \
|
remotelinuxdeployconfiguration.h \
|
||||||
remotelinuxdeployconfigurationfactory.h \
|
remotelinuxdeployconfigurationfactory.h \
|
||||||
genericremotelinuxdeploystepfactory.h
|
genericremotelinuxdeploystepfactory.h \
|
||||||
|
abstractpackagingstep.h \
|
||||||
|
tarpackagecreationstep.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
remotelinuxplugin.cpp \
|
remotelinuxplugin.cpp \
|
||||||
@@ -172,7 +174,9 @@ SOURCES += \
|
|||||||
genericdirectuploadservice.cpp \
|
genericdirectuploadservice.cpp \
|
||||||
remotelinuxdeployconfiguration.cpp \
|
remotelinuxdeployconfiguration.cpp \
|
||||||
remotelinuxdeployconfigurationfactory.cpp \
|
remotelinuxdeployconfigurationfactory.cpp \
|
||||||
genericremotelinuxdeploystepfactory.cpp
|
genericremotelinuxdeploystepfactory.cpp \
|
||||||
|
abstractpackagingstep.cpp \
|
||||||
|
tarpackagecreationstep.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
maemoconfigtestdialog.ui \
|
maemoconfigtestdialog.ui \
|
||||||
|
|||||||
@@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
#include "linuxdeviceconfiguration.h"
|
#include "linuxdeviceconfiguration.h"
|
||||||
#include "maemoglobal.h"
|
#include "maemoglobal.h"
|
||||||
#include "maemopackagecreationstep.h"
|
|
||||||
#include "remotelinuxdeployconfiguration.h"
|
#include "remotelinuxdeployconfiguration.h"
|
||||||
|
#include "tarpackagecreationstep.h"
|
||||||
#include "uploadandinstalltarpackagestep.h"
|
#include "uploadandinstalltarpackagestep.h"
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -78,7 +78,7 @@ DeployConfiguration *RemoteLinuxDeployConfigurationFactory::create(Target *paren
|
|||||||
|
|
||||||
DeployConfiguration * const dc = new RemoteLinuxDeployConfiguration(parent, id,
|
DeployConfiguration * const dc = new RemoteLinuxDeployConfiguration(parent, id,
|
||||||
genericLinuxDisplayName(), LinuxDeviceConfiguration::GenericLinuxOsType);
|
genericLinuxDisplayName(), LinuxDeviceConfiguration::GenericLinuxOsType);
|
||||||
dc->stepList()->insertStep(0, new MaemoTarPackageCreationStep(dc->stepList()));
|
dc->stepList()->insertStep(0, new TarPackageCreationStep(dc->stepList()));
|
||||||
dc->stepList()->insertStep(1, new UploadAndInstallTarPackageStep(dc->stepList()));
|
dc->stepList()->insertStep(1, new UploadAndInstallTarPackageStep(dc->stepList()));
|
||||||
return dc;
|
return dc;
|
||||||
}
|
}
|
||||||
|
|||||||
305
src/plugins/remotelinux/tarpackagecreationstep.cpp
Normal file
305
src/plugins/remotelinux/tarpackagecreationstep.cpp
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** This file may be used under the terms of the GNU Lesser General Public
|
||||||
|
** License version 2.1 as published by the Free Software Foundation and
|
||||||
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||||
|
** Please review the following information to ensure the GNU Lesser General
|
||||||
|
** Public License version 2.1 requirements will be met:
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** Other Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used in accordance with the terms and
|
||||||
|
** conditions contained in a signed written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at info@qt.nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
#include "tarpackagecreationstep.h"
|
||||||
|
|
||||||
|
#include "deployablefile.h"
|
||||||
|
#include "deploymentinfo.h"
|
||||||
|
#include "remotelinuxdeployconfiguration.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QFile>
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
|
namespace RemoteLinux {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class CreateTarStepWidget : public BuildStepConfigWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CreateTarStepWidget(TarPackageCreationStep *step) : m_step(step)
|
||||||
|
{
|
||||||
|
connect(m_step, SIGNAL(packageFilePathChanged()), SIGNAL(updateSummary()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString summaryText() const
|
||||||
|
{
|
||||||
|
if (m_step->packageFilePath().isEmpty()) {
|
||||||
|
return QLatin1String("<font color=\"red\">")
|
||||||
|
+ tr("Tarball creation not possible.") + QLatin1String("</font>");
|
||||||
|
}
|
||||||
|
|
||||||
|
return QLatin1String("<b>") + tr("Create tarball:") + QLatin1String("</b> ")
|
||||||
|
+ m_step->packageFilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString displayName() const { return QString(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
const TarPackageCreationStep * const m_step;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const int TarBlockSize = 512;
|
||||||
|
struct TarFileHeader {
|
||||||
|
char fileName[100];
|
||||||
|
char fileMode[8];
|
||||||
|
char uid[8];
|
||||||
|
char gid[8];
|
||||||
|
char length[12];
|
||||||
|
char mtime[12];
|
||||||
|
char chksum[8];
|
||||||
|
char typeflag;
|
||||||
|
char linkname[100];
|
||||||
|
char magic[6];
|
||||||
|
char version[2];
|
||||||
|
char uname[32];
|
||||||
|
char gname[32];
|
||||||
|
char devmajor[8];
|
||||||
|
char devminor[8];
|
||||||
|
char fileNamePrefix[155];
|
||||||
|
char padding[12];
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Anonymous namespace.
|
||||||
|
|
||||||
|
TarPackageCreationStep::TarPackageCreationStep(BuildStepList *bsl)
|
||||||
|
: AbstractPackagingStep(bsl, stepId())
|
||||||
|
{
|
||||||
|
ctor();
|
||||||
|
}
|
||||||
|
|
||||||
|
TarPackageCreationStep::TarPackageCreationStep(BuildStepList *bsl, TarPackageCreationStep *other)
|
||||||
|
: AbstractPackagingStep(bsl, other)
|
||||||
|
{
|
||||||
|
ctor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TarPackageCreationStep::ctor()
|
||||||
|
{
|
||||||
|
setDefaultDisplayName(displayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TarPackageCreationStep::run(QFutureInterface<bool> &fi)
|
||||||
|
{
|
||||||
|
setPackagingStarted();
|
||||||
|
const bool success = doPackage(fi);
|
||||||
|
setPackagingFinished(success);
|
||||||
|
if (success)
|
||||||
|
emit addOutput(tr("Packaging finished successfully."), MessageOutput);
|
||||||
|
else
|
||||||
|
emit addOutput(tr("Packaging failed."), ErrorMessageOutput);
|
||||||
|
fi.reportResult(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TarPackageCreationStep::doPackage(QFutureInterface<bool> &fi)
|
||||||
|
{
|
||||||
|
emit addOutput(tr("Creating tarball..."), MessageOutput);
|
||||||
|
if (!isPackagingNeeded()) {
|
||||||
|
emit addOutput(tr("Tarball up to date, skipping packaging."), MessageOutput);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Optimization: Only package changed files
|
||||||
|
QFile tarFile(packageFilePath());
|
||||||
|
|
||||||
|
if (!tarFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
|
raiseError(tr("Error: tar file %1 cannot be opened (%2).")
|
||||||
|
.arg(QDir::toNativeSeparators(packageFilePath()), tarFile.errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QSharedPointer<DeploymentInfo> deploymentInfo = deployConfiguration()->deploymentInfo();
|
||||||
|
for (int i = 0; i < deploymentInfo->deployableCount(); ++i) {
|
||||||
|
const DeployableFile &d = deploymentInfo->deployableAt(i);
|
||||||
|
QFileInfo fileInfo(d.localFilePath);
|
||||||
|
if (!appendFile(tarFile, fileInfo, d.remoteDir + QLatin1Char('/')
|
||||||
|
+ fileInfo.fileName(), fi)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const QByteArray eofIndicator(2*sizeof(TarFileHeader), 0);
|
||||||
|
if (tarFile.write(eofIndicator) != eofIndicator.length()) {
|
||||||
|
raiseError(tr("Error writing tar file '%1': %2.")
|
||||||
|
.arg(QDir::toNativeSeparators(tarFile.fileName()), tarFile.errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TarPackageCreationStep::appendFile(QFile &tarFile, const QFileInfo &fileInfo,
|
||||||
|
const QString &remoteFilePath, const QFutureInterface<bool> &fi)
|
||||||
|
{
|
||||||
|
if (!writeHeader(tarFile, fileInfo, remoteFilePath))
|
||||||
|
return false;
|
||||||
|
if (fileInfo.isDir()) {
|
||||||
|
QDir dir(fileInfo.absoluteFilePath());
|
||||||
|
foreach (const QString &fileName,
|
||||||
|
dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) {
|
||||||
|
const QString thisLocalFilePath = dir.path() + QLatin1Char('/') + fileName;
|
||||||
|
const QString thisRemoteFilePath = remoteFilePath + QLatin1Char('/') + fileName;
|
||||||
|
if (!appendFile(tarFile, QFileInfo(thisLocalFilePath), thisRemoteFilePath, fi))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString nativePath = QDir::toNativeSeparators(fileInfo.filePath());
|
||||||
|
QFile file(fileInfo.filePath());
|
||||||
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
raiseError(tr("Error reading file '%1': %2.").arg(nativePath, file.errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int chunkSize = 1024*1024;
|
||||||
|
|
||||||
|
emit addOutput(tr("Adding file '%1' to tarball...").arg(nativePath), MessageOutput);
|
||||||
|
|
||||||
|
// TODO: Wasteful. Work with fixed-size buffer.
|
||||||
|
while (!file.atEnd() && !file.error() != QFile::NoError && !tarFile.error() != QFile::NoError) {
|
||||||
|
const QByteArray data = file.read(chunkSize);
|
||||||
|
tarFile.write(data);
|
||||||
|
if (fi.isCanceled())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (file.error() != QFile::NoError) {
|
||||||
|
raiseError(tr("Error reading file '%1': %2.").arg(nativePath, file.errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int blockModulo = file.size() % TarBlockSize;
|
||||||
|
if (blockModulo != 0)
|
||||||
|
tarFile.write(QByteArray(TarBlockSize - blockModulo, 0));
|
||||||
|
|
||||||
|
if (tarFile.error() != QFile::NoError) {
|
||||||
|
raiseError(tr("Error writing tar file '%1': %2.")
|
||||||
|
.arg(QDir::toNativeSeparators(tarFile.fileName()), tarFile.errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileInfo,
|
||||||
|
const QString &remoteFilePath)
|
||||||
|
{
|
||||||
|
TarFileHeader header;
|
||||||
|
qMemSet(&header, '\0', sizeof header);
|
||||||
|
const QByteArray &filePath = remoteFilePath.toUtf8();
|
||||||
|
const int maxFilePathLength = sizeof header.fileNamePrefix + sizeof header.fileName;
|
||||||
|
if (filePath.count() > maxFilePathLength) {
|
||||||
|
raiseError(tr("Cannot add file '%1' to tar-archive: path too long.")
|
||||||
|
.arg(QDir::toNativeSeparators(filePath)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int fileNameBytesToWrite = qMin<int>(filePath.length(), sizeof header.fileName);
|
||||||
|
const int fileNameOffset = filePath.length() - fileNameBytesToWrite;
|
||||||
|
qMemCopy(&header.fileName, filePath.data() + fileNameOffset, fileNameBytesToWrite);
|
||||||
|
if (fileNameOffset > 0)
|
||||||
|
qMemCopy(&header.fileNamePrefix, filePath.data(), fileNameOffset);
|
||||||
|
int permissions = (0400 * fileInfo.permission(QFile::ReadOwner))
|
||||||
|
| (0200 * fileInfo.permission(QFile::WriteOwner))
|
||||||
|
| (0100 * fileInfo.permission(QFile::ExeOwner))
|
||||||
|
| (040 * fileInfo.permission(QFile::ReadGroup))
|
||||||
|
| (020 * fileInfo.permission(QFile::WriteGroup))
|
||||||
|
| (010 * fileInfo.permission(QFile::ExeGroup))
|
||||||
|
| (04 * fileInfo.permission(QFile::ReadOther))
|
||||||
|
| (02 * fileInfo.permission(QFile::WriteOther))
|
||||||
|
| (01 * fileInfo.permission(QFile::ExeOther));
|
||||||
|
const QByteArray permissionString = QString("%1").arg(permissions,
|
||||||
|
sizeof header.fileMode - 1, 8, QLatin1Char('0')).toAscii();
|
||||||
|
qMemCopy(&header.fileMode, permissionString.data(), permissionString.length());
|
||||||
|
const QByteArray uidString = QString("%1").arg(fileInfo.ownerId(),
|
||||||
|
sizeof header.uid - 1, 8, QLatin1Char('0')).toAscii();
|
||||||
|
qMemCopy(&header.uid, uidString.data(), uidString.length());
|
||||||
|
const QByteArray gidString = QString("%1").arg(fileInfo.groupId(),
|
||||||
|
sizeof header.gid - 1, 8, QLatin1Char('0')).toAscii();
|
||||||
|
qMemCopy(&header.gid, gidString.data(), gidString.length());
|
||||||
|
const QByteArray sizeString = QString("%1").arg(fileInfo.size(),
|
||||||
|
sizeof header.length - 1, 8, QLatin1Char('0')).toAscii();
|
||||||
|
qMemCopy(&header.length, sizeString.data(), sizeString.length());
|
||||||
|
const QByteArray mtimeString = QString("%1").arg(fileInfo.lastModified().toTime_t(),
|
||||||
|
sizeof header.mtime - 1, 8, QLatin1Char('0')).toAscii();
|
||||||
|
qMemCopy(&header.mtime, mtimeString.data(), mtimeString.length());
|
||||||
|
if (fileInfo.isDir())
|
||||||
|
header.typeflag = '5';
|
||||||
|
qMemCopy(&header.magic, "ustar", sizeof "ustar");
|
||||||
|
qMemCopy(&header.version, "00", 2);
|
||||||
|
const QByteArray &owner = fileInfo.owner().toUtf8();
|
||||||
|
qMemCopy(&header.uname, owner.data(), qMin<int>(owner.length(), sizeof header.uname - 1));
|
||||||
|
const QByteArray &group = fileInfo.group().toUtf8();
|
||||||
|
qMemCopy(&header.gname, group.data(), qMin<int>(group.length(), sizeof header.gname - 1));
|
||||||
|
qMemSet(&header.chksum, ' ', sizeof header.chksum);
|
||||||
|
quint64 checksum = 0;
|
||||||
|
for (size_t i = 0; i < sizeof header; ++i)
|
||||||
|
checksum += reinterpret_cast<char *>(&header)[i];
|
||||||
|
const QByteArray checksumString = QString("%1").arg(checksum,
|
||||||
|
sizeof header.chksum - 1, 8, QLatin1Char('0')).toAscii();
|
||||||
|
qMemCopy(&header.chksum, checksumString.data(), checksumString.length());
|
||||||
|
header.chksum[sizeof header.chksum-1] = 0;
|
||||||
|
if (!tarFile.write(reinterpret_cast<char *>(&header), sizeof header)) {
|
||||||
|
raiseError(tr("Error writing tar file '%1': %2")
|
||||||
|
.arg(QDir::toNativeSeparators(packageFilePath()), tarFile.errorString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TarPackageCreationStep::packageFileName() const
|
||||||
|
{
|
||||||
|
return target()->project()->displayName() + QLatin1String(".tar");
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildStepConfigWidget *TarPackageCreationStep::createConfigWidget()
|
||||||
|
{
|
||||||
|
return new CreateTarStepWidget(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TarPackageCreationStep::stepId()
|
||||||
|
{
|
||||||
|
return QLatin1String("MaemoTarPackageCreationStep");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TarPackageCreationStep::displayName()
|
||||||
|
{
|
||||||
|
return tr("Create tarball");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace RemoteLinux
|
||||||
|
|
||||||
|
#include "tarpackagecreationstep.moc"
|
||||||
70
src/plugins/remotelinux/tarpackagecreationstep.h
Normal file
70
src/plugins/remotelinux/tarpackagecreationstep.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** This file may be used under the terms of the GNU Lesser General Public
|
||||||
|
** License version 2.1 as published by the Free Software Foundation and
|
||||||
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||||
|
** Please review the following information to ensure the GNU Lesser General
|
||||||
|
** Public License version 2.1 requirements will be met:
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Nokia gives you certain additional
|
||||||
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
** Other Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used in accordance with the terms and
|
||||||
|
** conditions contained in a signed written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** If you have questions regarding the use of this file, please contact
|
||||||
|
** Nokia at info@qt.nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
#ifndef TARPACKAGECREATIONSTEP_H
|
||||||
|
#define TARPACKAGECREATIONSTEP_H
|
||||||
|
|
||||||
|
#include "abstractpackagingstep.h"
|
||||||
|
#include "remotelinux_export.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QFile;
|
||||||
|
class QFileInfo;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace RemoteLinux {
|
||||||
|
|
||||||
|
class REMOTELINUX_EXPORT TarPackageCreationStep : public AbstractPackagingStep
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
TarPackageCreationStep(ProjectExplorer::BuildStepList *bsl);
|
||||||
|
TarPackageCreationStep(ProjectExplorer::BuildStepList *bsl, TarPackageCreationStep *other);
|
||||||
|
|
||||||
|
static QString stepId();
|
||||||
|
static QString displayName();
|
||||||
|
|
||||||
|
void run(QFutureInterface<bool> &fi);
|
||||||
|
private:
|
||||||
|
ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||||
|
|
||||||
|
QString packageFileName() const;
|
||||||
|
|
||||||
|
void ctor();
|
||||||
|
bool doPackage(QFutureInterface<bool> &fi);
|
||||||
|
bool appendFile(QFile &tarFile, const QFileInfo &fileInfo,
|
||||||
|
const QString &remoteFilePath, const QFutureInterface<bool> &fi);
|
||||||
|
bool writeHeader(QFile &tarFile, const QFileInfo &fileInfo,
|
||||||
|
const QString &remoteFilePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace RemoteLinux
|
||||||
|
|
||||||
|
#endif // TARPACKAGECREATIONSTEP_H
|
||||||
@@ -32,9 +32,9 @@
|
|||||||
#include "uploadandinstalltarpackagestep.h"
|
#include "uploadandinstalltarpackagestep.h"
|
||||||
|
|
||||||
#include "maemoglobal.h"
|
#include "maemoglobal.h"
|
||||||
#include "maemopackagecreationstep.h"
|
|
||||||
#include "maemopackageinstaller.h"
|
#include "maemopackageinstaller.h"
|
||||||
#include "qt4maemodeployconfiguration.h"
|
#include "remotelinuxdeployconfiguration.h"
|
||||||
|
#include "tarpackagecreationstep.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ void UploadAndInstallTarPackageStep::ctor()
|
|||||||
|
|
||||||
bool UploadAndInstallTarPackageStep::isDeploymentPossible(QString *whyNot) const
|
bool UploadAndInstallTarPackageStep::isDeploymentPossible(QString *whyNot) const
|
||||||
{
|
{
|
||||||
const AbstractMaemoPackageCreationStep * const pStep
|
const TarPackageCreationStep * const pStep
|
||||||
= MaemoGlobal::earlierBuildStep<MaemoTarPackageCreationStep>(deployConfiguration(), this);
|
= MaemoGlobal::earlierBuildStep<TarPackageCreationStep>(deployConfiguration(), this);
|
||||||
if (!pStep) {
|
if (!pStep) {
|
||||||
if (whyNot)
|
if (whyNot)
|
||||||
*whyNot = tr("No tarball creation step found.");
|
*whyNot = tr("No tarball creation step found.");
|
||||||
|
|||||||
Reference in New Issue
Block a user