Add no decompression flag to magiskboot split

This commit is contained in:
osm0sis 2024-02-04 23:54:44 -04:00 committed by John Wu
parent 7f6b5305ba
commit 991802ab82
3 changed files with 14 additions and 6 deletions

View File

@ -520,12 +520,12 @@ bool boot_img::verify(const char *cert) const {
return rust::verify_boot_image(*this, cert);
}
int split_image_dtb(const char *filename) {
int split_image_dtb(const char *filename, bool skip_decomp) {
mmap_data img(filename);
if (int off = find_dtb_offset(img.buf(), img.sz()); off > 0) {
format_t fmt = check_fmt_lg(img.buf(), img.sz());
if (COMPRESSED(fmt)) {
if (!skip_decomp && COMPRESSED(fmt)) {
int fd = creat(KERNEL_FILE, 0644);
decompress(fmt, fd, img.buf(), off);
close(fd);

View File

@ -18,7 +18,7 @@ int unpack(const char *image, bool skip_decomp = false, bool hdr = false);
void repack(const char *src_img, const char *out_img, bool skip_comp = false);
int verify(const char *image, const char *cert);
int sign(const char *image, const char *name, const char *cert, const char *key);
int split_image_dtb(const char *filename);
int split_image_dtb(const char *filename, bool skip_decomp = false);
int dtb_commands(int argc, char *argv[]);
static inline bool check_env(const char *name) {

View File

@ -84,8 +84,10 @@ Supported actions:
Do dtb related actions to <file>.
See "dtb --help" for supported actions.
split <file>
Split image.*-dtb into kernel + kernel_dtb
split [-n] <file>
Split image.*-dtb into kernel + kernel_dtb.
If '-n' is provided, decompression operations will be skipped;
the kernel will remain untouched, split in its original format.
sha1 <file>
Print the SHA1 checksum for <file>
@ -150,7 +152,13 @@ int main(int argc, char *argv[]) {
printf("%02x", i);
printf("\n");
} else if (argc > 2 && action == "split") {
return split_image_dtb(argv[2]);
if (argv[2] == "-n"sv) {
if (argc == 3)
usage(argv[0]);
return split_image_dtb(argv[3], true);
} else {
return split_image_dtb(argv[2]);
}
} else if (argc > 2 && action == "unpack") {
int idx = 2;
bool nodecomp = false;