repack: correctly recompress ramdisk to the format of boot image
Change-Id: I90df3d2f63eb82a185d9af0d68e61c955cee9403
diff --git a/twrpRepacker.cpp b/twrpRepacker.cpp
index 2790697..93b70c2 100755
--- a/twrpRepacker.cpp
+++ b/twrpRepacker.cpp
@@ -175,7 +175,6 @@
LOGERR("Disabling force encrypt is not implemented yet\n");
std::string command = "cd " + path + " && /sbin/magiskboot repack ";
if (original_ramdisk_format != image_ramdisk_format) {
- command = command + "-n ";
recompress = true;
}
@@ -187,8 +186,8 @@
copy_compressed_image += "ramdisk-1.cpio";
if (recompress) {
- std::string compress_cmd = "/sbin/magiskboot compress=" + image_ramdisk_format + " " + orig_compressed_image + " " + copy_compressed_image;
- if (TWFunc::Exec_Cmd(compress_cmd) != 0) {
+ std::string decompress_cmd = "/sbin/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;
}
@@ -227,14 +226,13 @@
std::string command = "cd " + path + " && /sbin/magiskboot repack ";
if (original_ramdisk_format != image_ramdisk_format) {
- command = command + "-n ";
recompress = true;
}
command += path + "boot.img";
if (recompress) {
- std::string compress_cmd = "/sbin/magiskboot compress=" + image_ramdisk_format + " " + orig_compressed_image + " " + copy_compressed_image;
- if (TWFunc::Exec_Cmd(compress_cmd) != 0) {
+ std::string decompress_cmd = "/sbin/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;
}