Maemo: Don't monopolize the debian directory.

Using a debian directory in the project root directory might interfere
with non-MADDE configurations.
We therefore introduce an extra directory qtc_packaging, where we can
safely put our stuff. In the future, this should also contain
non-Fremantle (and possibly non-Debian) configurations.

Reviewed-by: Oswald Buddenhagen
This commit is contained in:
Christian Kandeler
2010-10-18 17:45:39 +02:00
parent 1b7a2dfe17
commit 9137c376e0
3 changed files with 49 additions and 9 deletions

View File

@@ -64,6 +64,7 @@
namespace { namespace {
const QLatin1String PackagingEnabledKey("Packaging Enabled"); const QLatin1String PackagingEnabledKey("Packaging Enabled");
const QLatin1String MagicFileName(".qtcreator");
} }
using namespace ProjectExplorer::Constants; using namespace ProjectExplorer::Constants;
@@ -168,7 +169,7 @@ bool MaemoPackageCreationStep::createPackage(QProcess *buildProc)
= buildConfiguration()->target()->project()->projectDirectory(); = buildConfiguration()->target()->project()->projectDirectory();
const bool inSourceBuild const bool inSourceBuild
= QFileInfo(buildDirectory()) == QFileInfo(projectDir); = QFileInfo(buildDirectory()) == QFileInfo(projectDir);
if (!inSourceBuild && !copyDebianFiles()) if (!copyDebianFiles(inSourceBuild))
return false; return false;
if (!runCommand(buildProc, QLatin1String("dpkg-buildpackage -nc -uc -us"))) if (!runCommand(buildProc, QLatin1String("dpkg-buildpackage -nc -uc -us")))
@@ -209,13 +210,26 @@ bool MaemoPackageCreationStep::createPackage(QProcess *buildProc)
buildProc->start(packagingCommand(maemoToolChain(), buildProc->start(packagingCommand(maemoToolChain(),
QLatin1String("dh_clean"))); QLatin1String("dh_clean")));
buildProc->waitForFinished(); buildProc->waitForFinished();
buildProc->terminate();
} }
return true; return true;
} }
bool MaemoPackageCreationStep::copyDebianFiles() bool MaemoPackageCreationStep::copyDebianFiles(bool inSourceBuild)
{ {
const QString debianDirPath = buildDirectory() + QLatin1String("/debian"); const QString debianDirPath = buildDirectory() + QLatin1String("/debian");
const QString magicFilePath
= debianDirPath + QLatin1Char('/') + MagicFileName;
if (inSourceBuild && QFileInfo(debianDirPath).isDir()
&& !QFileInfo(magicFilePath).exists()) {
raiseError(tr("Packaging failed: Foreign debian directory detected."),
tr("You are not using a shadow build and there is a debian "
"directory in your project root ('%1'). Qt Creator will not "
"overwrite that directory. Please remove it or use the "
"shadow build feature.")
.arg(QDir::toNativeSeparators(debianDirPath)));
return false;
}
if (!removeDirectory(debianDirPath)) { if (!removeDirectory(debianDirPath)) {
raiseError(tr("Packaging failed."), raiseError(tr("Packaging failed."),
tr("Could not remove directory '%1'.").arg(debianDirPath)); tr("Could not remove directory '%1'.").arg(debianDirPath));
@@ -251,6 +265,14 @@ bool MaemoPackageCreationStep::copyDebianFiles()
if (harmattanWorkaroundNeeded && fileName == QLatin1String("rules")) if (harmattanWorkaroundNeeded && fileName == QLatin1String("rules"))
addWorkaroundForHarmattanBug(destFile); addWorkaroundForHarmattanBug(destFile);
} }
QFile magicFile(magicFilePath);
if (!magicFile.open(QIODevice::WriteOnly)) {
raiseError(tr("Error: Could not create create file '%1'.")
.arg(QDir::toNativeSeparators(magicFilePath)));
return false;
}
return true; return true;
} }

View File

@@ -81,6 +81,7 @@ public:
static QString packageName(const ProjectExplorer::Project *project); static QString packageName(const ProjectExplorer::Project *project);
static QString packageFileName(const ProjectExplorer::Project *project, static QString packageFileName(const ProjectExplorer::Project *project,
const QString &version); const QString &version);
static bool removeDirectory(const QString &dirPath);
static const QLatin1String DefaultVersionNumber; static const QLatin1String DefaultVersionNumber;
@@ -105,8 +106,7 @@ private:
virtual bool fromMap(const QVariantMap &map); virtual bool fromMap(const QVariantMap &map);
bool createPackage(QProcess *buildProc); bool createPackage(QProcess *buildProc);
bool copyDebianFiles(); bool copyDebianFiles(bool inSourceBuild);
bool removeDirectory(const QString &dirPath);
bool runCommand(QProcess *buildProc, const QString &command); bool runCommand(QProcess *buildProc, const QString &command);
QString maddeRoot() const; QString maddeRoot() const;
QString targetRoot() const; QString targetRoot() const;

View File

@@ -62,6 +62,8 @@ namespace Internal {
namespace { namespace {
const QByteArray IconFieldName("XB-Maemo-Icon-26:"); const QByteArray IconFieldName("XB-Maemo-Icon-26:");
const QLatin1String PackagingDirName("qtc_packaging");
const QLatin1String DebianDirNameFremantle("debian_fremantle");
} // anonymous namespace } // anonymous namespace
@@ -140,8 +142,14 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
{ {
Project * const project = target->project(); Project * const project = target->project();
QDir projectDir(project->projectDirectory()); QDir projectDir(project->projectDirectory());
if (projectDir.exists(QLatin1String("debian"))) if (QFileInfo(debianDirPath(project)).exists())
return true; return true;
if (!projectDir.exists(PackagingDirName)
&& !projectDir.mkdir(PackagingDirName)) {
raiseError(tr("Error creating Maemo packaging directory '%1'.")
.arg(PackagingDirName));
return false;
}
QProcess dh_makeProc; QProcess dh_makeProc;
QString error; QString error;
@@ -154,11 +162,14 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
return false; return false;
} }
if (!MaemoPackageCreationStep::preparePackagingProcess(&dh_makeProc, tc, if (!MaemoPackageCreationStep::preparePackagingProcess(&dh_makeProc, tc,
projectDir.path(), &error)) { projectDir.path() + QLatin1Char('/') + PackagingDirName, &error)) {
raiseError(error); raiseError(error);
return false; return false;
} }
const QString dhMakeDebianDir = projectDir.path() + QLatin1Char('/')
+ PackagingDirName + QLatin1String("/debian");
MaemoPackageCreationStep::removeDirectory(dhMakeDebianDir);
const QString command = QLatin1String("dh_make -s -n -p ") const QString command = QLatin1String("dh_make -s -n -p ")
+ MaemoPackageCreationStep::packageName(project) + QLatin1Char('_') + MaemoPackageCreationStep::packageName(project) + QLatin1Char('_')
+ MaemoPackageCreationStep::DefaultVersionNumber; + MaemoPackageCreationStep::DefaultVersionNumber;
@@ -177,6 +188,13 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
return false; return false;
} }
if (!QFile::rename(dhMakeDebianDir, debianDirPath(project))) {
raiseError(tr("Unable to move new debian directory to '%1'.")
.arg(QDir::toNativeSeparators(debianDirPath(project))));
MaemoPackageCreationStep::removeDirectory(dhMakeDebianDir);
return false;
}
QDir debianDir(debianDirPath(project)); QDir debianDir(debianDirPath(project));
const QStringList &files = debianDir.entryList(QDir::Files); const QStringList &files = debianDir.entryList(QDir::Files);
foreach (const QString &fileName, files) { foreach (const QString &fileName, files) {
@@ -242,7 +260,7 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
adaptControlFileField(controlContents, "Priority", "optional"); adaptControlFileField(controlContents, "Priority", "optional");
const int buildDependsOffset = controlContents.indexOf("Build-Depends:"); const int buildDependsOffset = controlContents.indexOf("Build-Depends:");
if (buildDependsOffset == -1) { if (buildDependsOffset == -1) {
qWarning("Weird: no Build-Depends field in debian/control file."); qDebug("Unexpected: no Build-Depends field in debian control file.");
} else { } else {
int buildDependsNewlineOffset int buildDependsNewlineOffset
= controlContents.indexOf('\n', buildDependsOffset); = controlContents.indexOf('\n', buildDependsOffset);
@@ -554,8 +572,8 @@ QStringList MaemoTemplatesManager::debianFiles(const Project *project) const
QString MaemoTemplatesManager::debianDirPath(const Project *project) const QString MaemoTemplatesManager::debianDirPath(const Project *project) const
{ {
return project->projectDirectory() + QLatin1Char('/') return project->projectDirectory() + QLatin1Char('/') + PackagingDirName
+ QLatin1String("/debian"); + QLatin1Char('/') + DebianDirNameFremantle;
} }
QString MaemoTemplatesManager::changeLogFilePath(const Project *project) const QString MaemoTemplatesManager::changeLogFilePath(const Project *project) const