Custom OBSW update path #582

Merged
muellerr merged 6 commits from feature_custom_obsw_update_path into develop 2023-04-11 16:12:43 +02:00
2 changed files with 19 additions and 1 deletions

View File

@ -30,6 +30,13 @@ will consitute of a breaking change warranting a new major release:
This gives other tasks some time to register the SD cards being unusable, and therefore provides
a way for them to perform any re-initialization tasks necessary after SD card switches.
## Changed
- Allow specifying custom OBSW update filename. This allowed keeping a cleaner file structure
where each update has a name including the version
- The files extracted during an update process are deleted after the update was performed to keep
the update directory cleaner.
# [v1.44.0] 2023-04-07
- eive-tmtc: v2.22.0

View File

@ -1984,7 +1984,14 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
} else if (sourceDir == SwUpdateSources::TMP_DIR) {
prefixPath = path("/tmp");
}
path archivePath = prefixPath / path(config::OBSW_UPDATE_ARCHIVE_FILE_NAME);
path archivePath;
// It is optionally possible to supply the source file path
if (size > 2) {
archivePath = prefixPath / std::string(reinterpret_cast<const char *>(data + 2), size - 2);
} else {
archivePath = prefixPath / path(config::OBSW_UPDATE_ARCHIVE_FILE_NAME);
}
sif::info << "Updating with archive path " << archivePath << std::endl;
std::error_code e;
if (not exists(archivePath, e)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
@ -2071,6 +2078,10 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
cmd.str("");
cmd.clear();
// Remove the extracted files to keep directories clean.
std::filesystem::remove(strippedImagePath, e);
std::filesystem::remove(obswVersionFilePath, e);
// TODO: This takes a long time and will block the core controller.. Maybe use command executor?
// For now dont care..
cmd << "writeprotect " << std::to_string(data[0]) << " " << std::to_string(data[1]) << " 1";