#include "maemopackagecreationwidget.h"
#include "maemopackagecontents.h"
#include "maemotoolchain.h"
+#include "profilewrapper.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <qt4buildconfiguration.h>
{
}
+MaemoPackageCreationStep::~MaemoPackageCreationStep() {}
+
bool MaemoPackageCreationStep::init()
{
return true;
QVariantMap map(ProjectExplorer::BuildStep::toMap());
map.insert(PackagingEnabledKey, m_packagingEnabled);
map.insert(VersionNumberKey, m_versionString);
- return map.unite(m_packageContents->toMap());
+ return map;
}
bool MaemoPackageCreationStep::fromMap(const QVariantMap &map)
{
- m_packageContents->fromMap(map);
m_packagingEnabled = map.value(PackagingEnabledKey, true).toBool();
m_versionString = map.value(VersionNumberKey, DefaultVersionNumber).toString();
return ProjectExplorer::BuildStep::fromMap(map);
QString colon = QLatin1String(":");
#ifdef Q_OS_WIN
colon = QLatin1String(";");
- env.insert(key, targetRoot() % "/bin" % colon % env.value(key));
env.insert(key, path % QLatin1String("bin") % colon % env.value(key));
#endif
+ env.insert(key, targetRoot() % "/bin" % colon % env.value(key));
env.insert(key, path % QLatin1String("madbin") % colon % env.value(key));
env.insert(QLatin1String("PERL5LIB"), path % QLatin1String("madlib/perl5"));
QProcess buildProc;
buildProc.setProcessEnvironment(env);
buildProc.setWorkingDirectory(buildDir);
+ buildProc.start("cd " + buildDir);
+ buildProc.waitForFinished();
+
+ // cache those two since we can change the version number during packaging
+ // and might fail later to modify, copy, remove etc. the generated package
+ const QString version = versionString();
+ const QString pkgFilePath = packageFilePath();
if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) {
const QString command = QLatin1String("dh_make -s -n -p ")
QByteArray rulesContents = rulesFile.readAll();
rulesContents.replace("DESTDIR", "INSTALL_ROOT");
+
+ // Would be the right solution, but does not work (on Windows),
+ // because dpkg-genchanges doesn't know about it (and can't be told).
+ // rulesContents.replace("dh_builddeb", "dh_builddeb --destdir=.");
+
rulesFile.resize(0);
rulesFile.write(rulesContents);
if (rulesFile.error() != QFile::NoError) {
}
{
+ QFile::remove(buildDir + QLatin1String("/debian/files"));
QFile changeLog(buildDir + QLatin1String("/debian/changelog"));
if (changeLog.open(QIODevice::ReadWrite)) {
QString content = QString::fromUtf8(changeLog.readAll());
content.replace(QRegExp("\\([a-zA-Z0-9_\\.]+\\)"),
- QLatin1Char('(') % versionString() % QLatin1Char(')'));
+ QLatin1Char('(') % version % QLatin1Char(')'));
changeLog.resize(0);
changeLog.write(content.toUtf8());
}
}
- if (!runCommand(buildProc, QLatin1String("dh_installdirs")))
+ if (!runCommand(buildProc, "dpkg-buildpackage -nc -uc -us"))
return false;
-
- const QDir debianRoot = QDir(buildDir % QLatin1String("/debian/")
- % executableFileName().toLower());
- for (int i = 0; i < m_packageContents->rowCount(); ++i) {
- const MaemoDeployable &d = m_packageContents->deployableAt(i);
- const QString targetFile = debianRoot.path() + '/' + d.remoteFilePath;
- const QString absTargetDir = QFileInfo(targetFile).dir().path();
- const QString relTargetDir = debianRoot.relativeFilePath(absTargetDir);
- if (!debianRoot.exists(relTargetDir)
- && !debianRoot.mkpath(relTargetDir)) {
- raiseError(tr("Packaging Error: Could not create directory '%1'.")
- .arg(QDir::toNativeSeparators(absTargetDir)));
- return false;
- }
- if (QFile::exists(targetFile) && !QFile::remove(targetFile)) {
- raiseError(tr("Packaging Error: Could not replace file '%1'.")
- .arg(QDir::toNativeSeparators(targetFile)));
- return false;
- }
- if (!QFile::copy(d.localFilePath, targetFile)) {
- raiseError(tr("Packaging Error: Could not copy '%1' to '%2'.")
- .arg(QDir::toNativeSeparators(d.localFilePath))
- .arg(QDir::toNativeSeparators(targetFile)));
+ // Workaround for non-working dh_builddeb --destdir=.
+ if (!QDir(buildDir).isRoot()) {
+ const QString packageFileName = QFileInfo(pkgFilePath).fileName();
+ const QString changesFileName = QFileInfo(packageFileName)
+ .completeBaseName() + QLatin1String(".changes");
+ const QString packageSourceDir = buildDir + QLatin1String("/../");
+ const QString packageSourceFilePath
+ = packageSourceDir + packageFileName;
+ const QString changesSourceFilePath
+ = packageSourceDir + changesFileName;
+ const QString changesTargetFilePath
+ = buildDir + QLatin1Char('/') + changesFileName;
+ QFile::remove(pkgFilePath);
+ QFile::remove(changesTargetFilePath);
+ if (!QFile::rename(packageSourceFilePath, pkgFilePath)
+ || !QFile::rename(changesSourceFilePath, changesTargetFilePath)) {
+ raiseError(tr("Packaging failed."),
+ tr("Could not move package files from %1 to %2.")
+ .arg(packageSourceDir, buildDir));
return false;
}
}
- const QStringList commands = QStringList() << QLatin1String("dh_link")
- << QLatin1String("dh_fixperms") << QLatin1String("dh_installdeb")
- << QLatin1String("dh_shlibdeps") << QLatin1String("dh_gencontrol")
- << QLatin1String("dh_md5sums") << QLatin1String("dh_builddeb --destdir=.");
- foreach (const QString &command, commands) {
- if (!runCommand(buildProc, command))
- return false;
- }
-
emit addOutput(tr("Package created."), textCharFormat);
m_packageContents->setUnModified();
return true;
.arg(command);
if (proc.error() != QProcess::UnknownError)
mainMessage += tr(" Reason: %1").arg(proc.errorString());
+ else
+ mainMessage += tr("Exit code: %1").arg(proc.exitCode());
raiseError(mainMessage, mainMessage + QLatin1Char('\n')
+ tr("Output was: ") + proc.readAllStandardError()
+ QLatin1Char('\n') + proc.readAllStandardOutput());
->qt4Project()->rootProjectNode()->targetInformation();
if (!ti.valid)
return QString();
-
return QDir::toNativeSeparators(QDir::cleanPath(ti.workingDir
- + QLatin1Char('/') + ti.target));
+ + QLatin1Char('/') + executableFileName()));
}
QString MaemoPackageCreationStep::buildDirectory() const
QString MaemoPackageCreationStep::executableFileName() const
{
- return QFileInfo(localExecutableFilePath()).fileName();
+ const Qt4Project * const project
+ = qt4BuildConfiguration()->qt4Target()->qt4Project();
+ const TargetInformation &ti
+ = project->rootProjectNode()->targetInformation();
+ if (!ti.valid)
+ return QString();
+
+ return project->rootProjectNode()->projectType() == LibraryTemplate
+ ? QLatin1String("lib") + ti.target + QLatin1String(".so")
+ : ti.target;
}
const MaemoToolChain *MaemoPackageCreationStep::maemoToolChain() const
TASK_CATEGORY_BUILDSYSTEM));
}
+QSharedPointer<ProFileWrapper> MaemoPackageCreationStep::proFileWrapper() const
+{
+ if (!m_proFileWrapper) {
+ const Qt4ProFileNode * const proFileNode = qt4BuildConfiguration()
+ ->qt4Target()->qt4Project()->rootProjectNode();
+ m_proFileWrapper = QSharedPointer<ProFileWrapper>(
+ new ProFileWrapper(proFileNode->path()));
+ }
+
+ return m_proFileWrapper;
+}
+
const QLatin1String MaemoPackageCreationStep::CreatePackageId("Qt4ProjectManager.MaemoPackageCreationStep");
} // namespace Internal