diff options
author | Katja Marttila <katja.marttila@qt.io> | 2023-09-26 17:11:10 +0300 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2023-10-16 13:52:12 +0300 |
commit | b09ef64c72192569bad97484a77434e9a015e2e1 (patch) | |
tree | eac5bfad7f25524017077d9e303996cdd7341cef /src | |
parent | e8c4492693328568a1512303834e318aa1c1ea28 (diff) |
Enable component script postload setting per repository
This is a custom requirement for Qt Online Installer. Qt Online
Installer has a huge amount of scripts to be evaluated. Most of the
scripts don't need an evaluation unless those are installed. Skipping
the evaluation of scripts has quite significant
performance impact. As the postLoad setting in component level is a big
task, enabling support for Qt Online Installer to set the postLoad value
to scripts per repository.
Task-number: QTIFW-3173
Change-Id: If37d7ff39ad07ee56e9a9559c837966c23d76d6e
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 4 | ||||
-rw-r--r-- | src/libs/installer/packagesource.h | 4 | ||||
-rw-r--r-- | src/libs/installer/repository.cpp | 27 | ||||
-rw-r--r-- | src/libs/installer/repository.h | 4 | ||||
-rw-r--r-- | src/libs/kdtools/updatefinder.cpp | 4 | ||||
-rw-r--r-- | src/libs/kdtools/updatesinfo.cpp | 16 | ||||
-rw-r--r-- | src/libs/kdtools/updatesinfo_p.h | 2 | ||||
-rw-r--r-- | src/libs/kdtools/updatesinfodata_p.h | 3 |
8 files changed, 50 insertions, 14 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 94e8e5b79..7ccfe2b1c 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -2960,9 +2960,9 @@ bool PackageManagerCorePrivate::addUpdateResourcesFromRepositories(bool compress continue; if (data->repository().isCompressed()) - m_compressedPackageSources.insert(PackageSource(QUrl::fromLocalFile(data->path()), 2)); + m_compressedPackageSources.insert(PackageSource(QUrl::fromLocalFile(data->path()), 2, data->repository().postLoadComponentScript())); else - m_packageSources.insert(PackageSource(QUrl::fromLocalFile(data->path()), 0)); + m_packageSources.insert(PackageSource(QUrl::fromLocalFile(data->path()), 0, data->repository().postLoadComponentScript())); ProductKeyCheck::instance()->addPackagesFromXml(data->path() + QLatin1String("/Updates.xml")); } diff --git a/src/libs/installer/packagesource.h b/src/libs/installer/packagesource.h index 92245d906..f63b53cd8 100644 --- a/src/libs/installer/packagesource.h +++ b/src/libs/installer/packagesource.h @@ -40,13 +40,15 @@ struct INSTALLER_EXPORT PackageSource PackageSource() : priority(-1) {} - PackageSource(const QUrl &u, int p) + PackageSource(const QUrl &u, int p, bool pl = false) : url(u) , priority(p) + , postLoadComponentScript(pl) {} QUrl url; int priority; + bool postLoadComponentScript; }; INSTALLER_EXPORT hashValue qHash(const PackageSource &key, hashValue seed); diff --git a/src/libs/installer/repository.cpp b/src/libs/installer/repository.cpp index ca090ab05..f7035e732 100644 --- a/src/libs/installer/repository.cpp +++ b/src/libs/installer/repository.cpp @@ -49,6 +49,7 @@ Repository::Repository() : m_default(false) , m_enabled(false) , m_compressed(false) + , m_postLoadComponentScript(false) { } @@ -65,6 +66,7 @@ Repository::Repository(const Repository &other) , m_categoryname(other.m_categoryname) , m_compressed(other.m_compressed) , m_xmlChecksum(other.m_xmlChecksum) + , m_postLoadComponentScript(other.m_postLoadComponentScript) { } @@ -77,6 +79,7 @@ Repository::Repository(const QUrl &url, bool isDefault, bool compressed) , m_default(isDefault) , m_enabled(true) , m_compressed(compressed) + , m_postLoadComponentScript(false) { } @@ -252,6 +255,22 @@ bool Repository::isCompressed() const } /*! + \internal +*/ +bool Repository::postLoadComponentScript() const +{ + return m_postLoadComponentScript; +} + +/*! + \internal +*/ +void Repository::setPostLoadComponentScript(const bool postLoad) +{ + m_postLoadComponentScript = postLoad; +} + +/*! Compares the values of this repository to \a other and returns true if they are equal (same server, default state, enabled state as well as username and password). \sa operator!=() */ @@ -259,7 +278,8 @@ bool Repository::operator==(const Repository &other) const { return m_url == other.m_url && m_default == other.m_default && m_enabled == other.m_enabled && m_username == other.m_username && m_password == other.m_password - && m_displayname == other.m_displayname && m_xmlChecksum == other.m_xmlChecksum; + && m_displayname == other.m_displayname && m_xmlChecksum == other.m_xmlChecksum + && m_postLoadComponentScript == other.m_postLoadComponentScript; } /*! @@ -288,6 +308,7 @@ const Repository &Repository::operator=(const Repository &other) m_compressed = other.m_compressed; m_categoryname = other.m_categoryname; m_xmlChecksum = other.m_xmlChecksum; + m_postLoadComponentScript = other.m_postLoadComponentScript; return *this; } @@ -307,7 +328,7 @@ QDataStream &operator>>(QDataStream &istream, Repository &repository) { QByteArray url, username, password, displayname, compressed; istream >> url >> repository.m_default >> repository.m_enabled >> username >> password - >> displayname >> repository.m_categoryname >> repository.m_xmlChecksum; + >> displayname >> repository.m_categoryname >> repository.m_xmlChecksum >> repository.m_postLoadComponentScript; repository.setUrl(QUrl::fromEncoded(QByteArray::fromBase64(url))); repository.setUsername(QString::fromUtf8(QByteArray::fromBase64(username))); repository.setPassword(QString::fromUtf8(QByteArray::fromBase64(password))); @@ -323,7 +344,7 @@ QDataStream &operator<<(QDataStream &ostream, const Repository &repository) return ostream << repository.m_url.toEncoded().toBase64() << repository.m_default << repository.m_enabled << repository.m_username.toUtf8().toBase64() << repository.m_password.toUtf8().toBase64() << repository.m_displayname.toUtf8().toBase64() << repository.m_categoryname.toUtf8().toBase64() - << repository.m_xmlChecksum.toBase64(); + << repository.m_xmlChecksum.toBase64() << repository.m_postLoadComponentScript; } } diff --git a/src/libs/installer/repository.h b/src/libs/installer/repository.h index 80698e447..0a589a43e 100644 --- a/src/libs/installer/repository.h +++ b/src/libs/installer/repository.h @@ -71,6 +71,9 @@ public: void setXmlChecksum(const QByteArray &checksum); bool isCompressed() const; + bool postLoadComponentScript() const; + void setPostLoadComponentScript(const bool postLoad); + bool operator==(const Repository &other) const; bool operator!=(const Repository &other) const; @@ -90,6 +93,7 @@ private: QString m_categoryname; bool m_compressed; QByteArray m_xmlChecksum; + bool m_postLoadComponentScript; }; inline hashValue qHash(const Repository &repository) diff --git a/src/libs/kdtools/updatefinder.cpp b/src/libs/kdtools/updatefinder.cpp index 120dcb952..dbe7825df 100644 --- a/src/libs/kdtools/updatefinder.cpp +++ b/src/libs/kdtools/updatefinder.cpp @@ -301,9 +301,9 @@ bool UpdateFinder::downloadUpdateXMLFiles() connect(downloader, SIGNAL(downloadCanceled()), this, SLOT(slotDownloadDone())); connect(downloader, SIGNAL(downloadCompleted()), this, SLOT(slotDownloadDone())); connect(downloader, SIGNAL(downloadAborted(QString)), this, SLOT(slotDownloadDone())); - m_updatesInfoList.insert(new UpdatesInfo, Data(info, downloader)); + m_updatesInfoList.insert(new UpdatesInfo(info.postLoadComponentScript), Data(info, downloader)); } else { - UpdatesInfo *updatesInfo = new UpdatesInfo; + UpdatesInfo *updatesInfo = new UpdatesInfo(info.postLoadComponentScript); updatesInfo->setFileName(QInstaller::pathFromUrl(url)); m_updatesInfoList.insert(updatesInfo, Data(info)); } diff --git a/src/libs/kdtools/updatesinfo.cpp b/src/libs/kdtools/updatesinfo.cpp index 707daf11f..e82c1c1fb 100644 --- a/src/libs/kdtools/updatesinfo.cpp +++ b/src/libs/kdtools/updatesinfo.cpp @@ -40,8 +40,9 @@ using namespace KDUpdater; -UpdatesInfoData::UpdatesInfoData() +UpdatesInfoData::UpdatesInfoData(const bool postLoadComponentScript) : error(UpdatesInfo::NotYetReadError) + , m_postLoadComponentScript(postLoadComponentScript) { } @@ -135,7 +136,14 @@ bool UpdatesInfoData::parsePackageUpdateElement(QXmlStreamReader &reader, const parseOperations(reader, info.data); } else if (elementName == QLatin1String("Script")) { const QXmlStreamAttributes attr = reader.attributes(); - const bool postLoad = attr.value(QLatin1String("postLoad")).toString().toLower() == QInstaller::scTrue ? true : false; + bool postLoad = false; + // postLoad can be set either to individual components or to whole repositories. + // If individual components has the postLoad attribute, it overwrites the repository value. + if (attr.hasAttribute(QLatin1String("postLoad"))) + postLoad = attr.value(QLatin1String("postLoad")).toString().toLower() == QInstaller::scTrue ? true : false; + else if (m_postLoadComponentScript) + postLoad = true; + if (postLoad) scriptHash.insert(QLatin1String("postLoadScript"), reader.readElementText()); else @@ -238,8 +246,8 @@ void UpdatesInfoData::parseLicenses(QXmlStreamReader &reader, QHash<QString, QVa // // UpdatesInfo // -UpdatesInfo::UpdatesInfo() - : d(new UpdatesInfoData) +UpdatesInfo::UpdatesInfo(const bool postLoadComponentScript) + : d(new UpdatesInfoData(postLoadComponentScript)) { } diff --git a/src/libs/kdtools/updatesinfo_p.h b/src/libs/kdtools/updatesinfo_p.h index bd9885327..a3768232a 100644 --- a/src/libs/kdtools/updatesinfo_p.h +++ b/src/libs/kdtools/updatesinfo_p.h @@ -59,7 +59,7 @@ public: InvalidContentError }; - UpdatesInfo(); + UpdatesInfo(const bool postLoadComponentScript = false); ~UpdatesInfo(); bool isValid() const; diff --git a/src/libs/kdtools/updatesinfodata_p.h b/src/libs/kdtools/updatesinfodata_p.h index 9229f8577..c71a85193 100644 --- a/src/libs/kdtools/updatesinfodata_p.h +++ b/src/libs/kdtools/updatesinfodata_p.h @@ -43,7 +43,7 @@ struct UpdatesInfoData : public QSharedData Q_DECLARE_TR_FUNCTIONS(KDUpdater::UpdatesInfoData) public: - UpdatesInfoData(); + UpdatesInfoData(const bool postLoadComponentScript); ~UpdatesInfoData(); int error; @@ -53,6 +53,7 @@ public: QString applicationVersion; QString checkSha1CheckSum; QList<UpdateInfo> updateInfoList; + bool m_postLoadComponentScript; void parseFile(const QString &updateXmlFile); bool parsePackageUpdateElement(QXmlStreamReader &reader, const QString &checkSha1CheckSum); |