summaryrefslogtreecommitdiffstats
path: root/installerbuilder
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@nokia.com>2011-08-30 16:58:11 +0200
committerTim Jenssen <tim.jenssen@nokia.com>2011-08-31 10:48:52 +0200
commite365ebc4211b33a416bccb549abc5797c86e1420 (patch)
tree5eeb3c5e9427abedfa86f8d72ce754555771f909 /installerbuilder
parentb47128b6775f846fad33f599802d70563580f902 (diff)
allow archivegen to archive multiple directories
this includes changing the syntax, it is now like in 7za archivegen arch.7z dir1 dir2 ... We will need this for further packaging. Adding incrementally does not work as the fascade creates a temporary files and writes it back. Hence we cannot add one directory after another Change-Id: I1923a3beabacf7b8f3618807c5377061555d98b2 Reviewed-on: http://codereview.qt.nokia.com/3889 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'installerbuilder')
-rw-r--r--installerbuilder/archivegen/archive.cpp7
-rw-r--r--installerbuilder/common/binaryformat.cpp2
-rw-r--r--installerbuilder/common/repositorygen.cpp20
-rw-r--r--installerbuilder/common/repositorygen.h2
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp22
-rw-r--r--installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h4
6 files changed, 31 insertions, 26 deletions
diff --git a/installerbuilder/archivegen/archive.cpp b/installerbuilder/archivegen/archive.cpp
index dc4ac4952..e04f9b22a 100644
--- a/installerbuilder/archivegen/archive.cpp
+++ b/installerbuilder/archivegen/archive.cpp
@@ -38,6 +38,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QFileInfo>
+#include <QtCore/QStringList>
#include <iostream>
@@ -47,7 +48,7 @@ using namespace QInstaller;
static void printUsage()
{
std::cout << "Usage: " << QFileInfo(QCoreApplication::applicationFilePath()).fileName()
- << " directory directory.7z" << std::endl;
+ << " directory.7z directories" << std::endl;
}
int main(int argc, char **argv)
@@ -62,8 +63,8 @@ int main(int argc, char **argv)
QInstaller::init();
QInstaller::setVerbose(true);
-
- QInstaller::compressDirectory(app.arguments().at(1), app.arguments().at(2));
+ const QStringList sourceDirectories = app.arguments().mid(2);
+ QInstaller::compressDirectory(sourceDirectories, app.arguments().at(1));
return EXIT_SUCCESS;
} catch (const Lib7z::SevenZipException &e) {
std::cerr << e.message() << std::endl;
diff --git a/installerbuilder/common/binaryformat.cpp b/installerbuilder/common/binaryformat.cpp
index 01d028ca5..02b540115 100644
--- a/installerbuilder/common/binaryformat.cpp
+++ b/installerbuilder/common/binaryformat.cpp
@@ -464,7 +464,7 @@ bool Archive::createZippedFile()
file.close();
m_inputFile.open(QIODevice::ReadWrite);
try {
- Lib7z::createArchive(&m_inputFile, m_path);
+ Lib7z::createArchive(&m_inputFile, QStringList() << m_path);
} catch(Lib7z::SevenZipException &e) {
m_inputFile.close();
setErrorString(e.message());
diff --git a/installerbuilder/common/repositorygen.cpp b/installerbuilder/common/repositorygen.cpp
index 662df43ee..8d0185cb7 100644
--- a/installerbuilder/common/repositorygen.cpp
+++ b/installerbuilder/common/repositorygen.cpp
@@ -268,17 +268,19 @@ namespace {
};
}
-void QInstaller::compressDirectory(const QString& path, const QString& archivePath)
+void QInstaller::compressDirectory(const QStringList& paths, const QString& archivePath)
{
- if (!QFileInfo(path).exists())
- throw QInstaller::Error(QObject::tr("Folder %1 does not exist").arg(path));
+ foreach (QString path, paths) {
+ if (!QFileInfo(path).exists())
+ throw QInstaller::Error(QObject::tr("Folder %1 does not exist").arg(path));
- if (!QFileInfo(path).isDir())
- throw QInstaller::Error(QObject::tr("%1 is not a folder").arg(path));
+ if (!QFileInfo(path).isDir())
+ throw QInstaller::Error(QObject::tr("%1 is not a folder").arg(path));
+ }
QFile archive(archivePath);
openForWrite(&archive, archivePath);
- Lib7z::createArchive(&archive, path);
+ Lib7z::createArchive(&archive, paths);
}
void QInstaller::compressMetaDirectories(const QString& configDir, const QString& repoDir)
@@ -299,7 +301,7 @@ void QInstaller::compressMetaDirectories(const QString& configDir, const QString
const QString absPath = sd.absolutePath();
const QString fn = QLatin1String("meta.7z");
const QString tmpTarget = repoDir + QLatin1String("/") +fn;
- compressDirectory(absPath, tmpTarget);
+ compressDirectory(QStringList() << absPath, tmpTarget);
QFile tmp(tmpTarget);
const QString finalTarget = absPath + QLatin1String("/") + fn;
if (!tmp.rename(finalTarget)) {
@@ -679,7 +681,7 @@ void QInstaller::compressMetaDirectories(const QString& configDir, const QString
const QString absPath = sd.absolutePath();
const QString fn = QLatin1String(versionPrefix.toLatin1() + "meta.7z");
const QString tmpTarget = repoDir + QLatin1String("/") +fn;
- compressDirectory(absPath, tmpTarget);
+ compressDirectory(QStringList() << absPath, tmpTarget);
QFile tmp(tmpTarget);
tmp.open(QFile::ReadOnly);
QByteArray fileToCheck = tmp.readAll();
@@ -767,7 +769,7 @@ void QInstaller::copyComponentData(const QString& packageDir, const QString& con
verbose() << "Compressing data directory " << dir << std::endl;
const QString archiveName = QString::fromLatin1("%1/%2/%4%3.7z").arg(repoDir, i, dir,
info.version);
- compressDirectory(dataDir.absoluteFilePath(dir), archiveName);
+ compressDirectory(QStringList() << dataDir.absoluteFilePath(dir), archiveName);
verbose() << "Creating hash of archive "<< archiveName << std::endl;
QFile archiveFile(archiveName);
QString archiveHashFileName = archiveFile.fileName();
diff --git a/installerbuilder/common/repositorygen.h b/installerbuilder/common/repositorygen.h
index 9d2d8a5f3..4c0b95f66 100644
--- a/installerbuilder/common/repositorygen.h
+++ b/installerbuilder/common/repositorygen.h
@@ -42,7 +42,7 @@ namespace QInstaller {
QMap<QString, QString> buildPathToVersionMap( const QVector<PackageInfo>& info );
void compressMetaDirectories( const QString& configDir, const QString& repoDir, const QString& baseDir, const QMap<QString, QString>& versionMapping );
void compressMetaDirectories( const QString& configDir, const QString& repoDir );
- void compressDirectory( const QString& path, const QString& archivePath );
+ void compressDirectory( const QStringList& paths, const QString& archivePath );
void copyComponentData( const QString& packageDir, const QString& configDir, const QString& repoDir, const QVector<PackageInfo>& infos );
void generateMetaDataDirectory( const QString& outDir, const QString& dataDir, const QVector<PackageInfo>& packages, const QString& appName, const QString& appVersion );
QVector<PackageInfo> createListOfPackages( const QStringList& components, const QString& packagesDirectory, bool addDependencies = true );
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
index 7479ee047..843566836 100644
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.cpp
@@ -922,7 +922,7 @@ public:
// TODO!
return S_OK;
}
- void setSource( const QString& dir )
+ void setSource( const QStringList& dir )
{
sourceDir = dir;
}
@@ -935,7 +935,7 @@ private:
UpdateCallback* const q;
QIODevice* target;
- QString sourceDir;
+ QStringList sourceDir;
};
class Lib7z::UpdateCallbackPrivate
@@ -971,7 +971,7 @@ UpdateCallbackImpl* UpdateCallback::impl()
}
-void UpdateCallback::setSource( const QString& dir )
+void UpdateCallback::setSource( const QStringList& dir )
{
d->impl()->setSource( dir );
}
@@ -1038,7 +1038,7 @@ void ExtractItemJob::setTarget( QIODevice* dev )
d->target = dev;
}
-void Lib7z::createArchive( QIODevice* archive, const QString& sourceDirectory, UpdateCallback* callback )
+void Lib7z::createArchive( QIODevice* archive, const QStringList& sourceDirectories, UpdateCallback* callback )
{
assert( archive );
@@ -1061,11 +1061,13 @@ void Lib7z::createArchive( QIODevice* archive, const QString& sourceDirectory, U
const QString tempFile = generateTempFileName();
NWildcard::CCensor censor;
- const UString sourceDirectoryPath = QString2UString( QDir::toNativeSeparators( sourceDirectory ) );
- if( UString2QString( sourceDirectoryPath ) != QDir::toNativeSeparators( sourceDirectory ) )
- throw UString2QString( sourceDirectoryPath ).toLatin1().data();
- censor.AddItem( true, sourceDirectoryPath, true );
-
+ foreach( QString dir, sourceDirectories) {
+ const UString sourceDirectoryPath = QString2UString( QDir::toNativeSeparators( dir));
+ if( UString2QString( sourceDirectoryPath) != QDir::toNativeSeparators( dir))
+ throw UString2QString( sourceDirectoryPath ).toLatin1().data();
+ censor.AddItem( true, sourceDirectoryPath, true );
+ }
+
CUpdateOptions options;
CArchivePath archivePath;
archivePath.ParseFromPath( QString2UString( tempFile ) );
@@ -1079,7 +1081,7 @@ void Lib7z::createArchive( QIODevice* archive, const QString& sourceDirectory, U
CUpdateErrorInfo errorInfo;
callback->setTarget( archive );
- callback->setSource( sourceDirectory );
+ callback->setSource( sourceDirectories );
const HRESULT res = UpdateArchive( codecs.get(), censor, options, errorInfo, 0, callback->impl() );
if( res != S_OK || !QFile::exists( tempFile ) )
throw SevenZipException( QObject::tr( "Could not create archive %1" ).arg( tempFile ) );
diff --git a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
index 2441e3d35..855648aa2 100644
--- a/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
+++ b/installerbuilder/libinstaller/3rdparty/p7zip_9.04/lib7z_facade.h
@@ -96,7 +96,7 @@ namespace Lib7z {
virtual ~UpdateCallback();
void setTarget( QIODevice* archive );
- void setSource( const QString& dir );
+ void setSource( const QStringList& dir );
virtual UpdateCallbackImpl* impl();
@@ -130,7 +130,7 @@ namespace Lib7z {
/*
* @thows Lib7z::SevenZipException
*/
- void INSTALLER_EXPORT createArchive( QIODevice* archive, const QString& sourceDirectory, UpdateCallback* callback = 0 );
+ void INSTALLER_EXPORT createArchive( QIODevice* archive, const QStringList& sourceDirectory, UpdateCallback* callback = 0 );
/*
* @throws Lib7z::SevenZipException