magiskboot: allow forcing no recompression on ramdisk.cpio

- when input image had a compressed ramdisk magiskboot had no way to force the repack with the uncompressed ramdisk.cpio since it does not formally recognize cpio as its own format, so add a switch to support forcing repacking to any possible ramdisk format regardless of input image
This commit is contained in:
osm0sis
2019-06-07 15:56:20 -03:00
committed by topjohnwu
parent f341f3b2dd
commit ee407472cf
3 changed files with 14 additions and 7 deletions

View File

@ -340,7 +340,7 @@ int unpack(const char *image, bool hdr) {
}
#define file_align() write_zero(fd, align_off(lseek(fd, 0, SEEK_CUR) - header_off, boot.hdr.page_size()))
void repack(const char* orig_image, const char* out_image) {
void repack(const char* orig_image, const char* out_image, bool force_nocomp) {
boot_img boot {};
off_t header_off, kernel_off, ramdisk_off, second_off, extra_off, dtb_off;
@ -442,7 +442,7 @@ void repack(const char* orig_image, const char* out_image) {
size_t raw_size;
void *raw_buf;
mmap_ro(RAMDISK_FILE, raw_buf, raw_size);
if (!COMPRESSED_ANY(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.r_fmt)) {
if (!COMPRESSED_ANY(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.r_fmt) && !force_nocomp) {
boot.hdr->ramdisk_size = compress(boot.r_fmt, fd, raw_buf, raw_size);
} else {
boot.hdr->ramdisk_size = write(fd, raw_buf, raw_size);