Compare commits

..

10 Commits

Author SHA1 Message Date
bfa39eb3df Set version to 1.3.22.
After git clone: execute full update process (modulo settings in ATBUpdateTool.ini).
2023-12-13 14:00:21 +01:00
d7fcfa3d0f Click the Exit button after 5 seconds timeout (old timeout: 60s). 2023-12-13 13:59:00 +01:00
f1e449c108 Change known filename of device controller: dc2c.bin. 2023-12-13 13:57:46 +01:00
32346c2665 If the repository is cloned (or repaired and cloned) and the settings
always-download-config and always-download-dc are set in the ini-file,
then download the json-files and dc-file, even without an activated
WAIT-button. The tariff-files are always synced for a clone.
2023-12-13 13:49:22 +01:00
38e7bf4985 Minor: call rsync with -v instead of -vvv. 2023-12-13 13:48:23 +01:00
6df73e1082 Minor: change some debug output. 2023-12-13 13:47:02 +01:00
19250a0a2f If the update process is activated without a valid ISMAS trigger, then
wait for a valid trigger value 15x (=90s) instaed of 100x.
2023-12-13 13:44:55 +01:00
6f5c8103e4 When checking the sanity of the customer repository, check also for existence
of etc-directory inside repository.
2023-12-13 13:42:12 +01:00
07dcf0ba30 Minor: add some GUI debug output when checking ISMAS trigger. 2023-12-13 13:41:06 +01:00
1e379cf086 Fix: set directory of application for directory of the ini-file. 2023-12-13 13:38:34 +01:00
6 changed files with 57 additions and 38 deletions

View File

@ -65,7 +65,19 @@ DEFINES += QT_DEPRECATED_WARNINGS
# 1.3.18: Bug fixes found during testing. # 1.3.18: Bug fixes found during testing.
# 1.3.19: Bug fixes found during testing. # 1.3.19: Bug fixes found during testing.
# 1.3.20: Bug fixes found during testing. # 1.3.20: Bug fixes found during testing.
VERSION="1.3.21" # 1.3.21: Bug fixes found during testing:
# Fix directory of ATBUpdateTool.ini to be the working directory of
# the application rather than just ".".
# Check existance of etc-directory inside customer repository.
# Check for valid ISMAS trigger (button) 15x (=90s).
# NOTE: if the customer repository is cloned (or repaired and cloned
# again), and if the settings always-download-config=true and
# always-download-dc=true in the ATBUpdateTool.ini file, the download
# the printer-json files and the device controller file, even without
# an activated ISMAS trigger (button). The tariff-files are rsynced to
# the local filesystem for such clone.
# Set new filename for device controller: dc2c.bin.
VERSION="1.3.22"
# PLANNED TODOS: # PLANNED TODOS:
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT. # 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.

View File

@ -87,7 +87,7 @@ void CommandLineParser::configure() {
m_repositoryUrlOption.setDefaultValue("https://git.mimbach49.de/GerhardHoffmann"); m_repositoryUrlOption.setDefaultValue("https://git.mimbach49.de/GerhardHoffmann");
m_parser.addOption(m_repositoryUrlOption); m_parser.addOption(m_repositoryUrlOption);
m_iniFileDirectoryOption.setDefaultValue("."); m_iniFileDirectoryOption.setDefaultValue(QCoreApplication::applicationDirPath());
m_parser.addOption(m_iniFileDirectoryOption); m_parser.addOption(m_iniFileDirectoryOption);
m_iniFileNameOption.setDefaultValue("ATBUpdateTool.ini"); m_iniFileNameOption.setDefaultValue("ATBUpdateTool.ini");
@ -117,10 +117,10 @@ void CommandLineParser::configure() {
m_extendedVersionOption.setDefaultValue("false"); m_extendedVersionOption.setDefaultValue("false");
m_parser.addOption(m_extendedVersionOption); m_parser.addOption(m_extendedVersionOption);
m_yoctoVersionOption .setDefaultValue("false"); m_yoctoVersionOption.setDefaultValue("false");
m_parser.addOption(m_yoctoVersionOption); m_parser.addOption(m_yoctoVersionOption);
m_yoctoInstallStatusOption .setDefaultValue("false"); m_yoctoInstallStatusOption.setDefaultValue("false");
m_parser.addOption(m_yoctoInstallStatusOption); m_parser.addOption(m_yoctoInstallStatusOption);
} }
@ -128,7 +128,6 @@ void CommandLineParser::readSettings() {
QString const iniFileDir = m_parser.value(m_iniFileDirectoryOption); QString const iniFileDir = m_parser.value(m_iniFileDirectoryOption);
QString const iniFileName = m_parser.value(m_iniFileNameOption); QString const iniFileName = m_parser.value(m_iniFileNameOption);
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName); m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
if (!m_iniFileName.isEmpty()) { if (!m_iniFileName.isEmpty()) {
if (QFile(m_iniFileName).exists()) { if (QFile(m_iniFileName).exists()) {
QSettings settings(m_iniFileName, QSettings::IniFormat); QSettings settings(m_iniFileName, QSettings::IniFormat);

View File

@ -146,7 +146,7 @@ void MainWindow::onEnableExit() {
void MainWindow::onRestartExitTimer() { void MainWindow::onRestartExitTimer() {
m_exitTimer->stop(); m_exitTimer->stop();
m_exitTimer->start(60 * 1000); m_exitTimer->start(5 * 1000);
scrollDownTextEdit(); scrollDownTextEdit();
ui->updateStatus->setEnabled(false); ui->updateStatus->setEnabled(false);

View File

@ -505,8 +505,7 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) { for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
m_worker->startProgressLoop(); m_worker->startProgressLoop();
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed()); QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$"); if (fToWorkOn.contains("dc2c.bin")) {
if (fToWorkOn.contains(version)) {
bool updateBinaryRes = true; bool updateBinaryRes = true;
// CONSOLE() // CONSOLE()
@ -596,8 +595,6 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn; qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false; res = false;
} }
// m_worker->stopProgressLoop();
// m_worker->setProgress(100);
if (res == false) { if (res == false) {
break; break;

View File

@ -214,6 +214,12 @@ bool Worker::isRepositoryCorrupted() {
Utils::printCriticalErrorMsg("CORRUPTED CUSTOMER REPOSITORY .GIT DOES NOT EXIST"); Utils::printCriticalErrorMsg("CORRUPTED CUSTOMER REPOSITORY .GIT DOES NOT EXIST");
return true; return true;
} }
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
if (!customerRepositoryEtc.exists()) {
// should never happen
Utils::printCriticalErrorMsg(QString("CORRUPTED CUSTOMER REPOSITORY %1/etc DOES NOT EXIST").arg(m_customerRepository));
return true;
}
} }
return false; return false;
} }
@ -334,21 +340,30 @@ void Worker::privateUpdate() {
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
m_ismasTriggerActive = false; m_ismasTriggerActive = false;
if ((continueUpdate = updateTriggerSet()) == false) { if (m_clone == false) {
if ((continueUpdate = updateTriggerSet()) == false) {
return;
} else {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
setProgress(_CHECK_ISMAS_TRIGGER_SUCCESS);
}
} else {
if (m_initialClone) { if (m_initialClone) {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER)); GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER));
} }
return;
} else {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER));
} }
qCritical() << "**** m_ismasTriggerActive:" << m_ismasTriggerActive;
qCritical() << "**** m_clone:" << m_clone;
if (m_ismasTriggerActive == false) {// make it explicit again: only if the if (m_ismasTriggerActive == false) {// make it explicit again: only if the
// ismas trigger is active ('WAIT'), // ismas trigger is active ('WAIT'),
// then proceed // then proceed
return;
} if (m_clone == false) { // if it is an (initial) clone, then
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS)); return; // run the whole update process:
setProgress(_CHECK_ISMAS_TRIGGER_SUCCESS); } // sync tariff-files, download jsons,
} // download device controller
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -458,8 +473,8 @@ bool Worker::updateTriggerSet() {
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER)); GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER));
QString triggerValue("NOT CHECKED YET"); QString triggerValue("NOT CHECKED YET");
static constexpr int const repeats = 15;
for (int repeat = 1; repeat <= 100; ++repeat) { for (int repeat = 1; repeat <= repeats; ++repeat) {
if (repeat > 1) { if (repeat > 1) {
int const startMs = QTime::currentTime().msecsSinceStartOfDay(); int const startMs = QTime::currentTime().msecsSinceStartOfDay();
@ -467,10 +482,12 @@ bool Worker::updateTriggerSet() {
QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000); QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG; CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG;
} else { } else {
CONSOLE(QStringList(func) << QString("-> REPEAT=%1").arg(repeat)) << UPDATE_STEP::DEBUG; QStringList lst = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat));
// GUI(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER;
CONSOLE(lst) << UPDATE_STEP::DEBUG;
} }
if ((repeat % 10) == 0) { if ((repeat % 8) == 0) {
CONSOLE(QStringList(func) << "RESTART APISM") << UPDATE_STEP::DEBUG; CONSOLE(QStringList(func) << "RESTART APISM") << UPDATE_STEP::DEBUG;
Command c("systemctl restart apism"); Command c("systemctl restart apism");
if (c.execute("/tmp")) { if (c.execute("/tmp")) {
@ -560,7 +577,7 @@ bool Worker::updateTriggerSet() {
return m_ismasTriggerActive; return m_ismasTriggerActive;
} else } else
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
QStringList lst("empty update trigger"); QStringList lst(QString("%1 empty update trigger (%2)").arg(repeat).arg(repeats-repeat));
if (m_clone) { if (m_clone) {
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE); GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
// if the customer repository has just been cloned // if the customer repository has just been cloned
@ -642,10 +659,7 @@ bool Worker::filesToUpdate() {
// always execute contents of opkg_commands-file // always execute contents of opkg_commands-file
m_filesToUpdate << "etc/psa_update/opkg_commands"; m_filesToUpdate << "etc/psa_update/opkg_commands";
if (m_alwaysDownloadConfig) { if (m_clone && m_alwaysDownloadConfig) {
#if 0
QStringList lst(QString("m_alwaysDownloadConfig NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
// always download all json-config files, even if none of them have been // always download all json-config files, even if none of them have been
// changed in the git repository. useful for first installation. // changed in the git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config")); QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config"));
@ -655,24 +669,19 @@ bool Worker::filesToUpdate() {
m_filesToUpdate << jsons; m_filesToUpdate << jsons;
} }
} }
#endif
} }
if (m_alwaysDownloadDC) { if (m_clone && m_alwaysDownloadDC) {
#if 0
QStringList lst(QString("m_alwaysDownloadDC NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
// always download the last dc-binary, even if not changed in the // always download the last dc-binary, even if not changed in the
// git repository. useful for first installation. // git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_update")); QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/dc"));
if (dir.exists()) { if (dir.exists()) {
QStringList dc = dir.entryList(QStringList() << "dc2c*.bin", QDir::Files, QStringList dc = dir.entryList(QStringList() << "dc2c.bin", QDir::Files,
QDir::SortFlag::Time | QDir::SortFlag::Reversed); QDir::SortFlag::Time | QDir::SortFlag::Reversed);
if (!dc.isEmpty()) { if (!dc.isEmpty()) {
m_filesToUpdate << dc.first(); m_filesToUpdate << dc.first();
} }
} }
#endif
} }
if (std::optional<QString> changes = m_gc.gitPull()) { if (std::optional<QString> changes = m_gc.gitPull()) {
@ -705,8 +714,7 @@ bool Worker::computeFilesToDownload() {
fName.contains("DC2C_cash", Qt::CaseInsensitive)) { fName.contains("DC2C_cash", Qt::CaseInsensitive)) {
m_filesToDownload << fName; // download printer-config-files m_filesToDownload << fName; // download printer-config-files
} else { } else {
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$"); if (fName.contains("dc2c.bin")) {
if (fName.contains(version)) {
m_filesToDownload << fName; // download device controller m_filesToDownload << fName; // download device controller
} }
} }
@ -848,7 +856,7 @@ bool Worker::syncCustomerRepositoryAndFS() {
QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) { QStringList() << "-c" << "mkdir -p /etc/psa_config /etc/dc /etc/psa_tariff")) {
qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")"; qCritical() << "COULD NOT EXECUTE '" << md.command() << "' exitCode=(" << md.exitCode() << ")";
} }
QString const params("-vvv " QString const params("-v "
"--recursive " "--recursive "
"--progress " "--progress "
"--checksum " "--checksum "

View File

@ -1127,6 +1127,9 @@ private:
break; break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER: case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
emit worker->appendText("\n" CHECK_UPDATE_TRIGGER_SET); emit worker->appendText("\n" CHECK_UPDATE_TRIGGER_SET);
if (worker->m_guiMsg.size() > 0) {
emit worker->showStatusMessage(worker->m_guiMsg);
}
break; break;
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS: case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
break; break;