summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Holzammer <andreas.holzammer@kdab.com>2012-10-08 15:46:38 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2012-10-09 11:02:48 +0200
commit47ff91a584dedc2be4f09fa4cd92b186b58155b5 (patch)
tree9b08fe1ba58b18d60975dd6d07eb93dc60d4eaec
parent5554e3616e1a584107b3e1c80cf12bc618fff74e (diff)
downloadqt-creator-47ff91a584dedc2be4f09fa4cd92b186b58155b5.tar.gz
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>
-rw-r--r--src/plugins/projectexplorer/deployablefile.cpp14
-rw-r--r--src/plugins/projectexplorer/deployablefile.h15
-rw-r--r--src/plugins/projectexplorer/deploymentdata.h5
-rw-r--r--src/plugins/qt4projectmanager/qt4project.cpp3
-rw-r--r--src/plugins/remotelinux/deployablefile.h15
-rw-r--r--src/plugins/remotelinux/deployablefilesperprofile.cpp2
-rw-r--r--src/plugins/remotelinux/genericdirectuploadservice.cpp36
-rw-r--r--src/plugins/remotelinux/genericdirectuploadservice.h1
8 files changed, 74 insertions, 17 deletions
diff --git a/src/plugins/projectexplorer/deployablefile.cpp b/src/plugins/projectexplorer/deployablefile.cpp
index 46acd15343..967b05a538 100644
--- a/src/plugins/projectexplorer/deployablefile.cpp
+++ b/src/plugins/projectexplorer/deployablefile.cpp
@@ -38,16 +38,17 @@ using namespace Utils;
namespace ProjectExplorer {
DeployableFile::DeployableFile()
+ : m_type(TypeNormal)
{
}
-DeployableFile::DeployableFile(const QString &localFilePath, const QString &remoteDir)
- : m_localFilePath(FileName::fromUserInput(localFilePath)), m_remoteDir(remoteDir)
+DeployableFile::DeployableFile(const QString &localFilePath, const QString &remoteDir, Type type)
+ : m_localFilePath(FileName::fromUserInput(localFilePath)), m_remoteDir(remoteDir), m_type(type)
{
}
-DeployableFile::DeployableFile(const FileName &localFilePath, const QString &remoteDir)
- : m_localFilePath(localFilePath), m_remoteDir(remoteDir)
+DeployableFile::DeployableFile(const FileName &localFilePath, const QString &remoteDir, Type type)
+ : 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();
}
+bool DeployableFile::isExecutable() const
+{
+ return m_type == TypeExecutable;
+}
+
uint qHash(const DeployableFile &d)
{
return qHash(qMakePair(d.localFilePath().toString(), d.remoteDirectory()));
diff --git a/src/plugins/projectexplorer/deployablefile.h b/src/plugins/projectexplorer/deployablefile.h
index ab67311d06..6fe5207c90 100644
--- a/src/plugins/projectexplorer/deployablefile.h
+++ b/src/plugins/projectexplorer/deployablefile.h
@@ -41,9 +41,17 @@ namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT DeployableFile
{
public:
+ enum Type
+ {
+ TypeNormal,
+ TypeExecutable
+ };
+
DeployableFile();
- DeployableFile(const QString &m_localFilePath, const QString &m_remoteDir);
- DeployableFile(const Utils::FileName &localFilePath, const QString &remoteDir);
+ DeployableFile(const QString &m_localFilePath, const QString &m_remoteDir,
+ Type type = TypeNormal);
+ DeployableFile(const Utils::FileName &localFilePath, const QString &remoteDir,
+ Type type = TypeNormal);
Utils::FileName localFilePath() const { return m_localFilePath; }
QString remoteDirectory() const { return m_remoteDir; }
@@ -51,9 +59,12 @@ public:
bool isValid() const;
+ bool isExecutable() const;
+
private:
Utils::FileName m_localFilePath;
QString m_remoteDir;
+ Type m_type;
};
diff --git a/src/plugins/projectexplorer/deploymentdata.h b/src/plugins/projectexplorer/deploymentdata.h
index 06a5ce9799..1a2330429e 100644
--- a/src/plugins/projectexplorer/deploymentdata.h
+++ b/src/plugins/projectexplorer/deploymentdata.h
@@ -48,9 +48,10 @@ public:
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(); }
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index 0a7f01e5a3..eed22d62ae 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -1473,7 +1473,8 @@ void Qt4Project::collectData(const Qt4ProFileNode *node, DeploymentData &deploym
switch (node->projectType()) {
case ApplicationTemplate:
if (!installsList.targetPath.isEmpty())
- deploymentData.addFile(node->targetInformation().executable, installsList.targetPath);
+ deploymentData.addFile(node->targetInformation().executable, installsList.targetPath,
+ DeployableFile::TypeExecutable);
break;
case LibraryTemplate:
collectLibraryData(node, deploymentData);
diff --git a/src/plugins/remotelinux/deployablefile.h b/src/plugins/remotelinux/deployablefile.h
index 2e08884c6d..452850207d 100644
--- a/src/plugins/remotelinux/deployablefile.h
+++ b/src/plugins/remotelinux/deployablefile.h
@@ -41,10 +41,16 @@ namespace RemoteLinux {
class REMOTELINUX_EXPORT DeployableFile
{
public:
+ enum Type
+ {
+ TypeNormal,
+ TypeExecutable
+ };
+
DeployableFile() {}
- DeployableFile(const QString &localFilePath, const QString &remoteDir)
- : localFilePath(localFilePath), remoteDir(remoteDir) {}
+ DeployableFile(const QString &localFilePath, const QString &remoteDir, Type type = TypeNormal)
+ : localFilePath(localFilePath), remoteDir(remoteDir), type(type) {}
bool operator==(const DeployableFile &other) const
{
@@ -56,8 +62,13 @@ public:
return remoteDir + QLatin1Char('/') + QFileInfo(localFilePath).fileName();
}
+ bool isExecutable() const {
+ return type == TypeExecutable;
+ }
+
QString localFilePath;
QString remoteDir;
+ Type type;
};
inline uint qHash(const DeployableFile &d)
diff --git a/src/plugins/remotelinux/deployablefilesperprofile.cpp b/src/plugins/remotelinux/deployablefilesperprofile.cpp
index ee3cf3a184..9c7465faea 100644
--- a/src/plugins/remotelinux/deployablefilesperprofile.cpp
+++ b/src/plugins/remotelinux/deployablefilesperprofile.cpp
@@ -77,7 +77,7 @@ DeployableFilesPerProFile::DeployableFilesPerProFile(const Qt4ProFileNode *proFi
if (hasTargetPath()) {
if (d->projectType == ApplicationTemplate) {
d->deployables.prepend(DeployableFile(localExecutableFilePath(),
- d->installsList.targetPath));
+ d->installsList.targetPath, DeployableFile::TypeExecutable));
} else if (d->projectType == LibraryTemplate) {
foreach (const QString &filePath, localLibraryFilePaths()) {
d->deployables.prepend(DeployableFile(filePath,
diff --git a/src/plugins/remotelinux/genericdirectuploadservice.cpp b/src/plugins/remotelinux/genericdirectuploadservice.cpp
index 8e4a0ff11a..179401ba45 100644
--- a/src/plugins/remotelinux/genericdirectuploadservice.cpp
+++ b/src/plugins/remotelinux/genericdirectuploadservice.cpp
@@ -61,6 +61,7 @@ public:
SftpChannel::Ptr uploader;
SshRemoteProcess::Ptr mkdirProc;
SshRemoteProcess::Ptr lnProc;
+ SshRemoteProcess::Ptr chmodProc;
QList<DeployableFile> deployableFiles;
};
@@ -173,13 +174,19 @@ void GenericDirectUploadService::handleUploadFinished(QSsh::SftpJobId jobId, con
} else {
saveDeploymentTimeStamp(df);
- // Terrible hack for Windows.
- if (df.remoteDir.contains(QLatin1String("bin"))) {
+ // This is done for Windows.
+ if (df.isExecutable()) {
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();
}
}
@@ -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)
{
QTC_ASSERT(d->state == Uploading, setFinished(); return);
diff --git a/src/plugins/remotelinux/genericdirectuploadservice.h b/src/plugins/remotelinux/genericdirectuploadservice.h
index a36ba3e07d..e20a113fdb 100644
--- a/src/plugins/remotelinux/genericdirectuploadservice.h
+++ b/src/plugins/remotelinux/genericdirectuploadservice.h
@@ -67,6 +67,7 @@ private slots:
void handleUploadFinished(QSsh::SftpJobId jobId, const QString &errorMsg);
void handleMkdirFinished(int exitStatus);
void handleLnFinished(int exitStatus);
+ void handleChmodFinished(int exitStatus);
void handleStdOutData();
void handleStdErrData();