diff options
Diffstat (limited to 'src/libs/installer/packagemanagercore_p.cpp')
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index f102d79ed..aac392d47 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -225,7 +225,7 @@ PackageManagerCorePrivate::PackageManagerCorePrivate(PackageManagerCore *core, q , m_updaterApplication(new DummyConfigurationInterface) , m_FSEngineClientHandler(initFSEngineClientHandler()) , m_status(PackageManagerCore::Unfinished) - , m_forceRestart(false) + , m_needsHardRestart(false) , m_testChecksum(false) , m_launchedAsRoot(AdminAuthorization::hasAdminRights()) , m_completeUninstall(false) @@ -1094,7 +1094,25 @@ void PackageManagerCorePrivate::writeUninstallerBinaryData(QIODevice *output, QF const qint64 dataBlockStart = output->pos(); QVector<Range<qint64> >resourceSegments; - foreach (const Range<qint64> &segment, layout.metadataResourceSegments) { + QVector<Range<qint64> >existingResourceSegments = layout.metadataResourceSegments; + + const QString newDefaultResource = m_core->value(QString::fromLatin1("DefaultResourceReplacement")); + if (!newDefaultResource.isEmpty()) { + QFile file(newDefaultResource); + if (file.open(QIODevice::ReadOnly)) { + resourceSegments.append(Range<qint64>::fromStartAndLength(output->pos(), file.size())); + appendData(output, &file, file.size()); + existingResourceSegments.remove(0); + + file.remove(); // clear all possible leftovers + m_core->setValue(QString::fromLatin1("DefaultResourceReplacement"), QString()); + } else { + qWarning() << QString::fromLatin1("Could not replace default resource with '%1'.") + .arg(newDefaultResource); + } + } + + foreach (const Range<qint64> &segment, existingResourceSegments) { input->seek(segment.start()); resourceSegments.append(Range<qint64>::fromStartAndLength(output->pos(), segment.length())); appendData(output, input, segment.length()); @@ -1156,8 +1174,6 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio performedOperations.append(takeOwnedOperation(op)); } - writeMaintenanceConfigFiles(); - #ifdef Q_OS_MAC // if it is a bundle, we need some stuff in it... const QString sourceAppDirPath = QCoreApplication::applicationDirPath(); @@ -1264,7 +1280,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio bool newBinaryWritten = false; bool replacementExists = false; - const QString installerBaseBinary = m_core->replaceVariables(m_installerBaseBinaryUnreplaced); + const QString installerBaseBinary = replaceVariables(m_installerBaseBinaryUnreplaced); if (!installerBaseBinary.isEmpty() && QFileInfo(installerBaseBinary).exists()) { qDebug() << "Got a replacement installer base binary:" << installerBaseBinary; @@ -1272,8 +1288,8 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio try { openForRead(&replacementBinary, replacementBinary.fileName()); writeUninstallerBinary(&replacementBinary, replacementBinary.size(), true); + qDebug() << "Wrote the binary with the new replacement."; - m_forceRestart = true; newBinaryWritten = true; replacementExists = true; } catch (const Error &error) { @@ -1283,10 +1299,17 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio if (!replacementBinary.remove()) { // Is there anything more sensible we can do with this error? I think not. It's not serious // enough for throwing / aborting the process. - qDebug() << QString::fromLatin1("Could not remove installer base binary (%1) after updating " + qDebug() << QString::fromLatin1("Could not remove installer base binary '%1' after updating " "the uninstaller: %2").arg(installerBaseBinary, replacementBinary.errorString()); + } else { + qDebug() << QString::fromLatin1("Removed installer base binary '%1' after updating the " + "uninstaller/ maintenance tool.").arg(installerBaseBinary); } m_installerBaseBinaryUnreplaced.clear(); + } else if (!installerBaseBinary.isEmpty() && !QFileInfo(installerBaseBinary).exists()) { + qWarning() << QString::fromLatin1("The current uninstaller/ maintenance tool could not be " + "updated. '%1' does not exist. Please fix the 'setInstallerBaseBinary(<temp_installer_base_" + "binary_path>)' call in your script.").arg(installerBaseBinary); } QFile input; @@ -1330,9 +1353,7 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio #endif } - performedOperations = sortOperationsBasedOnComponentDependencies( - performedOperations); - + performedOperations = sortOperationsBasedOnComponentDependencies(performedOperations); m_core->setValue(QLatin1String("installedOperationAreSorted"), QLatin1String("true")); try { @@ -1363,10 +1384,11 @@ void PackageManagerCorePrivate::writeUninstaller(OperationList performedOperatio appendInt64(&file, MagicCookie); } input.close(); + writeMaintenanceConfigFiles(); deferredRename(dataFile + QLatin1String(".new"), dataFile, false); if (newBinaryWritten) { - const bool restart = replacementExists && isUpdater() && (!statusCanceledOrFailed()); + const bool restart = replacementExists && isUpdater() && (!statusCanceledOrFailed()) && m_needsHardRestart; deferredRename(uninstallerName() + QLatin1String(".new"), uninstallerName(), restart); qDebug() << "Maintenance tool restart:" << (restart ? "true." : "false."); } @@ -1888,7 +1910,7 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr throw Error(operation->errorString()); if (component->value(scEssential, scFalse) == scTrue) - m_forceRestart = true; + m_needsHardRestart = true; } registerPathesForUninstallation(component->pathesForUninstallation(), component->name()); @@ -2389,9 +2411,11 @@ OperationList PackageManagerCorePrivate::sortOperationsBasedOnComponentDependenc // create the complete component graph Graph<QString> componentGraph; + const QRegExp dash(QLatin1String("-.*")); foreach (const Component* componentNode, m_core->availableComponents()) { componentGraph.addNode(componentNode->name()); - componentGraph.addEdges(componentNode->name(), componentNode->dependencies()); + const QStringList dependencies = componentNode->dependencies().replaceInStrings(dash,QString()); + componentGraph.addEdges(componentNode->name(), dependencies); } foreach (const QString &componentName, componentGraph.sort()) |