Compare commits
3 Commits
c783b7a967
...
559298331b
Author | SHA1 | Date | |
---|---|---|---|
559298331b | |||
4f1efcf5cf | |||
3047df8130 |
@@ -86,7 +86,7 @@ SOURCES += \
|
|||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../common/include/message_handler.h \
|
../common/include/message_handler.h \
|
||||||
../common/src/commandline_parser.h \
|
../common/include/commandline_parser.h \
|
||||||
update.h \
|
update.h \
|
||||||
../common/include/System.h \
|
../common/include/System.h \
|
||||||
../common/include/utils_internal.h \
|
../common/include/utils_internal.h \
|
||||||
|
@@ -133,7 +133,6 @@ int main(int argc, char **argv) {
|
|||||||
QString const &customerRepo
|
QString const &customerRepo
|
||||||
= QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
= QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QString const &psaDcDir = internal::customerRepoDcDir();
|
QString const &psaDcDir = internal::customerRepoDcDir();
|
||||||
QString const &psaRepoRootDir = internal::customerRepoRoot();
|
QString const &psaRepoRootDir = internal::customerRepoRoot();
|
||||||
QString const &psaRepoDir = internal::customerRepoDir();
|
QString const &psaRepoDir = internal::customerRepoDir();
|
||||||
@@ -145,7 +144,6 @@ int main(int argc, char **argv) {
|
|||||||
QString libca;
|
QString libca;
|
||||||
|
|
||||||
std::unique_ptr<QSettings> settings = internal::readSettings();
|
std::unique_ptr<QSettings> settings = internal::readSettings();
|
||||||
|
|
||||||
if (settings) {
|
if (settings) {
|
||||||
settings->beginGroup("ATBUpdateDC");
|
settings->beginGroup("ATBUpdateDC");
|
||||||
debug = settings->value("debug", false).toBool();
|
debug = settings->value("debug", false).toBool();
|
||||||
@@ -154,29 +152,44 @@ int main(int argc, char **argv) {
|
|||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
qInfo() << " using dc directory: " << psaDcDir;
|
||||||
|
qInfo() << "using psa repo root directory: " << psaRepoRootDir;
|
||||||
|
qInfo() << " using customer repository: " << psaRepoDir;
|
||||||
|
qInfo() << " using branch: " << branchName;
|
||||||
|
}
|
||||||
|
|
||||||
// etc/dc: located under mount-path
|
// etc/dc: located under mount-path
|
||||||
std::optional<QString> mountPath = System::checkForUSBStick(psaDcDir);
|
std::optional<QString> mountPath = System::checkForUSBStick(psaDcDir);
|
||||||
QFileInfo fi;
|
QFileInfo fi;
|
||||||
if (mountPath.has_value()) {
|
if (mountPath.has_value()) {
|
||||||
fi.setFile(mountPath.value(), System::getDCFileOnUsbStick(mountPath.value()));
|
if (debug) {
|
||||||
|
qInfo() << "using mount path (USB): " << mountPath.value();
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
if ((mountPath = System::checkForSDCard(psaDcDir)).has_value()) {
|
if ((mountPath = System::checkForSDCard(psaDcDir)).has_value()) {
|
||||||
fi.setFile(mountPath.value(), System::getDCFileOnSDCard(mountPath.value()));
|
if (debug) {
|
||||||
|
qInfo() << "using mount path (SD): " << mountPath.value();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
qInfo() << "using customer repository" << psaRepoDir;
|
qInfo() << "using customer repository" << psaRepoDir;
|
||||||
}
|
}
|
||||||
|
mountPath = "";
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<QString> c = internal::dcCandidateToInstall("/etc/dc/");
|
if (debug) {
|
||||||
if (c) {
|
qInfo() << "using mount path: " << mountPath.value();
|
||||||
fi.setFile(*c);
|
}
|
||||||
if (fi.exists() == false) {
|
|
||||||
qCritical() << "dc2c.bin candidate" << *c << "does not exist. STOP.";
|
std::unique_ptr<QString> c = internal::dcCandidateToInstall("/etc/dc/", mountPath.value());
|
||||||
return -1;
|
if (c) {
|
||||||
}
|
fi.setFile(*c);
|
||||||
qInfo() << "dc2c.bin canditate" << fi.absoluteFilePath();
|
if (fi.exists() == false) {
|
||||||
|
qCritical() << "dc2c.bin candidate" << *c << "does not exist. STOP.";
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
qInfo() << "dc2c.bin canditate" << fi.absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@@ -185,6 +198,9 @@ int main(int argc, char **argv) {
|
|||||||
qInfo() << "dc-version" << Update::dcVersion(fi.absoluteFilePath());
|
qInfo() << "dc-version" << Update::dcVersion(fi.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only for testing
|
||||||
|
// return 0;
|
||||||
|
|
||||||
Update u(fi.absoluteFilePath(), libca, debug, noaction);
|
Update u(fi.absoluteFilePath(), libca, debug, noaction);
|
||||||
u.run();
|
u.run();
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ namespace internal {
|
|||||||
QString branchName();
|
QString branchName();
|
||||||
bool customerRepoExists();
|
bool customerRepoExists();
|
||||||
std::unique_ptr<QSettings> readSettings(QString const &optionalDirName = "");
|
std::unique_ptr<QSettings> readSettings(QString const &optionalDirName = "");
|
||||||
std::unique_ptr<QString> dcCandidateToInstall(QString const &dcDirectory = "");
|
std::unique_ptr<QString> dcCandidateToInstall(QString const &dcDirectory, QString const &rootDir = "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTILS_INTERNAL_H_INCLUDED
|
#endif // UTILS_INTERNAL_H_INCLUDED
|
||||||
|
@@ -76,11 +76,11 @@ std::unique_ptr<QSettings> readSettings(QString const &optionalDirName) {
|
|||||||
settings.reset(new QSettings(fi.absoluteFilePath(), QSettings::IniFormat));
|
settings.reset(new QSettings(fi.absoluteFilePath(), QSettings::IniFormat));
|
||||||
return settings;
|
return settings;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << fi.absoluteFilePath() << "not found."
|
qCritical().noquote() << "read" << fileName << ":" << fi.absoluteFilePath() << "not found."
|
||||||
<< "Try" << internal::DEFAULT_INI_DIR;
|
<< "Try" << internal::DEFAULT_INI_DIR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << optionalDirName << "not found."
|
qCritical().noquote() << "read" << fileName << ":" << optionalDirName << "not found."
|
||||||
<< "Try" << internal::DEFAULT_INSTALL_DIR;
|
<< "Try" << internal::DEFAULT_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,11 +91,11 @@ std::unique_ptr<QSettings> readSettings(QString const &optionalDirName) {
|
|||||||
settings.reset(new QSettings(fi.absoluteFilePath(), QSettings::IniFormat));
|
settings.reset(new QSettings(fi.absoluteFilePath(), QSettings::IniFormat));
|
||||||
return settings;
|
return settings;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << fi.absoluteFilePath() << "not found."
|
qCritical().noquote() << "read" << fileName << ":" << fi.absoluteFilePath() << "not found."
|
||||||
<< "Try" << internal::DEFAULT_INSTALL_DIR;
|
<< "Try" << internal::DEFAULT_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << internal::DEFAULT_INI_DIR << "not found."
|
qCritical().noquote() << "read" << fileName << ":" << internal::DEFAULT_INI_DIR << "not found."
|
||||||
<< "Try" << internal::DEFAULT_INSTALL_DIR;
|
<< "Try" << internal::DEFAULT_INSTALL_DIR;
|
||||||
}
|
}
|
||||||
d = QDir{internal::DEFAULT_INSTALL_DIR};
|
d = QDir{internal::DEFAULT_INSTALL_DIR};
|
||||||
@@ -105,22 +105,38 @@ std::unique_ptr<QSettings> readSettings(QString const &optionalDirName) {
|
|||||||
settings.reset(new QSettings(fi.absoluteFilePath(), QSettings::IniFormat));
|
settings.reset(new QSettings(fi.absoluteFilePath(), QSettings::IniFormat));
|
||||||
return settings;
|
return settings;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << fi.absoluteFilePath() << "not found.";
|
qCritical().noquote() << "read" << fileName << ":" << fi.absoluteFilePath() << "not found.";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << internal::DEFAULT_INSTALL_DIR << "not found.";
|
qCritical().noquote() << "read" << fileName << ":" << internal::DEFAULT_INSTALL_DIR << "not found.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<QString> dcCandidateToInstall(QString const &dcDirectory) {
|
std::unique_ptr<QString> dcCandidateToInstall(QString const &dcDirectory,
|
||||||
|
QString const &rootDir) {
|
||||||
std::unique_ptr<QString> dcCandidate{nullptr};
|
std::unique_ptr<QString> dcCandidate{nullptr};
|
||||||
|
|
||||||
qCritical() << __func__ << __LINE__ << dcDirectory;
|
QDir dcDir;
|
||||||
|
|
||||||
|
if (rootDir.isEmpty()) {
|
||||||
|
if (dcDirectory.isEmpty()) {
|
||||||
|
dcDir = customerRepoDcDir();
|
||||||
|
} else {
|
||||||
|
dcDir = dcDirectory;
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (dcDirectory.isEmpty()) {
|
||||||
|
dcDir = QDir::cleanPath(rootDir + QDir::separator() + customerRepoDcDir());
|
||||||
|
} else {
|
||||||
|
dcDir = QDir::cleanPath(rootDir + QDir::separator() + dcDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QDir dcDir{dcDirectory.isEmpty() ? customerRepoDcDir() : dcDirectory};
|
|
||||||
if (dcDir.exists()) {
|
if (dcDir.exists()) {
|
||||||
|
qCritical() << __func__ << __LINE__ << dcDir;
|
||||||
|
|
||||||
QFileInfoList fileInfoList =
|
QFileInfoList fileInfoList =
|
||||||
dcDir.entryInfoList(QStringList("*.bin"),
|
dcDir.entryInfoList(QStringList("*.bin"),
|
||||||
@@ -159,6 +175,8 @@ std::unique_ptr<QString> dcCandidateToInstall(QString const &dcDirectory) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << __func__ << __LINE__ << dcDir << "does not exist";
|
||||||
}
|
}
|
||||||
|
|
||||||
return dcCandidate;
|
return dcCandidate;
|
||||||
|
Reference in New Issue
Block a user