diff options
author | kh1 <karsten.heimrich@nokia.com> | 2012-08-21 12:10:07 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2012-09-25 10:43:59 +0200 |
commit | bc77a40ae8d9df9166fb91e240323a3524ac6055 (patch) | |
tree | 34f331ac7e89cad6948fcb29a8c2fec2fec2504b /tools/common/repositorygen.cpp | |
parent | 1f5e0021f0ac400dab075d4649320b237c2d3936 (diff) |
Compress all content, except already compressed files.
Task-number: QTIFW-136
This is now needed as we put the version number in front of
all content inside the data folder. This however results in
unexpected file name changes once the files are put inside the
repository and later are installed on the target system. If
we keep all files in zips, we can version them and install it
with the original name.
Change-Id: Ia700386c3f77de33818395a07d418c5ec40a0a14
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Reviewed-by: Niels Weber <niels.weber@digia.com>
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'tools/common/repositorygen.cpp')
-rw-r--r-- | tools/common/repositorygen.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index d72ea2548..3821dc913 100644 --- a/tools/common/repositorygen.cpp +++ b/tools/common/repositorygen.cpp @@ -567,33 +567,50 @@ void QInstallerTools::copyComponentData(const QString &packageDir, const QString const PackageInfo info = infos.at(i); const QString name = info.name; qDebug() << "Copying component data for" << name; - const QString dataDirPath = QString::fromLatin1("%1/%2/data").arg(packageDir, name); - const QDir dataDir(dataDirPath); - if (!QDir().mkpath(QString::fromLatin1("%1/%2").arg(repoDir, name))) { + + const QString namedRepoDir = QString::fromLatin1("%1/%2").arg(repoDir, name); + if (!QDir().mkpath(namedRepoDir)) { throw QInstaller::Error(QObject::tr("Could not create repository folder for component %1") .arg(name)); } - const QStringList entries = dataDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files); - foreach (const QString &entry, entries) { - QString target; + QStringList compressedFiles; + QStringList filesToCompress; + const QDir dataDir(QString::fromLatin1("%1/%2/data").arg(packageDir, name)); + foreach (const QString &entry, dataDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files)) { QFileInfo fileInfo(dataDir.absoluteFilePath(entry)); if (fileInfo.isFile()) { - target = QString::fromLatin1("%1/%2/%4%3").arg(repoDir, name, entry, info.version); - QFile tmp(dataDir.absoluteFilePath(entry)); - qDebug() << QString::fromLatin1("Copying archive from %1 to %2").arg(tmp.fileName(), target); - QInstaller::openForRead(&tmp, tmp.fileName()); - if (!tmp.copy(target)) { - throw QInstaller::Error(QObject::tr("Could not copy %1 to %2: %3").arg(tmp.fileName(), - target, tmp.errorString())); + const QString absoluteEntryFilePath = dataDir.absoluteFilePath(entry); + if (Lib7z::isSupportedArchive(absoluteEntryFilePath)) { + QFile tmp(absoluteEntryFilePath); + QString target = QString::fromLatin1("%1/%3%2").arg(namedRepoDir, entry, info.version); + qDebug() << QString::fromLatin1("Copying archive from %1 to %2").arg(tmp.fileName(), + target); + if (!tmp.copy(target)) { + throw QInstaller::Error(QObject::tr("Could not copy %1 to %2: %3").arg(tmp.fileName(), + target, tmp.errorString())); + } + compressedFiles.append(target); + } else { + filesToCompress.append(absoluteEntryFilePath); } } else if (fileInfo.isDir()) { qDebug() << "Compressing data directory" << entry; - target = QString::fromLatin1("%1/%2/%4%3.7z").arg(repoDir, name, entry, info.version); + QString target = QString::fromLatin1("%1/%3%2.7z").arg(namedRepoDir, entry, info.version); QInstallerTools::compressPaths(QStringList() << dataDir.absoluteFilePath(entry), target); - } else { - continue; + compressedFiles.append(target); } + } + + if (!filesToCompress.isEmpty()) { + qDebug() << "Compressing files found in data directory:" << filesToCompress; + QString target = QString::fromLatin1("%1/%3%2").arg(namedRepoDir, QLatin1String("content.7z"), + info.version); + QInstallerTools::compressPaths(filesToCompress, target); + compressedFiles.append(target); + } + + foreach (const QString &target, compressedFiles) { infos[i].copiedArchives.append(target); QFile archiveFile(target); |