forked from qt-creator/qt-creator
RemoteLinux: Make chmod a part of sftp transfer
Task-number: QTCREATORBUG-29971 Change-Id: Icee46c0442f58a054cf15021f64595765909a586 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -18,11 +18,17 @@ enum class FileTransferMethod {
|
||||
Default = Sftp
|
||||
};
|
||||
|
||||
enum class FilePermissions {
|
||||
Default,
|
||||
ForceExecutable
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT FileToTransfer
|
||||
{
|
||||
public:
|
||||
Utils::FilePath m_source;
|
||||
Utils::FilePath m_target;
|
||||
FilePermissions m_targetPermissions = FilePermissions::Default;
|
||||
};
|
||||
|
||||
using FilesToTransfer = QList<FileToTransfer>;
|
||||
|
@@ -186,9 +186,13 @@ GroupItem GenericDeployStep::deployRecipe()
|
||||
const auto onSetup = [this, storage] {
|
||||
const QList<DeployableFile> deployableFiles = target()->deploymentData().allFiles();
|
||||
FilesToTransfer &files = *storage;
|
||||
for (const DeployableFile &f : deployableFiles) {
|
||||
if (!ignoreMissingFiles() || f.localFilePath().exists())
|
||||
files.append({f.localFilePath(), deviceConfiguration()->filePath(f.remoteFilePath())});
|
||||
for (const DeployableFile &file : deployableFiles) {
|
||||
if (!ignoreMissingFiles() || file.localFilePath().exists()) {
|
||||
const FilePermissions permissions = file.isExecutable()
|
||||
? FilePermissions::ForceExecutable : FilePermissions::Default;
|
||||
files.append({file.localFilePath(),
|
||||
deviceConfiguration()->filePath(file.remoteFilePath()), permissions});
|
||||
}
|
||||
}
|
||||
if (files.isEmpty()) {
|
||||
addSkipDeploymentMessage();
|
||||
|
@@ -67,8 +67,6 @@ public:
|
||||
GroupItem statTree(const Storage<UploadStorage> &storage, FilesToStat filesToStat,
|
||||
StatEndHandler statEndHandler);
|
||||
GroupItem uploadTask(const Storage<UploadStorage> &storage);
|
||||
GroupItem chmodTask(const DeployableFile &file);
|
||||
GroupItem chmodTree(const Storage<UploadStorage> &storage);
|
||||
|
||||
BoolAspect incremental{this};
|
||||
BoolAspect ignoreMissingFiles{this};
|
||||
@@ -185,8 +183,10 @@ GroupItem GenericDirectUploadStep::uploadTask(const Storage<UploadStorage> &stor
|
||||
addErrorMessage(message);
|
||||
return SetupResult::StopWithError;
|
||||
}
|
||||
const FilePermissions permissions = file.isExecutable()
|
||||
? FilePermissions::ForceExecutable : FilePermissions::Default;
|
||||
files.append({file.localFilePath(),
|
||||
deviceConfiguration()->filePath(file.remoteFilePath())});
|
||||
deviceConfiguration()->filePath(file.remoteFilePath()), permissions});
|
||||
}
|
||||
if (files.isEmpty()) {
|
||||
addProgressMessage(Tr::tr("No files need to be uploaded."));
|
||||
@@ -204,43 +204,6 @@ GroupItem GenericDirectUploadStep::uploadTask(const Storage<UploadStorage> &stor
|
||||
return FileTransferTask(onSetup, onError, CallDoneIf::Error);
|
||||
}
|
||||
|
||||
GroupItem GenericDirectUploadStep::chmodTask(const DeployableFile &file)
|
||||
{
|
||||
const auto onSetup = [=](Process &process) {
|
||||
process.setCommand({deviceConfiguration()->filePath("chmod"),
|
||||
{"a+x", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}});
|
||||
};
|
||||
const auto onError = [=](const Process &process) {
|
||||
const QString error = process.errorString();
|
||||
if (!error.isEmpty()) {
|
||||
addWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
|
||||
.arg(file.remoteFilePath(), error));
|
||||
} else if (process.exitCode() != 0) {
|
||||
addWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
|
||||
.arg(file.remoteFilePath(), process.cleanedStdErr()));
|
||||
}
|
||||
};
|
||||
return ProcessTask(onSetup, onError, CallDoneIf::Error);
|
||||
}
|
||||
|
||||
GroupItem GenericDirectUploadStep::chmodTree(const Storage<UploadStorage> &storage)
|
||||
{
|
||||
const auto onSetup = [this, storage](TaskTree &tree) {
|
||||
QList<DeployableFile> filesToChmod;
|
||||
for (const DeployableFile &file : std::as_const(storage->filesToUpload)) {
|
||||
if (file.isExecutable())
|
||||
filesToChmod << file;
|
||||
}
|
||||
QList<GroupItem> chmodList{finishAllAndSuccess, parallelLimit(MaxConcurrentStatCalls)};
|
||||
for (const DeployableFile &file : std::as_const(filesToChmod)) {
|
||||
QTC_ASSERT(file.isValid(), continue);
|
||||
chmodList.append(chmodTask(file));
|
||||
}
|
||||
tree.setRecipe({chmodList});
|
||||
};
|
||||
return TaskTreeTask(onSetup);
|
||||
}
|
||||
|
||||
GroupItem GenericDirectUploadStep::deployRecipe()
|
||||
{
|
||||
const Storage<UploadStorage> storage;
|
||||
@@ -295,7 +258,6 @@ GroupItem GenericDirectUploadStep::deployRecipe()
|
||||
onGroupSetup(setupHandler),
|
||||
statTree(storage, preFilesToStat, preStatEndHandler),
|
||||
uploadTask(storage),
|
||||
chmodTree(storage),
|
||||
statTree(storage, postFilesToStat, postStatEndHandler),
|
||||
onGroupDone(doneHandler, CallDoneIf::Success)
|
||||
};
|
||||
|
@@ -1327,9 +1327,13 @@ private:
|
||||
sourceFileOrLinkTarget.withNewPath(fi.dir().relativeFilePath(fi.symLinkTarget()));
|
||||
}
|
||||
|
||||
batchData += transferCommand(link) + ' '
|
||||
+ ProcessArgs::quoteArgUnix(sourceFileOrLinkTarget.path()).toLocal8Bit() + ' '
|
||||
+ ProcessArgs::quoteArgUnix(file.m_target.path()).toLocal8Bit() + '\n';
|
||||
const QByteArray source = ProcessArgs::quoteArgUnix(sourceFileOrLinkTarget.path())
|
||||
.toLocal8Bit();
|
||||
const QByteArray target = ProcessArgs::quoteArgUnix(file.m_target.path()).toLocal8Bit();
|
||||
|
||||
batchData += transferCommand(link) + ' ' + source + ' ' + target + '\n';
|
||||
if (file.m_targetPermissions == FilePermissions::ForceExecutable)
|
||||
batchData += "chmod 1775 " + target + '\n';
|
||||
}
|
||||
process().setCommand({sftpBinary, fullConnectionOptions() << "-b" << "-" << host()});
|
||||
process().setWriteData(batchData);
|
||||
|
Reference in New Issue
Block a user