Compare commits

..

20 Commits

Author SHA1 Message Date
da102b5ed0 Set version to 1.4.6 2024-04-26 12:53:30 +02:00
7031c0e349 Replace INSTALL_ERROR with proper error codes. 2024-04-26 12:49:06 +02:00
c528ce377d Add some new messages sent to ISMAS. 2024-04-26 12:47:44 +02:00
5e7c848fca Replaced INSTALL_ERROR by proper error codes. 2024-04-26 12:47:13 +02:00
3165d77f49 Replaced U0010 by its macro _ISMAS_CONTINUE 2024-04-26 12:46:28 +02:00
f0d2d5f958 Replaced U0010 by its macro _ISMAS_CONTINUE 2024-04-26 12:45:08 +02:00
1da4c3b224 Add _ISMAS_TEST_TRIGGER 2024-04-26 12:43:21 +02:00
f1cedbf1d5 Define new error codes (and actually use them) -> ISMAS not affected. 2024-04-26 12:41:21 +02:00
0933274c82 Add update functionality (again using ATBUpdateTool as template) 2024-04-23 16:25:36 +02:00
2aa676f18c Implement json-download tool with ATBUpdateTool as template. 2024-04-23 16:23:58 +02:00
6c0d49b90c Start with project file for json-download tool. 2024-04-23 16:22:56 +02:00
18d04d15cf Set version to 1.4.5. 2024-04-11 16:31:44 +02:00
b81120f8dc Implemented:
bool branchExistsRemotely();
	Check if branch exists in remote customer-repository.

    bool branchExistsLocally();
	Check if branch exists locally in customer-repository.

    bool gitPullNewBranches();
	In case the remote branch exists, but not the corresponding local one,
	then fetch the remote-branch.
2024-04-11 16:25:36 +02:00
8b2fcb25db Added declarations for:
bool branchExistsRemotely();
    bool branchExistsLocally();
    bool gitPullNewBranches();
2024-04-11 16:24:33 +02:00
698cf74516 doUpdate(): re-check again if there are valid data form the device-controller. 2024-04-11 16:23:08 +02:00
20681b0d6c If we have pull a new remote branch, the behave as if the customer-repo
did not exist before: especially download all json-files inside
the new local branch.
2024-04-11 16:20:46 +02:00
763647c145 If customer-repo is already existent (i.e. not cloned),
then check for the existence of remote branch (zg/zone<zone-number of psa>).
If it exists remotely, but not locally, then execute 'git pull'
(could also be 'git pull origin zg1/zone<zone-number>').
A follwing 'git checkout zg1/zone<zone-number>' will switch to the
now local branch.
2024-04-11 16:16:34 +02:00
4aad14b181 Added PULL_NEW_BRANCH, PULL_NEW_BRANCH_FAILED, PULL_NEW_BRANCH_SUCCESS and corresponding output messages. 2024-04-11 16:15:49 +02:00
0a03228dea Added PULL_NEW_BRANCH, PULL_NEW_BRANCH_FAILED, PULL_NEW_BRANCH_SUCCESS and corresponding output messages. 2024-04-11 16:14:45 +02:00
23551066c1 Set version to 1.4.4 2024-04-09 15:02:59 +02:00
12 changed files with 941 additions and 104 deletions

View File

@@ -19,7 +19,8 @@ EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
!contains(CONFIG, INCLUDEINTERFACES) {
INCLUDEINTERFACES=/opt/ptu5/opt/DCLibraries/include
}
INCLUDEPATH += plugins $${INCLUDEINTERFACES}
INCLUDEPATH += plugins $${INCLUDEINTERFACES} $${_PRO_FILE_PWD_}/../UpdatePTUDevCtrl
CONFIG += c++17
@@ -73,12 +74,14 @@ contains( CONFIG, DesktopLinux ) {
SOURCES += \
main.cpp \
message_handler.cpp \
process/command.cpp
../UpdatePTUDevCtrl/message_handler.cpp \
../UpdatePTUDevCtrl/commandline_parser.cpp \
update.cpp
HEADERS += \
message_handler.h \
process/command.h
../UpdatePTUDevCtrl/message_handler.h \
../UpdatePTUDevCtrl/commandline_parser.h \
update.h
OTHER_FILES += \
ATBDownloadDCJsonFiles.ini

View File

@@ -3,7 +3,19 @@
#include <QCoreApplication>
#include <QByteArray>
#include <QProcess>
#include <QCommandLineParser>
#include <QStandardPaths>
#include <QSettings>
#include <QDir>
#include <QDebug>
#include "message_handler.h"
#include "commandline_parser.h"
#include "utils.h"
#include "update.h"
#include <DeviceController/interfaces.h>
@@ -16,6 +28,20 @@
#define SERIAL_PORT "ttyUSB0"
#endif
int read1stLineOfFile(QString fileName) {
QFile f(fileName);
if (f.exists()) {
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
QTextStream in(&f);
in.setCodec("UTF-8");
while(!in.atEnd()) {
return in.readLine().toInt();
}
}
}
return -1;
}
int main(int argc, char **argv) {
QByteArray const value = qgetenv("LC_ALL");
if (value != "C") {
@@ -34,23 +60,86 @@ int main(int argc, char **argv) {
setDebugLevel(LOG_NOTICE);
}
// int r = std::system("ls -l /proc/[0-9]*/fd/* 2>/dev/null | grep /dev/ttymxc2 > /tmp/slave-or-master.txt");
// lrwx------ 1 root root 64 Oct 31 14:55 /proc/884/fd/18 -> /dev/ttymxc2
CommandLineParser parser;
parser.process(a);
parser.readSettings();
//std::ifstream ifs("/tmp/slave-or-master.txt");
QString repositoryUrl = parser.repositoryUrl();
QString plugInDir = parser.plugInDir();
QString plugInName = parser.plugInName();
QString workingDir = parser.workingDir();
QString iniFileName = parser.iniFileName();
bool const dryRun = parser.dryRun();
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
bool const showYoctoVersion = parser.yoctoVersion();
bool const showYoctoInstallStatus = parser.yoctoInstallStatus();
bool const showExtendedVersion = parser.extendedVersion();
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
//if (ifs.is_open()) {
// std::string line;
// if (std::getline(ifs, line)) {
// if (line.size() > 0) {
// std::cout << "SLAVE " << line << std::endl;
// }
// } else {
// }
QString const rtPath = QCoreApplication::applicationDirPath();
// ifs.close();
int const machineNr = read1stLineOfFile("/mnt/system_data/machine_nr");
int const customerNr = read1stLineOfFile("/mnt/system_data/cust_nr");
int const zoneNr = read1stLineOfFile("/mnt/system_data/zone_nr");
QString const branchName = (zoneNr != 0)
? QString("zg1/zone%1").arg(zoneNr) : "master";
//}
qInfo() << "pwd ......................" << rtPath;
qInfo() << "repositoryUrl ............" << repositoryUrl;
qInfo() << "plugInDir ................" << plugInDir;
qInfo() << "plugInName ..............." << plugInName;
qInfo() << "workingDir ..............." << workingDir;
qInfo() << "dryRun ..................." << dryRun;
qInfo() << "noUpdatePsaHardware ......" << noUpdatePsaHardware;
qInfo() << "alwaysDownloadConfig ....." << alwaysDownloadConfig;
qInfo() << "alwaysDownloadDC ........." << alwaysDownloadDC;
qInfo() << "showYoctoVersion ........." << showYoctoVersion;
qInfo() << "showYoctoInstallStatus ..." << showYoctoInstallStatus;
qInfo() << "showExtendedVersion ......" << showExtendedVersion;
qInfo() << "iniFileName .............." << iniFileName;
qInfo() << "extended-version ........." << APP_EXTENDED_VERSION;
qInfo() << "machineNr ................" << machineNr;
qInfo() << "customerNr ..............." << customerNr;
qInfo() << "zoneNr ..................." << zoneNr;
return a.exec();
if (showExtendedVersion) {
printf(APP_EXTENDED_VERSION"\n");
return 0;
}
QString const customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
qCritical() << "Using customer repository" << customerRepo;
// always execute contents of opkg_commands-file
QStringList filesToUpdate;
QDir dir(QDir::cleanPath(customerRepo + QDir::separator() + "etc/psa_config"));
if (dir.exists()) {
QStringList jsons = dir.entryList(QStringList() << "DC2C*.json", QDir::Files);
if (!jsons.isEmpty()) {
for (QStringList::size_type i=0; i<jsons.size(); ++i) {
filesToUpdate << QDir::cleanPath(QString("etc/psa_config/") + jsons.at(i));
}
}
} else {
qCritical() << "DIRECTORY" << dir << "DOES NOT EXIST";
return -1;
}
qCritical() << "JSON FILES TO UPDATE" << filesToUpdate;
Update update(customerRepo,
QString::number(customerNr),
branchName,
plugInDir,
plugInName,
workingDir);
update.doUpdate(filesToUpdate);
//return a.exec();
return 0;
}

View File

@@ -0,0 +1,332 @@
#include "update.h"
#include <QCoreApplication>
#include <QFile>
#include <QTemporaryFile>
#include <QDebug>
#include <QTextStream>
#include <QRegularExpression>
#include <QRegExp>
#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX)
#include "unistd.h"
#endif
#include <DeviceController/interfaces.h>
#include <QSharedMemory>
#include <QScopedPointer>
#include <QDir>
#include <QThread>
#include <QDateTime>
#include <QPluginLoader>
#include <QMap>
#define UPDATE_OPKG (1)
#define UPDATE_DC (0)
static const QMap<QString, int> baudrateMap = {
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
{"57600" , 4}, {"115200" , 5}
};
QPluginLoader Update::pluginLoader;
hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
hwinf *hw = nullptr;
if (plugInDir.exists()) {
QString pluginLibName(fname);
pluginLibName = plugInDir.absoluteFilePath(pluginLibName);
QFileInfo info(pluginLibName);
if (info.exists()) {
pluginLibName = plugInDir.absoluteFilePath(pluginLibName);
pluginLoader.setFileName(pluginLibName);
// static QPluginLoader pluginLoader(pluginLibName);
if (!pluginLoader.load()) {
qCritical() << "in directory" << plugInDir.absolutePath();
qCritical() << "cannot load plugin" << pluginLoader.fileName();
qCritical() << pluginLoader.errorString();
exit(-1);
}
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
qCritical() << "loadDCPlugin() plugin file name:" << pluginLoader.fileName();
if (!pluginLoader.isLoaded()) {
qCritical() << pluginLoader.errorString();
exit(-2);
}
QObject *plugin = pluginLoader.instance();
if (!plugin) {
qCritical() << "cannot start instance";
exit(-3);
}
if (! (hw = qobject_cast<hwinf *>(plugin))) {
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
exit(-4);
}
} else {
qCritical() << pluginLibName << "does not exist";
exit(-5);
}
} else {
qCritical() << "plugins directory" << plugInDir.absolutePath()
<< "does not exist";
exit(-6);
}
return hw;
}
bool Update::unloadDCPlugin() {
if (pluginLoader.unload()) {
qCritical() << "unloaded plugin" << pluginLoader.fileName();
// Note: will re-instantiate the library !
// QObject *rootObject = pluginLoader.instance();
// if (rootObject) {
// qCritical() << "reloaded plugin: root object again available";
// return false;
// }
// qCritical()unloaded plugin: root object gone";
return true;
}
return false;
}
class hwapi;
Update::Update(QString customerRepository,
QString customerNrStr,
QString branchName,
QString plugInDir,
QString pluginName,
QString workingDir,
bool dryRun,
QObject *parent,
char const *serialInterface,
char const *baudrate)
: QObject(parent)
, m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
, m_serialInterface(serialInterface)
, m_baudrate(baudrate)
, m_customerRepository(customerRepository)
, m_customerNrStr(customerNrStr)
, m_branchName(branchName)
, m_pluginName(pluginName)
, m_workingDir(workingDir)
, m_dryRun(dryRun)
, m_sys_areDCdataValid(false) {
if (!m_hw) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin loaded ???";
} else {
int tries = 20;
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
// must deliver 'true', only then are all data from hwapi valid
if (--tries < 0) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
break;
}
m_hw->dc_autoRequest(true);
QThread::msleep(500);
}
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
<< m_sys_areDCdataValid;
#if 0
QObject const *obj = m_hw->getAPI();
Q_ASSERT(obj != nullptr);
QDebug critical = qCritical();
critical << "connect() to onReportDCDownloadStatus() ...";
if (!connect(obj,
SIGNAL(hwapi_reportDCDownloadStatus(QString const&)),
this,
SLOT(onReportDCDownloadStatus(QString const &)))) {
critical << "FAILED";
} else critical << "DONE";
critical = qCritical();
critical << "connect() to onReportDCDownloadSuccess() ...";
if (!connect(obj,
SIGNAL(hwapi_reportDCDownloadSuccess(QString const&)), this,
SLOT(onReportDCDownloadSuccess(QString const &)))) {
critical << "FAILED";
} else critical << "DONE";
critical = qCritical();
critical << "connect() to onReportDCDownloadFailure() ...";
if (!connect(obj,
SIGNAL(hwapi_reportDCDownloadFailure(QString const &)), this,
SLOT(onReportDCDownloadFailure(QString const &)))) {
critical << "FAILED";
} else critical << "DONE";
#endif
}
}
Update::~Update() {
// unloadDCPlugin();
}
bool Update::doUpdate(QStringList const &filesToWorkOn) {
int tries = 20;
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
// must deliver 'true', only then are all data from hwapi valid
if (--tries < 0) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
return false;
}
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
m_hw->dc_autoRequest(true);
QThread::msleep(500);
}
bool res = false;
QList<QString>::const_iterator it;
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
if ((templateIdx < 1) || (templateIdx > 32)) {
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
res = false;
} else {
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
qCritical() <<
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
.arg(fToWorkOn)
.arg(templateIdx);
}
}
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res = updateCashConf(fToWorkOn))) {
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
}
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res= updateConfig(fToWorkOn))) {
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
}
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true;
if ((res = updateDeviceConf(fToWorkOn))) {
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
}
} else {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false;
}
}
return res;
}
bool Update::downloadJson(enum FileTypeJson type,
int templateIdx,
QString jsFileToSendToDC) const {
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
qDebug() << "SET AUTO-REQUEST=TRUE";
QThread::sleep(1); // make sure the auto-request flag is acknowledged
QStringList lst;
bool ready = false;
int nTry = 25;
while ((ready = m_hw->sys_ready4sending()) == false) {
QThread::msleep(200);
if (--nTry <= 0) {
qCritical() << "SYS NOT READY FOR SENDING AFTER 5 SECONDS";
break;
}
}
bool ret = false;
QString msg;
lst.clear();
if (ready) {
QFile file(jsFileToSendToDC);
QFileInfo fi(jsFileToSendToDC); // max. size of template file is 800 bytes
if (file.exists()) {
if (file.open(QIODevice::ReadOnly)) {
if (fi.size() > 0 && fi.size() <= 800) {
QByteArray ba = file.readAll();
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
// nrOfTemplate=1...32 if kindOfFile==6
// content = content of the Json file, max 800byte ascii signs
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
templateIdx,
(uint8_t *)ba.data())) {
/*
* Note: the machine id is contained in DC2C_conf.json.
* The idea was to use this to check if the download of
* the json-file was correct. It did not work, as the
* update of the PSA (to reflect a change in the
* machine id) did not happen immediately.
*
m_hw->dc_autoRequest(true);
QThread::msleep(500);
// testing
m_hw->request_ReadbackMachineID();
QThread::msleep(500);
uint8_t data[64];
memset(data, 0x00, sizeof(data));
uint8_t length = 0;
m_hw->readback_machineIDdata(&length, data);
QThread::msleep(500);
QByteArray ba((const char*)data, length);
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
*/
ret = true;
} else {
qCritical() << QString("ERROR SEND JSON-FILE %1 TO DC").arg(file.fileName());
}
} else {
qCritical() << QString("SIZE OF %1 TOO BIG (%2 BYTES)").arg(jsFileToSendToDC).arg(fi.size());
}
} else {
qCritical() << QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING";
}
} else {
qCritical() << (QString(jsFileToSendToDC) + " DOES NOT EXIST");
}
}
m_hw->dc_autoRequest(false);
qDebug() << "SET AUTO-REQUEST=FALSE";
QThread::sleep(1); // make sure the auto-request flag is acknowledged
return ret;
}
bool Update::updatePrinterTemplate(int templateIdx, QString jsFile) const {
return downloadJson(FileTypeJson::PRINTER, templateIdx, jsFile);
}
bool Update::updateConfig(QString jsFile) {
return downloadJson(FileTypeJson::CONFIG, 0, jsFile);
}
bool Update::updateCashConf(QString jsFile) {
return downloadJson(FileTypeJson::CASH, 0, jsFile);
}
bool Update::updateDeviceConf(QString jsFile) {
return downloadJson(FileTypeJson::DEVICE, 0, jsFile);
}

View File

@@ -0,0 +1,105 @@
#ifndef UPDATE_H_INCLUDED
#define UPDATE_H_INCLUDED
#include <QObject>
#include <QString>
#include <QFile>
#include <QDir>
#include <QByteArray>
#include <QProcess>
#include <QPluginLoader>
#include <DeviceController/interfaces.h>
#ifdef PTU5
#define SERIAL_PORT "ttymxc2"
#else
#define SERIAL_PORT "ttyUSB0"
#endif
class Update : public QObject {
Q_OBJECT
hwinf *m_hw = nullptr;
char const *m_serialInterface;
char const *m_baudrate;
QString m_customerRepository;
QString m_customerNrStr;
QString m_branchName;
QString m_pluginName;
QString m_workingDir;
bool m_maintenanceMode;
bool m_dryRun;
bool m_sys_areDCdataValid;
static QPluginLoader pluginLoader;
public:
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
enum class FileTypeJson {CONFIG=1, DEVICE=2, CASH=3, SERIAL=4, TIME=5, PRINTER=6};
static hwinf *loadDCPlugin(QDir const &plugInDir, QString const &fn);
static bool unloadDCPlugin();
static QStringList split(QString line, QChar sep = ',');
explicit Update(QString customerRepository,
QString customerNrStr,
QString branchName,
QString plugInDir,
QString pluginName,
QString workingDir,
bool dryRun = false,
QObject *parent = nullptr,
char const *serialInterface = SERIAL_PORT,
char const *baudrate = "115200");
virtual ~Update() override;
bool doUpdate(QStringList const &jsonFilesToDownload);
bool updatePrinterTemplate(int templateIdx, QString fname) const;
bool updateConfig(QString jsFileToSendToDC);
bool updateCashConf(QString jsFileToSendToDC);
bool updateDeviceConf(QString jsFileToSendToDC);
bool downloadJson(enum FileTypeJson type, int templateIdx,
QString jsFileToSendToDC) const;
/*
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
hwinf *hw() { return m_hw; }
hwinf const *hw() const { return m_hw; }
//QString customerId() { return m_customerId; }
//QString const customerId() const { return m_customerId; }
QString branchName() { return m_branchName; }
QString const branchName() const { return m_branchName; }
//QString repositoryPath() { return m_repositoryPath; }
//QString const repositoryPath() const { return m_repositoryPath; }
private:
static QString jsonType(enum FileTypeJson type);
bool openSerial(int br, QString baudrate, QString comPort) const;
void closeSerial() const;
bool isSerialOpen() const;
bool resetDeviceController() const;
QByteArray loadBinaryDCFile(QString filename) const;
bool downloadBinaryToDC(QString const &bFile) const;
bool updateBinary(QString const &fileToSendToDC);
QStringList getDcSoftAndHardWareVersion();
QString getFileVersion(QString const& jsonFile);
private slots:
void readyReadStandardOutput();
void readyReadStandardError();
void finished(int exitCode, QProcess::ExitStatus exitStatus);
void onReportDCDownloadStatus(QString const &status);
void onReportDCDownloadSuccess(QString const &msg);
void onReportDCDownloadFailure(QString const &errorMsg);
*/
};
#endif // UPDATE_H_INCLUDED

View File

@@ -109,7 +109,15 @@ DEFINES += QT_DEPRECATED_WARNINGS
# the same after an rsync. They might be noy after a change of the
# customer-number.
# 1.4.3 : Use global directory for device-controller interfaces.h-file.
VERSION="1.4.3"
# 1.4.4 : Add additional debug messages when downloading json-files.
# Move rsyncing of the customer-repository after the actual fetching
# of the repository. Otherwise, the update of, for instance
# tariff-files, would always be a step behind.
# 1.4.5 : In case a new branch has been created in a remote
# customer-repository (e.g. origin/zg1/zone101), then fetch/pull
# this branch before switching to this now locally existen branch.
# : Improve output of GUI/Console and messages sent to ISMAS.
VERSION="1.4.6"
# PLANNED TODOS:
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu

View File

@@ -6,6 +6,7 @@
#include <QRegularExpression>
#include <QDebug>
#include <QDir>
#include <QStringList>
GitClient::GitClient(QString const &customerNrStr,
@@ -290,6 +291,100 @@ bool GitClient::gitFsck() {
}
return r;
}
bool GitClient::branchExistsRemotely() {
bool remoteBranchExists = false;
if (QDir(m_customerRepository).exists()) {
qInfo() << "BRANCH NAME" << m_branchName;
QString const cmd = QString("git ls-remote --exit-code --heads origin %1").arg(m_branchName);
Command c(cmd);
if (c.execute(m_customerRepository)) {
// expected result: c16c833c8778c1b3691a74afee5a469177e4e69b refs/heads/zg1/zone1000
QString const s = c.getCommandResult().trimmed();
if (!s.isEmpty()) {
// the result is only one line
if ((remoteBranchExists = s.contains(m_branchName)) == true) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") branch"
<< m_branchName << "EXISTS REMOTELY. (" << s << ")";
}
} else {
Utils::printCriticalErrorMsg(QString("EMPTY RESULT FOR CMD %1").arg(cmd));
}
} else {
Utils::printCriticalErrorMsg(QString("FAILED TO EXEC '%1'").arg(cmd));
}
}
return remoteBranchExists;
}
bool GitClient::branchExistsLocally() {
Command c("git branch -l");
if (c.execute(m_customerRepository)) {
QString const s = c.getCommandResult().trimmed();
if (!s.isEmpty()) {
QStringList lines = Update::split(s, '\n');
if (!lines.empty()) {
for (int i=0; i < lines.size(); ++i) {
QString line = lines.at(i);
// expected: * [new branch] zg1/zone12 -> origin/zg1/zone12"
if (line.contains(m_branchName)) {
if (m_worker) {
QStringList lst(QString("BRANCH-NAME %1 CONTAINED IN RESULT %2").arg(m_branchName).arg(s));
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH;
}
return true;
}
}
if (m_worker) {
QStringList lst(QString("BRANCH-NAME %1 NOT CONTAINED IN RESULT %2").arg(m_branchName).arg(s));
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
}
} else {
if (m_worker) {
QStringList lst(QString("'git branch -l' RETURNED NO LINES"));
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
}
}
} else {
if (m_worker) {
QStringList lst(QString("'git branch -l' RETURNED EMPTY RESULT"));
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
}
}
} else {
if (m_worker) {
QStringList lst(QString("FAILED TO EXEC 'git branch -l'"));
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
}
}
return false;
}
bool GitClient::gitPullNewBranches() {
if (QDir(m_customerRepository).exists()) {
Command c("git pull");
if (c.execute(m_customerRepository)) {
QString const s = c.getCommandResult().trimmed();
// expected: Already up-to-date.
if (!s.isEmpty()) {
QStringList lst;
QString msg(QString("GIT-PULL-NEW-BRANCH. RESULT=%1").arg(s));
if (m_worker) {
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH;
}
return true;
}
}
}
return false;
}
/*
Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
*/

View File

@@ -57,6 +57,10 @@ class GitClient : public QObject {
static QString gitBlob(QString fileName);
QString gitCommitForBlob(QString blob);
bool gitIsFileTracked(QString file2name);
bool branchExistsRemotely();
bool branchExistsLocally();
bool gitPullNewBranches();
};
#endif // GIT_CLIENT_H_INCLUDED

View File

@@ -384,7 +384,7 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
QString const &version) {
return updateNewsToIsmas("U0003",
m_progressInPercent,
RESULT_CODE::INSTALL_ERROR,
RESULT_CODE::ISMAS_NO_CONNECTION_ERROR,
"CHECK BACKEND CONNECTIVITY",
info.toStdString().c_str(),
version.toStdString().c_str());
@@ -394,7 +394,7 @@ QString IsmasClient::errorGitClone(QString const &info,
QString const &version) {
return updateNewsToIsmas("U0003",
m_progressInPercent,
RESULT_CODE::INSTALL_ERROR,
RESULT_CODE::GIT_CLONE_ERROR,
"CLONE CUSTOMER REPOSITORY FAILED",
info.toStdString().c_str(),
version.toStdString().c_str());
@@ -442,7 +442,7 @@ QString IsmasClient::updateTriggerSet(QString const &info, QString const &versio
QString IsmasClient::errorUpdateTrigger(QString const &info, QString const &version) {
return updateNewsToIsmas("U0003",
m_progressInPercent,
RESULT_CODE::INSTALL_ERROR,
RESULT_CODE::ISMAS_TRIGGER_ERROR,
"CHECK UPDATE TRIGGER",
info.toStdString().c_str(),
version.toStdString().c_str());

View File

@@ -145,13 +145,47 @@ public:
DIRECT_PORT = 7778
};
enum RESULT_CODE {
SUCCESS=0,
// if between 00:00 - 04:00 Wait-button state not WAIT, then we assume
// that's an automatic nightly (not-necessary) update
NO_UPDATE_NECESSARY=1,
BACKUP_FAILED=2,
WRONG_PACKAGE=3,
INSTALL_ERROR=4};
// if APISM reports the ISMAS is not available (15x, 6s delay each)
ISMAS_NO_CONNECTION_ERROR=2,
// if not within 00:00-04:00 and WAIT-button was not in state WAIT
ISMAS_TRIGGER_ERROR=3,
// cloning git repo. not possible
GIT_CLONE_ERROR=4,
// pulling from remote git server not possible
GIT_PULL_ERROR=5,
// fetching from remote git server not possible
GIT_FETCH_ERROR=6,
// merging fetched data not possible
GIT_MERGE_ERROR=7,
// check sanity of local customer-repository failed
GIT_CHECK_REPOSITORY_ERROR=8,
// switch/checkout of branch (i.e. zone) on error
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.
GIT_FETCH_NEW_BRANCH_ERROR=10,
// error computing git-blob hash-value
GIT_HASH_ERROR=11,
// update for general json files failed.
JSON_FILES_UPDATE_ERROR=12,
// error downloading config-json-files to device controller
JSON_FILES_DOWNLOAD_ERROR=13,
// error downloading device-controller
DC_DOWNLOAD_ERROR=14,
// error rsyncing json/ini-files to local filesystem
RSYN_ERROR=15,
// HASH_VALUE_ERROR=14,
// HW_COMPATIBILITY_ERROR=15,
OPKG_COMMANDS_ERROR=16,
// CLEANUP_ERROR=18,
UPDATE_IN_ERROR_STATE=99
};
enum REASON {
TIME_TRIGGERED = 0,

View File

@@ -670,9 +670,17 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
return false;
}
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
if (m_sys_areDCdataValid == false) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
return false;
int tries = 20;
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
// must deliver 'true', only then are all data from hwapi valid
if (--tries < 0) {
Utils::printCriticalErrorMsg("ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED");
return false;
}
Utils::printCriticalErrorMsg("DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED");
m_hw->dc_autoRequest(true);
QThread::msleep(500);
}
bool res = false;

View File

@@ -56,6 +56,9 @@ const QMap<UPDATE_STEP, const char*> Worker::smap (
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER),
INSERT_ELEMENT(UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER),
INSERT_ELEMENT(UPDATE_STEP::PULL_NEW_BRANCH),
INSERT_ELEMENT(UPDATE_STEP::PULL_NEW_BRANCH_FAILURE),
INSERT_ELEMENT(UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::CHECKOUT_BRANCH),
INSERT_ELEMENT(UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS),
INSERT_ELEMENT(UPDATE_STEP::CHECKOUT_BRANCH_FAILURE),
@@ -330,6 +333,7 @@ void Worker::privateUpdate() {
m_clone = false;
m_repairClone = false;
m_initialClone = false;
m_pulledNewBranch = false;
// the customer repository is cloned or
// repaired/re-cloned without checking the
// ISMAS-trigger (WAIT-)button.
@@ -724,6 +728,35 @@ bool Worker::customerEnvironment() {
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::CHECKOUT_BRANCH));
if (QDir(m_customerRepository).exists()) {
if (m_clone == false) {
if (m_gc.branchExistsRemotely()) {
QString msg("PULL NEW BRANCH " + m_branchName);
QStringList lst(msg);
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::PULL_NEW_BRANCH));
if (!m_gc.branchExistsLocally()) {
msg = QString("PULLING OF NEW BRANCH " + m_branchName + " DOES NOT EXIST LOCALLY");
QStringList lst(msg);
CONSOLE(lst) << UPDATE_STEP::PULL_NEW_BRANCH;
if (!m_gc.gitPullNewBranches()) {
msg = QString("PULLING OF NEW BRANCH " + m_branchName + "FAILED");
QStringList lst(msg);
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::PULL_NEW_BRANCH_FAILURE)));
return false;
} else {
msg = QString("PULLING OF NEW BRANCH " + m_branchName + "SUCCESS");
QStringList lst(msg);
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS)));
m_pulledNewBranch = true;
}
} else {
msg = QString("PULLING ALREADY EXISTING LOCAL BRANCH " + m_branchName + "SUCCESS");
QStringList lst(msg);
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS)));
m_pulledNewBranch = true;
}
}
}
if (m_gc.gitCheckoutBranch()) {
return true;
} else {
@@ -747,7 +780,7 @@ bool Worker::filesToUpdate() {
// always execute contents of opkg_commands-file
m_filesToUpdate << "etc/psa_update/opkg_commands";
if (m_clone && m_alwaysDownloadConfig) {
if ((m_clone || m_pulledNewBranch) && m_alwaysDownloadConfig) {
// always download all json-config files, even if none of them have been
// changed in the git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config"));
@@ -761,7 +794,7 @@ bool Worker::filesToUpdate() {
}
}
if (m_clone && m_alwaysDownloadDC) {
if ((m_clone || m_pulledNewBranch) && m_alwaysDownloadConfig) {
// always download the last dc-binary, even if not changed in the
// git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/dc"));

View File

@@ -26,11 +26,21 @@
#define SERIAL_PORT "ttyUSB0"
#endif
#define _ISMAS_DONE "U0001" // 100%
#define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button ("")
/*
Note:
! After U0002 immer ein CMD_SENDVERSION
! Only U0002 and U0003 finish the Update process.
! U0001: Update finished but not activated
! U0002: Update finished and activated
! U0003: Update finished but FAILed.
*/
#define _ISMAS_DONE "U0001" // 100%, Check: Resultcode: 0
#define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button (""), ResultCode: 0
#define _ISMAS_FAILURE "U0003" // FAIL
#define _ISMAS_CONTINUE "U0010" // %-values
#define _ISMAS_CONTINUE "U0010" // %-values: Update laeuft, Resultcodes entsprechend laufender Schritt
#define _ISMAS_RESET_WAIT "ISMAS" // reset WAIT-button to "WAIT"
#define _ISMAS_TEST_TRIGGER "U0099" // check the WAIT-button
#define _STARTED (1)
#define _CHECK_ISMAS_TRIGGER (2)
@@ -53,38 +63,41 @@
#define _CHECK_ISMAS_TRIGGER_WRONG_VALUE (19)
#define _CHECK_ISMAS_TRIGGER_SUCCESS (20)
#define _CHECK_ISMAS_TRIGGER_FAILURE (21)
#define _CHECKOUT_BRANCH (22)
#define _CHECKOUT_BRANCH_FAILURE (23)
#define _CHECKOUT_BRANCH_SUCCESS (24)
#define _UPDATE_REPOSITORY (25)
#define _UPDATE_REPOSITORY_FAILURE (26)
#define _UPDATE_REPOSITORY_SUCCESS (27)
#define _CHECK_FOR_REPOSITORY_CHANGES (28)
#define _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS (29)
#define _SYNC_CUSTOMER_REPOSITORY (30)
#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (31)
#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (32)
#define _FILES_TO_UPDATE (33)
#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (34)
#define _FILES_TO_DOWNLOAD (35)
#define _EXEC_OPKG_COMMANDS (41)
#define _EXEC_OPKG_COMMAND_1 (42)
#define _EXEC_OPKG_COMMAND_2 (43)
#define _EXEC_OPKG_COMMAND_3 (44)
#define _EXEC_OPKG_COMMAND_4 (45)
#define _EXEC_OPKG_COMMAND_5 (46)
#define _EXEC_OPKG_COMMAND_6 (47)
#define _EXEC_OPKG_COMMAND_7 (48)
#define _EXEC_OPKG_COMMAND_8 (49)
#define _EXEC_OPKG_COMMAND_9 (50)
#define _EXEC_OPKG_COMMAND_LAST (51)
#define _EXEC_OPKG_COMMAND_FAILURE (52)
#define _EXEC_OPKG_COMMAND_SUCCESS (53)
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE (54)
#define _DOWNLOAD_CONFIG_FILE (55)
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (56)
#define _DOWNLOAD_CONFIG_FILE_FAILURE (57)
#define _DOWNLOAD_DEVICE_CONTROLLER (65)
#define _PULL_NEW_BRANCH (22)
#define _PULL_NEW_BRANCH_FAILURE (23)
#define _PULL_NEW_BRANCH_SUCCESS (24)
#define _CHECKOUT_BRANCH (25)
#define _CHECKOUT_BRANCH_FAILURE (26)
#define _CHECKOUT_BRANCH_SUCCESS (27)
#define _UPDATE_REPOSITORY (28)
#define _UPDATE_REPOSITORY_FAILURE (29)
#define _UPDATE_REPOSITORY_SUCCESS (30)
#define _CHECK_FOR_REPOSITORY_CHANGES (31)
#define _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS (32)
#define _SYNC_CUSTOMER_REPOSITORY (33)
#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (34)
#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (35)
#define _FILES_TO_UPDATE (36)
#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (37)
#define _FILES_TO_DOWNLOAD (38)
#define _EXEC_OPKG_COMMANDS (39)
#define _EXEC_OPKG_COMMAND_1 (40)
#define _EXEC_OPKG_COMMAND_2 (41)
#define _EXEC_OPKG_COMMAND_3 (42)
#define _EXEC_OPKG_COMMAND_4 (43)
#define _EXEC_OPKG_COMMAND_5 (44)
#define _EXEC_OPKG_COMMAND_6 (45)
#define _EXEC_OPKG_COMMAND_7 (46)
#define _EXEC_OPKG_COMMAND_8 (47)
#define _EXEC_OPKG_COMMAND_9 (48)
#define _EXEC_OPKG_COMMAND_LAST (49)
#define _EXEC_OPKG_COMMAND_FAILURE (50)
#define _EXEC_OPKG_COMMAND_SUCCESS (51)
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE (60)
#define _DOWNLOAD_CONFIG_FILE (61)
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (62)
#define _DOWNLOAD_CONFIG_FILE_FAILURE (63)
#define _DOWNLOAD_DEVICE_CONTROLLER (64)
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (85)
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (86)
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE (87)
@@ -162,6 +175,7 @@ class Worker : public QThread{
bool m_ismasTriggerActive = false;
bool m_updateNotNecessary = false;
bool m_automaticUpdate = false;
bool m_pulledNewBranch = false;
QStringList m_ismasTriggerStatusMessage;
MainWindow *m_mainWindow;
@@ -281,6 +295,9 @@ public:
CHECK_ISMAS_TRIGGER_FAILURE = _CHECK_ISMAS_TRIGGER_FAILURE,
INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER = _INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER,
INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER = _INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER,
PULL_NEW_BRANCH = _PULL_NEW_BRANCH,
PULL_NEW_BRANCH_FAILURE = _PULL_NEW_BRANCH_FAILURE,
PULL_NEW_BRANCH_SUCCESS = _PULL_NEW_BRANCH_SUCCESS,
CHECKOUT_BRANCH = _CHECKOUT_BRANCH,
CHECKOUT_BRANCH_SUCCESS = _CHECKOUT_BRANCH_SUCCESS,
CHECKOUT_BRANCH_FAILURE = _CHECKOUT_BRANCH_FAILURE,
@@ -554,6 +571,18 @@ private:
break;
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER:
break;
case UPDATE_STEP::PULL_NEW_BRANCH: {
lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst);
} break;
case UPDATE_STEP::PULL_NEW_BRANCH_FAILURE: {
lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst);
} break;
case UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS: {
lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst);
} break;
case UPDATE_STEP::CHECKOUT_BRANCH:
lst << instance->m_debugMsg;
Utils::printUpdateStatusMsg(debug, lst);
@@ -720,7 +749,7 @@ private:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0010",
_ISMAS_CONTINUE, // U0010
_CHECKOUT_REPOSITORY_SUCCESS,
IsmasClient::RESULT_CODE::SUCCESS,
smap[UPDATE_STEP::CHECK_REPOSITORY],
@@ -736,9 +765,9 @@ private:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0010",
_ISMAS_CONTINUE, // U0010
_CHECKOUT_REPOSITORY_FAILURE,
IsmasClient::RESULT_CODE::INSTALL_ERROR,
IsmasClient::RESULT_CODE::GIT_SWITCH_BRANCH_ERROR,
smap[UPDATE_STEP::CHECKOUT_REPOSITORY],
QString("REPOSITORY %1 and BRANCH %2 ***NOT OK***")
.arg(instance->m_customerRepository)
@@ -755,7 +784,7 @@ private:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0010",
_ISMAS_CONTINUE, // U0010
_CHECK_SANITY_SUCCESS,
IsmasClient::RESULT_CODE::SUCCESS,
smap[UPDATE_STEP::CHECK_SANITY],
@@ -771,9 +800,9 @@ private:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0010",
_ISMAS_CONTINUE, // U0010
_CHECK_SANITY_FAILURE,
IsmasClient::RESULT_CODE::INSTALL_ERROR,
IsmasClient::RESULT_CODE::GIT_CHECK_REPOSITORY_ERROR,
smap[UPDATE_STEP::CHECK_SANITY],
QString("SANITY OF %1 and BRANCH %2 ***NOT*** OK")
.arg(instance->m_customerRepository)
@@ -782,21 +811,21 @@ private:
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
} break;
case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS:
case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS: {
ismasClient.setProgressInPercent(_REPOSITORY_RECOVERED_SUCCESS);
break;
case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE:
} break;
case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE: {
ismasClient.setProgressInPercent(_REPOSITORY_RECOVERED_FAILURE);
break;
case UPDATE_STEP::CLONE_REPOSITORY:
} break;
case UPDATE_STEP::CLONE_REPOSITORY: {
ismasClient.setProgressInPercent(_CLONE_REPOSITORY);
break;
} break;
case UPDATE_STEP::CLONE_REPOSITORY_SUCCESS: {
ismasClient.setProgressInPercent(_CLONE_REPOSITORY_SUCCESS);
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0010",
_ISMAS_CONTINUE, // U0010
_CLONE_REPOSITORY_SUCCESS,
IsmasClient::RESULT_CODE::SUCCESS,
smap[UPDATE_STEP::CLONE_REPOSITORY],
@@ -812,9 +841,9 @@ private:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0003",
_ISMAS_CONTINUE, // U0010 -> even on error: U0002/3 are sent only once
_CLONE_REPOSITORY_FAILURE,
IsmasClient::RESULT_CODE::INSTALL_ERROR,
IsmasClient::RESULT_CODE::GIT_CLONE_ERROR,
smap[UPDATE_STEP::CHECKOUT_REPOSITORY],
QString("CLONING REPOSITORY %1 OR CHECKING OUT BRANCH %2 FAILED")
.arg(instance->m_customerRepository)
@@ -826,7 +855,7 @@ private:
case UPDATE_STEP::CHECKOUT_REPOSITORY:
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY);
break;
case UPDATE_STEP::CHECKOUT_REPOSITORY_SUCCESS:
case UPDATE_STEP::CHECKOUT_REPOSITORY_SUCCESS: {
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY_SUCCESS);
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
@@ -835,42 +864,133 @@ private:
.arg(instance->m_customerRepository)
.arg(instance->m_gc.branchName()),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"));
break;
case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE:
} break;
case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE: {
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY_FAILURE);
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
_ISMAS_CONTINUE, // U0010 -> even on error: U0002/3 are sent only once
_CHECKOUT_REPOSITORY_FAILURE,
IsmasClient::RESULT_CODE::GIT_SWITCH_BRANCH_ERROR,
smap[UPDATE_STEP::CHECKOUT_REPOSITORY],
QString("%1: CHECKING OUT BRANCH %2 FAILED")
.arg(instance->m_customerRepository)
.arg(instance->m_gc.branchName()).toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
} break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER: {
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER);
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
} break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS: {
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_SUCCESS);
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateTriggerSet("ISMAS TRIGGER SET",
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"));
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE:
} break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE: {
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_WRONG_VALUE);
break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE: {
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_FAILURE);
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0003",
_CHECK_ISMAS_TRIGGER_FAILURE,
IsmasClient::RESULT_CODE::INSTALL_ERROR,
_ISMAS_TEST_TRIGGER, // U0099
_CHECK_ISMAS_TRIGGER_WRONG_VALUE,
IsmasClient::RESULT_CODE::ISMAS_TRIGGER_ERROR,
smap[UPDATE_STEP::CHECK_ISMAS_TRIGGER],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
} break;
case UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER:
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE: {
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_FAILURE);
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
_ISMAS_TEST_TRIGGER, // U0099
_CHECK_ISMAS_TRIGGER_FAILURE,
IsmasClient::RESULT_CODE::ISMAS_TRIGGER_ERROR,
smap[UPDATE_STEP::CHECK_ISMAS_TRIGGER],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
} break;
case UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER: {
ismasClient.setProgressInPercent(_INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER);
break;
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
_ISMAS_CONTINUE, // U0010
_INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER,
IsmasClient::RESULT_CODE::SUCCESS,
smap[UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
} break;
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER: {
ismasClient.setProgressInPercent(_INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER);
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
_ISMAS_CONTINUE, // U0010
_INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER,
IsmasClient::RESULT_CODE::SUCCESS,
smap[UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
} break;
case UPDATE_STEP::PULL_NEW_BRANCH: {
ismasClient.setProgressInPercent(_PULL_NEW_BRANCH);
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
_ISMAS_CONTINUE, // U0010
_PULL_NEW_BRANCH,
IsmasClient::RESULT_CODE::SUCCESS,
smap[UPDATE_STEP::CHECKOUT_BRANCH],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
}
break;
case UPDATE_STEP::PULL_NEW_BRANCH_FAILURE: {
ismasClient.setProgressInPercent(_PULL_NEW_BRANCH_FAILURE);
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
_ISMAS_CONTINUE, // U0010 -> even on error: U0002/3 are sent only once
_PULL_NEW_BRANCH_FAILURE,
IsmasClient::RESULT_CODE::GIT_PULL_ERROR,
smap[UPDATE_STEP::CHECKOUT_BRANCH],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
}
break;
case UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS: {
ismasClient.setProgressInPercent(_PULL_NEW_BRANCH_SUCCESS);
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
_ISMAS_CONTINUE, // U0010
_PULL_NEW_BRANCH_SUCCESS,
IsmasClient::RESULT_CODE::SUCCESS,
smap[UPDATE_STEP::CHECKOUT_BRANCH],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
ismasClient.sendRequestReceiveResponse(
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
}
break;
case UPDATE_STEP::CHECKOUT_BRANCH: {
ismasClient.setProgressInPercent(_CHECKOUT_BRANCH);
@@ -905,9 +1025,9 @@ private:
QString const &ismasUpdateNews =
QString("#M=APISM#C=CMD_EVENT#J=") +
ismasClient.updateNewsToIsmas(
"U0003",
_ISMAS_FAILURE, // U0003
_CHECKOUT_BRANCH_FAILURE,
IsmasClient::RESULT_CODE::INSTALL_ERROR,
IsmasClient::RESULT_CODE::GIT_SWITCH_BRANCH_ERROR,
smap[UPDATE_STEP::CHECKOUT_BRANCH],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
@@ -1069,7 +1189,7 @@ private:
ismasClient.updateNewsToIsmas(
_ISMAS_FAILURE,
ismasClient.getProgressInPercent(),
IsmasClient::RESULT_CODE::INSTALL_ERROR,
IsmasClient::RESULT_CODE::OPKG_COMMANDS_ERROR,
smap[step],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
@@ -1217,7 +1337,7 @@ private:
ismasClient.updateNewsToIsmas(
_ISMAS_FAILURE,
ismasClient.getProgressInPercent(),
IsmasClient::RESULT_CODE::INSTALL_ERROR,
IsmasClient::RESULT_CODE::UPDATE_IN_ERROR_STATE,
smap[UPDATE_STEP::UPDATE_FINALIZE],
instance->m_ismasMsg.join(' ').toStdString().c_str(),
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
@@ -1305,6 +1425,12 @@ private:
break;
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER:
break;
case UPDATE_STEP::PULL_NEW_BRANCH:
break;
case UPDATE_STEP::PULL_NEW_BRANCH_FAILURE:
break;
case UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS:
break;
case UPDATE_STEP::CHECKOUT_BRANCH:
emit worker->appendText("\nPrepare customer environment ...");
break;