Check if USB/SD is mounted and get dc-controller from etc/dc.
This commit is contained in:
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user