mirror of
https://github.com/QuasarApp/installer-framework.git
synced 2025-05-04 09:19:34 +00:00
Update selected components from command line
Selected components can be updated with --updatePackages <package_id>. If essential components are found, only the essential components are updated. Change-Id: I0eb8a8f5ca855af16eabd5f888cd9a0d5e933d84 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
This commit is contained in:
parent
e238e76433
commit
f8ade64515
@ -1879,20 +1879,15 @@ void PackageManagerCore::listInstalledPackages()
|
||||
}
|
||||
}
|
||||
|
||||
void PackageManagerCore::updateComponentsSilently()
|
||||
void PackageManagerCore::updateComponentsSilently(const QStringList &componentsToUpdate)
|
||||
{
|
||||
if (d->runningProcessesFound())
|
||||
return;
|
||||
setUpdater();
|
||||
autoRejectMessageBoxes();
|
||||
|
||||
autoAcceptMessageBoxes();
|
||||
|
||||
//Prevent infinite loop if installation for some reason fails.
|
||||
setMessageBoxAutomaticAnswer(QLatin1String("installationErrorWithRetry"), QMessageBox::Cancel);
|
||||
|
||||
fetchRemotePackagesTree();
|
||||
|
||||
const QList<QInstaller::Component*> componentList = components(
|
||||
ComponentType::Root | ComponentType::Descendants);
|
||||
// List contains components containing update, if essential found contains only essential component
|
||||
const QList<QInstaller::Component*> componentList = componentsMarkedForInstallation();
|
||||
|
||||
if (componentList.count() == 0) {
|
||||
qDebug() << "No updates available.";
|
||||
@ -1906,26 +1901,27 @@ void PackageManagerCore::updateComponentsSilently()
|
||||
essentialUpdatesFound = true;
|
||||
}
|
||||
if (!essentialUpdatesFound) {
|
||||
//Mark all components to be updated
|
||||
int componentToUpdateCount = componentsToUpdate.count();
|
||||
//Mark components to be updated
|
||||
foreach (Component *comp, componentList) {
|
||||
comp->setCheckState(Qt::Checked);
|
||||
}
|
||||
}
|
||||
QString htmlOutput;
|
||||
bool componentsOk = calculateComponents(&htmlOutput);
|
||||
if (componentsOk) {
|
||||
if (runPackageUpdater()) {
|
||||
writeMaintenanceTool();
|
||||
if (essentialUpdatesFound) {
|
||||
qDebug() << "Essential components updated successfully.";
|
||||
}
|
||||
else {
|
||||
qDebug() << "Components updated successfully.";
|
||||
if (componentToUpdateCount == 0) { // No components given, update all
|
||||
comp->setCheckState(Qt::Checked);
|
||||
} else { // Check only components we want to update
|
||||
foreach (const QString &name, componentsToUpdate) {
|
||||
if (comp->name() == name)
|
||||
comp->setCheckState(Qt::Checked);
|
||||
else
|
||||
comp->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << htmlOutput;
|
||||
|
||||
if (d->calculateComponentsAndRun()) {
|
||||
if (essentialUpdatesFound)
|
||||
qDebug() << "Essential components updated successfully.";
|
||||
else
|
||||
qDebug() << "Components updated successfully.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,8 +227,7 @@ public:
|
||||
ComponentModel *updaterComponentModel() const;
|
||||
void listInstalledPackages();
|
||||
void listAvailablePackages(const QString ®exp);
|
||||
void updateComponentsSilently();
|
||||
|
||||
void updateComponentsSilently(const QStringList &componentsToUpdate);
|
||||
// convenience
|
||||
Q_INVOKABLE bool isInstaller() const;
|
||||
Q_INVOKABLE bool isOfflineOnly() const;
|
||||
|
@ -118,6 +118,8 @@ CommandLineParser::CommandLineParser()
|
||||
QLatin1String("URI,...")));
|
||||
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::SilentUpdate),
|
||||
QLatin1String("Updates all packages silently.")));
|
||||
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::UpdatePackages),
|
||||
QLatin1String("Updates selected packages."), QLatin1String("package,...")));
|
||||
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ListInstalledPackages),
|
||||
QLatin1String("Lists installed packages.")));
|
||||
m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ListPackages),
|
||||
|
@ -54,6 +54,7 @@ const char StartServer[] = "startserver";
|
||||
const char StartClient[] = "startclient";
|
||||
const char InstallCompressedRepository[] = "installCompressedRepository";
|
||||
const char SilentUpdate[] = "silentUpdate";
|
||||
const char UpdatePackages[] = "updatePackages";
|
||||
const char ListInstalledPackages[] = "listInstalledPackages";
|
||||
const char ListPackages[] = "listPackages";
|
||||
const char Platform[] = "platform";
|
||||
|
@ -319,8 +319,7 @@ int InstallerBase::run()
|
||||
if (m_core->isInstaller())
|
||||
throw QInstaller::Error(QLatin1String("Cannot start installer binary as updater."));
|
||||
checkLicense();
|
||||
m_core->setUpdater();
|
||||
m_core->updateComponentsSilently();
|
||||
m_core->updateComponentsSilently(QStringList());
|
||||
} else if (parser.isSet(QLatin1String(CommandLineOptions::ListInstalledPackages))){
|
||||
if (m_core->isInstaller())
|
||||
throw QInstaller::Error(QLatin1String("Cannot start installer binary as package manager."));
|
||||
@ -333,6 +332,15 @@ int InstallerBase::run()
|
||||
checkLicense();
|
||||
QString regexp = parser.value(QLatin1String(CommandLineOptions::ListPackages));
|
||||
m_core->listAvailablePackages(regexp);
|
||||
} else if (parser.isSet(QLatin1String(CommandLineOptions::UpdatePackages))) {
|
||||
if (m_core->isInstaller())
|
||||
throw QInstaller::Error(QLatin1String("Cannot start installer binary as updater."));
|
||||
checkLicense();
|
||||
QStringList packages;
|
||||
const QString &value = parser.value(QLatin1String(CommandLineOptions::UpdatePackages));
|
||||
if (!value.isEmpty())
|
||||
packages = value.split(QLatin1Char(','), QString::SkipEmptyParts);
|
||||
m_core->updateComponentsSilently(packages);
|
||||
} else {
|
||||
//create the wizard GUI
|
||||
TabController controller(nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user