diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-02-27 14:05:06 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-04-13 11:33:21 +0000 |
commit | f074d72c8f9354fcf941fe32a9279d9c68944456 (patch) | |
tree | 845914c120ba71c490e205e346e0eedadefb7f43 /qmake/main.cpp | |
parent | fbcdf6d7532d62e4e11deda1b6e6aa8f4b9aebaa (diff) |
Preserve last modification timestamps of installed program files
Similar to the parent commit, this patch adds a unified code path in
qmake itself for installing program files while preserving their
original last modification timestamp.
Change-Id: I7b7dcfa6228c2bfd48ea6036549398bb6f90032f
Task-number: QTBUG-59004
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'qmake/main.cpp')
-rw-r--r-- | qmake/main.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/qmake/main.cpp b/qmake/main.cpp index 0b0b5ff128..2bdb5370df 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -236,7 +236,7 @@ static int doLink(int argc, char **argv) #endif -static int installFile(const QString &source, const QString &targetFileOrDirectory) +static int installFile(const QString &source, const QString &targetFileOrDirectory, bool exe = false) { QFile sourceFile(source); @@ -253,6 +253,17 @@ static int installFile(const QString &source, const QString &targetFileOrDirecto fprintf(stderr, "Error copying %s to %s: %s\n", source.toLatin1().constData(), qPrintable(target), qPrintable(sourceFile.errorString())); return 3; } + + if (exe) { + QFile targetFile(target); + 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; + } + } + // Copy file times QString error; if (!IoUtils::touchFile(target, sourceFile.fileName(), &error)) { @@ -274,6 +285,8 @@ static int doQInstall(int argc, char **argv) if (!strcmp(argv[0], "file")) return installFile(source, target); + if (!strcmp(argv[0], "program")) + return installFile(source, target, /*exe=*/true); fprintf(stderr, "Error: Unsupported qinstall command type %s\n", argv[0]); return 3; |