We need to cache the version number, since it can be changed

during the generation process and copy might fail afterwards.
This commit is contained in:
kh1
2010-06-28 17:58:09 +02:00
parent 40623d008d
commit f3171e8349

View File

@@ -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.")