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 a0b5d6e60f
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>
This commit is contained in:
parent
a02a2a1e73
commit
448177d857
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user