summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-07-28 14:41:28 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-08-27 10:44:00 +0200
commit2312e7fd59cc75aad51ef526a33982fda1ecb4fd (patch)
treec6079fb0095612b0e11bc8da66b66d0a0dae1ac8 /tools
parent492a66ad56610d81c86fae6d70d90dd0fbaf01f0 (diff)
Rename binary format classes and functions. Move to QInstaller.
Adjust some minor implementation details. Some renaming of member variables and function names is left out but will follow in later patches. Add some documentation. Change-Id: I929dcbe13fa701be5224b9e5fdf8d19bfff81235 Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/binarycreator/binarycreator.cpp38
-rw-r--r--tools/devtool/binarydump.cpp16
-rw-r--r--tools/devtool/binarydump.h2
-rw-r--r--tools/devtool/main.cpp31
4 files changed, 41 insertions, 46 deletions
diff --git a/tools/binarycreator/binarycreator.cpp b/tools/binarycreator/binarycreator.cpp
index 9263d13d0..c82d48b73 100644
--- a/tools/binarycreator/binarycreator.cpp
+++ b/tools/binarycreator/binarycreator.cpp
@@ -61,18 +61,17 @@
#include <iostream>
using namespace QInstaller;
-using namespace QInstallerCreator;
struct Input {
QString outputPath;
QString installerExePath;
- ComponentIndex componentIndex;
+ ResourceCollectionManager collectionManager;
QString binaryResourcePath;
QStringList binaryResources;
Range<qint64> operationsPos;
QVector<Range<qint64> > resourcePos;
- Range<qint64> componentIndexSegment;
+ Range<qint64> resourceCollectionsSegment;
};
class BundleBackup
@@ -315,18 +314,13 @@ static int assemble(Input input, const QInstaller::Settings &settings)
input.operationsPos = Range<qint64>::fromStartAndEnd(operationsStart, out.pos())
.moved(-dataBlockStart);
- // write out every components data
- input.componentIndex.writeComponentData(&out, -dataBlockStart);
- const qint64 compIndexStart = out.pos() - dataBlockStart;
-
- // write out the component index
- input.componentIndex.writeIndex(&out, -dataBlockStart);
- input.componentIndexSegment = Range<qint64>::fromStartAndEnd(compIndexStart, out.pos()
- - dataBlockStart);
+ // write out every resource collections data and index
+ input.resourceCollectionsSegment = input.collectionManager.write(&out, -dataBlockStart)
+ .moved(-dataBlockStart);
- qDebug("Component index: [%llu:%llu]", input.componentIndexSegment.start(),
- input.componentIndexSegment.end());
- QInstaller::appendInt64Range(&out, input.componentIndexSegment);
+ qDebug("Resource collections segment index: [%llu:%llu]", input.resourceCollectionsSegment
+ .start(), input.resourceCollectionsSegment.end());
+ QInstaller::appendInt64Range(&out, input.resourceCollectionsSegment);
foreach (const Range<qint64> &range, input.resourcePos)
QInstaller::appendInt64Range(&out, range);
QInstaller::appendInt64Range(&out, input.operationsPos);
@@ -765,17 +759,17 @@ int main(int argc, char **argv)
// now put the packages into the components section of the binary
foreach (const QInstallerTools::PackageInfo &info, packages) {
- Component comp;
- comp.setName(info.name.toUtf8());
+ ResourceCollection collection;
+ collection.setName(info.name.toUtf8());
qDebug() << "Creating component info for" << info.name;
- foreach (const QString &archive, info.copiedFiles) {
- const QSharedPointer<Archive> arch(new Archive(archive));
- qDebug() << QString::fromLatin1("Appending %1 (%2)").arg(archive,
- humanReadableSize(arch->size()));
- comp.appendArchive(arch);
+ foreach (const QString &file, info.copiedFiles) {
+ const QSharedPointer<Resource> resource(new Resource(file));
+ qDebug() << QString::fromLatin1("Appending %1 (%2)").arg(file,
+ humanReadableSize(resource->size()));
+ collection.appendResource(resource);
}
- input.componentIndex.insertComponent(comp);
+ input.collectionManager.insertCollection(collection);
}
qDebug() << "Creating the binary";
diff --git a/tools/devtool/binarydump.cpp b/tools/devtool/binarydump.cpp
index 6b871fd47..8c73d7642 100644
--- a/tools/devtool/binarydump.cpp
+++ b/tools/devtool/binarydump.cpp
@@ -50,7 +50,7 @@
#include <iostream>
-int BinaryDump::dump(const QInstallerCreator::ComponentIndex &index, const QString &target)
+int BinaryDump::dump(const QInstaller::ResourceCollectionManager &manager, const QString &target)
{
QDir targetDir(QFileInfo(target).absoluteFilePath());
if (targetDir.exists()) {
@@ -121,20 +121,18 @@ int BinaryDump::dump(const QInstallerCreator::ComponentIndex &index, const QStri
continue;
const QString fileName = it.fileName();
- QInstallerCreator::Component c = index.componentByName(fileName.toUtf8());
- if (c.archives().count() <= 0)
+ const QInstaller::ResourceCollection c = manager.collectionByName(fileName.toUtf8());
+ if (c.resources().count() <= 0)
continue;
- typedef QSharedPointer<QInstallerCreator::Archive> Archive;
- QVector<Archive> archives = c.archives();
- foreach (const Archive &archive, archives) {
- if (!archive->open(QIODevice::ReadOnly))
+ foreach (const QSharedPointer<QInstaller::Resource> &resource, c.resources()) {
+ if (!resource->open())
continue; // TODO: should we throw here?
QFile target(targetDir.filePath(fileName) + QDir::separator()
- + QString::fromUtf8(archive->name()));
+ + QString::fromUtf8(resource->name()));
QInstaller::openForWrite(&target);
- archive->copyData(&target); // copy the 7z files into the target directory
+ resource->copyData(&target); // copy the 7z files into the target directory
}
}
result = EXIT_SUCCESS;
diff --git a/tools/devtool/binarydump.h b/tools/devtool/binarydump.h
index 6211944a5..4504e169c 100644
--- a/tools/devtool/binarydump.h
+++ b/tools/devtool/binarydump.h
@@ -50,7 +50,7 @@ class BinaryDump
public:
BinaryDump() {}
- int dump(const QInstallerCreator::ComponentIndex &index, const QString &target);
+ int dump(const QInstaller::ResourceCollectionManager &manager, const QString &target);
};
#endif // BINARYDUMP_H
diff --git a/tools/devtool/main.cpp b/tools/devtool/main.cpp
index b03bc4ff1..ca11414a4 100644
--- a/tools/devtool/main.cpp
+++ b/tools/devtool/main.cpp
@@ -60,8 +60,6 @@
#include <iostream>
-using namespace QInstallerCreator;
-
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
@@ -165,33 +163,38 @@ int main(int argc, char *argv[])
performedOperations.append(op.take());
}
- // seek to the position of the component index
+ // seek to the position of the resource collections segment info
const qint64 resourceOffsetAndLengtSize = 2 * sizeof(qint64);
const qint64 resourceSectionSize = resourceOffsetAndLengtSize * layout.resourceCount;
- const qint64 offset = layout.endOfData - layout.indexSize - resourceSectionSize
+ qint64 offset = layout.endOfData - layout.indexSize - resourceSectionSize
- resourceOffsetAndLengtSize;
- if (!file->seek(offset))
- throw QInstaller::Error(QLatin1String("Could not seek to read component index info."));
+ if (!file->seek(offset)) {
+ throw QInstaller::Error(QLatin1String("Could not seek to read the resource collection "
+ "segment info."));
+ }
- const qint64 compIndexStart = QInstaller::retrieveInt64(file) + dataBlockStart;
- if (!file->seek(compIndexStart))
- throw QInstaller::Error(QLatin1String("Could not seek to start of component index."));
+ offset = QInstaller::retrieveInt64(file) + dataBlockStart;
+ if (!file->seek(offset)) {
+ throw QInstaller::Error(QLatin1String("Could not seek to start position of resource "
+ "collection block."));
+ }
- // setup the component index
+ // setup the collection manager
QSharedPointer<QFile> data(file);
- ComponentIndex index = ComponentIndex::read(data, dataBlockStart);
+ QInstaller::ResourceCollectionManager manager;
+ manager.read(data, dataBlockStart);
if (parser.isSet(dump)) {
// To dump the content we do not need the binary format engine.
if (layout.magicMarker != QInstaller::BinaryContent::MagicInstallerMarker)
throw QInstaller::Error(QLatin1String("Source file is not an installer."));
BinaryDump bd;
- return bd.dump(index, parser.value(dump));
+ return bd.dump(manager, parser.value(dump));
}
// setup the binary format engine
- QScopedPointer<BinaryFormatEngineHandler> binaryFormatEngineHandler;
- binaryFormatEngineHandler.reset(new BinaryFormatEngineHandler(index));
+ QScopedPointer<QInstaller::BinaryFormatEngineHandler> binaryFormatEngineHandler;
+ binaryFormatEngineHandler.reset(new QInstaller::BinaryFormatEngineHandler(manager));
if (parser.isSet(run)) {
OperationRunner runner(layout.magicMarker, performedOperations);