summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph VogtlÃĪnder <c.vogtlaender@sigma-surface-science.com>2014-11-12 17:57:35 +0100
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2014-11-13 11:44:36 +0100
commitfe97303ee7bf61db6e24880acb805a88c633d9ba (patch)
treef296b9aeedc5d62090a59d3fb5581c1a0e7e3f0b
parentb67c842ba8bba3ba908fffe9546ad364693acb2c (diff)
Fix binary data extraction
Extract binary data based on list of available package names when using "devtool --dump" or "--create-offline-repository" installer option. An entry in meta data resource only exists if the component actually has meta data (e.g. a script) so it is not possible to rely on sub directory structure after copying meta data to extract binary data. Change-Id: Icd70d3495a921229f0043360b93905dc36cf6514 Task-number: QTIFW-574 Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
-rw-r--r--src/libs/installer/createlocalrepositoryoperation.cpp42
-rw-r--r--tools/devtool/binarydump.cpp16
2 files changed, 22 insertions, 36 deletions
diff --git a/src/libs/installer/createlocalrepositoryoperation.cpp b/src/libs/installer/createlocalrepositoryoperation.cpp
index 53ca90eec..f3db5f9eb 100644
--- a/src/libs/installer/createlocalrepositoryoperation.cpp
+++ b/src/libs/installer/createlocalrepositoryoperation.cpp
@@ -256,28 +256,29 @@ bool CreateLocalRepositoryOperation::performOperation()
ResourceCollectionManager manager;
BinaryContent::readBinaryContent(&file, 0, &manager, 0, BinaryContent::MagicCookie);
- QDirIterator it(repoPath, QDirIterator::Subdirectories);
- while (it.hasNext() && !it.next().isEmpty()) {
- if (it.fileInfo().isDir()) {
- const QString fileName = it.fileName();
- const QString absoluteTargetPath = QDir(repoPath).absoluteFilePath(fileName);
+ emit progressChanged(0.75);
- // zip the meta files that come with the offline installer
- if (versionMap.contains(fileName)) {
- helper.m_files.prepend(Static::createArchive(repoPath, absoluteTargetPath,
- versionMap.value(fileName), &helper));
- versionMap.remove(fileName);
- emit outputTextChanged(helper.m_files.first());
+ QDir repo(repoPath);
+ if (!versionMap.isEmpty()) {
+ // extract meta and binary data
+ foreach (const QString &name, versionMap.keys()) {
+ if (!repo.mkpath(name)) {
+ throw QInstaller::Error(tr("Could not create target dir: %1.")
+ .arg(repo.filePath(name)));
}
+ // zip the meta files that come with the offline installer
+ helper.m_files.prepend(Static::createArchive(repoPath,
+ repo.filePath(name), versionMap.value(name), &helper));
+ emit outputTextChanged(helper.m_files.first());
// copy the 7z files that are inside the component index into the target
- const ResourceCollection collection = manager.collectionByName(fileName.toUtf8());
+ const ResourceCollection collection = manager.collectionByName(name.toUtf8());
foreach (const QSharedPointer<Resource> &resource, collection.resources()) {
const bool isOpen = resource->isOpen();
if ((!isOpen) && (!resource->open()))
continue;
- QFile target(absoluteTargetPath + QDir::separator()
+ QFile target(repo.filePath(name) + QDir::separator()
+ QString::fromUtf8(resource->name()));
QInstaller::openForWrite(&target);
resource->copyData(&target);
@@ -290,21 +291,6 @@ bool CreateLocalRepositoryOperation::performOperation()
}
}
- emit progressChanged(0.75);
-
- QDir repo(repoPath);
- if (!versionMap.isEmpty()) {
- // offline installers might miss possible old components
- foreach (const QString &dir, versionMap.keys()) {
- const QString missingDir = repoPath + dir;
- if (!repo.mkpath(missingDir))
- throw QInstaller::Error(tr("Could not create target dir: %1.").arg(missingDir));
- helper.m_files.prepend(Static::createArchive(repoPath, missingDir, versionMap.value(dir)
- , &helper));
- emit outputTextChanged(helper.m_files.first());
- }
- }
-
try {
// remove these, if we fail it doesn't hurt
Static::removeDirectory(QDir::cleanPath(repoPath + QLatin1String("/installer-config")),
diff --git a/tools/devtool/binarydump.cpp b/tools/devtool/binarydump.cpp
index 0952c92a4..046d41d25 100644
--- a/tools/devtool/binarydump.cpp
+++ b/tools/devtool/binarydump.cpp
@@ -108,22 +108,22 @@ int BinaryDump::dump(const QInstaller::ResourceCollectionManager &manager, const
}
}
- QDirIterator it(targetDir, QDirIterator::Subdirectories);
- while (it.hasNext() && !it.next().isEmpty()) {
- if (!it.fileInfo().isDir())
- continue;
-
- const QString fileName = it.fileName();
- const QInstaller::ResourceCollection c = manager.collectionByName(fileName.toUtf8());
+ foreach (const QString &name, versionMap.keys()) {
+ const QInstaller::ResourceCollection c = manager.collectionByName(name.toUtf8());
if (c.resources().count() <= 0)
continue;
+ if (!targetDir.mkpath(name)) {
+ throw QInstaller::Error(QString::fromLatin1("Could not create target dir: %1.")
+ .arg(targetDir.filePath(name)));
+ }
+
foreach (const QSharedPointer<QInstaller::Resource> &resource, c.resources()) {
const bool isOpen = resource->isOpen();
if ((!isOpen) && (!resource->open()))
continue; // TODO: should we throw here?
- QFile target(targetDir.filePath(fileName) + QDir::separator()
+ QFile target(targetDir.filePath(name) + QDir::separator()
+ QString::fromUtf8(resource->name()));
QInstaller::openForWrite(&target);
resource->copyData(&target); // copy the 7z files into the target directory