start to refactor update-procedure

This commit is contained in:
Gerhard Hoffmann 2025-02-05 16:26:16 +01:00
parent ea1d858f15
commit 3358e1a0d4
3 changed files with 78 additions and 2 deletions

View File

@ -203,7 +203,8 @@ int main(int argc, char *argv[]) {
mw.showFullScreen();
// test
worker.jsUpdate();
//worker.jsUpdate();
worker.workList().exec();
// worker.summary();
return a.exec();

View File

@ -20,6 +20,8 @@
#include <QRegularExpression>
#include <QJsonArray>
#include <memory>
#include "message_handler.h"
#include <DeviceController/interfaces.h>
#include "ismas/ismas_client.h"
@ -27,6 +29,15 @@
#include "mainwindow.h"
#include "utils.h"
#include "process/command.h"
#include "process/update_command.h"
#include "process/check_ismas_connectivity_command.h"
#include "process/check_update_activation_command.h"
#include "process/check_and_fetch_customer_repository_command.h"
#include "process/update_json_command.h"
#include "process/update_filesystem_command.h"
#include "process/exec_opkg_command.h"
#include "process/update_dc_command.h"
#include "process/show_software_status_command.h"
QString const Worker::UPDATE_STEP_OK ( " [ ok]");
QString const Worker::UPDATE_STEP_DONE ( " [done]");
@ -183,6 +194,63 @@ Worker::Worker(int customerNr,
//, m_withoutIsmasDirectPort(true) /* useful for testing */ {
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
// check ISMAS connectivity
m_workList.push_back(
std::make_unique<CheckIsmasConnectivityCommand>(
QString("echo CheckIsmasConnectivityCommand")
, this));
// check if update activated in ISMAS
m_workList.push_back(
std::make_unique<CheckUpdateActivationCommand>(
QString("echo CheckUpdateActivationCommand")
, this));
// check and fetch git-customer repository
m_workList.push_back(
std::make_unique<CheckAndFetchCustomerRepositoryCommand>(
QString("echo CheckAndFetchCustomerRepositoryCommand")
, this));
// exec opkg-commands
// first with no action -> dry-run
m_workList.push_back(
std::make_unique<ExecOpkgCommand>(
QString("echo ExecOpkgCommand")
, this, true));
// exec opkg-commands
// now with action -> no dry-run
// send json files down to device controller
m_workList.push_back(
std::make_unique<UpdateJsonCommand>(
QString("echo UpdateJsonCommand")
//QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())
, this, false));
// sync json files in repo etc-directory with /etc fs-directory
m_workList.push_back(
std::make_unique<UpdateFileSystemCommand>(
QString("echo UpdateFileSystemCommand")
, this));
// send device-controller firmware down to device-controller-hardware
m_workList.push_back(
std::make_unique<UpdateDCCommand>(
QString("echo UpdateDCCommand")
// QString("/opt/app/tools/atbupdate/ATBDownloadDCFirmware --read-dc-version true")
, this));
// show/send software-status
m_workList.push_back(
std::make_unique<ShowSoftwareStatusCommand>(
QString("echo ShowSoftwareStatusCommand")
, this));
// reboot machine
///////////////////////////////////////////////////////////
m_start = QDateTime::currentDateTime();
m_dcDownloadFirmware->setWorker(this);

View File

@ -12,6 +12,7 @@
#include <QDebug>
#include <QThread>
#include <QByteArray>
#include <QScopedPointer>
#include <optional>
#include <initializer_list>
@ -19,6 +20,7 @@
#include "git/git_client.h"
#include "ismas/ismas_client.h"
#include "utils.h"
#include "work_process_list.h"
#ifdef PTU5
#define SERIAL_PORT "ttymxc2"
@ -196,6 +198,8 @@ class Worker : public QThread{
bool m_withoutIsmasDirectPort;
QString m_apismVersion;
WorkList m_workList;
bool executeOpkgCommand(QString opkgCommand);
bool cleanUpOpkgCache();
QString getOsVersion() const;
@ -469,6 +473,9 @@ public:
QByteArray standardOutput() const { return m_standardOutput; }
WorkList const &workList() const { return m_workList; }
WorkList &workList() { return m_workList; }
signals:
void appendText(QString, QString suffix = "");
void insertText(QString);