diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-06-02 13:00:18 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-06-02 13:00:18 +0200 |
commit | 51afc1eb8ebc101ced5874eeadd73d5dfb8612bb (patch) | |
tree | 0f85822e97b9b1fb63a8792c2b9b85ab982270b1 /src/libs | |
parent | e89721bce16d6486e47b5b88d24467face5a11aa (diff) | |
parent | 8c9831108a2aa591908b9548dec911dbefa4fffb (diff) |
Merge remote-tracking branch 'origin/1.6'
Conflicts:
dist/config/config.xml
dist/packages/org.qtproject.ifw.binaries/meta/package.xml
dist/packages/org.qtproject.ifw/meta/package.xml
installerfw.pri
Change-Id: I32a2a17b8fd7dc0f1f9c12272fc5f814ea5d86cb
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/installer/binaryformat.cpp | 92 | ||||
-rw-r--r-- | src/libs/installer/binaryformat.h | 2 | ||||
-rw-r--r-- | src/libs/installer/consumeoutputoperation.cpp | 8 | ||||
-rw-r--r-- | src/libs/installer/downloadfiletask.cpp | 9 | ||||
-rw-r--r-- | src/libs/installer/installer.pro | 2 | ||||
-rw-r--r-- | src/libs/installer/macreplaceinstallnamesoperation.cpp | 10 | ||||
-rw-r--r-- | src/libs/installer/metadatajob.cpp | 8 | ||||
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 1 | ||||
-rw-r--r-- | src/libs/installer/zipjob.cpp | 215 | ||||
-rw-r--r-- | src/libs/installer/zipjob.h | 109 | ||||
-rw-r--r-- | src/libs/kdtools/kdsavefile.cpp | 9 |
11 files changed, 31 insertions, 434 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp index 7aa4d94ab..be5ff843b 100644 --- a/src/libs/installer/binaryformat.cpp +++ b/src/libs/installer/binaryformat.cpp @@ -45,7 +45,6 @@ #include "fileutils.h" #include "lib7z_facade.h" #include "utils.h" -#include "zipjob.h" #include <kdupdaterupdateoperationfactory.h> @@ -60,14 +59,6 @@ using namespace QInstaller; using namespace QInstallerCreator; -/* -TRANSLATOR QInstallerCreator::Archive -*/ - -/* -TRANSLATOR QInstallerCreator::Component -*/ - static inline QByteArray &theBuffer(int size) { static QByteArray b; @@ -88,9 +79,6 @@ void QInstaller::retrieveFileData(QIODevice *out, QIODevice *in) { qint64 size = QInstaller::retrieveInt64(in); appendData(in, out, size); -/* QByteArray &b = theBuffer(size); - blockingRead(in, b.data(), size); - blockingWrite(out, b.constData(), size);*/ } void QInstaller::appendInt64(QIODevice *out, qint64 n) @@ -302,58 +290,6 @@ Archive::~Archive() } /*! - Copies the archives contents to the path \a name. - If the archive is a zipped directory, \a name is treated as a directory. The archive gets extracted there. - - If the archive is a plain file and \a name an existing directory, it gets created - with it's name. Otherwise it gets saved as \a name. - Note that if a file with the \a name already exists, copy() return false (i.e. Archive will not overwrite it). - */ -bool Archive::copy(const QString &name) -{ - const QFileInfo fileInfo(name); - if (isZippedDirectory()) { - if (fileInfo.exists() && !fileInfo.isDir()) - return false; - - errno = 0; - const QString absoluteFilePath = fileInfo.absoluteFilePath(); - if (!fileInfo.exists() && !QDir().mkpath(absoluteFilePath)) { -#if defined(Q_OS_WIN) && !defined(Q_CC_MINGW) - char msg[128]; - if (strerror_s(msg, sizeof msg, errno) != 0) - setErrorString(tr("Could not create %1: %2").arg(name, QString::fromLocal8Bit(msg))); -#else - setErrorString(tr("Could not create %1: %2").arg(name, QString::fromLocal8Bit(strerror(errno)))); -#endif - return false; - } - - if (isOpen()) - close(); - open(QIODevice::ReadOnly); - - UnzipJob job; - job.setInputDevice(this); - job.setOutputPath(absoluteFilePath); - job.run(); - } else { - if (isOpen()) - close(); - open(QIODevice::ReadOnly); - - QFile target(fileInfo.isDir() ? QString::fromLatin1("%1/%2").arg(name) - .arg(QString::fromUtf8(m_name.data(), m_name.count())) : name); - if (target.exists()) - return false; - target.open(QIODevice::WriteOnly); - blockingCopy(this, &target, size()); - } - close(); - return true; -} - -/*! \reimp */ bool Archive::seek(qint64 pos) @@ -363,34 +299,6 @@ bool Archive::seek(qint64 pos) return QIODevice::seek(pos); } -/*! - Returns true, if this archive was created by zipping a directory. - */ -bool Archive::isZippedDirectory() const -{ - if (m_device == 0) { - // easy, just check whether it's a dir - return QFileInfo(m_path).isDir(); - } - - // more complex, check the zip header magic - Archive* const arch = const_cast<Archive*> (this); - - const bool notOpened = !isOpen(); - if (notOpened) - arch->open(QIODevice::ReadOnly); - const qint64 p = pos(); - arch->seek(0); - - const QByteArray ba = arch->read(4); - const bool result = ba == QByteArray("\x50\x4b\x03\04"); - - arch->seek(p); - if (notOpened) - arch->close(); - return result; -} - QByteArray Archive::name() const { return m_name; diff --git a/src/libs/installer/binaryformat.h b/src/libs/installer/binaryformat.h index 0abe78030..c3d8dbde9 100644 --- a/src/libs/installer/binaryformat.h +++ b/src/libs/installer/binaryformat.h @@ -105,8 +105,6 @@ public: qint64 size() const; bool createZippedFile(); - bool isZippedDirectory() const; - bool copy(const QString &name); QByteArray name() const; void setName(const QByteArray &name); diff --git a/src/libs/installer/consumeoutputoperation.cpp b/src/libs/installer/consumeoutputoperation.cpp index 95d143b4a..d3022fbf5 100644 --- a/src/libs/installer/consumeoutputoperation.cpp +++ b/src/libs/installer/consumeoutputoperation.cpp @@ -90,12 +90,12 @@ bool ConsumeOutputOperation::performOperation() } QString executablePath = arguments().at(1); + QFileInfo executable(executablePath); #ifdef Q_OS_WIN - if (!QFile::exists(executablePath)) - executablePath = executablePath + QLatin1String(".exe"); + if (!executable.exists() && executable.suffix().isEmpty()) + executable = QFileInfo(executablePath + QLatin1String(".exe")); #endif - const QFileInfo executable(executablePath); if (!executable.exists() || !executable.isExecutable()) { setError(UserDefinedError); setErrorString(tr("File '%1' does not exist or is not an executable binary.").arg( @@ -140,7 +140,7 @@ bool ConsumeOutputOperation::performOperation() qWarning() << QString::fromLatin1("Cannot get any query output from executable: '%1'").arg( executable.absoluteFilePath()); } - core->setValue(installerKeyName, QString::fromLatin1(executableOutput)); + core->setValue(installerKeyName, QString::fromLocal8Bit(executableOutput)); return true; } diff --git a/src/libs/installer/downloadfiletask.cpp b/src/libs/installer/downloadfiletask.cpp index 0e29aebe6..b978bb818 100644 --- a/src/libs/installer/downloadfiletask.cpp +++ b/src/libs/installer/downloadfiletask.cpp @@ -45,6 +45,7 @@ #include <QEventLoop> #include <QFile> +#include <QFileInfo> #include <QNetworkProxyFactory> #include <QSslError> #include <QTemporaryFile> @@ -307,8 +308,14 @@ QNetworkReply *Downloader::startDownload(const FileTaskItem &item) } else { file.reset(new QFile(target)); } + + if (file->exists() && (!QFileInfo(file->fileName()).isFile())) { + m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Target file " + "'%1' already exists but is not a file.").arg(file->fileName()))); + return 0; + } + if (!file->open(QIODevice::WriteOnly | QIODevice::Truncate)) { - file->remove(); m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Could not open " "target '%1' for write. Error: %2.").arg(file->fileName(), file->errorString()))); return 0; diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro index ac55883b2..3d1f5a9e7 100644 --- a/src/libs/installer/installer.pro +++ b/src/libs/installer/installer.pro @@ -43,7 +43,6 @@ HEADERS += packagemanagercore.h \ binaryformatengine.h \ binaryformatenginehandler.h \ repository.h \ - zipjob.h \ utils.h \ errors.h \ component.h \ @@ -120,7 +119,6 @@ HEADERS += packagemanagercore.h \ binaryformatengine.cpp \ binaryformatenginehandler.cpp \ repository.cpp \ - zipjob.cpp \ fileutils.cpp \ utils.cpp \ component.cpp \ diff --git a/src/libs/installer/macreplaceinstallnamesoperation.cpp b/src/libs/installer/macreplaceinstallnamesoperation.cpp index 9ec553358..b8f55dc14 100644 --- a/src/libs/installer/macreplaceinstallnamesoperation.cpp +++ b/src/libs/installer/macreplaceinstallnamesoperation.cpp @@ -146,9 +146,9 @@ bool MacReplaceInstallNamesOperation::apply(const QString &searchString, const Q int MacReplaceInstallNamesOperation::updateExecutableInfo(MacBinaryInfo *binaryInfo) { QProcessWrapper otool; - otool.start(QLatin1String("otool"), QStringList() << QLatin1String("-l") << binaryInfo->fileName); + otool.start(QLatin1String("xcrun"), QStringList(QLatin1String("otool")) << QLatin1String("-l") << binaryInfo->fileName); if (!otool.waitForStarted()) { - setError(UserDefinedError, tr("Cannot invoke otool. Is Xcode installed?")); + setError(UserDefinedError, tr("Cannot run otool. Is Xcode installed?")); return -1; } otool.waitForFinished(); @@ -201,8 +201,8 @@ void MacReplaceInstallNamesOperation::relocateBinary(const MacBinaryInfo &info, if (!info.dynamicLibId.isEmpty() && (info.dynamicLibId != QFileInfo(info.fileName).fileName()) && !info.dynamicLibId.contains(QLatin1String("@"))) { // error is set inside the execCommand method - if (!execCommand(QLatin1String("install_name_tool"), QStringList(QLatin1String("-id")) - << info.fileName << info.fileName)) { + if (!execCommand(QLatin1String("xcrun"), QStringList(QLatin1String("install_name_tool")) + << QLatin1String("-id") << info.fileName << info.fileName)) { return; } } @@ -220,7 +220,7 @@ void MacReplaceInstallNamesOperation::relocateBinary(const MacBinaryInfo &info, // error is set inside the execCommand method // last argument is the file target which will be patched - execCommand(QLatin1String("install_name_tool"), args << info.fileName); + execCommand(QLatin1String("xcrun"), QStringList(QLatin1String("install_name_tool")) << args << info.fileName); } bool MacReplaceInstallNamesOperation::execCommand(const QString &cmd, const QStringList &args) diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index d326b70bd..79c7c7b05 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -100,6 +100,7 @@ void MetadataJob::doStart() } } DownloadFileTask *const xmlTask = new DownloadFileTask(items); + xmlTask->setProxyFactory(m_core->proxyFactory()); m_xmlTask.setFuture(QtConcurrent::run(&DownloadFileTask::doTask, xmlTask)); } else { emitFinished(); @@ -135,6 +136,7 @@ void MetadataJob::xmlTaskFinished() if (status == XmlDownloadSuccess) { setProcessedAmount(0); DownloadFileTask *const metadataTask = new DownloadFileTask(m_packages); + metadataTask->setProxyFactory(m_core->proxyFactory()); m_metadataTask.setFuture(QtConcurrent::run(&DownloadFileTask::doTask, metadataTask)); emit infoMessage(this, tr("Retrieving meta information from remote repository...")); } else if (status == XmlDownloadRetry) { @@ -289,8 +291,14 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList<FileTaskResult> &re const QString repoUrl = metadata.repository.url().toString(); FileTaskItem item(QString::fromLatin1("%1/%2/%3meta.7z").arg(repoUrl, packageName, (online ? packageVersion : QString()))); + + QAuthenticator authenticator; + authenticator.setUser(metadata.repository.username()); + authenticator.setPassword(metadata.repository.password()); + item.insert(TaskRole::UserRole, metadata.directory); item.insert(TaskRole::Checksum, packageHash.toLatin1()); + item.insert(TaskRole::Authenticator, QVariant::fromValue(authenticator)); m_packages.append(item); } } diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 30e1a51d5..d5599791a 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -239,6 +239,7 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent) setWindowTitle(tr("%1 Setup").arg(m_core->value(scTitle))); else setWindowTitle(tr("Maintain %1").arg(m_core->value(scTitle))); + setWindowFlags(windowFlags() &~ Qt::WindowContextHelpButtonHint); #ifndef Q_OS_MAC setWindowIcon(QIcon(m_core->settings().installerWindowIcon())); diff --git a/src/libs/installer/zipjob.cpp b/src/libs/installer/zipjob.cpp deleted file mode 100644 index 413d1e01e..000000000 --- a/src/libs/installer/zipjob.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ -#include <zipjob.h> - -#include <QtCore/QDebug> -#include <QtCore/QDir> -#include <QtCore/QMetaType> -#include <QtCore/QStringList> - -#include <cassert> -#include <climits> - -class ZipJob::Private -{ -public: - Private() : outputDevice(0), process(0) {} - - QIODevice *outputDevice; - QDir workingDir; - QProcess *process; - QStringList filesToArchive; -}; - -Q_DECLARE_METATYPE(QProcess::ExitStatus) - -ZipJob::ZipJob() - : d(new Private()) -{ - qRegisterMetaType<QProcess::ExitStatus>(); -} - -ZipJob::~ZipJob() -{ - delete d; -} - -void ZipJob::run() -{ - assert(!d->process); - d->process = new QProcess; - d->process->setWorkingDirectory(d->workingDir.absolutePath()); - QStringList args; - args << QLatin1String( "-" ) << QLatin1String( "-r" ) << d->filesToArchive; - connect(d->process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); - connect(d->process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus))); - connect(d->process, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyReadStandardOutput())); - - d->process->start(QLatin1String("zip"), args); - if (!d->process->waitForStarted()) { - //TODO handle - } - - if (!d->process->waitForFinished(INT_MAX)) { - //TODO handle - } - - delete d->process; - d->process = 0; - // emit result -} - -void ZipJob::processError(QProcess::ProcessError) -{ - emit error(); -} - -void ZipJob::processFinished(int, QProcess::ExitStatus) -{ - emit finished(); -} - -void ZipJob::processReadyReadStandardOutput() -{ - const QByteArray buf = d->process->readAll(); - const qint64 toWrite = buf.size(); - qint64 written = 0; - while (written < toWrite) { - const qint64 num = d->outputDevice->write(buf.constData() + written, toWrite - written); - if (num < 0) { - //TODO: handle error - return; - } - written += num; - } -} - -void ZipJob::setOutputDevice(QIODevice *device) -{ - d->outputDevice = device; -} - -void ZipJob::setWorkingDirectory(const QDir &dir) -{ - d->workingDir = dir; -} - -void ZipJob::setFilesToArchive(const QStringList &files) -{ - d->filesToArchive = files; -} - -class UnzipJob::Private -{ -public: - Private() : inputDevice(0) {} - - QIODevice *inputDevice; - QString outputPath; - QStringList filesToExtract; -}; - -UnzipJob::UnzipJob() - : d(new Private()) -{ - qRegisterMetaType<QProcess::ExitStatus>(); -} - -UnzipJob::~UnzipJob() -{ - delete d; -} - -void UnzipJob::setInputDevice(QIODevice *device) -{ - d->inputDevice = device; -} - -void UnzipJob::setOutputPath(const QString &path) -{ - d->outputPath = path; -} - -void UnzipJob::processError(QProcess::ProcessError) -{ - emit error(); -} - -void UnzipJob::run() -{ - QProcess process; - // TODO: this won't work on Windows... grmpfl, but on Mac and Linux, at least... - QStringList args; - args << QLatin1String( "/dev/stdin" ); - if (!d->filesToExtract.isEmpty()) - args << QLatin1String("-x") << d->filesToExtract; - process.setWorkingDirectory(d->outputPath); - process.start(QLatin1String("unzip"), args); - connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); - connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus ))); - if (!process.waitForStarted()) { - // TODO handle - return; - } - - const int bufferSize = 4096; - QByteArray buffer; - while (d->inputDevice->bytesAvailable() > 0 || d->inputDevice->waitForReadyRead(INT_MAX)) { - buffer = d->inputDevice->read(bufferSize); - process.write(buffer); - process.waitForBytesWritten(INT_MAX); - } - process.closeWriteChannel(); - - if (!process.waitForFinished(INT_MAX)) { - // TODO handle - } -} - -void UnzipJob::processFinished(int, QProcess::ExitStatus) -{ - emit finished(); -} - -void UnzipJob::setFilesToExtract(const QStringList &files) -{ - d->filesToExtract = files; -} diff --git a/src/libs/installer/zipjob.h b/src/libs/installer/zipjob.h deleted file mode 100644 index a0c2ecbb1..000000000 --- a/src/libs/installer/zipjob.h +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012-2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the Qt Installer Framework. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -**************************************************************************/ - -#ifndef ZIPJOB_H -#define ZIPJOB_H - -#include <QProcess> -#include <QRunnable> - -QT_BEGIN_NAMESPACE -class QDir; -class QIODevice; -class QStringList; -QT_END_NAMESPACE - -class ZipJob : public QObject, public QRunnable -{ - Q_OBJECT - -public: - ZipJob(); - ~ZipJob(); - - void setOutputDevice(QIODevice *device); - void setWorkingDirectory(const QDir &dir); - void setFilesToArchive(const QStringList &files); - - void run(); - -Q_SIGNALS: - void finished(); - void error(); - -private Q_SLOTS: - void processError(QProcess::ProcessError); - void processFinished(int, QProcess::ExitStatus); - void processReadyReadStandardOutput(); - -private: - class Private; - Private *const d; -}; - -class UnzipJob : public QObject, public QRunnable -{ - Q_OBJECT - -public: - UnzipJob(); - ~UnzipJob(); - - void setInputDevice(QIODevice *device); - void setOutputPath(const QString &path); - void setFilesToExtract(const QStringList &files); - - void run(); - -Q_SIGNALS: - void finished(); - void error(); - -private Q_SLOTS: - void processError(QProcess::ProcessError); - void processFinished(int, QProcess::ExitStatus); - -private: - class Private; - Private *const d; -}; - -#endif // ZIPJOB_H diff --git a/src/libs/kdtools/kdsavefile.cpp b/src/libs/kdtools/kdsavefile.cpp index 8e2209604..da2d9db3a 100644 --- a/src/libs/kdtools/kdsavefile.cpp +++ b/src/libs/kdtools/kdsavefile.cpp @@ -174,10 +174,11 @@ static QFile *createFile(const QString &path, QIODevice::OpenMode m, QFile::Perm */ static QString generateTempFileName(const QString &path) { - QTemporaryFile tmpfile(path); - tmpfile.open(); - const QString tmp = tmpfile.fileName(); - return tmp; + const QString tmp = path + QLatin1String("tmp.dsfdf.%1"); //TODO: use random suffix + int count = 1; + while (QFile::exists(tmp.arg(count))) + ++count; + return tmp.arg(count); } /*! |