forked from qt-creator/qt-creator
Start making the Maemo support more generic.
This includes:
- decoupling deploy configurations from targets (Reviewed-by: dt)
- adding a "Generic Linux" device type
- splitting up the Maemo deployment step into small pieces that
can be combined in different ways (and much more easily maintained)
- adding a new version handler for pro.user files
(Reviewed-by: Tobias Hunger)
Also:
- Add and use an SSH manager class for easier connection sharing.
- Make the SSH connection parameters a fixed attribute of the connection.
This commit is contained in:
@@ -43,9 +43,9 @@
|
||||
|
||||
#include "maemoconstants.h"
|
||||
#include "maemodeployables.h"
|
||||
#include "maemodeploystep.h"
|
||||
#include "maemoglobal.h"
|
||||
#include "maemopackagecreationwidget.h"
|
||||
#include "qt4maemodeployconfiguration.h"
|
||||
#include "qt4maemotarget.h"
|
||||
|
||||
#include <projectexplorer/buildsteplist.h>
|
||||
@@ -62,7 +62,6 @@
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
namespace {
|
||||
const QLatin1String PackagingEnabledKey("Packaging Enabled");
|
||||
const QLatin1String MagicFileName(".qtcreator");
|
||||
}
|
||||
|
||||
@@ -74,31 +73,27 @@ using ProjectExplorer::Task;
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
const QLatin1String MaemoPackageCreationStep::DefaultVersionNumber("0.0.1");
|
||||
const QLatin1String AbstractMaemoPackageCreationStep::DefaultVersionNumber("0.0.1");
|
||||
|
||||
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildStepList *bsl)
|
||||
: ProjectExplorer::BuildStep(bsl, CreatePackageId),
|
||||
m_packagingEnabled(true)
|
||||
AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl,
|
||||
const QString &id)
|
||||
: ProjectExplorer::BuildStep(bsl, id)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
MaemoPackageCreationStep::MaemoPackageCreationStep(BuildStepList *bsl,
|
||||
MaemoPackageCreationStep *other)
|
||||
: BuildStep(bsl, other),
|
||||
m_packagingEnabled(other->m_packagingEnabled)
|
||||
AbstractMaemoPackageCreationStep::AbstractMaemoPackageCreationStep(BuildStepList *bsl,
|
||||
AbstractMaemoPackageCreationStep *other) : BuildStep(bsl, other)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
MaemoPackageCreationStep::~MaemoPackageCreationStep()
|
||||
AbstractMaemoPackageCreationStep::~AbstractMaemoPackageCreationStep()
|
||||
{
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::ctor()
|
||||
void AbstractMaemoPackageCreationStep::ctor()
|
||||
{
|
||||
setDefaultDisplayName(tr("Packaging for Maemo"));
|
||||
|
||||
m_lastBuildConfig = qt4BuildConfiguration();
|
||||
connect(target(),
|
||||
SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
||||
@@ -106,144 +101,278 @@ void MaemoPackageCreationStep::ctor()
|
||||
handleBuildConfigChanged();
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::init()
|
||||
bool AbstractMaemoPackageCreationStep::init()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariantMap MaemoPackageCreationStep::toMap() const
|
||||
void AbstractMaemoPackageCreationStep::run(QFutureInterface<bool> &fi)
|
||||
{
|
||||
QVariantMap map(ProjectExplorer::BuildStep::toMap());
|
||||
map.insert(PackagingEnabledKey, m_packagingEnabled);
|
||||
return map;
|
||||
}
|
||||
if (!packagingNeeded()) {
|
||||
emit addOutput(tr("Package up to date."), MessageOutput);
|
||||
fi.reportResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_packagingEnabled = map.value(PackagingEnabledKey, true).toBool();
|
||||
return ProjectExplorer::BuildStep::fromMap(map);
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::run(QFutureInterface<bool> &fi)
|
||||
{
|
||||
bool success;
|
||||
if (m_packagingEnabled) {
|
||||
// TODO: Make the build process asynchronous; i.e. no waitFor()-functions etc.
|
||||
QProcess * const buildProc = new QProcess;
|
||||
connect(buildProc, SIGNAL(readyReadStandardOutput()), this,
|
||||
SLOT(handleBuildOutput()));
|
||||
connect(buildProc, SIGNAL(readyReadStandardError()), this,
|
||||
SLOT(handleBuildOutput()));
|
||||
success = createPackage(buildProc);
|
||||
disconnect(buildProc, 0, this, 0);
|
||||
buildProc->deleteLater();
|
||||
} else {
|
||||
success = true;
|
||||
// TODO: Make the build process asynchronous; i.e. no waitFor()-functions etc.
|
||||
QProcess * const buildProc = new QProcess;
|
||||
connect(buildProc, SIGNAL(readyReadStandardOutput()), this,
|
||||
SLOT(handleBuildOutput()));
|
||||
connect(buildProc, SIGNAL(readyReadStandardError()), this,
|
||||
SLOT(handleBuildOutput()));
|
||||
emit addOutput(tr("Creating package file ..."), MessageOutput);
|
||||
const bool success = createPackage(buildProc);
|
||||
disconnect(buildProc, 0, this, 0);
|
||||
buildProc->deleteLater();
|
||||
if (success) {
|
||||
emit addOutput(tr("Package created."), BuildStep::MessageOutput);
|
||||
deployConfig()->deployables()->setUnmodified();
|
||||
}
|
||||
fi.reportResult(success);
|
||||
}
|
||||
|
||||
BuildStepConfigWidget *MaemoPackageCreationStep::createConfigWidget()
|
||||
BuildStepConfigWidget *AbstractMaemoPackageCreationStep::createConfigWidget()
|
||||
{
|
||||
return new MaemoPackageCreationWidget(this);
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::createPackage(QProcess *buildProc)
|
||||
void AbstractMaemoPackageCreationStep::handleBuildOutput()
|
||||
{
|
||||
if (!packagingNeeded()) {
|
||||
emit addOutput(tr("Package up to date."), MessageOutput);
|
||||
QProcess * const buildProc = qobject_cast<QProcess *>(sender());
|
||||
if (!buildProc)
|
||||
return;
|
||||
const QByteArray &stdOut = buildProc->readAllStandardOutput();
|
||||
if (!stdOut.isEmpty())
|
||||
emit addOutput(QString::fromLocal8Bit(stdOut), BuildStep::NormalOutput);
|
||||
const QByteArray &errorOut = buildProc->readAllStandardError();
|
||||
if (!errorOut.isEmpty()) {
|
||||
emit addOutput(QString::fromLocal8Bit(errorOut), BuildStep::ErrorOutput);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
||||
}
|
||||
|
||||
AbstractQt4MaemoTarget *AbstractMaemoPackageCreationStep::maemoTarget() const
|
||||
{
|
||||
return qobject_cast<AbstractQt4MaemoTarget *>(buildConfiguration()->target());
|
||||
}
|
||||
|
||||
AbstractDebBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::debBasedMaemoTarget() const
|
||||
{
|
||||
return qobject_cast<AbstractDebBasedQt4MaemoTarget*>(buildConfiguration()->target());
|
||||
}
|
||||
|
||||
AbstractRpmBasedQt4MaemoTarget *AbstractMaemoPackageCreationStep::rpmBasedMaemoTarget() const
|
||||
{
|
||||
return qobject_cast<AbstractRpmBasedQt4MaemoTarget*>(buildConfiguration()->target());
|
||||
}
|
||||
|
||||
Qt4MaemoDeployConfiguration *AbstractMaemoPackageCreationStep::deployConfig() const
|
||||
{
|
||||
return qobject_cast<Qt4MaemoDeployConfiguration *>(parent()->parent());
|
||||
}
|
||||
|
||||
QString AbstractMaemoPackageCreationStep::buildDirectory() const
|
||||
{
|
||||
return qt4BuildConfiguration()->buildDirectory();
|
||||
}
|
||||
|
||||
QString AbstractMaemoPackageCreationStep::projectName() const
|
||||
{
|
||||
return qt4BuildConfiguration()->qt4Target()->qt4Project()
|
||||
->rootProjectNode()->displayName().toLower();
|
||||
}
|
||||
|
||||
bool AbstractMaemoPackageCreationStep::packagingNeeded() const
|
||||
{
|
||||
const QSharedPointer<MaemoDeployables> &deployables
|
||||
= deployConfig()->deployables();
|
||||
QFileInfo packageInfo(packageFilePath());
|
||||
if (!packageInfo.exists() || deployables->isModified())
|
||||
return true;
|
||||
|
||||
const int deployableCount = deployables->deployableCount();
|
||||
for (int i = 0; i < deployableCount; ++i) {
|
||||
if (MaemoGlobal::isFileNewerThan(deployables->deployableAt(i).localFilePath,
|
||||
packageInfo.lastModified()))
|
||||
return true;
|
||||
}
|
||||
|
||||
emit addOutput(tr("Creating package file ..."), MessageOutput);
|
||||
checkProjectName();
|
||||
preparePackagingProcess(buildProc, qt4BuildConfiguration(),
|
||||
buildDirectory());
|
||||
return isMetaDataNewerThan(packageInfo.lastModified());
|
||||
}
|
||||
|
||||
QString AbstractMaemoPackageCreationStep::packageFilePath() const
|
||||
{
|
||||
QString error;
|
||||
const QString &version = versionString(&error);
|
||||
if (version.isEmpty())
|
||||
return QString();
|
||||
QFileInfo fi(maemoTarget()->packageFileName());
|
||||
const QString baseName = replaceDots(fi.completeBaseName());
|
||||
return buildDirectory() + QLatin1Char('/') + baseName
|
||||
+ QLatin1Char('.') + fi.suffix();
|
||||
}
|
||||
|
||||
QString AbstractMaemoPackageCreationStep::versionString(QString *error) const
|
||||
{
|
||||
return maemoTarget()->projectVersion(error);
|
||||
}
|
||||
|
||||
bool AbstractMaemoPackageCreationStep::setVersionString(const QString &version,
|
||||
QString *error)
|
||||
{
|
||||
const bool success = maemoTarget()->setProjectVersion(version, error);
|
||||
if (success)
|
||||
emit packageFilePathChanged();
|
||||
return success;
|
||||
}
|
||||
|
||||
QString AbstractMaemoPackageCreationStep::nativePath(const QFile &file)
|
||||
{
|
||||
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,
|
||||
const QStringList &arguments)
|
||||
{
|
||||
preparePackagingProcess(proc, qt4BuildConfiguration(), buildDirectory());
|
||||
const QtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion();
|
||||
const QString madCommand = MaemoGlobal::madCommand(qtVersion);
|
||||
const QString cmdLine = madCommand + QLatin1Char(' ')
|
||||
+ arguments.join(QLatin1String(" "));
|
||||
emit addOutput(tr("Package Creation: Running command '%1'.").arg(cmdLine),
|
||||
BuildStep::MessageOutput);
|
||||
MaemoGlobal::callMad(*proc, arguments, qtVersion, true);
|
||||
if (!proc->waitForStarted()) {
|
||||
raiseError(tr("Packaging failed."),
|
||||
tr("Packaging error: Could not start command '%1'. Reason: %2")
|
||||
.arg(cmdLine, proc->errorString()));
|
||||
return false;
|
||||
}
|
||||
proc->waitForFinished(-1);
|
||||
if (proc->error() != QProcess::UnknownError || proc->exitCode() != 0) {
|
||||
QString mainMessage = tr("Packaging Error: Command '%1' failed.")
|
||||
.arg(cmdLine);
|
||||
if (proc->error() != QProcess::UnknownError)
|
||||
mainMessage += tr(" Reason: %1").arg(proc->errorString());
|
||||
else
|
||||
mainMessage += tr("Exit code: %1").arg(proc->exitCode());
|
||||
raiseError(mainMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void AbstractMaemoPackageCreationStep::preparePackagingProcess(QProcess *proc,
|
||||
const Qt4BuildConfiguration *bc, const QString &workingDir)
|
||||
{
|
||||
Utils::Environment env = bc->environment();
|
||||
if (bc->qmakeBuildConfiguration() & QtVersion::DebugBuild) {
|
||||
env.appendOrSet(QLatin1String("DEB_BUILD_OPTIONS"),
|
||||
QLatin1String("nostrip"), QLatin1String(" "));
|
||||
}
|
||||
proc->setEnvironment(env.toStringList());
|
||||
proc->setWorkingDirectory(workingDir);
|
||||
}
|
||||
|
||||
QString AbstractMaemoPackageCreationStep::replaceDots(const QString &name)
|
||||
{
|
||||
QString adaptedName = name;
|
||||
return adaptedName.replace(QLatin1Char('.'), QLatin1Char('_'));
|
||||
}
|
||||
|
||||
|
||||
MaemoDebianPackageCreationStep::MaemoDebianPackageCreationStep(BuildStepList *bsl)
|
||||
: AbstractMaemoPackageCreationStep(bsl, CreatePackageId)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
const QString MaemoDebianPackageCreationStep::CreatePackageId
|
||||
= QLatin1String("MaemoDebianPackageCreationStep");
|
||||
|
||||
MaemoDebianPackageCreationStep::MaemoDebianPackageCreationStep(BuildStepList *buildConfig,
|
||||
MaemoDebianPackageCreationStep *other)
|
||||
: AbstractMaemoPackageCreationStep(buildConfig, other)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
void MaemoDebianPackageCreationStep::ctor()
|
||||
{
|
||||
setDefaultDisplayName(tr("Create Debian Package"));
|
||||
}
|
||||
|
||||
bool MaemoDebianPackageCreationStep::createPackage(QProcess *buildProc)
|
||||
{
|
||||
checkProjectName();
|
||||
const QString projectDir
|
||||
= buildConfiguration()->target()->project()->projectDirectory();
|
||||
const bool inSourceBuild
|
||||
= QFileInfo(buildDirectory()) == QFileInfo(projectDir);
|
||||
if (debBasedMaemoTarget() && !copyDebianFiles(inSourceBuild))
|
||||
if (!copyDebianFiles(inSourceBuild))
|
||||
return false;
|
||||
|
||||
const QtVersion * const qtVersion = qt4BuildConfiguration()->qtVersion();
|
||||
const QString madCommand = MaemoGlobal::madCommand(qtVersion);
|
||||
QStringList args;
|
||||
if (debBasedMaemoTarget()) {
|
||||
args << QLatin1String("dpkg-buildpackage") << QLatin1String("-nc")
|
||||
<< QLatin1String("-uc") << QLatin1String("-us");
|
||||
} else {
|
||||
args << QLatin1String("rrpmbuild") << QLatin1String("-bb")
|
||||
<< rpmBasedMaemoTarget()->specFilePath();
|
||||
}
|
||||
const QString cmdLine = madCommand + QLatin1Char(' ')
|
||||
+ args.join(QLatin1String(" "));
|
||||
emit addOutput(tr("Package Creation: Running command '%1'.").arg(cmdLine),
|
||||
BuildStep::MessageOutput);
|
||||
MaemoGlobal::callMad(*buildProc, args, qtVersion, true);
|
||||
if (!buildProc->waitForStarted()) {
|
||||
raiseError(tr("Packaging failed."),
|
||||
tr("Packaging error: Could not start command '%1'. Reason: %2")
|
||||
.arg(cmdLine, buildProc->errorString()));
|
||||
const QStringList args = QStringList() << QLatin1String("dpkg-buildpackage")
|
||||
<< QLatin1String("-nc") << QLatin1String("-uc") << QLatin1String("-us");
|
||||
if (!callPackagingCommand(buildProc, args))
|
||||
return false;
|
||||
}
|
||||
buildProc->waitForFinished(-1);
|
||||
if (buildProc->error() != QProcess::UnknownError
|
||||
|| buildProc->exitCode() != 0) {
|
||||
QString mainMessage = tr("Packaging Error: Command '%1' failed.")
|
||||
.arg(cmdLine);
|
||||
if (buildProc->error() != QProcess::UnknownError)
|
||||
mainMessage += tr(" Reason: %1").arg(buildProc->errorString());
|
||||
else
|
||||
mainMessage += tr("Exit code: %1").arg(buildProc->exitCode());
|
||||
raiseError(mainMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile::remove(packageFilePath());
|
||||
if (debBasedMaemoTarget()) {
|
||||
// Workaround for non-working dh_builddeb --destdir=.
|
||||
if (!QDir(buildDirectory()).isRoot()) {
|
||||
const AbstractQt4MaemoTarget * const target = maemoTarget();
|
||||
QString error;
|
||||
const QString pkgFileName = target->packageFileName();
|
||||
if (!error.isEmpty())
|
||||
raiseError(tr("Packaging failed."), "Failed to get package name.");
|
||||
const QString changesSourceFileName = QFileInfo(pkgFileName).completeBaseName()
|
||||
|
||||
// Workaround for non-working dh_builddeb --destdir=.
|
||||
if (!QDir(buildDirectory()).isRoot()) {
|
||||
const AbstractQt4MaemoTarget * const target = maemoTarget();
|
||||
QString error;
|
||||
const QString pkgFileName = target->packageFileName();
|
||||
if (!error.isEmpty())
|
||||
raiseError(tr("Packaging failed."), "Failed to get package name.");
|
||||
const QString changesSourceFileName = QFileInfo(pkgFileName).completeBaseName()
|
||||
+ QLatin1String(".changes");
|
||||
const QString changesTargetFileName = replaceDots(QFileInfo(pkgFileName).completeBaseName())
|
||||
const QString changesTargetFileName = replaceDots(QFileInfo(pkgFileName).completeBaseName())
|
||||
+ QLatin1String(".changes");
|
||||
const QString packageSourceDir = buildDirectory() + QLatin1String("/../");
|
||||
const QString packageSourceFilePath
|
||||
const QString packageSourceDir = buildDirectory() + QLatin1String("/../");
|
||||
const QString packageSourceFilePath
|
||||
= packageSourceDir + pkgFileName;
|
||||
const QString changesSourceFilePath
|
||||
const QString changesSourceFilePath
|
||||
= packageSourceDir + changesSourceFileName;
|
||||
const QString changesTargetFilePath
|
||||
const QString changesTargetFilePath
|
||||
= buildDirectory() + QLatin1Char('/') + changesTargetFileName;
|
||||
QFile::remove(changesTargetFilePath);
|
||||
if (!QFile::rename(packageSourceFilePath, packageFilePath())
|
||||
|| !QFile::rename(changesSourceFilePath, changesTargetFilePath)) {
|
||||
raiseError(tr("Packaging failed."),
|
||||
tr("Could not move package files from %1 to %2.")
|
||||
.arg(packageSourceDir, buildDirectory()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const QString packageSourceFilePath = rpmBuildDir(qt4BuildConfiguration())
|
||||
+ QLatin1Char('/') + rpmBasedMaemoTarget()->packageFileName();
|
||||
if (!QFile::rename(packageSourceFilePath, packageFilePath())) {
|
||||
QFile::remove(changesTargetFilePath);
|
||||
if (!QFile::rename(packageSourceFilePath, packageFilePath())
|
||||
|| !QFile::rename(changesSourceFilePath, changesTargetFilePath)) {
|
||||
raiseError(tr("Packaging failed."),
|
||||
tr("Could not move package file from %1 to %2.")
|
||||
.arg(packageSourceFilePath, packageFilePath()));
|
||||
tr("Could not move package files from %1 to %2.")
|
||||
.arg(packageSourceDir, buildDirectory()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
emit addOutput(tr("Package created."), BuildStep::MessageOutput);
|
||||
deployStep()->deployables()->setUnmodified();
|
||||
if (inSourceBuild && debBasedMaemoTarget()) {
|
||||
if (inSourceBuild) {
|
||||
buildProc->start(packagingCommand(qt4BuildConfiguration(),
|
||||
QLatin1String("dh_clean")));
|
||||
buildProc->waitForFinished();
|
||||
@@ -252,7 +381,35 @@ bool MaemoPackageCreationStep::createPackage(QProcess *buildProc)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::copyDebianFiles(bool inSourceBuild)
|
||||
bool MaemoDebianPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const
|
||||
{
|
||||
const QString debianPath = debBasedMaemoTarget()->debianDirPath();
|
||||
if (packageDate <= QFileInfo(debianPath).lastModified())
|
||||
return true;
|
||||
const QStringList debianFiles = debBasedMaemoTarget()->debianFiles();
|
||||
foreach (const QString &debianFile, debianFiles) {
|
||||
const QString absFilePath
|
||||
= debianPath + QLatin1Char('/') + debianFile;
|
||||
if (packageDate <= QFileInfo(absFilePath).lastModified())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MaemoDebianPackageCreationStep::checkProjectName()
|
||||
{
|
||||
const QRegExp legalName(QLatin1String("[0-9-+a-z\\.]+"));
|
||||
if (!legalName.exactMatch(buildConfiguration()->target()->project()->displayName())) {
|
||||
emit addTask(Task(Task::Warning,
|
||||
tr("Your project name contains characters not allowed in "
|
||||
"Debian packages.\nThey must only use lower-case letters, "
|
||||
"numbers, '-', '+' and '.'.\n""We will try to work around that, "
|
||||
"but you may experience problems."),
|
||||
QString(), -1, TASK_CATEGORY_BUILDSYSTEM));
|
||||
}
|
||||
}
|
||||
|
||||
bool MaemoDebianPackageCreationStep::copyDebianFiles(bool inSourceBuild)
|
||||
{
|
||||
const QString debianDirPath = buildDirectory() + QLatin1String("/debian");
|
||||
const QString magicFilePath
|
||||
@@ -308,185 +465,7 @@ bool MaemoPackageCreationStep::copyDebianFiles(bool inSourceBuild)
|
||||
return true;
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::handleBuildOutput()
|
||||
{
|
||||
QProcess * const buildProc = qobject_cast<QProcess *>(sender());
|
||||
if (!buildProc)
|
||||
return;
|
||||
const QByteArray &stdOut = buildProc->readAllStandardOutput();
|
||||
if (!stdOut.isEmpty())
|
||||
emit addOutput(QString::fromLocal8Bit(stdOut), BuildStep::NormalOutput);
|
||||
const QByteArray &errorOut = buildProc->readAllStandardError();
|
||||
if (!errorOut.isEmpty()) {
|
||||
emit addOutput(QString::fromLocal8Bit(errorOut), BuildStep::ErrorOutput);
|
||||
}
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::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 *MaemoPackageCreationStep::qt4BuildConfiguration() const
|
||||
{
|
||||
return static_cast<Qt4BuildConfiguration *>(buildConfiguration());
|
||||
}
|
||||
|
||||
AbstractQt4MaemoTarget *MaemoPackageCreationStep::maemoTarget() const
|
||||
{
|
||||
return qobject_cast<AbstractQt4MaemoTarget *>(buildConfiguration()->target());
|
||||
}
|
||||
|
||||
AbstractDebBasedQt4MaemoTarget *MaemoPackageCreationStep::debBasedMaemoTarget() const
|
||||
{
|
||||
return qobject_cast<AbstractDebBasedQt4MaemoTarget*>(buildConfiguration()->target());
|
||||
}
|
||||
|
||||
AbstractRpmBasedQt4MaemoTarget *MaemoPackageCreationStep::rpmBasedMaemoTarget() const
|
||||
{
|
||||
return qobject_cast<AbstractRpmBasedQt4MaemoTarget*>(buildConfiguration()->target());
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::buildDirectory() const
|
||||
{
|
||||
return qt4BuildConfiguration()->buildDirectory();
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::projectName() const
|
||||
{
|
||||
return qt4BuildConfiguration()->qt4Target()->qt4Project()
|
||||
->rootProjectNode()->displayName().toLower();
|
||||
}
|
||||
|
||||
MaemoDeployStep *MaemoPackageCreationStep::deployStep() const
|
||||
{
|
||||
MaemoDeployStep * const deployStep
|
||||
= MaemoGlobal::buildStep<MaemoDeployStep>(target()->activeDeployConfiguration());
|
||||
Q_ASSERT(deployStep &&
|
||||
"Fatal error: Maemo build configuration without deploy step.");
|
||||
return deployStep;
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::packagingNeeded() const
|
||||
{
|
||||
const QSharedPointer<MaemoDeployables> &deployables
|
||||
= deployStep()->deployables();
|
||||
QFileInfo packageInfo(packageFilePath());
|
||||
if (!packageInfo.exists() || deployables->isModified())
|
||||
return true;
|
||||
|
||||
const int deployableCount = deployables->deployableCount();
|
||||
for (int i = 0; i < deployableCount; ++i) {
|
||||
if (isFileNewerThan(deployables->deployableAt(i).localFilePath,
|
||||
packageInfo.lastModified()))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (debBasedMaemoTarget()) {
|
||||
const QString debianPath = debBasedMaemoTarget()->debianDirPath();
|
||||
if (packageInfo.lastModified() <= QFileInfo(debianPath).lastModified())
|
||||
return true;
|
||||
const QStringList debianFiles = debBasedMaemoTarget()->debianFiles();
|
||||
foreach (const QString &debianFile, debianFiles) {
|
||||
const QString absFilePath
|
||||
= debianPath + QLatin1Char('/') + debianFile;
|
||||
if (packageInfo.lastModified() <= QFileInfo(absFilePath).lastModified())
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
const QDateTime specFileChangeDate
|
||||
= QFileInfo(rpmBasedMaemoTarget()->specFilePath()).lastModified();
|
||||
if (packageInfo.lastModified() <= specFileChangeDate)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::isFileNewerThan(const QString &filePath,
|
||||
const QDateTime &timeStamp) const
|
||||
{
|
||||
QFileInfo fileInfo(filePath);
|
||||
if (!fileInfo.exists() || fileInfo.lastModified() >= timeStamp)
|
||||
return true;
|
||||
if (fileInfo.isDir()) {
|
||||
const QStringList dirContents = QDir(filePath)
|
||||
.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
foreach (const QString &curFileName, dirContents) {
|
||||
const QString curFilePath
|
||||
= filePath + QLatin1Char('/') + curFileName;
|
||||
if (isFileNewerThan(curFilePath, timeStamp))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::packageFilePath() const
|
||||
{
|
||||
QString error;
|
||||
const QString &version = versionString(&error);
|
||||
if (version.isEmpty())
|
||||
return QString();
|
||||
QFileInfo fi(maemoTarget()->packageFileName());
|
||||
const QString baseName = replaceDots(fi.completeBaseName());
|
||||
return buildDirectory() + QLatin1Char('/') + baseName
|
||||
+ QLatin1Char('.') + fi.suffix();
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::isPackagingEnabled() const
|
||||
{
|
||||
return m_packagingEnabled || !maemoTarget()->allowsPackagingDisabling();
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::versionString(QString *error) const
|
||||
{
|
||||
return maemoTarget()->projectVersion(error);
|
||||
}
|
||||
|
||||
bool MaemoPackageCreationStep::setVersionString(const QString &version,
|
||||
QString *error)
|
||||
{
|
||||
const bool success = maemoTarget()->setProjectVersion(version, error);
|
||||
if (success)
|
||||
emit packageFilePathChanged();
|
||||
return success;
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::nativePath(const QFile &file)
|
||||
{
|
||||
return QDir::toNativeSeparators(QFileInfo(file).filePath());
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::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));
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::preparePackagingProcess(QProcess *proc,
|
||||
const Qt4BuildConfiguration *bc, const QString &workingDir)
|
||||
{
|
||||
Utils::Environment env = bc->environment();
|
||||
if (bc->qmakeBuildConfiguration() & QtVersion::DebugBuild) {
|
||||
env.appendOrSet(QLatin1String("DEB_BUILD_OPTIONS"),
|
||||
QLatin1String("nostrip"), QLatin1String(" "));
|
||||
}
|
||||
proc->setEnvironment(env.toStringList());
|
||||
proc->setWorkingDirectory(workingDir);
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::packagingCommand(const Qt4BuildConfiguration *bc,
|
||||
QString MaemoDebianPackageCreationStep::packagingCommand(const Qt4BuildConfiguration *bc,
|
||||
const QString &commandName)
|
||||
{
|
||||
QString perl;
|
||||
@@ -497,21 +476,7 @@ QString MaemoPackageCreationStep::packagingCommand(const Qt4BuildConfiguration *
|
||||
return perl + maddeRoot % QLatin1String("/madbin/") % commandName;
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::checkProjectName()
|
||||
{
|
||||
if (debBasedMaemoTarget()) {
|
||||
const QRegExp legalName(QLatin1String("[0-9-+a-z\\.]+"));
|
||||
if (!legalName.exactMatch(buildConfiguration()->target()->project()->displayName())) {
|
||||
emit addTask(Task(Task::Warning,
|
||||
tr("Your project name contains characters not allowed in Debian packages.\n"
|
||||
"They must only use lower-case letters, numbers, '-', '+' and '.'.\n"
|
||||
"We will try to work around that, but you may experience problems."),
|
||||
QString(), -1, TASK_CATEGORY_BUILDSYSTEM));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::ensureShlibdeps(QByteArray &rulesContent)
|
||||
void MaemoDebianPackageCreationStep::ensureShlibdeps(QByteArray &rulesContent)
|
||||
{
|
||||
QString contentAsString = QString::fromLocal8Bit(rulesContent);
|
||||
const QString whiteSpace(QLatin1String("[ \\t]*"));
|
||||
@@ -523,7 +488,7 @@ void MaemoPackageCreationStep::ensureShlibdeps(QByteArray &rulesContent)
|
||||
rulesContent = contentAsString.toLocal8Bit();
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::adaptRulesFile(const QString &rulesFilePath)
|
||||
void MaemoDebianPackageCreationStep::adaptRulesFile(const QString &rulesFilePath)
|
||||
{
|
||||
QFile rulesFile(rulesFilePath);
|
||||
rulesFile.setPermissions(rulesFile.permissions() | QFile::ExeUser);
|
||||
@@ -542,7 +507,7 @@ void MaemoPackageCreationStep::adaptRulesFile(const QString &rulesFilePath)
|
||||
+ QLatin1Char('/') + projectName()
|
||||
+ QLatin1String("/usr/share/applications/");
|
||||
const Qt4BuildConfiguration * const bc = qt4BuildConfiguration();
|
||||
const MaemoGlobal::MaemoVersion version
|
||||
const MaemoGlobal::OsVersion version
|
||||
= MaemoGlobal::version(bc->qtVersion());
|
||||
if (version == MaemoGlobal::Maemo5)
|
||||
desktopFileDir += QLatin1String("hildon/");
|
||||
@@ -551,9 +516,9 @@ void MaemoPackageCreationStep::adaptRulesFile(const QString &rulesFilePath)
|
||||
desktopFileDir.prepend(QLatin1Char('/'));
|
||||
#endif
|
||||
int insertPos = makeInstallEol + 1;
|
||||
for (int i = 0; i < deployStep()->deployables()->modelCount(); ++i) {
|
||||
for (int i = 0; i < deployConfig()->deployables()->modelCount(); ++i) {
|
||||
const MaemoDeployableListModel * const model
|
||||
= deployStep()->deployables()->modelAt(i);
|
||||
= deployConfig()->deployables()->modelAt(i);
|
||||
if (!model->hasDesktopFile())
|
||||
continue;
|
||||
if (version == MaemoGlobal::Maemo6) {
|
||||
@@ -582,7 +547,7 @@ void MaemoPackageCreationStep::adaptRulesFile(const QString &rulesFilePath)
|
||||
rulesFile.write(content);
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::addWorkaroundForHarmattanBug(QByteArray &rulesFileContent,
|
||||
void MaemoDebianPackageCreationStep::addWorkaroundForHarmattanBug(QByteArray &rulesFileContent,
|
||||
int &insertPos, const MaemoDeployableListModel *model,
|
||||
const QString &desktopFileDir)
|
||||
{
|
||||
@@ -597,7 +562,7 @@ void MaemoPackageCreationStep::addWorkaroundForHarmattanBug(QByteArray &rulesFil
|
||||
lineBefore, lineAfter);
|
||||
}
|
||||
|
||||
void MaemoPackageCreationStep::addSedCmdToRulesFile(QByteArray &rulesFileContent,
|
||||
void MaemoDebianPackageCreationStep::addSedCmdToRulesFile(QByteArray &rulesFileContent,
|
||||
int &insertPos, const QString &desktopFilePath, const QByteArray &oldString,
|
||||
const QByteArray &newString)
|
||||
{
|
||||
@@ -613,18 +578,133 @@ void MaemoPackageCreationStep::addSedCmdToRulesFile(QByteArray &rulesFileContent
|
||||
insertPos += mvCmd.length();
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::replaceDots(const QString &name)
|
||||
|
||||
MaemoRpmPackageCreationStep::MaemoRpmPackageCreationStep(BuildStepList *bsl)
|
||||
: AbstractMaemoPackageCreationStep(bsl, CreatePackageId)
|
||||
{
|
||||
QString adaptedName = name;
|
||||
return adaptedName.replace(QLatin1Char('.'), QLatin1Char('_'));
|
||||
ctor();
|
||||
}
|
||||
|
||||
QString MaemoPackageCreationStep::rpmBuildDir(const Qt4BuildConfiguration *bc)
|
||||
MaemoRpmPackageCreationStep::MaemoRpmPackageCreationStep(BuildStepList *buildConfig,
|
||||
MaemoRpmPackageCreationStep *other)
|
||||
: AbstractMaemoPackageCreationStep(buildConfig, other)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
void MaemoRpmPackageCreationStep::ctor()
|
||||
{
|
||||
setDefaultDisplayName(tr("Create RPM Package"));
|
||||
}
|
||||
|
||||
bool MaemoRpmPackageCreationStep::createPackage(QProcess *buildProc)
|
||||
{
|
||||
const QStringList args = QStringList() << QLatin1String("rrpmbuild")
|
||||
<< QLatin1String("-bb") << rpmBasedMaemoTarget()->specFilePath();
|
||||
if (!callPackagingCommand(buildProc, args))
|
||||
return false;
|
||||
QFile::remove(packageFilePath());
|
||||
const QString packageSourceFilePath = rpmBuildDir(qt4BuildConfiguration())
|
||||
+ QLatin1Char('/') + rpmBasedMaemoTarget()->packageFileName();
|
||||
if (!QFile::rename(packageSourceFilePath, packageFilePath())) {
|
||||
raiseError(tr("Packaging failed."),
|
||||
tr("Could not move package file from %1 to %2.")
|
||||
.arg(packageSourceFilePath, packageFilePath()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MaemoRpmPackageCreationStep::isMetaDataNewerThan(const QDateTime &packageDate) const
|
||||
{
|
||||
const QDateTime specFileChangeDate
|
||||
= QFileInfo(rpmBasedMaemoTarget()->specFilePath()).lastModified();
|
||||
return packageDate <= specFileChangeDate;
|
||||
}
|
||||
|
||||
QString MaemoRpmPackageCreationStep::rpmBuildDir(const Qt4BuildConfiguration *bc)
|
||||
{
|
||||
return bc->buildDirectory() + QLatin1String("/rrpmbuild");
|
||||
}
|
||||
|
||||
const QLatin1String MaemoPackageCreationStep::CreatePackageId("Qt4ProjectManager.MaemoPackageCreationStep");
|
||||
const QString MaemoRpmPackageCreationStep::CreatePackageId
|
||||
= QLatin1String("MaemoRpmPackageCreationStep");
|
||||
|
||||
|
||||
|
||||
class PROJECTEXPLORER_EXPORT CreateTarStepWidget : public BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CreateTarStepWidget(MaemoTarPackageCreationStep *step) : m_step(step) {}
|
||||
|
||||
virtual void init()
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
MaemoTarPackageCreationStep::MaemoTarPackageCreationStep(BuildStepList *bsl)
|
||||
: AbstractMaemoPackageCreationStep(bsl, CreatePackageId)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
MaemoTarPackageCreationStep::MaemoTarPackageCreationStep(BuildStepList *buildConfig,
|
||||
MaemoTarPackageCreationStep *other)
|
||||
: AbstractMaemoPackageCreationStep(buildConfig, other)
|
||||
{
|
||||
ctor();
|
||||
}
|
||||
|
||||
void MaemoTarPackageCreationStep::ctor()
|
||||
{
|
||||
setDefaultDisplayName(tr("Create tar ball"));
|
||||
}
|
||||
|
||||
bool MaemoTarPackageCreationStep::createPackage(QProcess *buildProc)
|
||||
{
|
||||
Q_UNUSED(buildProc);
|
||||
|
||||
// TODO: Copy files one by one into tar file.
|
||||
|
||||
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 Qt4ProjectManager
|
||||
|
||||
#include "maemopackagecreationstep.moc"
|
||||
|
||||
Reference in New Issue
Block a user