From 34adba4642ed75ada0468c278e81b868f7c375f2 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Mon, 22 Mar 2021 16:54:36 +0200 Subject: CLI: Fix offline installer creation with empty component meta-archive Task-number: QTIFW-2189 Change-Id: Ic6f56156194039cca7bebf095fad8c1fc66fc275 Reviewed-by: Qt CI Bot Reviewed-by: Katja Marttila --- src/libs/installer/metadatajob.cpp | 7 +++++-- .../A/1.0.2-1content.7z | Bin 0 -> 182 bytes .../A/1.0.2-1content.7z.sha1 | 1 + .../A/1.0.2-1meta.7z | Bin 0 -> 106 bytes .../repository-componentmeta-emptymetafile/Updates.xml | 16 ++++++++++++++++ tests/auto/installer/createoffline/settings.qrc | 5 +++++ .../auto/installer/createoffline/tst_createoffline.cpp | 3 +++ 7 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z create mode 100644 tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z.sha1 create mode 100644 tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1meta.7z create mode 100644 tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/Updates.xml diff --git a/src/libs/installer/metadatajob.cpp b/src/libs/installer/metadatajob.cpp index a8405a0e8..2a9cb5ae7 100644 --- a/src/libs/installer/metadatajob.cpp +++ b/src/libs/installer/metadatajob.cpp @@ -654,8 +654,11 @@ MetadataJob::Status MetadataJob::parseUpdatesXml(const QList &re metaFound = parsePackageUpdate(c2, packageName, packageVersion, packageHash, online, testCheckSum); - //If meta element (script, licenses, etc.) is not found, no need to fetch metadata - if (metaFound) { + // If meta element (script, licenses, etc.) is not found, no need to fetch metadata. + // The offline-generator instance is an exception to this - if the Updates.xml contains + // checksum element for the meta-archive, we will fetch it, so that the temporary + // location contents match the remote repository. + if (metaFound || (m_core->isOfflineGenerator() && !packageHash.isEmpty())) { const QString repoUrl = metadata.repository.url().toString(); addFileTaskItem(QString::fromLatin1("%1/%2/%3meta.7z").arg(repoUrl, packageName, packageVersion), metadata.directory + QString::fromLatin1("/%1-%2-meta.7z").arg(packageName, packageVersion), diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z new file mode 100644 index 000000000..1c5ff001a Binary files /dev/null and b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z differ diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z.sha1 b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z.sha1 new file mode 100644 index 000000000..b36346655 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z.sha1 @@ -0,0 +1 @@ +5097e37368b44fc5242f3bb2fce08f5ade6c4c40 \ No newline at end of file diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1meta.7z b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1meta.7z new file mode 100644 index 000000000..408550be6 Binary files /dev/null and b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/A/1.0.2-1meta.7z differ diff --git a/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/Updates.xml b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/Updates.xml new file mode 100644 index 000000000..d3b180e43 --- /dev/null +++ b/tests/auto/installer/createoffline/data/repository-componentmeta-emptymetafile/Updates.xml @@ -0,0 +1,16 @@ + + {AnyApplication} + 1.0.0 + true + + A + A + Example component A + 1.0.2-1 + 2015-01-01 + true + + content.7z + 65c0db5bcf28139d434dce0e21674e33c87ab6d9 + + diff --git a/tests/auto/installer/createoffline/settings.qrc b/tests/auto/installer/createoffline/settings.qrc index 2c546d7f2..4b7666b4a 100644 --- a/tests/auto/installer/createoffline/settings.qrc +++ b/tests/auto/installer/createoffline/settings.qrc @@ -23,5 +23,10 @@ data/repository-unifiedmeta-script/Updates.xml data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z data/repository-unifiedmeta-script/org.qtproject.ifw.example/1.0.0-1content.7z.sha1 + + data/repository-componentmeta-emptymetafile/Updates.xml + data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z + data/repository-componentmeta-emptymetafile/A/1.0.2-1content.7z.sha1 + data/repository-componentmeta-emptymetafile/A/1.0.2-1meta.7z diff --git a/tests/auto/installer/createoffline/tst_createoffline.cpp b/tests/auto/installer/createoffline/tst_createoffline.cpp index 474b1d5de..3a3431442 100644 --- a/tests/auto/installer/createoffline/tst_createoffline.cpp +++ b/tests/auto/installer/createoffline/tst_createoffline.cpp @@ -85,6 +85,9 @@ private slots: QTest::newRow("Unified metaformat | Script") << ":///data/repository-unifiedmeta-script" << "org.qtproject.ifw.example" << PackageManagerCore::Success; + QTest::newRow("Component metaformat | Empty component meta-archive") + << ":///data/repository-componentmeta-emptymetafile" << "A" + << PackageManagerCore::Success; QTest::newRow("Non-existing component") << ":///data/repository-unifiedmeta-script" << "a.dummy.component" << PackageManagerCore::Canceled; -- cgit v1.2.3 From 6122f6e2e5efa17967a8004c368290afc2fa27f1 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Fri, 26 Mar 2021 15:45:35 +0200 Subject: CLI: Calculate required temporary and installation disk space Task-number: QTIFW-2197 Change-Id: I63a0bb265105f5a722ab8c645fa3511328bbcb33 Reviewed-by: Qt CI Bot Reviewed-by: Katja Marttila --- src/libs/installer/packagemanagercore.cpp | 5 ++++- src/libs/installer/packagemanagercore_p.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index ddfc0f832..5b36f8bc6 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -733,7 +733,7 @@ quint64 PackageManagerCore::requiredDiskSpace() const quint64 result = 0; foreach (QInstaller::Component *component, orderedComponentsToInstall()) - result += size(component, scUncompressedSize); + result += size(component, isOfflineGenerator() ? scCompressedSize : scUncompressedSize); return result; } @@ -2653,6 +2653,9 @@ bool PackageManagerCore::checkAvailableSpace(QString &message) const // if we create a local repository, take that space into account as well required += repositorySize; } + // if we create offline installer, take current executable size into account + if (isOfflineGenerator()) + required += QFile(QCoreApplication::applicationFilePath()).size(); qDebug() << "Installation space required:" << humanReadableSize(required) << "Temporary space " "required:" << humanReadableSize(tempRequired) << "Local repository size:" diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index f4670c738..fbc3f473d 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -2806,7 +2806,12 @@ bool PackageManagerCorePrivate::calculateComponentsAndRun() qCDebug(QInstaller::lcInstallerInstallLog) << "Installation canceled."; } else if (componentsOk && acceptLicenseAgreements()) { qCDebug(QInstaller::lcInstallerInstallLog).noquote() << htmlToString(htmlOutput); - if (!(m_autoConfirmCommand || askUserConfirmCommand())) { + + QString spaceInfo; + const bool spaceOk = m_core->checkAvailableSpace(spaceInfo); + qCDebug(QInstaller::lcInstallerInstallLog) << spaceInfo; + + if (!spaceOk || !(m_autoConfirmCommand || askUserConfirmCommand())) { qCDebug(QInstaller::lcInstallerInstallLog) << "Installation aborted."; } else if (m_core->run()) { // Write maintenance tool if required -- cgit v1.2.3 From 12b44ee5198165df1933576e0c6df14b6ed27010 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Fri, 26 Mar 2021 12:55:47 +0200 Subject: Fix segfault when selecting non-existing component from script Task-number: QTIFW-2195 Change-Id: Iaf75d4a4ff20f20a36c0b2d21abb3969b86b5a84 Reviewed-by: Katja Marttila --- src/libs/installer/packagemanagercore_p.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index fbc3f473d..d1e482912 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -2279,6 +2279,11 @@ void PackageManagerCorePrivate::setComponentSelection(const QString &id, Qt::Che { ComponentModel *model = m_core->isUpdater() ? m_core->updaterComponentModel() : m_core->defaultComponentModel(); Component *component = m_core->componentByName(id); + if (!component) { + qCWarning(QInstaller::lcInstallerInstallLog).nospace() + << "Unable to set selection for: " << id << ". Component not found."; + return; + } const QModelIndex &idx = model->indexFromComponentName(component->treeName()); if (idx.isValid()) model->setData(idx, state, Qt::CheckStateRole); -- cgit v1.2.3 From e98269889b6156b7b027e1848477607b6151dfa4 Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Tue, 30 Mar 2021 14:50:38 +0300 Subject: Sign only generated IFW installer IFW binaries cannot be signed as then the end executable is signed making it impossible for users to sign their own installers with their own keys. This change also exports IFW tools, examples and docs for online repository usage. Change-Id: I5094c50ea804854ba619216b03f6dc25ebedee57 Reviewed-by: Iikka Eklund --- coin/instructions/make_instructions.yaml | 23 ++++++++++++++--------- coin/qt-installer-package-config.json | 3 ++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/coin/instructions/make_instructions.yaml b/coin/instructions/make_instructions.yaml index 003e9d746..411a988eb 100644 --- a/coin/instructions/make_instructions.yaml +++ b/coin/instructions/make_instructions.yaml @@ -86,12 +86,12 @@ instructions: - type: ChangeDirectory directory: "{{.InstallRoot}}/{{.AgentWorkingDir}}" - type: ExecuteCommand - command: "python3 {{.SourceDir}}/coin/create_ifw_installer.py --src-dir {{.SourceDir}} --bld-dir {{.SourceDir}} --target-dir {{.SourceDir}} --target-name QtInstallerFramework-linux-x64-4.1.0.run" + command: "python3 {{.SourceDir}}/coin/create_ifw_installer.py --src-dir {{.SourceDir}} --bld-dir {{.SourceDir}} --target-dir {{.SourceDir}}/IfwInstaller --target-name QtInstallerFramework-linux-x64-4.1.0.run" maxTimeInSeconds: 36000 maxTimeBetweenOutput: 3600 userMessageOnFailure: "Failed to create ifw installer." - type: Rename - sourcePath: "{{.SourceDir}}/QtInstallerFramework-linux-x64-4.1.0.run" + sourcePath: "{{.SourceDir}}/IfwInstaller/QtInstallerFramework-linux-x64-4.1.0.run" targetPath: "{{.InstallRoot}}/{{.AgentWorkingDir}}/QtInstallerFramework-linux-x64-4.1.0.run" userMessageOnFailure: "Failed to copy installer." enable_if: @@ -106,7 +106,7 @@ instructions: - type: ChangeDirectory directory: "{{.InstallRoot}}/{{.AgentWorkingDir}}" - type: ExecuteCommand - command: "python3 {{.SourceDir}}/coin/create_ifw_installer.py --src-dir {{.SourceDir}} --bld-dir {{.SourceDir}} --target-dir {{.SourceDir}} --target-name QtInstallerFramework-macOS-x86_64-4.1.0.app" + command: "python3 {{.SourceDir}}/coin/create_ifw_installer.py --src-dir {{.SourceDir}} --bld-dir {{.SourceDir}} --target-dir {{.SourceDir}}/IfwInstaller --target-name QtInstallerFramework-macOS-x86_64-4.1.0.app" maxTimeInSeconds: 36000 maxTimeBetweenOutput: 3600 userMessageOnFailure: "Failed to create ifw installer." @@ -114,17 +114,17 @@ instructions: variableName: QT_CODESIGN_IDENTITY_KEY variableValue: "A5GTH44LYL" - type: ExecuteCommand - command: "{{.AgentWorkingDir}}/qtsdk/qtsdk/packaging-tools/sign_installer.py mac --file={{.SourceDir}}/QtInstallerFramework-macOS-x86_64-4.1.0.app" + command: "{{.AgentWorkingDir}}/qtsdk/qtsdk/packaging-tools/sign_installer.py mac --file={{.SourceDir}}/IfwInstaller/QtInstallerFramework-macOS-x86_64-4.1.0.app" maxTimeInSeconds: 36000 maxTimeBetweenOutput: 3600 userMessageOnFailure: "Failed to sign the ifw installer" - type: ExecuteCommand - command: "{{.AgentWorkingDir}}/qtsdk/qtsdk/packaging-tools/notarize.py --dmg={{.SourceDir}}/QtInstallerFramework-macOS-x86_64-4.1.0.dmg" + command: "{{.AgentWorkingDir}}/qtsdk/qtsdk/packaging-tools/notarize.py --dmg={{.SourceDir}}/IfwInstaller/QtInstallerFramework-macOS-x86_64-4.1.0.dmg" maxTimeInSeconds: 36000 maxTimeBetweenOutput: 3600 userMessageOnFailure: "Failed to notarize the ifw installer" - type: Rename - sourcePath: "{{.SourceDir}}/QtInstallerFramework-macOS-x86_64-4.1.0.dmg" + sourcePath: "{{.SourceDir}}/IfwInstaller/QtInstallerFramework-macOS-x86_64-4.1.0.dmg" targetPath: "{{.InstallRoot}}/{{.AgentWorkingDir}}/QtInstallerFramework-macOS-x86_64-4.1.0.dmg" userMessageOnFailure: "Failed to copy installer." enable_if: @@ -139,7 +139,7 @@ instructions: - type: ChangeDirectory directory: "{{.SourceDir}}" - type: ExecuteCommand - command: "{{.Env.PYTHON3_PATH}}\\python {{.SourceDir}}\\coin\\create_ifw_installer.py --src-dir {{.SourceDir}} --bld-dir {{.SourceDir}} --target-dir C:\\{{.SourceDir}} --target-name QtInstallerFramework-windows-x86-4.1.0" + command: "{{.Env.PYTHON3_PATH}}\\python {{.SourceDir}}\\coin\\create_ifw_installer.py --src-dir {{.SourceDir}} --bld-dir {{.SourceDir}} --target-dir C:\\{{.SourceDir}}\\IfwInstaller --target-name QtInstallerFramework-windows-x86-4.1.0" maxTimeInSeconds: 1200 maxTimeBetweenOutput: 1200 userMessageOnFailure: "Failed to create ifw installer." @@ -151,7 +151,7 @@ instructions: equals_value: Windows - type: SignPackage - directory: "{{.SourceDir}}" + directory: "{{.SourceDir}}/IfwInstaller" maxTimeInSeconds: 1200 maxTimeBetweenOutput: 1200 enable_if: @@ -160,7 +160,7 @@ instructions: equals_value: Windows - type: Rename - sourcePath: "{{.SourceDir}}/QtInstallerFramework-windows-x86-4.1.0.exe" + sourcePath: "{{.SourceDir}}/IfwInstaller/QtInstallerFramework-windows-x86-4.1.0.exe" targetPath: "{{.InstallRoot}}/{{.AgentWorkingDir}}/QtInstallerFramework-windows-x86-4.1.0.exe" userMessageOnFailure: "Failed to copy installer." enable_if: @@ -168,6 +168,11 @@ instructions: property: host.os equals_value: Windows + - type: Rename + sourcePath: "{{.SourceDir}}/dist/packages/org.qtproject.ifw.binaries/data/data.7z" + targetPath: "{{.InstallRoot}}/{{.AgentWorkingDir}}/ifw_data.7z" + userMessageOnFailure: "Failed to copy IFW binary archive." + - type: UploadArtifact archiveDirectory: "{{.InstallRoot}}/{{.AgentWorkingDir}}" transferType: UploadModuleBuildArtifact diff --git a/coin/qt-installer-package-config.json b/coin/qt-installer-package-config.json index 563110519..9654c513d 100644 --- a/coin/qt-installer-package-config.json +++ b/coin/qt-installer-package-config.json @@ -2,7 +2,8 @@ "version": "1", "module-split": { "__extract__": [ - "**/*QtInstallerFramework-*" + "**/*QtInstallerFramework-*", + "**/*ifw_data*" ] } } -- cgit v1.2.3