From 3358e1a0d4fd5c65e0855689b3882f1897498c56 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 5 Feb 2025 16:26:16 +0100 Subject: [PATCH] start to refactor update-procedure --- UpdatePTUDevCtrl/main.cpp | 3 +- UpdatePTUDevCtrl/worker.cpp | 70 ++++++++++++++++++++++++++++++++++++- UpdatePTUDevCtrl/worker.h | 7 ++++ 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/UpdatePTUDevCtrl/main.cpp b/UpdatePTUDevCtrl/main.cpp index 1f7592b..4319e29 100644 --- a/UpdatePTUDevCtrl/main.cpp +++ b/UpdatePTUDevCtrl/main.cpp @@ -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(); diff --git a/UpdatePTUDevCtrl/worker.cpp b/UpdatePTUDevCtrl/worker.cpp index 22ff1a8..aad8cfe 100644 --- a/UpdatePTUDevCtrl/worker.cpp +++ b/UpdatePTUDevCtrl/worker.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "message_handler.h" #include #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]"); @@ -181,8 +192,65 @@ Worker::Worker(int customerNr, , m_dcDownloadJsonFiles(new Command( QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid()))) //, m_withoutIsmasDirectPort(true) /* useful for testing */ { - , m_withoutIsmasDirectPort(false) /* useful for testing */ { + , m_withoutIsmasDirectPort(false) /* useful for testing */ { + // check ISMAS connectivity + m_workList.push_back( + std::make_unique( + QString("echo CheckIsmasConnectivityCommand") + , this)); + + // check if update activated in ISMAS + m_workList.push_back( + std::make_unique( + QString("echo CheckUpdateActivationCommand") + , this)); + + // check and fetch git-customer repository + m_workList.push_back( + std::make_unique( + QString("echo CheckAndFetchCustomerRepositoryCommand") + , this)); + + // exec opkg-commands + // first with no action -> dry-run + m_workList.push_back( + std::make_unique( + 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( + 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( + QString("echo UpdateFileSystemCommand") + , this)); + + + // send device-controller firmware down to device-controller-hardware + m_workList.push_back( + std::make_unique( + 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( + QString("echo ShowSoftwareStatusCommand") + , this)); + + // reboot machine + /////////////////////////////////////////////////////////// m_start = QDateTime::currentDateTime(); m_dcDownloadFirmware->setWorker(this); diff --git a/UpdatePTUDevCtrl/worker.h b/UpdatePTUDevCtrl/worker.h index 039575c..10750ac 100644 --- a/UpdatePTUDevCtrl/worker.h +++ b/UpdatePTUDevCtrl/worker.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -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);