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