Commit 87a6db09 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Lose one level of packaging directory structure.

We will now behave friendlier to projects that already have a
debian directory. Also, building a source package will be more
straightforward.

Reviewed-by: kh1
parent 8a498cf1
......@@ -154,34 +154,12 @@ bool MaemoPackageCreationStep::createPackage()
connect(m_buildProc.data(), SIGNAL(readyReadStandardError()), this,
SLOT(handleBuildOutput()));
const QString debianDirPath = buildDirectory() + QLatin1String("/debian");
if (!removeDirectory(debianDirPath)) {
raiseError(tr("Packaging failed."),
tr("Could not remove directory '%1'.").arg(debianDirPath));
const QString projectDir
= buildConfiguration()->target()->project()->projectDirectory();
const bool inSourceBuild
= QFileInfo(buildDirectory()) == QFileInfo(projectDir);
if (!inSourceBuild && !copyDebianFiles())
return false;
}
QDir buildDir(buildDirectory());
if (!buildDir.mkdir("debian")) {
raiseError(tr("Could not create debian directory '%1'.")
.arg(debianDirPath));
return false;
}
const QString templatesDirPath = MaemoTemplatesManager::instance()
->debianDirPath(buildConfiguration()->target()->project());
QDir templatesDir(templatesDirPath);
const QStringList &files = templatesDir.entryList(QDir::Files);
foreach (const QString &fileName, files) {
const QString srcFile
= templatesDirPath + QLatin1Char('/') + fileName;
const QString destFile
= debianDirPath + QLatin1Char('/') + fileName;
if (!QFile::copy(srcFile, destFile)) {
raiseError(tr("Could not copy file '%1' to '%2'")
.arg(QDir::toNativeSeparators(srcFile),
QDir::toNativeSeparators(destFile)));
return false;
}
}
if (!runCommand(QLatin1String("dpkg-buildpackage -nc -uc -us")))
return false;
......@@ -217,6 +195,44 @@ bool MaemoPackageCreationStep::createPackage()
emit addOutput(tr("Package created."), BuildStep::MessageOutput);
deployStep()->deployables()->setUnmodified();
if (inSourceBuild) {
m_buildProc->start(packagingCommand(maemoToolChain(),
QLatin1String("dh_clean")));
m_buildProc->waitForFinished();
}
return true;
}
bool MaemoPackageCreationStep::copyDebianFiles()
{
const QString debianDirPath = buildDirectory() + QLatin1String("/debian");
if (!removeDirectory(debianDirPath)) {
raiseError(tr("Packaging failed."),
tr("Could not remove directory '%1'.").arg(debianDirPath));
return false;
}
QDir buildDir(buildDirectory());
if (!buildDir.mkdir("debian")) {
raiseError(tr("Could not create debian directory '%1'.")
.arg(debianDirPath));
return false;
}
const QString templatesDirPath = MaemoTemplatesManager::instance()
->debianDirPath(buildConfiguration()->target()->project());
QDir templatesDir(templatesDirPath);
const QStringList &files = templatesDir.entryList(QDir::Files);
foreach (const QString &fileName, files) {
const QString srcFile
= templatesDirPath + QLatin1Char('/') + fileName;
const QString destFile
= debianDirPath + QLatin1Char('/') + fileName;
if (!QFile::copy(srcFile, destFile)) {
raiseError(tr("Could not copy file '%1' to '%2'")
.arg(QDir::toNativeSeparators(srcFile),
QDir::toNativeSeparators(destFile)));
return false;
}
}
return true;
}
......
......@@ -107,6 +107,7 @@ private:
virtual bool fromMap(const QVariantMap &map);
bool createPackage();
bool copyDebianFiles();
bool removeDirectory(const QString &dirPath);
bool runCommand(const QString &command);
QString maddeRoot() const;
......
......@@ -62,7 +62,6 @@ namespace Internal {
namespace {
const QByteArray IconFieldName("XB-Maemo-Icon-26:");
const QString PackagingDirName = ("maemopackaging");
} // anonymous namespace
......@@ -139,15 +138,8 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
{
Project * const project = target->project();
QDir projectDir(project->projectDirectory());
if (projectDir.exists(PackagingDirName))
if (projectDir.exists(QLatin1String("debian")))
return true;
const QString packagingTemplatesDir
= projectDir.path() + QLatin1Char('/') + PackagingDirName;
if (!projectDir.mkpath(PackagingDirName)) {
raiseError(tr("Could not create directory '%1'.")
.arg(QDir::toNativeSeparators(packagingTemplatesDir)));
return false;
}
QProcess dh_makeProc;
QString error;
......@@ -157,7 +149,7 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
= dynamic_cast<MaemoToolChain *>(qt4Target->activeBuildConfiguration()->toolChain());
Q_ASSERT_X(tc, Q_FUNC_INFO, "Maemo target has no maemo toolchain.");
if (!MaemoPackageCreationStep::preparePackagingProcess(&dh_makeProc, tc,
packagingTemplatesDir, &error)) {
projectDir.path(), &error)) {
raiseError(error);
return false;
}
......@@ -527,7 +519,7 @@ QStringList MaemoTemplatesManager::debianFiles(const Project *project) const
QString MaemoTemplatesManager::debianDirPath(const Project *project) const
{
return project->projectDirectory() + QLatin1Char('/')
+ PackagingDirName + QLatin1String("/debian");
+ QLatin1String("/debian");
}
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