mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 01:27:48 +00:00
Always use zopfli for zImage compression
This commit is contained in:
parent
01ebe5724a
commit
449989ddd9
@ -570,19 +570,16 @@ void repack(const char *src_img, const char *out_img, bool skip_comp) {
|
|||||||
void *raw_buf;
|
void *raw_buf;
|
||||||
mmap_ro(KERNEL_FILE, raw_buf, raw_size);
|
mmap_ro(KERNEL_FILE, raw_buf, raw_size);
|
||||||
if (!COMPRESSED_ANY(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.k_fmt)) {
|
if (!COMPRESSED_ANY(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.k_fmt)) {
|
||||||
hdr->kernel_size() = compress(boot.k_fmt, fd, raw_buf, raw_size);
|
// Always use zopfli for zImage compression
|
||||||
|
auto fmt = (boot.flags[ZIMAGE_KERNEL] && boot.k_fmt == GZIP) ? ZOPFLI : boot.k_fmt;
|
||||||
|
hdr->kernel_size() = compress(fmt, fd, raw_buf, raw_size);
|
||||||
} else {
|
} else {
|
||||||
hdr->kernel_size() = xwrite(fd, raw_buf, raw_size);
|
hdr->kernel_size() = xwrite(fd, raw_buf, raw_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boot.flags[ZIMAGE_KERNEL]) {
|
if (boot.flags[ZIMAGE_KERNEL]) {
|
||||||
if (boot.k_fmt == GZIP && hdr->kernel_size() > boot.hdr->kernel_size()) {
|
|
||||||
// Revert and try zopfli
|
|
||||||
ftruncate64(fd, lseek64(fd, -(off64_t)hdr->kernel_size(), SEEK_CUR));
|
|
||||||
hdr->kernel_size() = compress(ZOPFLI, fd, raw_buf, raw_size);
|
|
||||||
}
|
|
||||||
if (hdr->kernel_size() > boot.hdr->kernel_size()) {
|
if (hdr->kernel_size() > boot.hdr->kernel_size()) {
|
||||||
LOGW("! Recompressed kernel is too large, using original kernel\n");
|
fprintf(stderr, "! Recompressed kernel is too large, using original kernel\n");
|
||||||
ftruncate64(fd, lseek64(fd, - (off64_t) hdr->kernel_size(), SEEK_CUR));
|
ftruncate64(fd, lseek64(fd, - (off64_t) hdr->kernel_size(), SEEK_CUR));
|
||||||
xwrite(fd, boot.kernel, boot.hdr->kernel_size());
|
xwrite(fd, boot.kernel, boot.hdr->kernel_size());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user