Commit 8fe7ac89 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Adapt Debian files.

- Set priority to "optional", as recommended for Maemo.
- Fix rules file so it can be used for source packages.
parent 1e680bd1
......@@ -204,6 +204,13 @@ bool MaemoTemplatesManager::adaptRulesFile(const Project *project)
rulesContents.replace("DESTDIR", "INSTALL_ROOT");
rulesContents.replace("dh_shlibdeps", "# dh_shlibdeps");
rulesContents.replace("dh_strip", "# dh_strip");
rulesContents.replace("$(MAKE) clean", "# $(MAKE) clean");
const Qt4Project * const qt4Project
= static_cast<const Qt4Project *>(project);
const QString proFileName
= QFileInfo(qt4Project->rootProjectNode()->path()).fileName();
rulesContents.replace("# Add here commands to configure the package.",
"qmake " + proFileName.toLocal8Bit());
// Would be the right solution, but does not work (on Windows),
// because dpkg-genchanges doesn't know about it (and can't be told).
......@@ -228,20 +235,12 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
.arg(QDir::toNativeSeparators(controlFilePath(project))));
return false;
}
QByteArray sectionLine = "Section: user/hidden";
QByteArray controlContents = controlFile.readAll();
const int sectionOffset = controlContents.indexOf("Section:");
if (sectionOffset == -1) {
controlContents.append(sectionLine).append('\n');
} else {
int sectionNewlineOffset = controlContents.indexOf('\n', sectionOffset);
if (sectionNewlineOffset == -1) {
sectionNewlineOffset = controlContents.length();
sectionLine += '\n';
}
controlContents.replace(sectionOffset,
sectionNewlineOffset - sectionOffset, sectionLine);
}
adaptControlFileField(controlContents, "Section", "user/hidden");
adaptControlFileField(controlContents, "Priority", "optional");
controlFile.resize(0);
controlFile.write(controlContents);
controlFile.close();
......@@ -253,6 +252,23 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
return true;
}
void MaemoTemplatesManager::adaptControlFileField(QByteArray &document,
const QByteArray &fieldName, const QByteArray &newFieldValue)
{
QByteArray adaptedLine = fieldName + ": " + newFieldValue;
const int lineOffset = document.indexOf(fieldName + ":");
if (lineOffset == -1) {
document.append(adaptedLine).append('\n');
} else {
int newlineOffset = document.indexOf('\n', lineOffset);
if (newlineOffset == -1) {
newlineOffset = document.length();
adaptedLine += '\n';
}
document.replace(lineOffset, newlineOffset - lineOffset, adaptedLine);
}
}
bool MaemoTemplatesManager::updateDesktopFiles(const Qt4Target *target)
{
const Qt4Target * const qt4Target = qobject_cast<const Qt4Target *>(target);
......
......@@ -98,6 +98,8 @@ private:
int &lineEndPos, int &valuePos);
bool adaptRulesFile(const ProjectExplorer::Project *project);
bool adaptControlFile(const ProjectExplorer::Project *project);
void adaptControlFileField(QByteArray &document, const QByteArray &fieldName,
const QByteArray &newFieldValue);
QSharedPointer<QFile> openFile(const QString &filePath,
QIODevice::OpenMode mode, QString *error) 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