diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-04-04 20:28:10 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-04-08 18:39:39 +0000 |
commit | 448177d857963a8d3ab1db8d1bc8332d552e6bed (patch) | |
tree | 3e8ee5ad7c96793b74405cd89bdeffed86c07e17 /qmake | |
parent | a02a2a1e73206b3955438b38bb9311067ef04794 (diff) |
Let "qmake -install qinstall" set default permissions 0644 and 0755
...like the install commands before Qt 5.9 did.
This ensures consistent permissions. Also, we can throw away the code
that took care of removing and re-adding the read-only flag on Windows.
This reverts commit a0b5d6e60f96359d88352e0b1c000678cdc80988 with the
addition of preserving permissions when copying directories to properly
install app bundles (QTBUG-74912).
Fixes: QTBUG-74733
Task-number: QTBUG-74912
Change-Id: Iee6d7c5e86787dd3ada5e5e9441209d418100b1f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/main.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/qmake/main.cpp b/qmake/main.cpp index a4ef79227b..69dff1073e 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -242,7 +242,8 @@ static int doLink(int argc, char **argv) #endif -static int installFile(const QString &source, const QString &target, bool exe = false) +static int installFile(const QString &source, const QString &target, bool exe = false, + bool preservePermissions = false) { QFile sourceFile(source); QFile targetFile(target); @@ -260,35 +261,32 @@ static int installFile(const QString &source, const QString &target, bool exe = return 3; } + QFileDevice::Permissions targetPermissions = preservePermissions + ? sourceFile.permissions() + : (QFileDevice::ReadOwner | QFileDevice::WriteOwner + | QFileDevice::ReadUser | QFileDevice::WriteUser + | QFileDevice::ReadGroup | QFileDevice::ReadOther); if (exe) { - if (!targetFile.setPermissions(sourceFile.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeUser | - QFileDevice::ExeGroup | QFileDevice::ExeOther)) { - fprintf(stderr, "Error setting execute permissions on %s: %s\n", - qPrintable(target), qPrintable(targetFile.errorString())); - return 3; - } + targetPermissions |= QFileDevice::ExeOwner | QFileDevice::ExeUser | + QFileDevice::ExeGroup | QFileDevice::ExeOther; + } + if (!targetFile.setPermissions(targetPermissions)) { + fprintf(stderr, "Error setting permissions on %s: %s\n", + qPrintable(target), qPrintable(targetFile.errorString())); + return 3; } // Copy file times QString error; -#ifdef Q_OS_WIN - const QFile::Permissions permissions = targetFile.permissions(); - const bool readOnly = !(permissions & QFile::WriteUser); - if (readOnly) - targetFile.setPermissions(permissions | QFile::WriteUser); -#endif if (!IoUtils::touchFile(target, sourceFile.fileName(), &error)) { fprintf(stderr, "%s", qPrintable(error)); return 3; } -#ifdef Q_OS_WIN - if (readOnly) - targetFile.setPermissions(permissions); -#endif return 0; } -static int installFileOrDirectory(const QString &source, const QString &target) +static int installFileOrDirectory(const QString &source, const QString &target, + bool preservePermissions = false) { QFileInfo fi(source); if (false) { @@ -314,12 +312,12 @@ static int installFileOrDirectory(const QString &source, const QString &target) const QFileInfo &entry = it.fileInfo(); const QString &entryTarget = target + QDir::separator() + entry.fileName(); - const int recursionResult = installFileOrDirectory(entry.filePath(), entryTarget); + const int recursionResult = installFileOrDirectory(entry.filePath(), entryTarget, true); if (recursionResult != 0) return recursionResult; } } else { - const int fileCopyResult = installFile(source, target); + const int fileCopyResult = installFile(source, target, /*exe*/ false, preservePermissions); if (fileCopyResult != 0) return fileCopyResult; } |