summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-10-10 15:31:35 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-10-10 15:50:47 +0200
commit6857a0e87e43465db4804bf40e6f85c9195e2574 (patch)
tree0d1fbcb3325d61b778adac9e434c3bddb7a77151 /tools
parenta88d6dc9d329387c7cb8fe4c53208561e0986daf (diff)
Fix broken update option.
We need to read the marker on our own, BinaryContent::binaryLayout() throws cause it cannot read the full layout in case of maintenance tool binary (part of the stuff is inside the .dat file). To be able to read the layout from the .dat file, we need to open it. Pass the right file to relace, in both cases the executable. Change-Id: Ic76e78a2ee289f3d59d51cc8984d84ab5edf5b46 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/devtool/main.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/devtool/main.cpp b/tools/devtool/main.cpp
index b249af7cc..2c4fad8cf 100644
--- a/tools/devtool/main.cpp
+++ b/tools/devtool/main.cpp
@@ -108,8 +108,11 @@ int main(int argc, char *argv[])
QFile tmp(path);
QInstaller::openForRead(&tmp);
- QInstaller::BinaryLayout layout = QInstaller::BinaryContent::binaryLayout(&tmp,
- cookie);
+ if (!tmp.seek(QInstaller::BinaryContent::findMagicCookie(&tmp, cookie) - sizeof(qint64)))
+ throw QInstaller::Error(QLatin1String("Could not seek to read magic marker."));
+
+ QInstaller::BinaryLayout layout;
+ layout.magicMarker = QInstaller::retrieveInt64(&tmp);
if (layout.magicMarker == QInstaller::BinaryContent::MagicUninstallerMarker) {
QFileInfo fi(path);
@@ -118,15 +121,17 @@ int main(int argc, char *argv[])
path = fi.absolutePath() + QLatin1Char('/') + fi.baseName() + QLatin1String(".dat");
tmp.setFileName(path);
+ QInstaller::openForRead(&tmp);
+
cookie = QInstaller::BinaryContent::MagicCookieDat;
- layout = QInstaller::BinaryContent::binaryLayout(&tmp, cookie);
}
+ layout = QInstaller::BinaryContent::binaryLayout(&tmp, cookie);
tmp.close();
if (parser.isSet(update)) {
- // To update the binary we do not need any mapping.
- BinaryReplace br(layout);
- return br.replace(parser.value(update), path);
+ BinaryReplace br(layout); // To update the binary we do not need any mapping.
+ return br.replace(parser.value(update), QFileInfo(arguments.first())
+ .absoluteFilePath());
}
}