Set executable flag on applications while deploying

Under Windows there is no executable flag in the filesystem.
So take the information that we got, which file
is an executable and set the executable flag if needed.

Change-Id: I0a7026911d1f7791434c39cc0917d6e49cfa1667
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
Andreas Holzammer
2012-10-08 15:46:38 +02:00
committed by Christian Kandeler
parent 5554e3616e
commit 47ff91a584
8 changed files with 74 additions and 17 deletions

View File

@@ -38,16 +38,17 @@ using namespace Utils;
namespace ProjectExplorer { namespace ProjectExplorer {
DeployableFile::DeployableFile() DeployableFile::DeployableFile()
: m_type(TypeNormal)
{ {
} }
DeployableFile::DeployableFile(const QString &localFilePath, const QString &remoteDir) DeployableFile::DeployableFile(const QString &localFilePath, const QString &remoteDir, Type type)
: m_localFilePath(FileName::fromUserInput(localFilePath)), m_remoteDir(remoteDir) : m_localFilePath(FileName::fromUserInput(localFilePath)), m_remoteDir(remoteDir), m_type(type)
{ {
} }
DeployableFile::DeployableFile(const FileName &localFilePath, const QString &remoteDir) DeployableFile::DeployableFile(const FileName &localFilePath, const QString &remoteDir, Type type)
: m_localFilePath(localFilePath), m_remoteDir(remoteDir) : m_localFilePath(localFilePath), m_remoteDir(remoteDir), m_type(type)
{ {
} }
@@ -62,6 +63,11 @@ bool DeployableFile::isValid() const
return !m_localFilePath.toString().isEmpty() && !m_remoteDir.isEmpty(); return !m_localFilePath.toString().isEmpty() && !m_remoteDir.isEmpty();
} }
bool DeployableFile::isExecutable() const
{
return m_type == TypeExecutable;
}
uint qHash(const DeployableFile &d) uint qHash(const DeployableFile &d)
{ {
return qHash(qMakePair(d.localFilePath().toString(), d.remoteDirectory())); return qHash(qMakePair(d.localFilePath().toString(), d.remoteDirectory()));

View File

@@ -41,9 +41,17 @@ namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT DeployableFile class PROJECTEXPLORER_EXPORT DeployableFile
{ {
public: public:
enum Type
{
TypeNormal,
TypeExecutable
};
DeployableFile(); DeployableFile();
DeployableFile(const QString &m_localFilePath, const QString &m_remoteDir); DeployableFile(const QString &m_localFilePath, const QString &m_remoteDir,
DeployableFile(const Utils::FileName &localFilePath, const QString &remoteDir); Type type = TypeNormal);
DeployableFile(const Utils::FileName &localFilePath, const QString &remoteDir,
Type type = TypeNormal);
Utils::FileName localFilePath() const { return m_localFilePath; } Utils::FileName localFilePath() const { return m_localFilePath; }
QString remoteDirectory() const { return m_remoteDir; } QString remoteDirectory() const { return m_remoteDir; }
@@ -51,9 +59,12 @@ public:
bool isValid() const; bool isValid() const;
bool isExecutable() const;
private: private:
Utils::FileName m_localFilePath; Utils::FileName m_localFilePath;
QString m_remoteDir; QString m_remoteDir;
Type m_type;
}; };

View File

@@ -48,9 +48,10 @@ public:
m_files << file; m_files << file;
} }
void addFile(const QString &localFilePath, const QString &remoteDirectory) void addFile(const QString &localFilePath, const QString &remoteDirectory,
DeployableFile::Type type = DeployableFile::TypeNormal)
{ {
addFile(DeployableFile(localFilePath, remoteDirectory)); addFile(DeployableFile(localFilePath, remoteDirectory, type));
} }
int fileCount() const { return m_files.count(); } int fileCount() const { return m_files.count(); }

View File

@@ -1473,7 +1473,8 @@ void Qt4Project::collectData(const Qt4ProFileNode *node, DeploymentData &deploym
switch (node->projectType()) { switch (node->projectType()) {
case ApplicationTemplate: case ApplicationTemplate:
if (!installsList.targetPath.isEmpty()) if (!installsList.targetPath.isEmpty())
deploymentData.addFile(node->targetInformation().executable, installsList.targetPath); deploymentData.addFile(node->targetInformation().executable, installsList.targetPath,
DeployableFile::TypeExecutable);
break; break;
case LibraryTemplate: case LibraryTemplate:
collectLibraryData(node, deploymentData); collectLibraryData(node, deploymentData);

View File

@@ -41,10 +41,16 @@ namespace RemoteLinux {
class REMOTELINUX_EXPORT DeployableFile class REMOTELINUX_EXPORT DeployableFile
{ {
public: public:
enum Type
{
TypeNormal,
TypeExecutable
};
DeployableFile() {} DeployableFile() {}
DeployableFile(const QString &localFilePath, const QString &remoteDir) DeployableFile(const QString &localFilePath, const QString &remoteDir, Type type = TypeNormal)
: localFilePath(localFilePath), remoteDir(remoteDir) {} : localFilePath(localFilePath), remoteDir(remoteDir), type(type) {}
bool operator==(const DeployableFile &other) const bool operator==(const DeployableFile &other) const
{ {
@@ -56,8 +62,13 @@ public:
return remoteDir + QLatin1Char('/') + QFileInfo(localFilePath).fileName(); return remoteDir + QLatin1Char('/') + QFileInfo(localFilePath).fileName();
} }
bool isExecutable() const {
return type == TypeExecutable;
}
QString localFilePath; QString localFilePath;
QString remoteDir; QString remoteDir;
Type type;
}; };
inline uint qHash(const DeployableFile &d) inline uint qHash(const DeployableFile &d)

View File

@@ -77,7 +77,7 @@ DeployableFilesPerProFile::DeployableFilesPerProFile(const Qt4ProFileNode *proFi
if (hasTargetPath()) { if (hasTargetPath()) {
if (d->projectType == ApplicationTemplate) { if (d->projectType == ApplicationTemplate) {
d->deployables.prepend(DeployableFile(localExecutableFilePath(), d->deployables.prepend(DeployableFile(localExecutableFilePath(),
d->installsList.targetPath)); d->installsList.targetPath, DeployableFile::TypeExecutable));
} else if (d->projectType == LibraryTemplate) { } else if (d->projectType == LibraryTemplate) {
foreach (const QString &filePath, localLibraryFilePaths()) { foreach (const QString &filePath, localLibraryFilePaths()) {
d->deployables.prepend(DeployableFile(filePath, d->deployables.prepend(DeployableFile(filePath,

View File

@@ -61,6 +61,7 @@ public:
SftpChannel::Ptr uploader; SftpChannel::Ptr uploader;
SshRemoteProcess::Ptr mkdirProc; SshRemoteProcess::Ptr mkdirProc;
SshRemoteProcess::Ptr lnProc; SshRemoteProcess::Ptr lnProc;
SshRemoteProcess::Ptr chmodProc;
QList<DeployableFile> deployableFiles; QList<DeployableFile> deployableFiles;
}; };
@@ -173,14 +174,20 @@ void GenericDirectUploadService::handleUploadFinished(QSsh::SftpJobId jobId, con
} else { } else {
saveDeploymentTimeStamp(df); saveDeploymentTimeStamp(df);
// Terrible hack for Windows. // This is done for Windows.
if (df.remoteDir.contains(QLatin1String("bin"))) { if (df.isExecutable()) {
const QString command = QLatin1String("chmod a+x ") + df.remoteFilePath(); const QString command = QLatin1String("chmod a+x ") + df.remoteFilePath();
connection()->createRemoteProcess(command.toUtf8())->start(); d->chmodProc = connection()->createRemoteProcess(command.toUtf8());
} connect(d->chmodProc.data(), SIGNAL(closed(int)), SLOT(handleChmodFinished(int)));
connect(d->chmodProc.data(), SIGNAL(readyReadStandardOutput()),
SLOT(handleStdOutData()));
connect(d->chmodProc.data(), SIGNAL(readyReadStandardError()),
SLOT(handleStdErrData()));
d->chmodProc->start();
} else {
uploadNextFile(); uploadNextFile();
} }
}
} }
void GenericDirectUploadService::handleLnFinished(int exitStatus) void GenericDirectUploadService::handleLnFinished(int exitStatus)
@@ -205,6 +212,25 @@ void GenericDirectUploadService::handleLnFinished(int exitStatus)
} }
} }
void GenericDirectUploadService::handleChmodFinished(int exitStatus)
{
QTC_ASSERT(d->state == Uploading, setFinished(); return);
if (d->stopRequested) {
setFinished();
handleDeploymentDone();
return;
}
if (exitStatus != SshRemoteProcess::NormalExit || d->chmodProc->exitCode() != 0) {
emit errorMessage(tr("Failed to set executable flag."));
setFinished();
handleDeploymentDone();
return;
}
uploadNextFile();
}
void GenericDirectUploadService::handleMkdirFinished(int exitStatus) void GenericDirectUploadService::handleMkdirFinished(int exitStatus)
{ {
QTC_ASSERT(d->state == Uploading, setFinished(); return); QTC_ASSERT(d->state == Uploading, setFinished(); return);

View File

@@ -67,6 +67,7 @@ private slots:
void handleUploadFinished(QSsh::SftpJobId jobId, const QString &errorMsg); void handleUploadFinished(QSsh::SftpJobId jobId, const QString &errorMsg);
void handleMkdirFinished(int exitStatus); void handleMkdirFinished(int exitStatus);
void handleLnFinished(int exitStatus); void handleLnFinished(int exitStatus);
void handleChmodFinished(int exitStatus);
void handleStdOutData(); void handleStdOutData();
void handleStdErrData(); void handleStdErrData();