Commit 6bbc5536 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Adapt to OVI store requirements.

Reviewed-by: kh1
parent 849b91e5
...@@ -60,8 +60,8 @@ bool MaemoDeployableListModel::buildModel() ...@@ -60,8 +60,8 @@ bool MaemoDeployableListModel::buildModel()
const MaemoProFileWrapper::InstallsList &installs = m_proFileWrapper->installs(); const MaemoProFileWrapper::InstallsList &installs = m_proFileWrapper->installs();
if (installs.targetPath.isEmpty()) { if (installs.targetPath.isEmpty()) {
const QString remoteDir = m_proFileNode->projectType() == LibraryTemplate const QString remoteDir = m_proFileNode->projectType() == LibraryTemplate
? QLatin1String("/usr/lib") ? QLatin1String("/opt/lib")
: QLatin1String("/usr/bin"); : QLatin1String("/opt/bin");
m_deployables.prepend(MaemoDeployable(localExecutableFilePath(), m_deployables.prepend(MaemoDeployable(localExecutableFilePath(),
remoteDir)); remoteDir));
QFile projectFile(m_proFileNode->path()); QFile projectFile(m_proFileNode->path());
......
...@@ -180,7 +180,7 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor ...@@ -180,7 +180,7 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
return false; return false;
} }
QDir debianDir(packagingTemplatesDir + QLatin1String("/debian")); QDir debianDir(debianDirPath(project));
const QStringList &files = debianDir.entryList(QDir::Files); const QStringList &files = debianDir.entryList(QDir::Files);
QStringList filesToAddToProject; QStringList filesToAddToProject;
foreach (const QString &fileName, files) { foreach (const QString &fileName, files) {
...@@ -196,15 +196,18 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor ...@@ -196,15 +196,18 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
qobject_cast<Qt4Project *>(project)->rootProjectNode() qobject_cast<Qt4Project *>(project)->rootProjectNode()
->addFiles(UnknownFileType, filesToAddToProject); ->addFiles(UnknownFileType, filesToAddToProject);
const QString rulesFilePath return adaptRulesFile(project) && adaptControlFile(project);
= packagingTemplatesDir + QLatin1String("/debian/rules"); }
bool MaemoTemplatesManager::adaptRulesFile(const Project *project)
{
const QString rulesFilePath = debianDirPath(project) + "/rules";
QFile rulesFile(rulesFilePath); QFile rulesFile(rulesFilePath);
if (!rulesFile.open(QIODevice::ReadWrite)) { if (!rulesFile.open(QIODevice::ReadWrite)) {
raiseError(tr("Packaging Error: Cannot open file '%1'.") raiseError(tr("Packaging Error: Cannot open file '%1'.")
.arg(QDir::toNativeSeparators(rulesFilePath))); .arg(QDir::toNativeSeparators(rulesFilePath)));
return false; return false;
} }
QByteArray rulesContents = rulesFile.readAll(); QByteArray rulesContents = rulesFile.readAll();
rulesContents.replace("DESTDIR", "INSTALL_ROOT"); rulesContents.replace("DESTDIR", "INSTALL_ROOT");
rulesContents.replace("dh_shlibdeps", "# dh_shlibdeps"); rulesContents.replace("dh_shlibdeps", "# dh_shlibdeps");
...@@ -216,6 +219,7 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor ...@@ -216,6 +219,7 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
rulesFile.resize(0); rulesFile.resize(0);
rulesFile.write(rulesContents); rulesFile.write(rulesContents);
rulesFile.close();
if (rulesFile.error() != QFile::NoError) { if (rulesFile.error() != QFile::NoError) {
raiseError(tr("Packaging Error: Cannot write file '%1'.") raiseError(tr("Packaging Error: Cannot write file '%1'.")
.arg(QDir::toNativeSeparators(rulesFilePath))); .arg(QDir::toNativeSeparators(rulesFilePath)));
...@@ -224,6 +228,39 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor ...@@ -224,6 +228,39 @@ bool MaemoTemplatesManager::createDebianTemplatesIfNecessary(const ProjectExplor
return true; return true;
} }
bool MaemoTemplatesManager::adaptControlFile(const Project *project)
{
QFile controlFile(controlFilePath(project));
if (!controlFile.open(QIODevice::ReadWrite)) {
raiseError(tr("Packaging Error: Cannot open file '%1'.")
.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);
}
controlFile.resize(0);
controlFile.write(controlContents);
controlFile.close();
if (controlFile.error() != QFile::NoError) {
raiseError(tr("Packaging Error: Cannot write file '%1'.")
.arg(QDir::toNativeSeparators(controlFilePath(project))));
return false;
}
return true;
}
bool MaemoTemplatesManager::updateDesktopFiles(const Qt4Target *target) bool MaemoTemplatesManager::updateDesktopFiles(const Qt4Target *target)
{ {
const Qt4Target * const qt4Target = qobject_cast<const Qt4Target *>(target); const Qt4Target * const qt4Target = qobject_cast<const Qt4Target *>(target);
......
...@@ -96,7 +96,8 @@ private: ...@@ -96,7 +96,8 @@ private:
ProjectExplorer::Project *findProject(const QFileSystemWatcher *fsWatcher) const; ProjectExplorer::Project *findProject(const QFileSystemWatcher *fsWatcher) const;
void findLine(const QByteArray &string, QByteArray &document, void findLine(const QByteArray &string, QByteArray &document,
int &lineEndPos, int &valuePos); int &lineEndPos, int &valuePos);
bool adaptRulesFile(const ProjectExplorer::Project *project);
bool adaptControlFile(const ProjectExplorer::Project *project);
QSharedPointer<QFile> openFile(const QString &filePath, QSharedPointer<QFile> openFile(const QString &filePath,
QIODevice::OpenMode mode, QString *error) const; 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