Skip to content
Snippets Groups Projects
Commit c31d7074 authored by ck's avatar ck
Browse files

Maemo: Make packaging errors appear in task windows.

Reviewed-by: kh1
parent 44a953e8
No related branches found
No related tags found
No related merge requests found
...@@ -45,10 +45,12 @@ ...@@ -45,10 +45,12 @@
#include "maemopackagecreationwidget.h" #include "maemopackagecreationwidget.h"
#include "maemotoolchain.h" #include "maemotoolchain.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <qt4buildconfiguration.h> #include <qt4buildconfiguration.h>
#include <qt4project.h> #include <qt4project.h>
#include <qt4target.h> #include <qt4target.h>
#include <QtCore/QDir>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QProcess> #include <QtCore/QProcess>
...@@ -56,8 +58,10 @@ ...@@ -56,8 +58,10 @@
#include <QtCore/QStringBuilder> #include <QtCore/QStringBuilder>
#include <QtGui/QWidget> #include <QtGui/QWidget>
using namespace ProjectExplorer::Constants;
using ProjectExplorer::BuildConfiguration; using ProjectExplorer::BuildConfiguration;
using ProjectExplorer::BuildStepConfigWidget; using ProjectExplorer::BuildStepConfigWidget;
using ProjectExplorer::Task;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
...@@ -91,13 +95,14 @@ BuildStepConfigWidget *MaemoPackageCreationStep::createConfigWidget() ...@@ -91,13 +95,14 @@ BuildStepConfigWidget *MaemoPackageCreationStep::createConfigWidget()
bool MaemoPackageCreationStep::createPackage() bool MaemoPackageCreationStep::createPackage()
{ {
qDebug("%s", Q_FUNC_INFO);
if (!packagingNeeded()) if (!packagingNeeded())
return true; return true;
emit addOutput(tr("Creating package file ..."));
QFile configFile(targetRoot() % QLatin1String("/config.sh")); QFile configFile(targetRoot() % QLatin1String("/config.sh"));
if (!configFile.open(QIODevice::ReadOnly)) { if (!configFile.open(QIODevice::ReadOnly)) {
qDebug("Cannot open config file '%s'", qPrintable(configFile.fileName())); raiseError(tr("Cannot open MADDE config file '%1'.")
.arg(nativePath(configFile)));
return false; return false;
} }
...@@ -125,9 +130,6 @@ bool MaemoPackageCreationStep::createPackage() ...@@ -125,9 +130,6 @@ bool MaemoPackageCreationStep::createPackage()
env.insert(envPattern.cap(1), envPattern.cap(2)); env.insert(envPattern.cap(1), envPattern.cap(2));
} while (!line.isEmpty()); } while (!line.isEmpty());
qDebug("Process environment: %s", qPrintable(env.toStringList().join("\n")));
qDebug("sysroot: '%s'", qPrintable(env.value(QLatin1String("SYSROOT_DIR"))));
QProcess buildProc; QProcess buildProc;
buildProc.setProcessEnvironment(env); buildProc.setProcessEnvironment(env);
buildProc.setWorkingDirectory(projectDir); buildProc.setWorkingDirectory(projectDir);
...@@ -139,7 +141,8 @@ bool MaemoPackageCreationStep::createPackage() ...@@ -139,7 +141,8 @@ bool MaemoPackageCreationStep::createPackage()
return false; return false;
QFile rulesFile(projectDir + QLatin1String("/debian/rules")); QFile rulesFile(projectDir + QLatin1String("/debian/rules"));
if (!rulesFile.open(QIODevice::ReadWrite)) { if (!rulesFile.open(QIODevice::ReadWrite)) {
qDebug("Error: Could not open debian/rules."); raiseError(tr("Packaging Error: Cannot open file '%1'.")
.arg(nativePath(rulesFile)));
return false; return false;
} }
...@@ -148,7 +151,8 @@ bool MaemoPackageCreationStep::createPackage() ...@@ -148,7 +151,8 @@ bool MaemoPackageCreationStep::createPackage()
rulesFile.resize(0); rulesFile.resize(0);
rulesFile.write(rulesContents); rulesFile.write(rulesContents);
if (rulesFile.error() != QFile::NoError) { if (rulesFile.error() != QFile::NoError) {
qDebug("Error: could not access debian/rules"); raiseError(tr("Packaging Error: Cannot write file '%1'.")
.arg(nativePath(rulesFile)));
return false; return false;
} }
} }
...@@ -160,13 +164,15 @@ bool MaemoPackageCreationStep::createPackage() ...@@ -160,13 +164,15 @@ bool MaemoPackageCreationStep::createPackage()
% executableFileName().toLower() % executableFilePathOnTarget()); % executableFileName().toLower() % executableFilePathOnTarget());
if (QFile::exists(targetFile)) { if (QFile::exists(targetFile)) {
if (!QFile::remove(targetFile)) { if (!QFile::remove(targetFile)) {
qDebug("Error: Could not remove '%s'", qPrintable(targetFile)); raiseError(tr("Packaging Error: Could not replace file '%1'.")
.arg(QDir::toNativeSeparators(targetFile)));
return false; return false;
} }
} }
if (!QFile::copy(executable(), targetFile)) { if (!QFile::copy(executable(), targetFile)) {
qDebug("Error: Could not copy '%s' to '%s'", raiseError(tr("Packaging Error: Could not copy '%1' to '%2'.")
qPrintable(executable()), qPrintable(targetFile)); .arg(QDir::toNativeSeparators(executable()))
.arg(QDir::toNativeSeparators(targetFile)));
return false; return false;
} }
...@@ -179,12 +185,13 @@ bool MaemoPackageCreationStep::createPackage() ...@@ -179,12 +185,13 @@ bool MaemoPackageCreationStep::createPackage()
return false; return false;
} }
emit addOutput(tr("Package created."));
return true; return true;
} }
bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command) bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command)
{ {
qDebug("Running command '%s'", qPrintable(command)); emit addOutput(tr("Package Creation: Running command '%1'.").arg(command));
QString perl; QString perl;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
perl = maddeRoot() + QLatin1String("/bin/perl.exe "); perl = maddeRoot() + QLatin1String("/bin/perl.exe ");
...@@ -192,17 +199,17 @@ bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command ...@@ -192,17 +199,17 @@ bool MaemoPackageCreationStep::runCommand(QProcess &proc, const QString &command
proc.start(perl + maddeRoot() % QLatin1String("/madbin/") % command); proc.start(perl + maddeRoot() % QLatin1String("/madbin/") % command);
proc.write("\n"); // For dh_make proc.write("\n"); // For dh_make
if (!proc.waitForFinished(100000) && proc.error() == QProcess::Timedout) { if (!proc.waitForFinished(100000) && proc.error() == QProcess::Timedout) {
qDebug("command '%s' hangs", qPrintable(command)); raiseError(tr("Packaging failed."),
tr("Packaging Error: Command '%1' timed out.").arg(command));
return false; return false;
} }
if (proc.exitCode() != 0) { if (proc.exitCode() != 0) {
qDebug("command '%s' failed with return value %d and output '%s'", const QString mainMessage = tr("Packaging Error: Command '%1' failed.")
qPrintable(command), proc.exitCode(), (proc.readAllStandardOutput() .arg(command);
+ "\n" + proc.readAllStandardError()).data()); raiseError(mainMessage, mainMessage + QLatin1Char(' ')
+ tr("Output was: ") + proc.readAllStandardError());
return false; return false;
} }
qDebug("Command finished, output was '%s'", (proc.readAllStandardOutput()
+ "\n" + proc.readAllStandardError()).data());
return true; return true;
} }
...@@ -272,6 +279,19 @@ QString MaemoPackageCreationStep::versionString() const ...@@ -272,6 +279,19 @@ QString MaemoPackageCreationStep::versionString() const
return QLatin1String("_0.1"); return QLatin1String("_0.1");
} }
QString MaemoPackageCreationStep::nativePath(const QFile &file) const
{
return QDir::toNativeSeparators(QFileInfo(file).filePath());
}
void MaemoPackageCreationStep::raiseError(const QString &shortMsg,
const QString &detailedMsg)
{
emit addOutput(detailedMsg.isNull() ? shortMsg : detailedMsg);
emit addTask(Task(Task::Error, shortMsg, QString(), -1,
TASK_CATEGORY_BUILDSYSTEM));
}
const QLatin1String MaemoPackageCreationStep::CreatePackageId("Qt4ProjectManager.MaemoPackageCreationStep"); const QLatin1String MaemoPackageCreationStep::CreatePackageId("Qt4ProjectManager.MaemoPackageCreationStep");
} // namespace Internal } // namespace Internal
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <projectexplorer/buildstep.h> #include <projectexplorer/buildstep.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QFile;
class QProcess; class QProcess;
QT_END_NAMESPACE QT_END_NAMESPACE
...@@ -80,9 +81,11 @@ private: ...@@ -80,9 +81,11 @@ private:
QString executableFileName() const; QString executableFileName() const;
QString maddeRoot() const; QString maddeRoot() const;
QString targetRoot() const; QString targetRoot() const;
QString nativePath(const QFile &file) const;
bool packagingNeeded() const; bool packagingNeeded() const;
QString versionString() const; QString versionString() const;
void raiseError(const QString &shortMsg,
const QString &detailedMsg = QString());
static const QLatin1String CreatePackageId; static const QLatin1String CreatePackageId;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment