Compare commits

..

10 Commits

Author SHA1 Message Date
81c5f8ee7e Save for the weekend. 2023-10-20 13:55:18 +02:00
29e6a25e72 Add comment for version 1.3.13 2023-10-19 13:45:52 +02:00
5abc057bda Minor: add possible debug messages. 2023-10-19 13:44:51 +02:00
8aeb7ecfea Don't check opkg_commands-file in the system-filesystem to remove
confusing error-messages.
2023-10-19 13:43:53 +02:00
4bb8e241b6 Update process: check sanity of customer repository: are etc/ and
opt/directories contained? If not, remove the repository and clone it
again. This is done without checking the ISMAS-WAIT-button.
2023-10-19 13:41:44 +02:00
4469a23f9c Implemented helpers:
bool isRepositoryCorrupted();
    bool repairCorruptedRepository();

    int sendCloneAndCheckoutSuccess();
    int sendCloneAndCheckoutFailure();
    int sendIsmasTriggerFailure();
2023-10-19 13:39:48 +02:00
d1f795e2db Added helpers:
bool isRepositoryCorrupted();
    bool repairCorruptedRepository();

    int sendCloneAndCheckoutSuccess();
    int sendCloneAndCheckoutFailure();
    int sendIsmasTriggerFailure();

and static variables

    static constexpr const int CLONE_AND_CHECKOUT_SUCCESS = 0;
    static constexpr const int CLONE_AND_CHECKOUT_FAILURE = -3;
    static constexpr const int ISMAS_TRIGGER_FAILURE = -5;
2023-10-19 13:38:16 +02:00
6865056f4b Replace regex in gitCloneCustomerRepository() with straight-forward
steing-handling: regex sometimes returned error.
2023-10-19 13:35:07 +02:00
37bd5c90d3 Add printUpdateStatus() helper for QString 2023-10-19 13:34:07 +02:00
fcba120dfa Minor: commented out unnecessary debug/info output 2023-10-18 16:21:44 +02:00
12 changed files with 771 additions and 286 deletions

View File

@ -39,6 +39,11 @@ DEFINES += QT_DEPRECATED_WARNINGS
# Use 'git pull' instead of 'git fetch'.
# Use 'git clone --filter=blob:none' instead of 'git clone' to speed
# up cloning of customer repository.
# 1.3.13: Fix: if the customer repository is corrupted, remove it and re-clone
# the repository (without checking the ISMAS-trigger (WAIT-)button.
# 1.3.14: Add additional check for sanity of customer repository using
# "git fsck".
# Stream-lined code of update process.
win32 {
BUILD_DATE=$$system("date /t")

View File

@ -68,7 +68,11 @@ bool GitClient::gitCloneCustomerRepository() {
Note: git v2.18 does not support treeless clones: --filter=tree:0.
*/
QString gitCommand("git clone --filter=blob:none ");
// Note: for some reason it is necessary to pass "--progress ---v",
// otherwise QProcess returns an error of 128 = 0x80 for the command.
QString gitCommand("git clone --progress -vvv --filter=blob:none ");
gitCommand += m_repositoryPath;
Command c(gitCommand);
@ -79,26 +83,32 @@ bool GitClient::gitCloneCustomerRepository() {
QString const result = c.getCommandResult();
if (!result.isEmpty()) {
// Cloning into 'customer_281'...\n
static QRegularExpression re("(^\\s*Cloning\\s+into\\s+[']\\s*)(.*)(\\s*['].*$)");
QRegularExpressionMatch match = re.match(result);
if (match.hasMatch()) {
if (re.captureCount() == 3) { // start with full match (0), then the other 3 matches
QString const &customerNr = match.captured(2).trimmed();
if (customerNr == m_customerNr) {
qInfo() << "CLONING" << m_repositoryPath << "OK";
return true;
int customer = -1;
int cloning = result.indexOf("Cloning", 0, Qt::CaseInsensitive);
if (cloning != -1) {
customer = result.indexOf("customer_", cloning, Qt::CaseInsensitive);
if (customer != -1) {
QString customerNr = result.mid(customer);
static constexpr char const ch = '\'';
int i = customerNr.indexOf(QChar(ch));
if (i != -1) {
if ((customerNr = customerNr.mid(0, i)) == m_customerNr) {
qInfo() << "CLONING" << m_repositoryPath << "OK";
return true;
}
Utils::printCriticalErrorMsg(
QString("ERROR CLONE RESULT HAS WRONG CUSTOMER-NR. (%1 != %2) CLONE_RESULT=%3")
.arg(customerNr)
.arg(m_customerNr)
.arg(result));
return false;
}
Utils::printCriticalErrorMsg(
QString("ERROR CLONE RESULT HAS WRONG CUSTOMER-NR. rcc=%1 customer=%2 CLONE_RESULT=%3")
.arg(re.captureCount())
.arg(customerNr)
.arg(result));
return false;
}
}
Utils::printCriticalErrorMsg(
QString("ERROR CLONE RESULT HAS WRONG FORMAT. rcc=%1 CLONE_RESULT=%2")
.arg(re.captureCount())
QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONING=%1 CUSTOMER=%2 CLONE_RESULT=%3")
.arg(cloning)
.arg(customer)
.arg(result));
return false;
}
@ -269,6 +279,17 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
return std::nullopt;
}
bool GitClient::gitFsck() {
bool r = false;
if (QDir(m_customerRepository).exists()) {
Command c("git fsck");
if ((r = c.execute(m_customerRepository)) == false) {
QString const &s = c.getCommandResult().trimmed();
Utils::printCriticalErrorMsg(QString("GIT FSCK FAILED: %1").arg(s));
}
}
return r;
}
/*
Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
*/

View File

@ -47,6 +47,8 @@ class GitClient : public QObject {
std::optional<QStringList> gitDiff(QString const &commit);
std::optional<QStringList> gitMerge();
bool gitFsck();
QString gitLastCommit(QString fileName);
QStringList gitShowReason(QString branchName);
static QString gitBlob(QString fileName);

View File

@ -56,6 +56,12 @@ void IsmasClient::printDebugMessage(int port,
QString const &clientIP,
int clientPort,
QString const &message) {
#if 1
Q_UNUSED(port);
Q_UNUSED(clientIP);
Q_UNUSED(clientPort);
Q_UNUSED(message);
#else
qDebug().noquote()
<< "\n"
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
@ -64,12 +70,19 @@ void IsmasClient::printDebugMessage(int port,
<< "local address ..." << clientIP << "\n"
<< "local port ......" << clientPort << "\n"
<< message;
#endif
}
void IsmasClient::printInfoMessage(int port,
QString const &clientIP,
int clientPort,
QString const &message) {
#if 1
Q_UNUSED(port);
Q_UNUSED(clientIP);
Q_UNUSED(clientPort);
Q_UNUSED(message);
#else
qInfo().noquote()
<< "\n"
<< "SEND-REQUEST-RECEIVE-RESPONSE ..." << "\n"
@ -78,6 +91,7 @@ void IsmasClient::printInfoMessage(int port,
<< "local address ..." << clientIP << "\n"
<< "local port ......" << clientPort << "\n"
<< message;
#endif
}
void IsmasClient::printErrorMessage(int port,
@ -376,16 +390,18 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
version.toStdString().c_str());
}
QString IsmasClient::errorGitClone(int percent, QString const &info, QString const &version) {
QString IsmasClient::errorGitClone(QString const &info,
QString const &version) {
return updateNewsToIsmas("U0003",
percent,
m_progressInPercent,
RESULT_CODE::INSTALL_ERROR,
"CLONE CUSTOMER REPOSITORY FAILED",
info.toStdString().c_str(),
version.toStdString().c_str());
}
QString IsmasClient::backendConnected(QString const &info, QString const &version) {
QString IsmasClient::backendConnected(QString const &info,
QString const &version) {
return updateNewsToIsmas("U0010",
m_progressInPercent,
RESULT_CODE::SUCCESS,
@ -394,7 +410,8 @@ QString IsmasClient::backendConnected(QString const &info, QString const &versio
version.toStdString().c_str());
}
QString IsmasClient::execOpkgCommand(QString const &info, QString const &version) {
QString IsmasClient::execOpkgCommand(QString const &info,
QString const &version) {
return updateNewsToIsmas("U0010",
m_progressInPercent,
RESULT_CODE::SUCCESS,

View File

@ -177,7 +177,7 @@ public:
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
QString errorGitClone(int percent, QString const &info, QString const &version = QString());
QString errorGitClone(QString const &info, QString const &version = QString());
QString backendConnected(QString const &info, QString const &version = QString());
QString updateTriggerSet(QString const &info, QString const &version = QString());
QString errorUpdateTrigger(QString const &info, QString const &version = QString());

View File

@ -96,7 +96,7 @@ MainWindow::MainWindow(hwinf *hw, Worker *worker, Update *update, QWidget *paren
, m_worker(worker)
, m_width(70)
, m_progressRunning(false)
, m_progressValue(0)
// , m_progressValue(0)
, m_update(update)
, m_updateStep(UpdateDcEvent::UpdateStep::NONE) {
@ -178,22 +178,22 @@ void MainWindow::customEvent(QEvent *event) {
case START_PROGRESS_LOOP: {
m_progressRunning = true;
ui->updateProgress->reset();
m_progressValue = 10;
QApplication::postEvent(this, new ProgressEvent(this, m_progressValue));
// m_progressValue = 10;
QApplication::postEvent(this, new ProgressEvent(this, 1));
} break;
case STOP_PROGRESS_LOOP: {
m_progressRunning = false;
m_progressValue -= 10;
m_worker->setProgress(m_progressValue/10);
// m_progressValue -= 10;
// m_worker->setProgress(m_progressValue/10);
} break;
default: {
if (m_progressRunning) {
m_progressValue = progress;
ui->updateProgress->setValue(progress/10);
QApplication::postEvent(this, new ProgressEvent(this, progress+10));
QThread::msleep(500);
}
}
if (m_progressRunning) {
// m_progressValue = progress;
ui->updateProgress->setValue(progress);
// ueberpruefen: hauptfenster schickt sich selber ein event
// QApplication::postEvent(this, new ProgressEvent(this, progress));
// QThread::msleep(500);
}}
}
} else
if (sender == m_worker) {

View File

@ -34,7 +34,7 @@ public:
static const int BL_IS_UP_COUNT = 5;
static const int BL_STOP_COUNT = 5;
int progressValue() const { return m_progressValue; }
// int progressValue() const { return m_progressValue; }
hwinf *getPlugin() { return m_hw; }
hwinf const *getPlugin() const { return m_hw; }
Update *getUpdate() { return m_update; }
@ -76,7 +76,7 @@ private:
QTimer *m_startTimer;
QTimer *m_exitTimer;
bool m_progressRunning;
int m_progressValue;
//int m_progressValue;
Update *m_update;
UpdateDcEvent::UpdateStep m_updateStep;
};

View File

@ -846,8 +846,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false;
}
m_worker->stopProgressLoop();
m_worker->setProgress(100);
// m_worker->stopProgressLoop();
// m_worker->setProgress(100);
if (res == false) {
break;

View File

@ -68,6 +68,12 @@ void Utils::printUpdateStatusMsg(QStringList const &updateMsg) {
qCritical() << QString(80, 'U');
}
void Utils::printUpdateStatusMsg(QString const &updateMsg) {
qCritical() << QString(80, 'U');
qCritical() << updateMsg;
qCritical() << QString(80, 'U');
}
void Utils::printInfoMsg(QString const &infoMsg) {
qCritical() << QString(80, 'I');
qCritical() << infoMsg;

View File

@ -17,6 +17,7 @@ namespace Utils {
void printInfoMsg(QString const &infoMsg);
void printInfoMsg(QStringList const &infoMsg);
void printUpdateStatusMsg(QStringList const &updateMsg);
void printUpdateStatusMsg(QString const &updateMsg);
void printLineEditInfo(QStringList const &lines);
QString getTariffLoadTime(QString fileName);
QString rstrip(QString const &str);

View File

@ -17,8 +17,6 @@
#include <QJsonParseError>
#include <Qt>
#include <thread>
#include "message_handler.h"
#include "plugins/interfaces.h"
#include "ismas/ismas_client.h"
@ -31,6 +29,8 @@ QString const Worker::UPDATE_STEP_DONE(" [done]");
QString const Worker::UPDATE_STEP_FAIL(" [FAIL]");
QString const Worker::UPDATE_STEP_SUCCESS(" [SUCCESS]");
Worker const *Worker::instance = nullptr;
Worker::Worker(int customerNr,
int machineNr,
int zoneNr,
@ -73,10 +73,12 @@ Worker::Worker(int customerNr,
, m_updateProcessRunning(true)
, m_returnCode(0)
, m_mainWindow(nullptr) /* contains plugin */
, m_progressValue(0)
//, m_withoutIsmasDirectPort(true) /* useful for testing */ {
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
// TODO: turn object into singleton
instance = this;
this->setObjectName("worker-object");
QDir::setCurrent(m_workingDirectory);
@ -127,19 +129,25 @@ Worker::~Worker() {
}
}
void Worker::setProgress(int progress) {
void Worker::displayProgressInMainWindow(int progress) {
if (m_mainWindow) {
m_progressValue = progress;
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, progress));
QApplication::postEvent(m_mainWindow,
new ProgressEvent(this, progress));
}
}
void Worker::setProgress(int progress) {
m_ismasClient.setProgressInPercent(progress);
displayProgressInMainWindow(progress);
}
void Worker::startProgressLoop() {
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::START_PROGRESS_LOOP));
displayProgressInMainWindow(MainWindow::START_PROGRESS_LOOP);
}
void Worker::stopProgressLoop() {
QApplication::postEvent(m_mainWindow, new ProgressEvent(this, MainWindow::STOP_PROGRESS_LOOP));
displayProgressInMainWindow(MainWindow::STOP_PROGRESS_LOOP);
}
static std::once_flag once;
@ -148,6 +156,244 @@ void Worker::update() {
std::call_once(once, &Worker::privateUpdate, this);
}
bool Worker::isRepositoryCorrupted() {
QDir customerRepository(m_customerRepository);
if (customerRepository.exists()) {
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
QDir customerRepositoryOpt(QDir::cleanPath(m_customerRepository + QDir::separator() + "opt/"));
QDir customerRepositoryGit(QDir::cleanPath(m_customerRepository + QDir::separator() + ".git/"));
if (!m_gc.gitFsck()
// etc-directory inside git-repository does not exist, which means the
// git-repository is corrupted -> remove it and start from scratch
|| !customerRepositoryEtc.exists()
|| !customerRepositoryGit.exists()
|| !customerRepositoryOpt.exists()) {
// should never happen
Utils::printCriticalErrorMsg("CORRUPTED CUSTOMER REPOSITORY");
return true;
}
}
return false;
}
bool Worker::repairCorruptedRepository() {
QDir customerRepository(m_customerRepository);
if (!customerRepository.removeRecursively()) {
Utils::printCriticalErrorMsg("ERROR REMOVING CORR. CUST-REPOSITORY");
m_updateStatus = UpdateStatus(UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED,
QString("REMOVAL OF GIT-REPOSITORY %1 FAILED").arg(m_customerRepository));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
m_updateStatus.m_statusDescription));
emit showErrorMessage("apism sanity check", m_updateStatus.m_statusDescription);
return false;
}
return true;
}
int Worker::sendCloneAndCheckoutFailure() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE,
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.errorGitClone(m_updateStatus.m_statusDescription));
return CLONE_AND_CHECKOUT_FAILURE;
}
int Worker::sendCloneAndCheckoutSuccess() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
QString("CLONED REPOSITORY %1 AND CHECKED OUT BRANCH %2")
.arg(m_customerRepository)
.arg(m_gc.branchName()));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.cloneAndCheckoutCustomerRepository(
m_updateStatus.m_statusDescription));
return CLONE_AND_CHECKOUT_SUCCESS;
}
int Worker::sendIsmasTriggerFailure() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
QString("ISMAS update trigger wrong"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"CHECK-UPDATE-TRIGGER",
m_updateStatus.m_statusDescription));
return ISMAS_TRIGGER_FAILURE;
}
int Worker::sendCustomerEnvironmentConfigurationFailed() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
QString("Configuring customer environment failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"GIT-CHECKOUT-BRANCH",
m_updateStatus.m_statusDescription));
return ENVIRONMENT_CONFIG_FAILURE;
}
int Worker::sendPullFailure() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
QString("No files to update"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"FETCH-FILES-TO-UPDATE",
m_updateStatus.m_statusDescription));
return GIT_PULL_FAILURE;
}
int Worker::sendFileUpdateFailure() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
QString("Updating files failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"UPDATE-FILES",
m_updateStatus.m_statusDescription));
return UPDATE_FILES_FAILURE;
}
int Worker::sendRsyncFailure() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
QString("Syncing files to update failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"RSYNC-UPDATE-FILES",
m_updateStatus.m_statusDescription));
return RSYNC_FAILURE;
}
int Worker::sendLastVersionFailure() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
QString("Sending ISMAS last version failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"ISMAS-SEND-LAST-VERSION",
m_updateStatus.m_statusDescription));
return SEND_LAST_VERSION_FAILURE;
}
int Worker::sendSaveLogFilesFailure() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
QString("Saving log files failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"SAVE-LOG-FILES",
m_updateStatus.m_statusDescription));
return SAVE_LOG_FILES_FAILURE;
}
int Worker::sendFoundFilesToUpdateSuccess() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
QString("Files to update: ") + m_filesToUpdate.join(','));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
m_updateStatus.m_statusDescription));
return 0;
}
int Worker::sendUpdateSucceededAndActivated() {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSASucceeded(""));
//m_ismasClient.setProgressInPercent(100);
// mark update as activated -> this resets the WAIT button
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAActivated());
return UPDATE_SUCCESS_AND_ACTIVATED;
}
int Worker::sendFinalResult() {
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
QString("Update process succeeded. Reset WAIT."));
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
m_updateStatus.m_statusDescription)) {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
}
return 0;
}
#if 0
void Worker::printProgress(UPDATE_STEP step) {
switch(step) {
case UPDATE_STEP::SANITY_CHECK:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 1: CHECKED SANITY OF CUSTOMER REPOSITORY %1 DONE")
.arg(m_customerRepository)
<< QString("STEP 2: FETCH CUSTOMER REPOSITORY %1...")
.arg(m_customerRepository));
break;
case UPDATE_STEP::FETCH_REPOSITORY:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 2: FETCHED CUSTOMER REPOSITORY %1 DONE")
.arg(m_customerRepository)
<< QString("STEP 3: CHECK ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS..."));
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 3: CHECKED ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS. SUCCESS.")
<< QString("STEP 4: CHECK-OUT BRANCH %1...").arg(m_gc.branchName()));
break;
case UPDATE_STEP::CHECKED_OUT_BRANCH:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 4: CHECKED-OUT BRANCH %1 DONE")
.arg(m_gc.branchName())
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE..."));
break;
case UPDATE_STEP::COMPUTE_FILES_TO_UPDATE:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE %1 DONE")
.arg(m_filesToUpdate.join(','))
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS...")
.arg(m_filesToDownload.join(',')));
break;
case UPDATE_STEP::DOWNLOAD_FILES_TO_UPDATE:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS DONE")
.arg(m_filesToDownload.join(','))
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM...")
.arg(m_customerRepository));
break;
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM DONE")
.arg(m_customerRepository)
<< QString("STEP 8: SEND-LAST-VERSION TO ISMAS..."));
break;
case UPDATE_STEP::UPDATE_SUCCESS:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 9: SAVE-LOG-FILES (FUTURE USE) DONE")
<< QString("STEP 10: MARK UPDATE AS SUCCESSFUL AND ACTIVE..."));
break;
}
}
#endif
void Worker::privateUpdate() {
if (!m_mainWindow) {
Utils::printCriticalErrorMsg("m_mainWindow NOT SET");
@ -160,183 +406,134 @@ void Worker::privateUpdate() {
emit disableExit();
m_returnCode = -1;
QDir customerRepository(m_customerRepository);
if (!customerRepository.exists()) {
emit appendText("\nInitializing customer environment ...");
startProgressLoop();
if (m_gc.gitCloneAndCheckoutBranch()) {
stopProgressLoop();
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
setProgress(5);
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 1: CHECK SANITY OF CUSTOMER REPOSITORY %1...")
.arg(m_customerRepository));
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS,
QString("CLONED AND CHECKED OUT: ") + m_customerRepository);
bool initialClone = false; // the customer repository is cloned without
// checking the ISMAS-trigger (WAIT-)button.
// but if there was a sane repository
// available, then the trigger-button must
// have been activated in ISMAS.
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.cloneAndCheckoutCustomerRepository(
m_updateStatus.m_statusDescription));
setProgress(10);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSASucceeded(""));
setProgress(100);
m_ismasClient.setProgressInPercent(100);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated());
m_returnCode = 0;
bool continueUpdate = true; // check if git-clone command has timed-out,
// resulting in a corrupted git-repository, which
// does not contain an ./etc-directory
if (isRepositoryCorrupted()) {
QString s("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...");
if ((continueUpdate = repairCorruptedRepository()) == true) {
Utils::printUpdateStatusMsg(
QStringList() << s <<
QString("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...DONE"));
} else {
stopProgressLoop();
setProgress(0);
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_FAILURE,
QString("CLONE OR CHECKOUT FAILED: ") + m_customerRepository);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.errorGitClone(100, m_updateStatus.m_statusDescription));
m_returnCode = -3;
}
} else {
if (updateTriggerSet(5)) {
if (customerEnvironment(30)) {
m_ismasClient.setProgressInPercent(50);
if (filesToUpdate()) {
// send message to ISMAS about files which have been
// checked in into git repository
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
QString("Files to update: ") + m_filesToUpdate.join(','));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
m_updateStatus.m_statusDescription));
if (updateFiles(60)) {
m_ismasClient.setProgressInPercent(70);
if (syncCustomerRepositoryAndFS()) {
m_ismasClient.setProgressInPercent(80);
if (sendIsmasLastVersionNotification()) {
m_ismasClient.setProgressInPercent(90);
sentIsmasLastVersionNotification = true;
if (saveLogFile()) {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSASucceeded(""));
// mark update as activated -> this resets the WAIT button
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAActivated());
m_returnCode = 0;
} else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
QString("Saving log files failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"SAVE-LOG-FILES",
m_updateStatus.m_statusDescription));
m_returnCode = -11;
}
} else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
QString("Sending ISMAS last version failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"ISMAS-SEND-LAST-VERSION",
m_updateStatus.m_statusDescription));
m_returnCode = -10;
}
} else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
QString("Syncing files to update failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"RSYNC-UPDATE-FILES",
m_updateStatus.m_statusDescription));
m_returnCode = -9;
}
} else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
QString("Updating files failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"UPDATE-FILES",
m_updateStatus.m_statusDescription));
m_returnCode = -8;
}
} else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
QString("No files to update"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"FETCH-FILES-TO-UPDATE",
m_updateStatus.m_statusDescription));
m_returnCode = -7;
}
} else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
QString("Configuring customer environment failed"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"GIT-CHECKOUT-BRANCH",
m_updateStatus.m_statusDescription));
m_returnCode = -6;
}
} else {
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
QString("ISMAS update trigger wrong"));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
"CHECK-UPDATE-TRIGGER",
m_updateStatus.m_statusDescription));
m_returnCode = -5;
Utils::printUpdateStatusMsg(
QStringList() << s <<
QString("CORRUPTED CUSTOMER REPOSITORY. REPAIRING...FAIL"));
}
}
m_ismasClient.setProgressInPercent(100);
setProgress(100);
if (continueUpdate) {
// qDebug() << UPDATE_STEP::SANITY_CHECK;
if ((continueUpdate = customerRepository.exists()) == false) {
emit appendText("\nInitializing customer environment ...");
startProgressLoop();
for (int i = 0; i < 5; ++i) { // try to checkout git repository
setProgress(i); // and switch to branch
if (m_gc.gitCloneAndCheckoutBranch()) {
if (!isRepositoryCorrupted()) {
emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE);
m_returnCode = sendCloneAndCheckoutSuccess();
continueUpdate = true;
initialClone = true;
Utils::printInfoMsg("INITIAL CLONE DONE");
break;
}
}
QThread::sleep(1); // maybe git needs more time
}
if (continueUpdate == false) {
emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL);
m_returnCode = sendCloneAndCheckoutFailure();
}
}
if (m_returnCode != 0) {
stopProgressLoop();
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
if (!initialClone) {
// qDebug() << UPDATE_STEP::FETCH_REPOSITORY;
} else {
Utils::printUpdateStatusMsg(
QString("STEP 2: FETCHED CUSTOMER REPOSITORY %1 DONE")
.arg(m_customerRepository));
} // repository is neither not existent nor
} // corrupted. check now if the ISMAS-trigger
if (continueUpdate) { // (WAIT-BUTTON) is activated even in case of
// initial checkout
if ((continueUpdate = updateTriggerSet(10)) == false) {
m_returnCode = sendIsmasTriggerFailure();
}
if (continueUpdate) { // configure customer environment -> checkout
// branch in case someone has change the zone_nr
//qDebug() << UPDATE_STEP::CHECK_ISMAS_TRIGGER;
if ((continueUpdate = customerEnvironment(30)) == false) {
m_returnCode = sendCustomerEnvironmentConfigurationFailed();
} // determine which files has to be updated:
} // either sent to the hardware or rsynced with
if (continueUpdate) { // the filesystem in case of tariff-files
//qDebug() << UPDATE_STEP::CHECKED_OUT_BRANCH;
if ((continueUpdate = filesToUpdate(50)) == false) {
m_returnCode = sendPullFailure();
}
} // send message to ISMAS about files which have
if (continueUpdate) { // been checked in into git repository
//qDebug() << UPDATE_STEP::COMPUTE_FILES_TO_UPDATE;
sendFoundFilesToUpdateSuccess();
if ((continueUpdate = updateFiles(60)) == false) {
m_returnCode = sendFileUpdateFailure();
}
}
if (continueUpdate) { // rsync (changed) files to file system
//qDebug() << UPDATE_STEP::DOWNLOAD_FILES_TO_UPDATE;
// TODO: rsync das komplette repository
if ((continueUpdate = syncCustomerRepositoryAndFS(70)) == false) {
m_returnCode = sendRsyncFailure();
}
}
if (continueUpdate) { // send message to ISMAS about installed versions
//qDebug() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY;
if ((continueUpdate = sendIsmasLastVersionNotification(80)) == false) {
m_returnCode = sendLastVersionFailure();
}
}
if (continueUpdate) { // future use: save logs of update process
sentIsmasLastVersionNotification = true;
if ((continueUpdate = saveLogFile(90)) == false) {
m_returnCode = sendSaveLogFilesFailure();
}
} // send message to ISMAS that update process
if (continueUpdate) { // succeeded
//qDebug() << UPDATE_STEP::UPDATE_SUCCESS;
sendUpdateSucceededAndActivated();
m_returnCode = UPDATE_SUCCESS_AND_ACTIVATED;
}
// m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
// QString("Update process failed"));
// if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
// m_updateStatus.m_statusDescription)) {
// IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
// QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
// }
setProgress(100);
} else {
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
QString("Update process succeeded. Reset WAIT."));
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
m_updateStatus.m_statusDescription)) {
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
if (m_returnCode != 0) {
stopProgressLoop();
emit appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
} else {
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
sendFinalResult();
}
}
if (!sentIsmasLastVersionNotification) {
// try even if the backend is not connected
sendIsmasLastVersionNotification();
sendIsmasLastVersionNotification(100);
}
m_updateProcessRunning = false;
@ -440,7 +637,7 @@ bool Worker::updateTriggerSet(int progress) {
= IsmasClient::sendRequestReceiveResponse(
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
stopProgressLoop();
setProgress(m_mainWindow->progressValue()/10 + 11);
// setProgress(m_mainWindow->progressValue()/10 + 11);
QString msg = result.value();
@ -451,7 +648,7 @@ bool Worker::updateTriggerSet(int progress) {
if (parseError.error != QJsonParseError::NoError) {
qCritical() << "(2) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
<< parseError.error << parseError.errorString();
setProgress(100);
//setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
QString("(2) INVALID JSON %1 %2 %3")
.arg(msg)
@ -468,7 +665,7 @@ bool Worker::updateTriggerSet(int progress) {
}
if (!document.isObject()) {
qCritical() << "FILE IS NOT A JSON OBJECT!";
setProgress(100);
//setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
QString("NOT A JSON-OBJECT %1").arg(msg));
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -479,13 +676,13 @@ bool Worker::updateTriggerSet(int progress) {
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
return false;
}
setProgress(m_mainWindow->progressValue()/10 + 11);
// setProgress(m_mainWindow->progressValue()/10 + 11);
QJsonObject obj = document.object();
// always look for an 'error' first
if (obj.contains("error")) {
setProgress(m_mainWindow->progressValue()/10 + 11);
// setProgress(m_mainWindow->progressValue()/10 + 11);
QString value = obj.value("error").toString();
emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">");
qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<"
@ -506,7 +703,7 @@ bool Worker::updateTriggerSet(int progress) {
int customerNr = c.toInt(-1);
int machineNr = m.toInt(-1);
if (customerNr != m_customerNr) {
setProgress(100);
//setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
.arg(customerNr).arg(m_customerNr));
@ -519,7 +716,6 @@ bool Worker::updateTriggerSet(int progress) {
return false;
}
if (machineNr != m_machineNr) {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
.arg(machineNr).arg(m_machineNr));
@ -535,7 +731,6 @@ bool Worker::updateTriggerSet(int progress) {
qInfo() << "MACHINE-AND-CUSTOMER-CHECK" << m_updateStatus.m_statusDescription;
} else {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
"Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -547,7 +742,6 @@ bool Worker::updateTriggerSet(int progress) {
return false;
}
} else {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
"Dev_ID KEY NOT A JSON-OBJECT");
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -559,7 +753,6 @@ bool Worker::updateTriggerSet(int progress) {
return false;
}
} else {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
"Dev_ID KEY NOT AVAILABLE");
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -570,7 +763,7 @@ bool Worker::updateTriggerSet(int progress) {
emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
return false;
}
setProgress(m_mainWindow->progressValue()/10 + 11);
// setProgress(m_mainWindow->progressValue()/10 + 11);
if (obj.contains("Fileupload")) {
QJsonValue v = obj.value("Fileupload");
@ -584,7 +777,6 @@ bool Worker::updateTriggerSet(int progress) {
<< triggerValue << ">";
if (triggerValue == "WAIT") {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK,
QString("MACHINE-NR (%1) AND CUST-NR (%2) OK")
.arg(m_machineNr).arg(m_customerNr));
@ -610,13 +802,12 @@ bool Worker::updateTriggerSet(int progress) {
} else
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
stopProgressLoop();
setProgress(m_mainWindow->progressValue()/10 + 11);
// setProgress(m_mainWindow->progressValue()/10 + 11);
emit showErrorMessage("check update trigger", "empty update-trigger");
QThread::sleep(6);
continue;
} else {
// if the download-button once has the wrong value, it will never recover
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
QString("TRIGGER-VALUE=<") + triggerValue + "> NOT 'WAIT'");
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -628,7 +819,6 @@ bool Worker::updateTriggerSet(int progress) {
return false;
}
} else {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
"TRG KEY NOT AVAILABLE");
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -640,7 +830,6 @@ bool Worker::updateTriggerSet(int progress) {
return false;
}
} else {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
"Fileupload NOT A JSON-OBJECT");
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -652,7 +841,6 @@ bool Worker::updateTriggerSet(int progress) {
return false;
}
} else {
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_WAIT_STATE_CHECK_FAILURE,
"Fileupload KEY NOT AVAILABLE");
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
@ -665,13 +853,12 @@ bool Worker::updateTriggerSet(int progress) {
}
} else {
stopProgressLoop();
setProgress(m_mainWindow->progressValue()/10 + 11);
//setProgress(m_mainWindow->progressValue()/10 + 11);
emit showErrorMessage("check update trigger", "no ISMAS response");
QThread::sleep(6);
}
}
setProgress(100);
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_NOT_SET_OR_WRONG,
QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") +
triggerValue + ")");
@ -687,7 +874,7 @@ bool Worker::customerEnvironment(int progress) {
emit appendText("\nPrepare customer environment ...");
if (QDir(m_customerRepository).exists()) {
startProgressLoop();
setProgress(m_mainWindow->progressValue()/10 + 11);
// setProgress(m_mainWindow->progressValue()/10 + 11);
if (m_gc.gitCheckoutBranch()) {
stopProgressLoop();
m_ismasClient.setProgressInPercent(progress);
@ -699,7 +886,6 @@ bool Worker::customerEnvironment(int progress) {
QString("#M=APISM#C=CMD_EVENT#J=") +
m_ismasClient.checkoutBranch(m_updateStatus.m_statusDescription, ""));
setProgress(100);
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_DONE);
qInfo() << "PREPARE CUSTOMER ENVIRONMENT DONE";
return true;
@ -716,12 +902,13 @@ bool Worker::customerEnvironment(int progress) {
Utils::printCriticalErrorMsg(m_customerRepository + " DOES NOT EXIST");
}
setProgress(100);
emit replaceLast("Prepare customer environment ...", UPDATE_STEP_FAIL);
return false;
}
bool Worker::filesToUpdate() {
bool Worker::filesToUpdate(int progress) {
m_ismasClient.setProgressInPercent(progress);
emit appendText("\nFetch changes files ...");
startProgressLoop();
@ -729,17 +916,11 @@ bool Worker::filesToUpdate() {
m_filesToUpdate << "etc/psa_update/opkg_commands";
if (std::optional<QString> changes = m_gc.gitPull()) {
stopProgressLoop();
int progress = (m_mainWindow->progressValue()/10) + 10;
setProgress(progress);
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES,
QString("FETCHING OF ") + m_customerRepositoryPath +
QString(" INTO ") + m_customerRepository);
setProgress(progress + 10);
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
setProgress(progress + 20);
if (m_gc.gitPull()) {
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_DONE);
m_filesToUpdate << changedFileNames.value();
@ -748,10 +929,6 @@ bool Worker::filesToUpdate() {
Utils::printCriticalErrorMsg("PULLING FILES FAILED");
emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);
stopProgressLoop();
setProgress(100);
return false;
}
}
@ -769,15 +946,13 @@ bool Worker::filesToUpdate() {
emit appendText("Found 1 file to update :", UPDATE_STEP_DONE);
emit appendText(QString("\n ") + m_filesToUpdate.at(0));
}
setProgress(progress + 30);
}
return true;
}
bool Worker::updateFiles(quint8 percent) {
QStringList filesToDownload;
bool Worker::updateFiles(int percent) {
m_filesToDownload.clear();
m_displayIndex = 0;
startProgressLoop();
for (int i = 0; i < m_filesToUpdate.size(); ++i) {
@ -830,8 +1005,6 @@ bool Worker::updateFiles(quint8 percent) {
emit replaceLast(QString("(") + QString("%1").arg(m_displayIndex).rightJustified(3, ' ') + QString(")")
+ QString(" Update opkg pakets ... "), UPDATE_STEP_FAIL);
stopProgressLoop();
setProgress(100);
return false;
}
}
@ -842,24 +1015,21 @@ bool Worker::updateFiles(quint8 percent) {
fName.contains("DC2C_device", Qt::CaseInsensitive) ||
fName.contains("DC2C_conf", Qt::CaseInsensitive) ||
fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
filesToDownload << fName; // download printer-config-files
m_filesToDownload << fName; // download printer-config-files
} else {
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
if (fName.contains(version)) {
filesToDownload << fName; // download device controller
m_filesToDownload << fName; // download device controller
}
}
}
stopProgressLoop();
setProgress(100);
if (filesToDownload.size() > 0) {
Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + filesToDownload.join(','));
if (m_filesToDownload.size() > 0) {
Utils::printInfoMsg(QString("FILES_TO_DOWNLOAD_TO_PSA_HW ") + m_filesToDownload.join(','));
Update *update = m_mainWindow->getUpdate();
if (update) {
return update->doUpdate(m_displayIndex, filesToDownload);
return update->doUpdate(m_displayIndex, m_filesToDownload);
} else {
Utils::printCriticalErrorMsg("UPDATE NOT SET");
}
@ -870,9 +1040,9 @@ bool Worker::updateFiles(quint8 percent) {
return true;
}
bool Worker::syncCustomerRepositoryAndFS() {
bool Worker::syncCustomerRepositoryAndFS(int progress) {
m_ismasClient.setProgressInPercent(progress);
// this step is currently needed only for updating tariff-files
setProgress(0);
emit appendText("\nSync customer environment with filesystem ...");
if (QDir(m_customerRepository).exists()) {
if (QDir::setCurrent(m_customerRepository)) {
@ -881,8 +1051,6 @@ bool Worker::syncCustomerRepositoryAndFS() {
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
}
int progress = 10;
setProgress(progress);
QString const params("-vvv "
"--recursive "
"--progress "
@ -905,8 +1073,6 @@ bool Worker::syncCustomerRepositoryAndFS() {
QString cmd;
bool error = false;
foreach (cmd, cmds) {
progress += 5;
setProgress(progress);
if (!error) {
Command c("bash");
qInfo() << "EXECUTING CMD..." << cmd;
@ -940,14 +1106,11 @@ bool Worker::syncCustomerRepositoryAndFS() {
}
}
}
progress += 5;
setProgress(progress);
if (!error) {
// now check tariff-files in etc and /etc/psa_tariff
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
QDir dir2("/etc/psa_tariff");
if (Utils::sameFilesInDirs(dir1, dir2)) {
setProgress(100);
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_DONE);
return true;
} else {
@ -956,12 +1119,12 @@ bool Worker::syncCustomerRepositoryAndFS() {
}
}
}
setProgress(100);
emit replaceLast(QString("Sync customer environment with filesystem ..."), UPDATE_STEP_FAIL);
return false;
}
bool Worker::sendIsmasLastVersionNotification() {
bool Worker::sendIsmasLastVersionNotification(int progress) {
m_ismasClient.setProgressInPercent(progress);
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_SENDVERSION#J=") +
m_ismasClient.updateOfPSASendVersion(getPSAInstalled()));
@ -969,7 +1132,8 @@ bool Worker::sendIsmasLastVersionNotification() {
return true;
}
bool Worker::saveLogFile() {
bool Worker::saveLogFile(int progress) {
m_ismasClient.setProgressInPercent(progress);
return true;
}
QString Worker::getOsVersion() const {
@ -1148,8 +1312,8 @@ PSAInstalled Worker::getPSAInstalled() {
psaInstalled.hw.cpuSerial = m_cpuSerial;
psaInstalled.opkg.blob = m_gc.gitBlob(absPathNameRepositoryOpkg);
psaInstalled.opkg.size = getFileSize(absPathNameRepositoryOpkg);
psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameRepositoryOpkg);
// psaInstalled.opkg.size = getFileSize(absPathNameRepositoryOpkg);
// psaInstalled.opkg.loadTime = Utils::getTariffLoadTime(absPathNameRepositoryOpkg);
psaInstalled.opkg.lastCommit = m_gc.gitLastCommit(absPathNameRepositoryOpkg);
psaInstalled.dc.versionHW = deviceControllerVersionHW;
@ -1209,6 +1373,7 @@ hwinf const *Worker::getPlugin() const {
/************************************************************************************************
* operators
*/
#if 0
QDebug operator<< (QDebug debug, UpdateStatus status) {
switch(status.m_updateStatus) {
case UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED:
@ -1327,6 +1492,10 @@ QDebug operator<< (QDebug debug, UpdateStatus status) {
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
<< status.m_statusDescription;
break;
case UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED:
debug << QString("UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED: ")
<< status.m_statusDescription;
break;
// default:;
}
return debug;
@ -1450,7 +1619,12 @@ QString& operator<< (QString& str, UpdateStatus status) {
str = QString("UPDATE_STATUS::RSYNC_FILE_SUCCESS: ");
str += status.m_statusDescription;
break;
case UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED:
str = QString("UPDATE_STATUS::REMOVE_GIT_REPOSITORY_FAILED: ");
str += status.m_statusDescription;
break;
//default:;
}
return str;
}
#endif

295
worker.h
View File

@ -8,13 +8,17 @@
#include <QFile>
#include <QJsonObject>
#include <QHash>
#include <QMap>
#include <QDebug>
#include <optional>
#include <initializer_list>
#include "worker_thread.h"
#include "update.h"
#include "git/git_client.h"
#include "ismas/ismas_client.h"
#include "utils.h"
#ifdef PTU5
#define SERIAL_PORT "ttymxc2"
@ -52,7 +56,8 @@ enum class UPDATE_STATUS : quint8 {
PSA_UPDATE_FILES_FAILED,
GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
ISMAS_SEND_LAST_VERSION_FAILED,
SAVE_LOG_FILES_FAILED
SAVE_LOG_FILES_FAILED,
REMOVE_GIT_REPOSITORY_FAILED
};
struct UpdateStatus {
@ -64,8 +69,6 @@ struct UpdateStatus {
: m_updateStatus(s), m_statusDescription(d) {}
};
QDebug operator<<(QDebug debug, UpdateStatus status);
QString& operator<<(QString &str, UpdateStatus status);
#define ISMAS_UPDATE_REQUESTS (10)
@ -108,12 +111,12 @@ class Worker : public QObject {
UpdateStatus m_updateStatus;
QStringList m_filesToUpdate;
QStringList m_filesToDownload;
bool m_updateProcessRunning;
int m_displayIndex;
int m_returnCode;
MainWindow *m_mainWindow;
int m_progressValue;
bool m_withoutIsmasDirectPort;
QString m_apismVersion;
@ -128,6 +131,76 @@ class Worker : public QObject {
QStringList getDCVersion() const;
qint64 getFileSize(QString const &fileName) const;
bool isRepositoryCorrupted();
bool repairCorruptedRepository();
int sendCloneAndCheckoutSuccess();
int sendCloneAndCheckoutFailure();
int sendIsmasTriggerFailure();
int sendPullFailure();
int sendFileUpdateFailure();
int sendRsyncFailure();
int sendLastVersionFailure();
int sendSaveLogFilesFailure();
int sendCustomerEnvironmentConfigurationFailed();
int sendFoundFilesToUpdateSuccess();
int sendUpdateSucceededAndActivated();
int sendFinalResult();
static constexpr const int UPDATE_SUCCESS_AND_ACTIVATED = 0;
static constexpr const int CLONE_AND_CHECKOUT_SUCCESS = 0;
static constexpr const int CLONE_AND_CHECKOUT_FAILURE = -3;
static constexpr const int ISMAS_TRIGGER_FAILURE = -5;
static constexpr const int ENVIRONMENT_CONFIG_FAILURE = -6;
static constexpr const int GIT_PULL_FAILURE = -7;
static constexpr const int UPDATE_FILES_FAILURE = -8;
static constexpr const int RSYNC_FAILURE = -9;
static constexpr const int SEND_LAST_VERSION_FAILURE = -10;
static constexpr const int SAVE_LOG_FILES_FAILURE = -11;
enum class UPDATE_STEP {
STARTED = 1,
CHECK_REPOSITORY = 2,
CHECK_SANITY = 3,
CHECK_SANITY_SUCCESS = 4,
CHECK_SANITY_FAILURE = 5,
CLONE_REPOSITORY = 6,
CLONE_REPOSITORY_SUCCESS = 7,
CLONE_REPOSITORY_FAILURE = 8,
SWITCH_BRANCH = 12,
SWITCH_BRANCH_SUCCESS = 13,
SWITCH_BRANCH_FAILURE = 14,
CHECK_ISMAS_TRIGGER = 15,
CHECK_ISMAS_TRIGGER_SUCCESS = 23,
CHECK_ISMAS_TRIGGER_FAILURE = 24,
UPDATE_REPOSITORY = 25,
UPDATE_REPOSITORY_SUCCESS = 28,
UPDATE_REPOSITORY_FAILURE = 29,
CHECK_FOR_REPOSITORY_CHANGES = 30,
CHECK_FOR_REPOSITORY_CHANGES_SUCCESS = 38,
CHECK_FOR_REPOSITORY_CHANGES_FAILURE = 39,
APPLY_REPOSITORY_CHANGES = 40,
DOWNLOAD_CONFIG_FILE = 41,
DOWNLOAD_CONFIG_FILE_SUCCESS = 63,
DOWNLOAD_CONFIG_FILE_FAILURE = 64,
DOWNLOAD_DEVICE_CONTROLLER = 65,
DOWNLOAD_DEVICE_CONTROLLER_SUCCESS = 86,
DOWNLOAD_DEVICE_CONTROLLER_FAILURE = 87,
APPLY_REPOSITORY_CHANGES_SUCCESS = 88,
APPLY_REPOSITORY_CHANGES_FAILURE = 89,
SYNC_CUSTOMER_REPOSITORY = 90,
SYNC_CUSTOMER_REPOSITORY_SUCCESS = 91,
SYNC_CUSTOMER_REPOSITORY_FAILURE = 92,
SAVE_LOGS = 94,
SAVE_LOGS_SUCCESS = 95,
SAVE_LOGS_FAILURE = 96,
SEND_LAST_VERSION = 97,
UPDATE_SUCCEEDED = 98,
UPDATE_FAILED = 99,
FINISHED = 100
};
static Worker const *instance;
public:
static QString getATBUpdateToolYoctoVersion();
@ -154,6 +227,7 @@ public:
hwinf *getPlugin();
hwinf const *getPlugin() const;
void setProgress(int progress);
void displayProgressInMainWindow(int progress);
void startProgressLoop();
void stopProgressLoop();
@ -172,15 +246,6 @@ public:
MainWindow *mainWindow() { return m_mainWindow; }
MainWindow const *mainWindow() const { return m_mainWindow; }
//friend QDebug operator<<(QDebug debug, Worker const &w) {
// Q_UNUSED(w);
// return debug;
//}
//friend QString& operator<<(QString &str, Worker const &w) {
// Q_UNUSED(w);
// return str;
//}
signals:
void appendText(QString, QString suffix = "");
void replaceLast(QString, QString);
@ -198,16 +263,210 @@ public slots:
private slots:
bool updateTriggerSet(int progress);
bool customerEnvironment(int progress);
bool filesToUpdate();
bool updateFiles(quint8 percent);
bool syncCustomerRepositoryAndFS();
bool sendIsmasLastVersionNotification();
bool saveLogFile();
bool filesToUpdate(int progress);
bool updateFiles(int percent);
bool syncCustomerRepositoryAndFS(int progress);
bool sendIsmasLastVersionNotification(int progress);
bool saveLogFile(int progress);
private:
PSAInstalled getPSAInstalled();
void privateUpdate();
std::optional<QString> getApismVersion();
void printProgress(UPDATE_STEP step);
friend QDebug operator<<(QDebug debug, UPDATE_STEP step) {
if (!Worker::instance) {
return debug;
}
static const QMap<UPDATE_STEP, const char*> smap (
std::initializer_list<std::pair<UPDATE_STEP, const char*>>{
#define INSERT_ELEMENT(p) std::pair(p, #p)
INSERT_ELEMENT(UPDATE_STEP::STARTED),
INSERT_ELEMENT(UPDATE_STEP::CHECK_REPOSITORY),
INSERT_ELEMENT(UPDATE_STEP::CHECK_SANITY),
INSERT_ELEMENT(UPDATE_STEP::CHECK_SANITY_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::CHECK_SANITY_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::CLONE_REPOSITORY),
INSERT_ELEMENT(UPDATE_STEP::CLONE_REPOSITORY_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::CLONE_REPOSITORY_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::SWITCH_BRANCH),
INSERT_ELEMENT(UPDATE_STEP::SWITCH_BRANCH_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::SWITCH_BRANCH_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER),
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::UPDATE_REPOSITORY),
INSERT_ELEMENT(UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::UPDATE_REPOSITORY_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES),
INSERT_ELEMENT(UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::APPLY_REPOSITORY_CHANGES),
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE),
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER),
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY),
INSERT_ELEMENT(UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS),
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::SEND_LAST_VERSION),
INSERT_ELEMENT(UPDATE_STEP::UPDATE_SUCCEEDED),
INSERT_ELEMENT(UPDATE_STEP::UPDATE_FAILED),
INSERT_ELEMENT(UPDATE_STEP::FINISHED)
#undef INSERT_ELEMENT
});
switch (step) {
case UPDATE_STEP::STARTED:
break;
case UPDATE_STEP::CHECK_REPOSITORY:
break;
case UPDATE_STEP::CHECK_SANITY:
break;
case UPDATE_STEP::CHECK_SANITY_SUCCESS:
break;
case UPDATE_STEP::CHECK_SANITY_FAILURE:
break;
case UPDATE_STEP::CLONE_REPOSITORY:
break;
case UPDATE_STEP::CLONE_REPOSITORY_SUCCESS:
break;
case UPDATE_STEP::CLONE_REPOSITORY_FAILURE:
break;
case UPDATE_STEP::SWITCH_BRANCH:
break;
case UPDATE_STEP::SWITCH_BRANCH_SUCCESS:
break;
case UPDATE_STEP::SWITCH_BRANCH_FAILURE:
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE:
break;
case UPDATE_STEP::UPDATE_REPOSITORY:
break;
case UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS:
break;
case UPDATE_STEP::UPDATE_REPOSITORY_FAILURE:
break;
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES:
break;
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_SUCCESS:
break;
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE:
break;
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES:
break;
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
break;
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
break;
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
break;
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
break;
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS:
break;
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
break;
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
break;
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
break;
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
break;
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS:
break;
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE:
break;
case UPDATE_STEP::SAVE_LOGS:
break;
case UPDATE_STEP::SAVE_LOGS_SUCCESS:
break;
case UPDATE_STEP::SAVE_LOGS_FAILURE:
break;
case UPDATE_STEP::SEND_LAST_VERSION:
break;
case UPDATE_STEP::UPDATE_SUCCEEDED:
break;
case UPDATE_STEP::UPDATE_FAILED:
break;
case UPDATE_STEP::FINISHED:
break;
}
#if 0
case UPDATE_STEP::CHECK_SANITY:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 1: CHECKED SANITY OF CUSTOMER REPOSITORY %1 DONE")
.arg(instance->m_customerRepository)
<< QString("STEP 2: FETCH CUSTOMER REPOSITORY %1...")
.arg(instance->m_customerRepository));
break;
//case UPDATE_STEP::FETCH_REPOSITORY:
// Utils::printUpdateStatusMsg(
// QStringList()
// << QString("STEP 2: FETCHED CUSTOMER REPOSITORY %1 DONE")
// .arg(instance->m_customerRepository)
// << QString("STEP 3: CHECK ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS..."));
// break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 3: CHECKED ISMAS-UPDATE-TRIGGER FOR WAIT-STATUS. SUCCESS.")
<< QString("STEP 4: CHECK-OUT BRANCH %1...").arg(instance->m_gc.branchName()));
break;
case UPDATE_STEP::CHECKED_OUT_BRANCH:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 4: CHECKED-OUT BRANCH %1 DONE")
.arg(instance->m_gc.branchName())
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE..."));
break;
case UPDATE_STEP::COMPUTE_FILES_TO_UPDATE:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 5: COMPUTE FILES-TO-UPDATE %1 DONE")
.arg(instance->m_filesToUpdate.join(','))
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS...")
.arg(instance->m_filesToDownload.join(',')));
break;
case UPDATE_STEP::DOWNLOAD_FILES_TO_UPDATE:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 6: DOWNLOAD FILES-TO-DOWNLOAD %1 AND EXECUTE OPKG_COMMANDS DONE")
.arg(instance->m_filesToDownload.join(','))
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM...")
.arg(instance->m_customerRepository));
break;
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 7: SYNC CUSTOMER REPOSITORY %1 WITH FILESYSTEM DONE")
.arg(instance->m_customerRepository)
<< QString("STEP 8: SEND-LAST-VERSION TO ISMAS..."));
break;
case UPDATE_STEP::UPDATE_SUCCESS:
Utils::printUpdateStatusMsg(
QStringList()
<< QString("STEP 9: SAVE-LOG-FILES (FUTURE USE) DONE")
<< QString("STEP 10: MARK UPDATE AS SUCCESSFUL AND ACTIVE..."));
break;
}
#endif
return debug;
}
};
#endif // WORKER_H_INCLUDED