Remove unused code in delta_generator
LoadSettings() is inherited from chrome os code base, where
delta_generator will read /etc/update_engine.conf on input image to
determine update_engine's version number. However, we never added
update_engine.conf to platform build artifacts, so this code path is
useless on aosp. In addition, ota_from_target_files always specify a
minor version, so we do not need this code path.
Test: th
Bug: 281960439
Change-Id: Ia00459bdebc91c37960f071c71f86c58004728af
diff --git a/payload_generator/squashfs_filesystem.cc b/payload_generator/squashfs_filesystem.cc
index 16b26eb..22b431d 100644
--- a/payload_generator/squashfs_filesystem.cc
+++ b/payload_generator/squashfs_filesystem.cc
@@ -34,7 +34,6 @@
#include "update_engine/payload_generator/deflate_utils.h"
#include "update_engine/payload_generator/delta_diff_generator.h"
#include "update_engine/payload_generator/extent_ranges.h"
-#include "update_engine/payload_generator/extent_utils.h"
#include "update_engine/update_metadata.pb.h"
using base::FilePath;
@@ -52,8 +51,6 @@
constexpr uint64_t kSquashfsCompressedBit = 1 << 24;
constexpr uint32_t kSquashfsZlibCompression = 1;
-constexpr char kUpdateEngineConf[] = "etc/update_engine.conf";
-
bool ReadSquashfsHeader(const brillo::Blob blob,
SquashfsFilesystem::SquashfsHeader* header) {
if (blob.size() < kSquashfsSuperBlockSize) {
@@ -88,47 +85,6 @@
return true;
}
-bool GetUpdateEngineConfig(const std::string& sqfs_path, string* config) {
- ScopedTempDir unsquash_dir;
- if (!unsquash_dir.CreateUniqueTempDir()) {
- PLOG(ERROR) << "Failed to create a temporary directory.";
- return false;
- }
-
- // Run unsquashfs to extract update_engine.conf
- // -f: To force overriding if the target directory exists.
- // -d: The directory to unsquash the files.
- vector<string> cmd = {"unsquashfs",
- "-f",
- "-d",
- unsquash_dir.GetPath().value(),
- sqfs_path,
- kUpdateEngineConf};
- string stdout_str, stderr_str;
- int exit_code;
- if (!Subprocess::SynchronousExec(cmd, &exit_code, &stdout_str, &stderr_str) ||
- exit_code != 0) {
- PLOG(ERROR) << "Failed to unsquashfs etc/update_engine.conf with stdout: "
- << stdout_str << " and stderr: " << stderr_str;
- return false;
- }
-
- auto config_path = unsquash_dir.GetPath().Append(kUpdateEngineConf);
- string config_content;
- if (!utils::ReadFile(config_path.value(), &config_content)) {
- PLOG(ERROR) << "Failed to read " << config_path.value();
- return false;
- }
-
- if (config_content.empty()) {
- LOG(ERROR) << "update_engine config file was empty!!";
- return false;
- }
-
- *config = std::move(config_content);
- return true;
-}
-
} // namespace
bool SquashfsFilesystem::Init(const string& map,
@@ -292,7 +248,7 @@
}
unique_ptr<SquashfsFilesystem> SquashfsFilesystem::CreateFromFile(
- const string& sqfs_path, bool extract_deflates, bool load_settings) {
+ const string& sqfs_path, bool extract_deflates) {
if (sqfs_path.empty())
return nullptr;
@@ -331,12 +287,6 @@
return nullptr;
}
- if (load_settings) {
- if (!GetUpdateEngineConfig(sqfs_path, &sqfs->update_engine_config_)) {
- return nullptr;
- }
- }
-
return sqfs;
}
@@ -369,15 +319,6 @@
return true;
}
-bool SquashfsFilesystem::LoadSettings(brillo::KeyValueStore* store) const {
- if (!store->LoadFromString(update_engine_config_)) {
- LOG(ERROR) << "Failed to load the settings with config: "
- << update_engine_config_;
- return false;
- }
- return true;
-}
-
bool SquashfsFilesystem::IsSquashfsImage(const brillo::Blob& blob) {
SquashfsHeader header;
return ReadSquashfsHeader(blob, &header) && CheckHeader(header);