magiskboot: add unpack -n to help with repack validity tests

- support unpack without decompression to allow easy testing of magiskboot's header, structure and hashing handling by comparing repack checksum versus origbootimg
- make -n first to match repack
This commit is contained in:
osm0sis
2019-10-29 15:48:58 -03:00
committed by John Wu
parent 0a89edf3b0
commit 353c3c7d81
3 changed files with 27 additions and 9 deletions

View File

@ -312,14 +312,14 @@ void boot_img::find_kernel_dtb() {
}
}
int unpack(const char *image, bool hdr) {
int unpack(const char *image, bool nodecomp, bool hdr) {
boot_img boot(image);
if (hdr)
boot.hdr->dump_hdr_file();
// Dump kernel
if (COMPRESSED(boot.k_fmt)) {
if (COMPRESSED(boot.k_fmt) && !nodecomp) {
int fd = creat(KERNEL_FILE, 0644);
decompress(boot.k_fmt, fd, boot.kernel, boot.hdr->kernel_size());
close(fd);
@ -331,7 +331,7 @@ int unpack(const char *image, bool hdr) {
dump(boot.kernel_dtb, boot.kernel_dt_size, KER_DTB_FILE);
// Dump ramdisk
if (COMPRESSED(boot.r_fmt)) {
if (COMPRESSED(boot.r_fmt) && !nodecomp) {
int fd = creat(RAMDISK_FILE, 0644);
decompress(boot.r_fmt, fd, boot.ramdisk, boot.hdr->ramdisk_size());
close(fd);