Commit 875b425d authored by ck's avatar ck
Browse files

Maemo: Warn about problematic project name and try to work around it.

Reviewed-by: kh1
parent 9704844e
......@@ -58,6 +58,7 @@
#include <QtCore/QProcess>
#include <QtCore/QProcessEnvironment>
#include <QtCore/QRegExp>
#include <QtCore/QStringBuilder>
#include <QtGui/QWidget>
......@@ -134,6 +135,7 @@ bool MaemoPackageCreationStep::createPackage()
return true;
emit addOutput(tr("Creating package file ..."), BuildStep::MessageOutput);
checkProjectName();
m_buildProc.reset(new QProcess);
QString error;
if (!preparePackagingProcess(m_buildProc.data(), maemoToolChain(),
......@@ -221,7 +223,8 @@ bool MaemoPackageCreationStep::removeDirectory(const QString &dirPath)
if (!dir.exists())
return true;
const QStringList &files = dir.entryList(QDir::Files);
const QStringList &files
= dir.entryList(QDir::Files | QDir::Hidden | QDir::System);
foreach (const QString &fileName, files) {
if (!dir.remove(fileName))
return false;
......@@ -428,10 +431,34 @@ QString MaemoPackageCreationStep::packagingCommand(const MaemoToolChain *tc,
return perl + tc->maddeRoot() % QLatin1String("/madbin/") % commandName;
}
void MaemoPackageCreationStep::checkProjectName()
{
const QRegExp legalName(QLatin1String("[0-9-+a-z\\.]+"));
if (!legalName.exactMatch(buildConfiguration()->target()->project()->displayName())) {
emit addTask(Task(Task::Warning,
tr("Your project name contains characters not allowed in Debian packages.\n"
"They must only use lower-case letters, numbers, '-', '+' and '.'.\n"
"We will try to work around that, but you may experience problems."),
QString(), -1, TASK_CATEGORY_BUILDSYSTEM));
}
}
QString MaemoPackageCreationStep::packageName(const ProjectExplorer::Project *project)
{
QString packageName = project->displayName().toLower();
const QRegExp legalLetter(QLatin1String("[a-z0-9+-.]"), Qt::CaseSensitive,
QRegExp::WildcardUnix);
for (int i = 0; i < packageName.length(); ++i) {
if (!legalLetter.exactMatch(packageName.mid(i, 1)))
packageName[i] = QLatin1Char('-');
}
return packageName;
}
QString MaemoPackageCreationStep::packageFileName(const ProjectExplorer::Project *project,
const QString &version)
{
return project->displayName() % QLatin1Char('_') % version
return packageName(project) % QLatin1Char('_') % version
% QLatin1String("_armel.deb");
}
......
......@@ -79,6 +79,7 @@ public:
const QString &workingDir, QString *error);
static QString packagingCommand(const MaemoToolChain *tc,
const QString &commandName);
static QString packageName(const ProjectExplorer::Project *project);
static QString packageFileName(const ProjectExplorer::Project *project,
const QString &version);
......@@ -116,6 +117,7 @@ private:
const Qt4BuildConfiguration *qt4BuildConfiguration() const;
const MaemoToolChain *maemoToolChain() const;
MaemoDeployStep * deployStep() const;
void checkProjectName();
static const QLatin1String CreatePackageId;
......
......@@ -147,7 +147,7 @@ bool MaemoTemplatesManager::createTemplatesIfNecessary(const ProjectExplorer::Ta
}
const QString command = QLatin1String("dh_make -s -n -p ")
+ project->displayName() + QLatin1Char('_')
+ MaemoPackageCreationStep::packageName(project) + QLatin1Char('_')
+ MaemoPackageCreationStep::DefaultVersionNumber;
dh_makeProc.start(MaemoPackageCreationStep::packagingCommand(tc, command));
if (!dh_makeProc.waitForStarted()) {
......
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