diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp index 3471288a33ebcbc787b24e3fd636feeb5a45ca89..861c0a9738e85d09994e503befda5d1d6e58a866 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp @@ -164,9 +164,14 @@ bool MaemoPackageCreationStep::createPackage() 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 ") - % executableFileName().toLower() % QLatin1Char('_') % versionString(); + % executableFileName().toLower() % QLatin1Char('_') % version; if (!runCommand(buildProc, command)) return false; @@ -194,11 +199,12 @@ bool MaemoPackageCreationStep::createPackage() } { + 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()); } @@ -209,7 +215,7 @@ bool MaemoPackageCreationStep::createPackage() // Workaround for non-working dh_builddeb --destdir=. if (!QDir(buildDir).isRoot()) { - const QString packageFileName = QFileInfo(packageFilePath()).fileName(); + const QString packageFileName = QFileInfo(pkgFilePath).fileName(); const QString changesFileName = QFileInfo(packageFileName) .completeBaseName() + QLatin1String(".changes"); const QString packageSourceDir = buildDir + QLatin1String("/../"); @@ -219,9 +225,9 @@ bool MaemoPackageCreationStep::createPackage() = packageSourceDir + changesFileName; const QString changesTargetFilePath = buildDir + QLatin1Char('/') + changesFileName; - QFile::remove(packageFilePath()); + QFile::remove(pkgFilePath); QFile::remove(changesTargetFilePath); - if (!QFile::rename(packageSourceFilePath, packageFilePath()) + if (!QFile::rename(packageSourceFilePath, pkgFilePath) || !QFile::rename(changesSourceFilePath, changesTargetFilePath)) { raiseError(tr("Packaging failed."), tr("Could not move package files from %1 to %2.")