Commit 9137c376 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

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
parent 1b7a2dfe
......@@ -64,6 +64,7 @@
namespace {
const QLatin1String PackagingEnabledKey("Packaging Enabled");
const QLatin1String MagicFileName(".qtcreator");
}
using namespace ProjectExplorer::Constants;
......@@ -168,7 +169,7 @@ bool MaemoPackageCreationStep::createPackage(QProcess *buildProc)
= buildConfiguration()->target()->project()->projectDirectory();
const bool inSourceBuild
= QFileInfo(buildDirectory()) == QFileInfo(projectDir);
if (!inSourceBuild && !copyDebianFiles())
if (!copyDebianFiles(inSourceBuild))
return false;
if (!runCommand(buildProc, QLatin1String("dpkg-buildpackage -nc -uc -us")))
......@@ -209,13 +210,26 @@ bool MaemoPackageCreationStep::createPackage(QProcess *buildProc)
buildProc->start(packagingCommand(maemoToolChain(),
QLatin1String("dh_clean")));
buildProc->waitForFinished();
buildProc->terminate();
}
return true;
}
bool MaemoPackageCreationStep::copyDebianFiles()
bool MaemoPackageCreationStep::copyDebianFiles(bool inSourceBuild)
{
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)) {
raiseError(tr("Packaging failed."),
tr("Could not remove directory '%1'.").arg(debianDirPath));
......@@ -251,6 +265,14 @@ bool MaemoPackageCreationStep::copyDebianFiles()
if (harmattanWorkaroundNeeded && fileName == QLatin1String("rules"))
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;
}
......
......@@ -81,6 +81,7 @@ public:
static QString packageName(const ProjectExplorer::Project *project);
static QString packageFileName(const ProjectExplorer::Project *project,
const QString &version);
static bool removeDirectory(const QString &dirPath);
static const QLatin1String DefaultVersionNumber;
......@@ -105,8 +106,7 @@ private:
virtual bool fromMap(const QVariantMap &map);
bool createPackage(QProcess *buildProc);
bool copyDebianFiles();
bool removeDirectory(const QString &dirPath);
bool copyDebianFiles(bool inSourceBuild);
bool runCommand(QProcess *buildProc, const QString &command);
QString maddeRoot() const;
QString targetRoot() const;
......
......@@ -62,6 +62,8 @@ namespace Internal {
namespace {
const QByteArray IconFieldName("XB-Maemo-Icon-26:");
const QLatin1String PackagingDirName("qtc_packaging");
const QLatin1String DebianDirNameFremantle("debian_fremantle");
} // anonymous namespace
......@@ -140,8 +142,14 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
{
Project * const project = target->project();
QDir projectDir(project->projectDirectory());
if (projectDir.exists(QLatin1String("debian")))
if (QFileInfo(debianDirPath(project)).exists())
return true;
if (!projectDir.exists(PackagingDirName)
&& !projectDir.mkdir(PackagingDirName)) {
raiseError(tr("Error creating Maemo packaging directory '%1'.")
.arg(PackagingDirName));
return false;
}
QProcess dh_makeProc;
QString error;
......@@ -154,11 +162,14 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
return false;
}
if (!MaemoPackageCreationStep::preparePackagingProcess(&dh_makeProc, tc,
projectDir.path(), &error)) {
projectDir.path() + QLatin1Char('/') + PackagingDirName, &error)) {
raiseError(error);
return false;
}
const QString dhMakeDebianDir = projectDir.path() + QLatin1Char('/')
+ PackagingDirName + QLatin1String("/debian");
MaemoPackageCreationStep::removeDirectory(dhMakeDebianDir);
const QString command = QLatin1String("dh_make -s -n -p ")
+ MaemoPackageCreationStep::packageName(project) + QLatin1Char('_')
+ MaemoPackageCreationStep::DefaultVersionNumber;
......@@ -177,6 +188,13 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
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));
const QStringList &files = debianDir.entryList(QDir::Files);
foreach (const QString &fileName, files) {
......@@ -242,7 +260,7 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
adaptControlFileField(controlContents, "Priority", "optional");
const int buildDependsOffset = controlContents.indexOf("Build-Depends:");
if (buildDependsOffset == -1) {
qWarning("Weird: no Build-Depends field in debian/control file.");
qDebug("Unexpected: no Build-Depends field in debian control file.");
} else {
int buildDependsNewlineOffset
= controlContents.indexOf('\n', buildDependsOffset);
......@@ -554,8 +572,8 @@ QStringList MaemoTemplatesManager::debianFiles(const Project *project) const
QString MaemoTemplatesManager::debianDirPath(const Project *project) const
{
return project->projectDirectory() + QLatin1Char('/')
+ QLatin1String("/debian");
return project->projectDirectory() + QLatin1Char('/') + PackagingDirName
+ QLatin1Char('/') + DebianDirNameFremantle;
}
QString MaemoTemplatesManager::changeLogFilePath(const Project *project) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment