summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2017-03-14 17:16:44 +0100
committerDominik Holland <dominik.holland@pelagicore.com>2017-03-14 16:46:10 +0000
commitaa18282edf7bac3124d3b2be365c4c59a4b96315 (patch)
treeb95469ee373dcee1d2d739265698970d687b43ef
parent73a175aee57f73c81864ca8b9d2f88e14448d80d (diff)
downloadqtapplicationmanager-aa18282edf7bac3124d3b2be365c4c59a4b96315.tar.gz
Automatically set the x-bit on Windows when packaging
Windows file-systems do not have an x-bit, so we try to automatically set it when packaging files that start with a standard ELF header. Change-Id: I09d42abbc8752bbc892ef77a0b77be2c91a014bd Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--src/package-lib/packagecreator.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/package-lib/packagecreator.cpp b/src/package-lib/packagecreator.cpp
index df0c0342..e487ba43 100644
--- a/src/package-lib/packagecreator.cpp
+++ b/src/package-lib/packagecreator.cpp
@@ -250,6 +250,15 @@ bool PackageCreatorPrivate::create()
} else if (fi.isFile() && !fi.isSymLink()) {
packageEntryType = PackageEntry_File;
mode = S_IFREG | S_IREAD | (fi.permission(QFile::ExeOwner) ? S_IEXEC : 0);
+#if defined(Q_OS_WIN)
+ // We do not have x-bits for stuff that has been cross-compiled on Windows,
+ // so this crude hack sets the x-bit in the package for all ELF files.
+ QFile f(fi.absoluteFilePath());
+ if (f.open(QFile::ReadOnly)) {
+ if (f.read(4) == "\x7f""ELF")
+ mode |= S_IEXEC;
+ }
+#endif
} else {
throw Exception(Error::Package, "inode '%1' is neither a directory or a file").arg(fi.filePath());
}