From 7378254120b38d67ada6ae2a4f07f4daf4de9428 Mon Sep 17 00:00:00 2001 From: nebrassy Date: Sat, 7 Aug 2021 00:37:30 +0200 Subject: [PATCH] repack: correctly recompress ramdisk to the format of boot image Change-Id: I90df3d2f63eb82a185d9af0d68e61c955cee9403 --- twrpRepacker.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/twrpRepacker.cpp b/twrpRepacker.cpp index e61d3285..10be2fcf 100755 --- a/twrpRepacker.cpp +++ b/twrpRepacker.cpp @@ -159,7 +159,6 @@ bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const LOGERR("Disabling force encrypt is not implemented yet\n"); std::string command = "cd " + path + " && /system/bin/magiskboot repack "; if (original_ramdisk_format != image_ramdisk_format) { - command = command + "-n "; recompress = true; } @@ -171,8 +170,8 @@ bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const copy_compressed_image += "ramdisk-1.cpio"; if (recompress) { - std::string compress_cmd = "/system/bin/magiskboot compress=" + image_ramdisk_format + " " + orig_compressed_image + " " + copy_compressed_image; - if (TWFunc::Exec_Cmd(compress_cmd) != 0) { + std::string decompress_cmd = "/system/bin/magiskboot decompress " + orig_compressed_image + " " + copy_compressed_image; + if (TWFunc::Exec_Cmd(decompress_cmd) != 0) { gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); return false; } @@ -211,14 +210,13 @@ bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const std::string command = "cd " + path + " && /system/bin/magiskboot repack "; if (original_ramdisk_format != image_ramdisk_format) { - command = command + "-n "; recompress = true; } command += path + "boot.img"; if (recompress) { - std::string compress_cmd = "/system/bin/magiskboot compress=" + image_ramdisk_format + " " + orig_compressed_image + " " + copy_compressed_image; - if (TWFunc::Exec_Cmd(compress_cmd) != 0) { + std::string decompress_cmd = "/system/bin/magiskboot decompress " + orig_compressed_image + " " + copy_compressed_image; + if (TWFunc::Exec_Cmd(decompress_cmd) != 0) { gui_msg(Msg(msg::kError, "repack_error=Error repacking image.")); return false; }