Compare commits
10 Commits
43f60251ef
...
2189684cad
Author | SHA1 | Date | |
---|---|---|---|
2189684cad | |||
f4d785ea9d | |||
5bae9fcdf1 | |||
eddf67739a | |||
cb28bd2a1f | |||
618430bcc5 | |||
037b91b889 | |||
96e3b606ef | |||
5d3849dcf3 | |||
8c66e03ea3 |
@ -15,6 +15,7 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <optional>
|
||||
|
||||
@ -119,16 +120,25 @@ int main(int argc, char **argv) {
|
||||
|
||||
for (QString const &m : d.object().keys()) { // request ack
|
||||
if (!m.contains("FileUpload", Qt::CaseInsensitive)) continue;
|
||||
QJsonObject o = d.object()[m].toObject();
|
||||
QJsonObject o2 = d.object()[m].toObject();
|
||||
|
||||
QJsonObject::const_iterator it = o.find("TRG");
|
||||
if (it == o.constEnd()) break;
|
||||
QJsonObject::const_iterator it2 = o2.find("TRG");
|
||||
if (it2 == o2.constEnd()) break;
|
||||
|
||||
QString const &v = it->toString();
|
||||
if (v == "WAIT") {
|
||||
QString const &v2 = it2->toString();
|
||||
if (v2 == "WAIT") {
|
||||
updateRequestStatus = internal::UPDATE_REQUESTED;
|
||||
} else {
|
||||
updateRequestStatus = internal::UPDATE_NOT_NECESSARY;
|
||||
// the customer-repository does exist, and the ISMAS-trigger is
|
||||
// *NOT* "WAIT", but from 00:00:00 - 00:03:59 this counts as an
|
||||
// automatic update
|
||||
QDateTime const ¤t = QDateTime::currentDateTime();
|
||||
if (current.time().hour() < 4) {
|
||||
updateRequestStatus = internal::UPDATE_NOT_NECESSARY;
|
||||
} else {
|
||||
updateRequestStatus = internal::UPDATE_NOT_REQUESTED;
|
||||
exitCode = -2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -149,7 +159,5 @@ int main(int argc, char **argv) {
|
||||
debug.noquote() << connectionStatus;
|
||||
}
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << exitCode;
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
@ -50,12 +50,17 @@ GitCommand::GitCommand()
|
||||
}
|
||||
|
||||
bool GitCommand::exec(QStringList const &options, int start_timeout, int finish_timeout) {
|
||||
bool ret = false;
|
||||
if (GitCommand::initEnv) {
|
||||
Command cmd(QString("git"), options, m_workingDirectory,
|
||||
start_timeout, finish_timeout);
|
||||
return cmd.exec();
|
||||
ret = cmd.exec();
|
||||
//qCritical() << __func__ << ":" << __LINE__ << cmd.command()
|
||||
// << "," << cmd.args()
|
||||
// << ", result" << cmd.commandResult();
|
||||
m_commandResult = cmd.commandResult();
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GitCommand::check(int start_timeout, int finish_timeout) {
|
||||
|
@ -11,9 +11,14 @@ class GitCommand {
|
||||
|
||||
bool exec(QStringList const &options, int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
QString m_commandResult{};
|
||||
|
||||
public:
|
||||
GitCommand();
|
||||
|
||||
void resetCommandResult() { m_commandResult.clear(); }
|
||||
QString const &commandResult() const { return m_commandResult; }
|
||||
|
||||
bool status(int start_timeout = 100000, int finish_timeout = 100000);
|
||||
bool check(int start_timeout = 100000, int finish_timeout = 100000);
|
||||
|
14
Git/main.cpp
14
Git/main.cpp
@ -15,6 +15,7 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <optional>
|
||||
|
||||
@ -90,6 +91,19 @@ int main(int argc, char **argv) {
|
||||
if (!gitCmd.pull()) {
|
||||
return -4;
|
||||
}
|
||||
QString const result = gitCmd.commandResult().trimmed();
|
||||
if (result.contains("Already", Qt::CaseInsensitive)
|
||||
&& result.contains("up", Qt::CaseInsensitive)
|
||||
&& result.contains("to", Qt::CaseInsensitive)
|
||||
&& result.contains("date", Qt::CaseInsensitive)) {
|
||||
qCritical() << internal::GIT_CUSTOMER_REPO_NO_UPDATE_NECESSARY;
|
||||
return internal::GIT_NOT_NECESSARY_CODE;
|
||||
} else
|
||||
if (result.contains(QRegularExpression("[Uu]pdating\\s+[a-z0-9]{6,}\\.\\.[a-z0-9]{6,}"))) {
|
||||
// Updating 49a97f5..13a0321
|
||||
qCritical() << internal::GIT_CUSTOMER_REPO_UPDATED;
|
||||
return internal::GIT_UPDATED_CODE;
|
||||
}
|
||||
} else {
|
||||
if (!gitCmd.clone()) {
|
||||
return -3;
|
||||
|
@ -200,14 +200,17 @@ void MainWindow::onShowCustRepoStatus(QString status) {
|
||||
QString s = ui->stepLabel->text();
|
||||
s.chop(m_stepLabelChopCount);
|
||||
|
||||
QString tmp("Check customer repository ");
|
||||
QString tmp("Update customer repository ");
|
||||
int len = m_showLineLength - tmp.length();
|
||||
while (--len > 0) {
|
||||
tmp += " ";
|
||||
}
|
||||
|
||||
if (status.contains(UpdateCommand::GIT_CUSTOMER_REPO_UP_TO_DATE, Qt::CaseInsensitive)) {
|
||||
s += QString("%1 <font color='Green'>up to date</font><br />").arg(tmp);
|
||||
if (status.contains(internal::GIT_CUSTOMER_REPO_UP_TO_DATE, Qt::CaseInsensitive)) {
|
||||
s += QString("%1 <font color='Green'>%2</font><br />").arg(tmp).arg(internal::GIT_CUSTOMER_REPO_UP_TO_DATE);
|
||||
} else
|
||||
if (status.contains(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY, Qt::CaseInsensitive)) {
|
||||
s += QString("%1 <font color='Green'>%2</font><br />").arg(tmp).arg(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY);
|
||||
} else {
|
||||
s += QString( "%1 <font color='Red'>UNKNOWN STATUS</font><br />").arg(tmp);
|
||||
}
|
||||
@ -399,7 +402,7 @@ void MainWindow::onShowUpdateRequest(QString status) {
|
||||
}
|
||||
|
||||
m_stepLabelChopCount = -s.length();
|
||||
s += "Check customer repository";
|
||||
s += "Update customer repository";
|
||||
m_stepLabelChopCount += s.length();
|
||||
|
||||
ui->stepLabel->setText(s);
|
||||
|
@ -13,12 +13,20 @@ void CheckAndFetchCustomerRepositoryCommand::finished(int exitCode, QProcess::Ex
|
||||
Worker *w = worker();
|
||||
if (w) {
|
||||
switch (exitCode) {
|
||||
case -2:
|
||||
case internal::GIT_CHECKOUT_ERROR_CODE:
|
||||
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_CHECKOUT_ERROR);
|
||||
break;
|
||||
case -4:
|
||||
case internal::GIT_PULL_ERROR_CODE:
|
||||
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_PULL_ERROR);
|
||||
break;
|
||||
case internal::GIT_NOT_NECESSARY_CODE:
|
||||
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY);
|
||||
exitCode = 0;
|
||||
break;
|
||||
case internal::GIT_UPDATED_CODE:
|
||||
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_UPDATED);
|
||||
exitCode = 0;
|
||||
break;
|
||||
case 0:
|
||||
emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_UP_TO_DATE);
|
||||
default:;
|
||||
@ -29,13 +37,21 @@ void CheckAndFetchCustomerRepositoryCommand::finished(int exitCode, QProcess::Ex
|
||||
}
|
||||
|
||||
void CheckAndFetchCustomerRepositoryCommand::readyReadStandardOutput() {
|
||||
//QProcess *p = (QProcess *)sender();
|
||||
//if (p) {
|
||||
// Worker *w = worker();
|
||||
// if (w) {
|
||||
// QString s = p->readAllStandardOutput().trimmed();
|
||||
//
|
||||
// qCritical() << __func__ << ":" << __LINE__ << s;
|
||||
QProcess *p = (QProcess *)sender();
|
||||
if (p) {
|
||||
Worker *w = worker();
|
||||
if (w) {
|
||||
QString s = p->readAllStandardOutput().trimmed();
|
||||
m_commandResult += s;
|
||||
if (m_commandResult.contains(internal::GIT_CUSTOMER_REPO_NO_UPDATE_NECESSARY)) {
|
||||
//emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_NOT_NECESSARY);
|
||||
m_commandResult.clear();
|
||||
} else
|
||||
if (m_commandResult.contains(internal::GIT_CUSTOMER_REPO_UPDATED)) {
|
||||
//emit w->showCustRepoStatus(internal::GIT_CUSTOMER_REPO_UPDATED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static constexpr const char *GIT_CUSTOMER_REPO_UP_TO_DATE{"up to date"};
|
||||
// emit w->showCustRepoStatus(UpdateCommand::GIT_CUSTOMER_REPO_UP_TO_DATE);
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
int nextCommandIndex,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
QString m_commandResult{};
|
||||
public slots:
|
||||
virtual void readyReadStandardOutput() override;
|
||||
virtual void finished(int exitCode, QProcess::ExitStatus exitStatus) override;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "process/check_update_activation_command.h"
|
||||
#include "worker.h"
|
||||
#include "utils_internal.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -22,17 +23,17 @@ void CheckUpdateActivationCommand::readyReadStandardOutput() {
|
||||
Worker *w = worker();
|
||||
if (w) {
|
||||
QString s = p->readAllStandardOutput().trimmed();
|
||||
if (s == UpdateCommand::UPDATE_REQUESTED) {
|
||||
emit w->showUpdateRequest(UpdateCommand::UPDATE_REQUESTED);
|
||||
if (s == internal::UPDATE_REQUESTED) {
|
||||
emit w->showUpdateRequest(internal::UPDATE_REQUESTED);
|
||||
} else
|
||||
if (s == UpdateCommand::UPDATE_NOT_NECESSARY) {
|
||||
emit w->showUpdateRequest(UpdateCommand::UPDATE_NOT_NECESSARY);
|
||||
if (s == internal::UPDATE_NOT_NECESSARY) {
|
||||
emit w->showUpdateRequest(internal::UPDATE_NOT_NECESSARY);
|
||||
} else
|
||||
if (s == UpdateCommand::UPDATE_NOT_REQUESTED) {
|
||||
emit w->showUpdateRequest(UpdateCommand::UPDATE_NOT_REQUESTED);
|
||||
if (s == internal::UPDATE_NOT_REQUESTED) {
|
||||
emit w->showUpdateRequest(internal::UPDATE_NOT_REQUESTED);
|
||||
} else
|
||||
if (s == UpdateCommand::NO_CUSTOMER_REPOSITORY) {
|
||||
emit w->showUpdateRequest(UpdateCommand::NO_CUSTOMER_REPOSITORY);
|
||||
if (s == internal::NO_CUSTOMER_REPOSITORY) {
|
||||
emit w->showUpdateRequest(internal::NO_CUSTOMER_REPOSITORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,11 @@ public:
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
void resetCommandResult() { m_commandResult.clear(); }
|
||||
QString getCommandResult(bool reset = false);
|
||||
QString command() const { return m_command; }
|
||||
QString const &command() const { return m_command; }
|
||||
QString const &commandResult() const { return m_commandResult; }
|
||||
QStringList const &args() const { return m_args; }
|
||||
|
||||
bool exec();
|
||||
int exitCode() const { return m_exitCode; }
|
||||
|
@ -8,21 +8,37 @@ namespace internal {
|
||||
static constexpr const char *UPDATE_NOT_NECESSARY{"not necessary"};
|
||||
static constexpr const char *UPDATE_NOT_REQUESTED{"not requested"};
|
||||
static constexpr const char *UPDATE_REQUESTED{"requested"};
|
||||
|
||||
static constexpr const char *NO_CUSTOMER_REPOSITORY{"no customer repository"};
|
||||
|
||||
static constexpr const char *ISMAS_CONNECTED{"connected"};
|
||||
static constexpr const char *ISMAS_DISCONNECTED{"disconnected"};
|
||||
static constexpr const char *ISMAS_DISCONNECTING{"disconnecting"};
|
||||
static constexpr const char *ISMAS_NOT_CONNECTED{"not connected"};
|
||||
static constexpr const char *ISMAS_CONNECTION_IN_PROGRESS{"connecting"};
|
||||
|
||||
static constexpr const int GIT_CHECKOUT_ERROR_CODE{-2};
|
||||
static constexpr const int GIT_PULL_ERROR_CODE{-4};
|
||||
static constexpr const int GIT_NOT_NECESSARY_CODE{1};
|
||||
static constexpr const int GIT_UPDATED_CODE{2};
|
||||
|
||||
static constexpr const char *GIT_CUSTOMER_REPO_CHECKOUT_ERROR{"checkout error"};
|
||||
static constexpr const char *GIT_CUSTOMER_REPO_PULL_ERROR{"pull error"};
|
||||
static constexpr const char *GIT_CUSTOMER_REPO_UP_TO_DATE{"up to date"};
|
||||
static constexpr const char *GIT_CUSTOMER_REPO_NO_UPDATE_NECESSARY{"no repository update necessary"};
|
||||
static constexpr const char *GIT_CUSTOMER_REPO_NOT_NECESSARY{"not necessary"};
|
||||
static constexpr const char *GIT_CUSTOMER_REPO_UPDATED{"repository updated"};
|
||||
static constexpr const char *GIT_UPDATED{"updated"};
|
||||
|
||||
static constexpr const char *EXEC_OPKG_COMMANDS_SUCCESS{"success"};
|
||||
static constexpr const char *EXEC_OPKG_COMMANDS_FAIL{"FAIL"};
|
||||
static constexpr const char *EXEC_OPKG_COMMANDS_NOACTION_SUCCESS{"success"};
|
||||
static constexpr const char *EXEC_OPKG_COMMANDS_NOACTION_FAIL{"FAIL"};
|
||||
|
||||
static constexpr const char *UPDATE_DC_JSON_FILES_SUCCESS{"success"};
|
||||
|
||||
static constexpr const char *SYNC_CUSTOMER_REPO_FILES_SUCCESS{"success"};
|
||||
|
||||
static constexpr const char *UPDATE_DC_FIRMARE_SUCCESS{"success"};
|
||||
|
||||
static constexpr const char *OPKG_MARKER{"<OPKG>"};
|
||||
|
@ -22,6 +22,48 @@ namespace ISMAS {
|
||||
return QString (local.toString(Qt::ISODateWithMs) + st);
|
||||
}
|
||||
|
||||
enum RESULT_CODE {
|
||||
E_SUCCESS=0,
|
||||
// if between 00:00 - 04:00 Wait-button state not WAIT, then we assume
|
||||
// that's an automatic nightly (not-necessary) update
|
||||
E_NO_UPDATE_NECESSARY=1,
|
||||
// if APISM reports the ISMAS is not available (15x, 6s delay each)
|
||||
E_ISMAS_NO_CONNECTION_ERROR=2,
|
||||
// if not within 00:00-04:00 and WAIT-button was not in state WAIT
|
||||
E_ISMAS_TRIGGER_ERROR=3,
|
||||
// cloning git repo. not possible
|
||||
E_GIT_CLONE_ERROR=4,
|
||||
// pulling from remote git server not possible
|
||||
E_GIT_PULL_ERROR=5,
|
||||
// fetching from remote git server not possible
|
||||
E_GIT_FETCH_ERROR=6,
|
||||
// merging fetched data not possible
|
||||
E_GIT_MERGE_ERROR=7,
|
||||
// check sanity of local customer-repository failed
|
||||
E_GIT_CHECK_REPOSITORY_ERROR=8,
|
||||
// switch/checkout of branch (i.e. zone) on error
|
||||
E_GIT_SWITCH_BRANCH_ERROR=9,
|
||||
// fetch/pull of new branch failed. the new branch was not available
|
||||
// when installing via SD-card followed by intial clone during the
|
||||
// update process.
|
||||
E_GIT_FETCH_NEW_BRANCH_ERROR=10,
|
||||
// error computing git-blob hash-value
|
||||
E_GIT_HASH_ERROR=11,
|
||||
// update for general json files failed.
|
||||
E_JSON_FILES_UPDATE_ERROR=12,
|
||||
// error downloading config-json-files to device controller
|
||||
E_JSON_FILES_DOWNLOAD_ERROR=13,
|
||||
// error downloading device-controller
|
||||
E_DC_DOWNLOAD_ERROR=14,
|
||||
// error rsyncing json/ini-files to local filesystem
|
||||
E_RSYN_ERROR=15,
|
||||
// HASH_VALUE_ERROR=14,
|
||||
// HW_COMPATIBILITY_ERROR=15,
|
||||
E_OPKG_COMMANDS_ERROR=16,
|
||||
// CLEANUP_ERROR=18,
|
||||
E_UPDATE_IN_ERROR_STATE=99
|
||||
};
|
||||
|
||||
//
|
||||
// Note:
|
||||
// ! After U0002 immer ein CMD_SENDVERSION
|
||||
|
@ -31,7 +31,8 @@ void Command::readyReadStandardOutput() {
|
||||
if (p) {
|
||||
QString s = p->readAllStandardOutput();
|
||||
if (m_verbose) {
|
||||
qCritical().noquote() << s;
|
||||
// qCritical().noquote() << s;
|
||||
m_commandResult += s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,7 +40,9 @@ void Command::readyReadStandardOutput() {
|
||||
void Command::readyReadStandardError() {
|
||||
QProcess *p = (QProcess *)sender();
|
||||
if (p) {
|
||||
qCritical().noquote() << p->readAllStandardError();
|
||||
QString s = p->readAllStandardError();
|
||||
// qCritical().noquote() << s;
|
||||
m_commandResult += s;
|
||||
}
|
||||
}
|
||||
|
||||
|
3147
documentation/atb-update-tool.tex
Normal file
3147
documentation/atb-update-tool.tex
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user