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/boot_img_filesystem.cc b/payload_generator/boot_img_filesystem.cc
index 3e324f1..fe45125 100644
--- a/payload_generator/boot_img_filesystem.cc
+++ b/payload_generator/boot_img_filesystem.cc
@@ -178,8 +178,4 @@
return true;
}
-bool BootImgFilesystem::LoadSettings(brillo::KeyValueStore* store) const {
- return false;
-}
-
} // namespace chromeos_update_engine
diff --git a/payload_generator/boot_img_filesystem.h b/payload_generator/boot_img_filesystem.h
index 7773461..065299a 100644
--- a/payload_generator/boot_img_filesystem.h
+++ b/payload_generator/boot_img_filesystem.h
@@ -40,8 +40,6 @@
// ramdisk.
bool GetFiles(std::vector<File>* files) const override;
- bool LoadSettings(brillo::KeyValueStore* store) const override;
-
private:
friend class BootImgFilesystemTest;
diff --git a/payload_generator/deflate_utils.cc b/payload_generator/deflate_utils.cc
index 30e3f67..cc2e4d6 100644
--- a/payload_generator/deflate_utils.cc
+++ b/payload_generator/deflate_utils.cc
@@ -27,7 +27,6 @@
#include "update_engine/common/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/payload_generator/squashfs_filesystem.h"
#include "update_engine/update_metadata.pb.h"
@@ -316,9 +315,8 @@
TEST_AND_RETURN_FALSE(
CopyExtentsToFile(part.path, file.extents, path.value(), kBlockSize));
// Test if it is actually a Squashfs file.
- auto sqfs = SquashfsFilesystem::CreateFromFile(path.value(),
- extract_deflates,
- /*load_settings=*/false);
+ auto sqfs =
+ SquashfsFilesystem::CreateFromFile(path.value(), extract_deflates);
if (sqfs) {
// It is an squashfs file. Get its files to replace with itself.
vector<FilesystemInterface::File> files;
diff --git a/payload_generator/erofs_filesystem.h b/payload_generator/erofs_filesystem.h
index 0863b50..d0abcb3 100644
--- a/payload_generator/erofs_filesystem.h
+++ b/payload_generator/erofs_filesystem.h
@@ -56,11 +56,6 @@
bool GetFiles(std::vector<File>* files) const override;
- bool LoadSettings(
- [[maybe_unused]] brillo::KeyValueStore* store) const override {
- return true;
- }
-
private:
ErofsFilesystem(std::string filename, size_t fs_size, std::vector<File> files)
: filename_(filename), fs_size_(fs_size), files_(std::move(files)) {}
diff --git a/payload_generator/ext2_filesystem.cc b/payload_generator/ext2_filesystem.cc
index 06304f4..535d8ad 100644
--- a/payload_generator/ext2_filesystem.cc
+++ b/payload_generator/ext2_filesystem.cc
@@ -329,43 +329,4 @@
return true;
}
-bool Ext2Filesystem::LoadSettings(brillo::KeyValueStore* store) const {
- // First search for the settings inode following symlinks if we find some.
- ext2_ino_t ino_num = 0;
- errcode_t err = ext2fs_namei_follow(filsys_,
- EXT2_ROOT_INO /* root */,
- EXT2_ROOT_INO /* cwd */,
- "/etc/update_engine.conf",
- &ino_num);
- if (err != 0)
- return false;
-
- ext2_inode ino_data;
- if (ext2fs_read_inode(filsys_, ino_num, &ino_data) != 0)
- return false;
-
- // Load the list of blocks and then the contents of the inodes.
- vector<Extent> extents;
- err = ext2fs_block_iterate2(filsys_,
- ino_num,
- BLOCK_FLAG_DATA_ONLY,
- nullptr, // block_buf
- ProcessInodeAllBlocks,
- &extents);
- if (err != 0)
- return false;
-
- brillo::Blob blob;
- uint64_t physical_size = utils::BlocksInExtents(extents) * filsys_->blocksize;
- // Sparse holes in the settings file are not supported.
- if (EXT2_I_SIZE(&ino_data) > physical_size)
- return false;
- if (!utils::ReadExtents(
- filename_, extents, &blob, physical_size, filsys_->blocksize))
- return false;
-
- string text(blob.begin(), blob.begin() + EXT2_I_SIZE(&ino_data));
- return store->LoadFromString(text);
-}
-
} // namespace chromeos_update_engine
diff --git a/payload_generator/ext2_filesystem.h b/payload_generator/ext2_filesystem.h
index c0562d0..4789638 100644
--- a/payload_generator/ext2_filesystem.h
+++ b/payload_generator/ext2_filesystem.h
@@ -60,8 +60,6 @@
// and bitmap tables.
bool GetFiles(std::vector<File>* files) const override;
- bool LoadSettings(brillo::KeyValueStore* store) const override;
-
private:
Ext2Filesystem() = default;
diff --git a/payload_generator/ext2_filesystem_unittest.cc b/payload_generator/ext2_filesystem_unittest.cc
index 8fa5080..4ac7299 100644
--- a/payload_generator/ext2_filesystem_unittest.cc
+++ b/payload_generator/ext2_filesystem_unittest.cc
@@ -184,26 +184,4 @@
}
}
-TEST_F(Ext2FilesystemTest, LoadSettingsFailsTest) {
- unique_ptr<Ext2Filesystem> fs = Ext2Filesystem::CreateFromFile(
- GetBuildArtifactsPath("gen/disk_ext2_1k.img"));
- ASSERT_NE(nullptr, fs.get());
-
- brillo::KeyValueStore store;
- // disk_ext2_1k.img doesn't have the /etc/update_engine.conf file.
- EXPECT_FALSE(fs->LoadSettings(&store));
-}
-
-TEST_F(Ext2FilesystemTest, LoadSettingsWorksTest) {
- unique_ptr<Ext2Filesystem> fs = Ext2Filesystem::CreateFromFile(
- GetBuildArtifactsPath("gen/disk_ext2_unittest.img"));
- ASSERT_NE(nullptr, fs.get());
-
- brillo::KeyValueStore store;
- EXPECT_TRUE(fs->LoadSettings(&store));
- string minor_version;
- EXPECT_TRUE(store.GetString("PAYLOAD_MINOR_VERSION", &minor_version));
- EXPECT_EQ("1234", minor_version);
-}
-
} // namespace chromeos_update_engine
diff --git a/payload_generator/fake_filesystem.cc b/payload_generator/fake_filesystem.cc
index 7448286..5328207 100644
--- a/payload_generator/fake_filesystem.cc
+++ b/payload_generator/fake_filesystem.cc
@@ -48,11 +48,4 @@
files_.push_back(file);
}
-bool FakeFilesystem::LoadSettings(brillo::KeyValueStore* store) const {
- if (minor_version_ < 0)
- return false;
- store->SetString("PAYLOAD_MINOR_VERSION", std::to_string(minor_version_));
- return true;
-}
-
} // namespace chromeos_update_engine
diff --git a/payload_generator/fake_filesystem.h b/payload_generator/fake_filesystem.h
index e41a7a2..57e4644 100644
--- a/payload_generator/fake_filesystem.h
+++ b/payload_generator/fake_filesystem.h
@@ -38,7 +38,6 @@
size_t GetBlockSize() const override;
size_t GetBlockCount() const override;
bool GetFiles(std::vector<File>* files) const override;
- bool LoadSettings(brillo::KeyValueStore* store) const override;
// Fake methods.
diff --git a/payload_generator/filesystem_interface.h b/payload_generator/filesystem_interface.h
index 0c2f05e..2d0fe46 100644
--- a/payload_generator/filesystem_interface.h
+++ b/payload_generator/filesystem_interface.h
@@ -31,11 +31,9 @@
#include <string>
#include <vector>
-#include <brillo/key_value_store.h>
#include <puffin/utils.h>
#include "update_engine/lz4diff/lz4diff_format.h"
-#include "update_engine/lz4diff/lz4diff.h"
#include "update_engine/update_metadata.pb.h"
namespace chromeos_update_engine {
@@ -93,10 +91,6 @@
// Returns whether the function succeeded.
virtual bool GetFiles(std::vector<File>* files) const = 0;
- // Load the image settings stored in the filesystem in the
- // /etc/update_engine.conf file. Returns whether the settings were found.
- virtual bool LoadSettings(brillo::KeyValueStore* store) const = 0;
-
protected:
FilesystemInterface() = default;
diff --git a/payload_generator/generate_delta_main.cc b/payload_generator/generate_delta_main.cc
index 6616ee1..6daa36c 100644
--- a/payload_generator/generate_delta_main.cc
+++ b/payload_generator/generate_delta_main.cc
@@ -731,23 +731,8 @@
// Autodetect minor_version by looking at the update_engine.conf in the old
// image.
if (payload_config.is_delta) {
- brillo::KeyValueStore store;
- uint32_t minor_version{};
- bool minor_version_found = false;
- for (const PartitionConfig& part : payload_config.source.partitions) {
- if (part.fs_interface && part.fs_interface->LoadSettings(&store) &&
- utils::GetMinorVersion(store, &minor_version)) {
- payload_config.version.minor = minor_version;
- minor_version_found = true;
- LOG(INFO) << "Auto-detected minor_version="
- << payload_config.version.minor;
- break;
- }
- }
- if (!minor_version_found) {
- LOG(FATAL) << "Failed to detect the minor version.";
- return 1;
- }
+ LOG(FATAL) << "Minor version is required for delta update!";
+ return 1;
} else {
payload_config.version.minor = kFullPayloadMinorVersion;
LOG(INFO) << "Using non-delta minor_version="
diff --git a/payload_generator/mapfile_filesystem.cc b/payload_generator/mapfile_filesystem.cc
index 5264a9c..5bca577 100644
--- a/payload_generator/mapfile_filesystem.cc
+++ b/payload_generator/mapfile_filesystem.cc
@@ -27,7 +27,6 @@
#include "update_engine/common/utils.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 std::string;
@@ -141,10 +140,4 @@
return true;
}
-bool MapfileFilesystem::LoadSettings(brillo::KeyValueStore* store) const {
- // Settings not supported in mapfile since the storage format is unknown.
- LOG(ERROR) << "mapfile doesn't support LoadSettings().";
- return false;
-}
-
} // namespace chromeos_update_engine
diff --git a/payload_generator/mapfile_filesystem.h b/payload_generator/mapfile_filesystem.h
index fc03c4c..0bd23cc 100644
--- a/payload_generator/mapfile_filesystem.h
+++ b/payload_generator/mapfile_filesystem.h
@@ -46,8 +46,6 @@
// Files may overlap with other files in the same block.
bool GetFiles(std::vector<File>* files) const override;
- bool LoadSettings(brillo::KeyValueStore* store) const override;
-
private:
MapfileFilesystem(const std::string& mapfile_filename, off_t num_blocks);
diff --git a/payload_generator/payload_generation_config.cc b/payload_generator/payload_generation_config.cc
index a9926d1..f8469ea 100644
--- a/payload_generator/payload_generation_config.cc
+++ b/payload_generator/payload_generation_config.cc
@@ -108,8 +108,7 @@
}
fs_interface = SquashfsFilesystem::CreateFromFile(path,
- /*extract_deflates=*/true,
- /*load_settings=*/true);
+ /*extract_deflates=*/true);
if (fs_interface) {
TEST_AND_RETURN_FALSE(fs_interface->GetBlockSize() == kBlockSize);
return true;
diff --git a/payload_generator/raw_filesystem.h b/payload_generator/raw_filesystem.h
index 0ecbc9c..28b3db0 100644
--- a/payload_generator/raw_filesystem.h
+++ b/payload_generator/raw_filesystem.h
@@ -43,10 +43,6 @@
// with the name passed during construction.
bool GetFiles(std::vector<File>* files) const override;
- bool LoadSettings(brillo::KeyValueStore* store) const override {
- return false;
- }
-
private:
RawFilesystem() = default;
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);
diff --git a/payload_generator/squashfs_filesystem.h b/payload_generator/squashfs_filesystem.h
index 5045dfc..e1b6f69 100644
--- a/payload_generator/squashfs_filesystem.h
+++ b/payload_generator/squashfs_filesystem.h
@@ -30,8 +30,6 @@
#include <brillo/secure_blob.h>
-#include "update_engine/payload_consumer/file_descriptor.h"
-#include "update_engine/payload_generator/extent_utils.h"
#include "update_engine/payload_generator/filesystem_interface.h"
namespace chromeos_update_engine {
@@ -59,7 +57,7 @@
// |extract_deflates| is true, it will process files to find location of all
// deflate streams.
static std::unique_ptr<SquashfsFilesystem> CreateFromFile(
- const std::string& sqfs_path, bool extract_deflates, bool load_settings);
+ const std::string& sqfs_path, bool extract_deflates);
// Creates the file system from a file map |filemap| which is a multi-line
// string with each line with the following format:
@@ -89,9 +87,6 @@
// one for the metadata at the end.
bool GetFiles(std::vector<File>* files) const override;
- // Squashfs image does not support this yet.
- bool LoadSettings(brillo::KeyValueStore* store) const override;
-
// Returns true if the first few bytes of a file indicates a valid Squashfs
// image. The size of the |blob| should be at least
// sizeof(SquashfsHeader) or for now 96 bytes.
@@ -108,14 +103,11 @@
bool extract_deflates);
// The size of the image in bytes.
- size_t size_;
+ size_t size_{};
// All the files in the filesystem.
std::vector<File> files_;
- // The content of /etc/update_engine.conf.
- std::string update_engine_config_;
-
DISALLOW_COPY_AND_ASSIGN(SquashfsFilesystem);
};