Merge "Switch to zip64 in recovery" am: a35202befd
am: a973d68fcb
am: 5bb0917365
am: 805e3a983f
Original change: https://android-review.googlesource.com/c/platform/bootable/recovery/+/1429048 Change-Id: Id0990957f4cdf47e6e2ea004180246f9d64ce700
This commit is contained in:
commit
df4c28991b
12 changed files with 24 additions and 23 deletions
|
@ -682,9 +682,9 @@ bool ZipModeImage::InitializeChunks(const std::string& filename, ZipArchiveHandl
|
|||
}
|
||||
|
||||
// Create a list of deflated zip entries, sorted by offset.
|
||||
std::vector<std::pair<std::string, ZipEntry>> temp_entries;
|
||||
std::vector<std::pair<std::string, ZipEntry64>> temp_entries;
|
||||
std::string name;
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
while ((ret = Next(cookie, &entry, &name)) == 0) {
|
||||
if (entry.method == kCompressDeflated || limit_ > 0) {
|
||||
temp_entries.emplace_back(name, entry);
|
||||
|
@ -757,7 +757,7 @@ bool ZipModeImage::InitializeChunks(const std::string& filename, ZipArchiveHandl
|
|||
}
|
||||
|
||||
bool ZipModeImage::AddZipEntryToChunks(ZipArchiveHandle handle, const std::string& entry_name,
|
||||
ZipEntry* entry) {
|
||||
ZipEntry64* entry) {
|
||||
size_t compressed_len = entry->compressed_length;
|
||||
if (compressed_len == 0) return true;
|
||||
|
||||
|
|
|
@ -257,7 +257,8 @@ class ZipModeImage : public Image {
|
|||
// Initialize image chunks based on the zip entries.
|
||||
bool InitializeChunks(const std::string& filename, ZipArchiveHandle handle);
|
||||
// Add the a zip entry to the list.
|
||||
bool AddZipEntryToChunks(ZipArchiveHandle handle, const std::string& entry_name, ZipEntry* entry);
|
||||
bool AddZipEntryToChunks(ZipArchiveHandle handle, const std::string& entry_name,
|
||||
ZipEntry64* entry);
|
||||
// Return the real size of the zip file. (omit the trailing zeros that used for alignment)
|
||||
bool GetZipFileSize(size_t* input_file_size);
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map<std::string, std::st
|
|||
CHECK(metadata != nullptr);
|
||||
|
||||
static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata";
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
if (FindEntry(zip, METADATA_PATH, &entry) != 0) {
|
||||
LOG(ERROR) << "Failed to find " << METADATA_PATH;
|
||||
return false;
|
||||
|
@ -241,7 +241,7 @@ bool SetUpAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, int
|
|||
// For A/B updates we extract the payload properties to a buffer and obtain the RAW payload offset
|
||||
// in the zip file.
|
||||
static constexpr const char* AB_OTA_PAYLOAD_PROPERTIES = "payload_properties.txt";
|
||||
ZipEntry properties_entry;
|
||||
ZipEntry64 properties_entry;
|
||||
if (FindEntry(zip, AB_OTA_PAYLOAD_PROPERTIES, &properties_entry) != 0) {
|
||||
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD_PROPERTIES;
|
||||
return false;
|
||||
|
@ -256,7 +256,7 @@ bool SetUpAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, int
|
|||
}
|
||||
|
||||
static constexpr const char* AB_OTA_PAYLOAD = "payload.bin";
|
||||
ZipEntry payload_entry;
|
||||
ZipEntry64 payload_entry;
|
||||
if (FindEntry(zip, AB_OTA_PAYLOAD, &payload_entry) != 0) {
|
||||
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD;
|
||||
return false;
|
||||
|
@ -278,7 +278,7 @@ bool SetUpNonAbUpdateCommands(const std::string& package, ZipArchiveHandle zip,
|
|||
|
||||
// In non-A/B updates we extract the update binary from the package.
|
||||
static constexpr const char* UPDATE_BINARY_NAME = "META-INF/com/google/android/update-binary";
|
||||
ZipEntry binary_entry;
|
||||
ZipEntry64 binary_entry;
|
||||
if (FindEntry(zip, UPDATE_BINARY_NAME, &binary_entry) != 0) {
|
||||
LOG(ERROR) << "Failed to find update binary " << UPDATE_BINARY_NAME;
|
||||
return false;
|
||||
|
|
|
@ -321,7 +321,7 @@ static std::vector<Certificate> IterateZipEntriesAndSearchForKeys(const ZipArchi
|
|||
std::vector<Certificate> result;
|
||||
|
||||
std::string_view name;
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
while ((iter_status = Next(cookie, &entry, &name)) == 0) {
|
||||
std::vector<uint8_t> pem_content(entry.uncompressed_length);
|
||||
if (int32_t extract_status =
|
||||
|
|
|
@ -49,7 +49,7 @@ std::vector<std::string> GetWipePartitionList(Package* wipe_package) {
|
|||
constexpr char RECOVERY_WIPE_ENTRY_NAME[] = "recovery.wipe";
|
||||
|
||||
std::string partition_list_content;
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
if (FindEntry(zip, RECOVERY_WIPE_ENTRY_NAME, &entry) == 0) {
|
||||
uint32_t length = entry.uncompressed_length;
|
||||
partition_list_content = std::string(length, '\0');
|
||||
|
|
|
@ -190,7 +190,7 @@ static void VerifyAbUpdateCommands(const std::string& serialno, bool success = t
|
|||
|
||||
ZipArchiveHandle zip;
|
||||
ASSERT_EQ(0, OpenArchive(temp_file.path, &zip));
|
||||
ZipEntry payload_entry;
|
||||
ZipEntry64 payload_entry;
|
||||
ASSERT_EQ(0, FindEntry(zip, "payload.bin", &payload_entry));
|
||||
|
||||
std::map<std::string, std::string> metadata;
|
||||
|
|
|
@ -106,7 +106,7 @@ TEST_F(PackageTest, GetZipArchiveHandle_extract_entry) {
|
|||
|
||||
// Check that we can extract one zip entry.
|
||||
std::string_view entry_name = "dir1/file3.txt";
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
ASSERT_EQ(0, FindEntry(zip, entry_name, &entry));
|
||||
|
||||
std::vector<uint8_t> extracted(entry_name.size());
|
||||
|
|
|
@ -37,7 +37,7 @@ TEST(ZipTest, OpenFromMemory) {
|
|||
ASSERT_EQ(0, OpenArchiveFromMemory(map.addr, map.length, zip_path.c_str(), &handle));
|
||||
|
||||
static constexpr const char* BINARY_PATH = "META-INF/com/google/android/update-binary";
|
||||
ZipEntry binary_entry;
|
||||
ZipEntry64 binary_entry;
|
||||
// Make sure the package opens correctly and its entry can be read.
|
||||
ASSERT_EQ(0, FindEntry(handle, BINARY_PATH, &binary_entry));
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ class RangeSinkWriter {
|
|||
*/
|
||||
struct NewThreadInfo {
|
||||
ZipArchiveHandle za;
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry{};
|
||||
bool brotli_compressed;
|
||||
|
||||
std::unique_ptr<RangeSinkWriter> writer;
|
||||
|
@ -1626,7 +1626,7 @@ static bool Sha1DevicePath(const std::string& path, uint8_t digest[SHA_DIGEST_LE
|
|||
static Value* PerformBlockImageUpdate(const char* name, State* state,
|
||||
const std::vector<std::unique_ptr<Expr>>& argv,
|
||||
const CommandMap& command_map, bool dryrun) {
|
||||
CommandParameters params = {};
|
||||
CommandParameters params{};
|
||||
stash_map.clear();
|
||||
params.canwrite = !dryrun;
|
||||
|
||||
|
@ -1687,7 +1687,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state,
|
|||
}
|
||||
|
||||
std::string_view path_data(patch_data_fn->data);
|
||||
ZipEntry patch_entry;
|
||||
ZipEntry64 patch_entry;
|
||||
if (FindEntry(za, path_data, &patch_entry) != 0) {
|
||||
LOG(ERROR) << name << "(): no file \"" << patch_data_fn->data << "\" in package";
|
||||
return StringValue("");
|
||||
|
@ -1695,7 +1695,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state,
|
|||
params.patch_start = updater->GetMappedPackageAddress() + patch_entry.offset;
|
||||
|
||||
std::string_view new_data(new_data_fn->data);
|
||||
ZipEntry new_entry;
|
||||
ZipEntry64 new_entry;
|
||||
if (FindEntry(za, new_data, &new_entry) != 0) {
|
||||
LOG(ERROR) << name << "(): no file \"" << new_data_fn->data << "\" in package";
|
||||
return StringValue("");
|
||||
|
|
|
@ -115,7 +115,7 @@ Value* PackageExtractFileFn(const char* name, State* state,
|
|||
std::string dest_path = args[1];
|
||||
|
||||
ZipArchiveHandle za = state->updater->GetPackageHandle();
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
if (FindEntry(za, zip_path, &entry) != 0) {
|
||||
LOG(ERROR) << name << ": no " << zip_path << " in package";
|
||||
return StringValue("");
|
||||
|
@ -165,7 +165,7 @@ Value* PackageExtractFileFn(const char* name, State* state,
|
|||
const std::string& zip_path = args[0];
|
||||
|
||||
ZipArchiveHandle za = state->updater->GetPackageHandle();
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
if (FindEntry(za, zip_path, &entry) != 0) {
|
||||
return ErrorAbort(state, kPackageExtractFileFailure, "%s(): no %s in package", name,
|
||||
zip_path.c_str());
|
||||
|
|
|
@ -115,7 +115,7 @@ bool TargetFile::EntryExists(const std::string_view name) const {
|
|||
}
|
||||
|
||||
CHECK(handle_);
|
||||
ZipEntry img_entry;
|
||||
ZipEntry64 img_entry;
|
||||
return FindEntry(handle_, name, &img_entry) == 0;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ bool TargetFile::ReadEntryToString(const std::string_view name, std::string* con
|
|||
}
|
||||
|
||||
CHECK(handle_);
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
if (auto find_err = FindEntry(handle_, name, &entry); find_err != 0) {
|
||||
LOG(ERROR) << "failed to find " << name << " in the package: " << ErrorCodeString(find_err);
|
||||
return false;
|
||||
|
@ -157,7 +157,7 @@ bool TargetFile::ExtractEntryToTempFile(const std::string_view name,
|
|||
}
|
||||
|
||||
CHECK(handle_);
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
if (auto find_err = FindEntry(handle_, name, &entry); find_err != 0) {
|
||||
LOG(ERROR) << "failed to find " << name << " in the package: " << ErrorCodeString(find_err);
|
||||
return false;
|
||||
|
|
|
@ -163,7 +163,7 @@ void Updater::ParseAndReportErrorCode(State* state) {
|
|||
|
||||
bool Updater::ReadEntryToString(ZipArchiveHandle za, const std::string& entry_name,
|
||||
std::string* content) {
|
||||
ZipEntry entry;
|
||||
ZipEntry64 entry;
|
||||
int find_err = FindEntry(za, entry_name, &entry);
|
||||
if (find_err != 0) {
|
||||
LOG(ERROR) << "failed to find " << entry_name
|
||||
|
|
Loading…
Reference in a new issue