Merge "Track libziparchive API change."
This commit is contained in:
+5
-10
@@ -73,9 +73,8 @@ bool ReadMetadataFromPackage(ZipArchiveHandle zip, std::map<std::string, std::st
|
|||||||
CHECK(metadata != nullptr);
|
CHECK(metadata != nullptr);
|
||||||
|
|
||||||
static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata";
|
static constexpr const char* METADATA_PATH = "META-INF/com/android/metadata";
|
||||||
ZipString path(METADATA_PATH);
|
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
if (FindEntry(zip, path, &entry) != 0) {
|
if (FindEntry(zip, METADATA_PATH, &entry) != 0) {
|
||||||
LOG(ERROR) << "Failed to find " << METADATA_PATH;
|
LOG(ERROR) << "Failed to find " << METADATA_PATH;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -236,9 +235,8 @@ 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
|
// For A/B updates we extract the payload properties to a buffer and obtain the RAW payload offset
|
||||||
// in the zip file.
|
// in the zip file.
|
||||||
static constexpr const char* AB_OTA_PAYLOAD_PROPERTIES = "payload_properties.txt";
|
static constexpr const char* AB_OTA_PAYLOAD_PROPERTIES = "payload_properties.txt";
|
||||||
ZipString property_name(AB_OTA_PAYLOAD_PROPERTIES);
|
|
||||||
ZipEntry properties_entry;
|
ZipEntry properties_entry;
|
||||||
if (FindEntry(zip, property_name, &properties_entry) != 0) {
|
if (FindEntry(zip, AB_OTA_PAYLOAD_PROPERTIES, &properties_entry) != 0) {
|
||||||
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD_PROPERTIES;
|
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD_PROPERTIES;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -252,9 +250,8 @@ bool SetUpAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
static constexpr const char* AB_OTA_PAYLOAD = "payload.bin";
|
static constexpr const char* AB_OTA_PAYLOAD = "payload.bin";
|
||||||
ZipString payload_name(AB_OTA_PAYLOAD);
|
|
||||||
ZipEntry payload_entry;
|
ZipEntry payload_entry;
|
||||||
if (FindEntry(zip, payload_name, &payload_entry) != 0) {
|
if (FindEntry(zip, AB_OTA_PAYLOAD, &payload_entry) != 0) {
|
||||||
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD;
|
LOG(ERROR) << "Failed to find " << AB_OTA_PAYLOAD;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -275,9 +272,8 @@ bool SetUpNonAbUpdateCommands(const std::string& package, ZipArchiveHandle zip,
|
|||||||
|
|
||||||
// In non-A/B updates we extract the update binary from the package.
|
// 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";
|
static constexpr const char* UPDATE_BINARY_NAME = "META-INF/com/google/android/update-binary";
|
||||||
ZipString binary_name(UPDATE_BINARY_NAME);
|
|
||||||
ZipEntry binary_entry;
|
ZipEntry binary_entry;
|
||||||
if (FindEntry(zip, binary_name, &binary_entry) != 0) {
|
if (FindEntry(zip, UPDATE_BINARY_NAME, &binary_entry) != 0) {
|
||||||
LOG(ERROR) << "Failed to find update binary " << UPDATE_BINARY_NAME;
|
LOG(ERROR) << "Failed to find update binary " << UPDATE_BINARY_NAME;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -508,9 +504,8 @@ bool verify_package_compatibility(ZipArchiveHandle package_zip) {
|
|||||||
LOG(INFO) << "Verifying package compatibility...";
|
LOG(INFO) << "Verifying package compatibility...";
|
||||||
|
|
||||||
static constexpr const char* COMPATIBILITY_ZIP_ENTRY = "compatibility.zip";
|
static constexpr const char* COMPATIBILITY_ZIP_ENTRY = "compatibility.zip";
|
||||||
ZipString compatibility_entry_name(COMPATIBILITY_ZIP_ENTRY);
|
|
||||||
ZipEntry compatibility_entry;
|
ZipEntry compatibility_entry;
|
||||||
if (FindEntry(package_zip, compatibility_entry_name, &compatibility_entry) != 0) {
|
if (FindEntry(package_zip, COMPATIBILITY_ZIP_ENTRY, &compatibility_entry) != 0) {
|
||||||
LOG(INFO) << "Package doesn't contain " << COMPATIBILITY_ZIP_ENTRY << " entry";
|
LOG(INFO) << "Package doesn't contain " << COMPATIBILITY_ZIP_ENTRY << " entry";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,8 @@ std::vector<std::string> GetWipePartitionList(Package* wipe_package) {
|
|||||||
constexpr char RECOVERY_WIPE_ENTRY_NAME[] = "recovery.wipe";
|
constexpr char RECOVERY_WIPE_ENTRY_NAME[] = "recovery.wipe";
|
||||||
|
|
||||||
std::string partition_list_content;
|
std::string partition_list_content;
|
||||||
ZipString path(RECOVERY_WIPE_ENTRY_NAME);
|
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
if (FindEntry(zip, path, &entry) == 0) {
|
if (FindEntry(zip, RECOVERY_WIPE_ENTRY_NAME, &entry) == 0) {
|
||||||
uint32_t length = entry.uncompressed_length;
|
uint32_t length = entry.uncompressed_length;
|
||||||
partition_list_content = std::string(length, '\0');
|
partition_list_content = std::string(length, '\0');
|
||||||
if (auto err = ExtractToMemory(
|
if (auto err = ExtractToMemory(
|
||||||
|
|||||||
@@ -271,9 +271,8 @@ static void VerifyAbUpdateCommands(const std::string& serialno, bool success = t
|
|||||||
|
|
||||||
ZipArchiveHandle zip;
|
ZipArchiveHandle zip;
|
||||||
ASSERT_EQ(0, OpenArchive(temp_file.path, &zip));
|
ASSERT_EQ(0, OpenArchive(temp_file.path, &zip));
|
||||||
ZipString payload_name("payload.bin");
|
|
||||||
ZipEntry payload_entry;
|
ZipEntry payload_entry;
|
||||||
ASSERT_EQ(0, FindEntry(zip, payload_name, &payload_entry));
|
ASSERT_EQ(0, FindEntry(zip, "payload.bin", &payload_entry));
|
||||||
|
|
||||||
std::map<std::string, std::string> metadata;
|
std::map<std::string, std::string> metadata;
|
||||||
ASSERT_TRUE(ReadMetadataFromPackage(zip, &metadata));
|
ASSERT_TRUE(ReadMetadataFromPackage(zip, &metadata));
|
||||||
|
|||||||
@@ -105,10 +105,9 @@ TEST_F(PackageTest, GetZipArchiveHandle_extract_entry) {
|
|||||||
ASSERT_TRUE(zip);
|
ASSERT_TRUE(zip);
|
||||||
|
|
||||||
// Check that we can extract one zip entry.
|
// Check that we can extract one zip entry.
|
||||||
std::string entry_name = "dir1/file3.txt";
|
std::string_view entry_name = "dir1/file3.txt";
|
||||||
ZipString path(entry_name.c_str());
|
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
ASSERT_EQ(0, FindEntry(zip, path, &entry));
|
ASSERT_EQ(0, FindEntry(zip, entry_name, &entry));
|
||||||
|
|
||||||
std::vector<uint8_t> extracted(entry_name.size());
|
std::vector<uint8_t> extracted(entry_name.size());
|
||||||
ASSERT_EQ(0, ExtractToMemory(zip, &entry, extracted.data(), extracted.size()));
|
ASSERT_EQ(0, ExtractToMemory(zip, &entry, extracted.data(), extracted.size()));
|
||||||
|
|||||||
@@ -37,10 +37,9 @@ TEST(ZipTest, OpenFromMemory) {
|
|||||||
ASSERT_EQ(0, OpenArchiveFromMemory(map.addr, map.length, zip_path.c_str(), &handle));
|
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";
|
static constexpr const char* BINARY_PATH = "META-INF/com/google/android/update-binary";
|
||||||
ZipString binary_path(BINARY_PATH);
|
|
||||||
ZipEntry binary_entry;
|
ZipEntry binary_entry;
|
||||||
// Make sure the package opens correctly and its entry can be read.
|
// Make sure the package opens correctly and its entry can be read.
|
||||||
ASSERT_EQ(0, FindEntry(handle, binary_path, &binary_entry));
|
ASSERT_EQ(0, FindEntry(handle, BINARY_PATH, &binary_entry));
|
||||||
|
|
||||||
TemporaryFile tmp_binary;
|
TemporaryFile tmp_binary;
|
||||||
ASSERT_NE(-1, tmp_binary.fd);
|
ASSERT_NE(-1, tmp_binary.fd);
|
||||||
|
|||||||
@@ -1680,7 +1680,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state,
|
|||||||
return StringValue("");
|
return StringValue("");
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipString path_data(patch_data_fn->data.c_str());
|
std::string_view path_data(patch_data_fn->data);
|
||||||
ZipEntry patch_entry;
|
ZipEntry patch_entry;
|
||||||
if (FindEntry(za, path_data, &patch_entry) != 0) {
|
if (FindEntry(za, path_data, &patch_entry) != 0) {
|
||||||
LOG(ERROR) << name << "(): no file \"" << patch_data_fn->data << "\" in package";
|
LOG(ERROR) << name << "(): no file \"" << patch_data_fn->data << "\" in package";
|
||||||
@@ -1688,7 +1688,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state,
|
|||||||
}
|
}
|
||||||
|
|
||||||
params.patch_start = ui->package_zip_addr + patch_entry.offset;
|
params.patch_start = ui->package_zip_addr + patch_entry.offset;
|
||||||
ZipString new_data(new_data_fn->data.c_str());
|
std::string_view new_data(new_data_fn->data);
|
||||||
ZipEntry new_entry;
|
ZipEntry new_entry;
|
||||||
if (FindEntry(za, new_data, &new_entry) != 0) {
|
if (FindEntry(za, new_data, &new_entry) != 0) {
|
||||||
LOG(ERROR) << name << "(): no file \"" << new_data_fn->data << "\" in package";
|
LOG(ERROR) << name << "(): no file \"" << new_data_fn->data << "\" in package";
|
||||||
|
|||||||
+2
-4
@@ -130,9 +130,8 @@ Value* PackageExtractFileFn(const char* name, State* state,
|
|||||||
const std::string& dest_path = args[1];
|
const std::string& dest_path = args[1];
|
||||||
|
|
||||||
ZipArchiveHandle za = static_cast<UpdaterInfo*>(state->cookie)->package_zip;
|
ZipArchiveHandle za = static_cast<UpdaterInfo*>(state->cookie)->package_zip;
|
||||||
ZipString zip_string_path(zip_path.c_str());
|
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
if (FindEntry(za, zip_string_path, &entry) != 0) {
|
if (FindEntry(za, zip_path, &entry) != 0) {
|
||||||
LOG(ERROR) << name << ": no " << zip_path << " in package";
|
LOG(ERROR) << name << ": no " << zip_path << " in package";
|
||||||
return StringValue("");
|
return StringValue("");
|
||||||
}
|
}
|
||||||
@@ -174,9 +173,8 @@ Value* PackageExtractFileFn(const char* name, State* state,
|
|||||||
const std::string& zip_path = args[0];
|
const std::string& zip_path = args[0];
|
||||||
|
|
||||||
ZipArchiveHandle za = static_cast<UpdaterInfo*>(state->cookie)->package_zip;
|
ZipArchiveHandle za = static_cast<UpdaterInfo*>(state->cookie)->package_zip;
|
||||||
ZipString zip_string_path(zip_path.c_str());
|
|
||||||
ZipEntry entry;
|
ZipEntry entry;
|
||||||
if (FindEntry(za, zip_string_path, &entry) != 0) {
|
if (FindEntry(za, zip_path, &entry) != 0) {
|
||||||
return ErrorAbort(state, kPackageExtractFileFailure, "%s(): no %s in package", name,
|
return ErrorAbort(state, kPackageExtractFileFailure, "%s(): no %s in package", name,
|
||||||
zip_path.c_str());
|
zip_path.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -101,9 +101,8 @@ int main(int argc, char** argv) {
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipString script_name(SCRIPT_NAME);
|
|
||||||
ZipEntry script_entry;
|
ZipEntry script_entry;
|
||||||
int find_err = FindEntry(za, script_name, &script_entry);
|
int find_err = FindEntry(za, SCRIPT_NAME, &script_entry);
|
||||||
if (find_err != 0) {
|
if (find_err != 0) {
|
||||||
LOG(ERROR) << "failed to find " << SCRIPT_NAME << " in " << package_filename << ": "
|
LOG(ERROR) << "failed to find " << SCRIPT_NAME << " in " << package_filename << ": "
|
||||||
<< ErrorCodeString(find_err);
|
<< ErrorCodeString(find_err);
|
||||||
|
|||||||
Reference in New Issue
Block a user