diff options
author | 2024-03-05 23:28:49 +0300 | |
---|---|---|
committer | 2024-05-20 07:58:59 -0500 | |
commit | 9d16c25da9935b1b0beb38357fe3c8b4ee2e236b (patch) | |
tree | 75d53602738796683ef415c0a76e4708e044e0ac | |
parent | gen_initramfs.sh: copy compressed firmwares (diff) | |
download | genkernel-9d16c25da9935b1b0beb38357fe3c8b4ee2e236b.tar.gz genkernel-9d16c25da9935b1b0beb38357fe3c8b4ee2e236b.tar.bz2 genkernel-9d16c25da9935b1b0beb38357fe3c8b4ee2e236b.zip |
gen_initramfs.sh: unpack compressed modules/firmwares to reduce image size
Signed-off-by: Dmitriy Baranov <reagentoo@gmail.com>
Signed-off-by: Ben Kohler <bkohler@gentoo.org>
-rwxr-xr-x | gen_funcs.sh | 34 | ||||
-rwxr-xr-x | gen_initramfs.sh | 8 |
2 files changed, 42 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh index c31e15aa..70a49695 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -2054,6 +2054,40 @@ expand_file() { echo "${expanded_file}" } +find_and_unpack() { + local flist + + local fmt + for fmt in "$@" + do + case "${fmt}" in + "gz"|"xz"|"zstd") + flist=( $(find -type f -name "*.${fmt}") ) + ;; + *) + gen_die "unknown compression format: ${fmt}" + ;; + esac + + if [ ${#flist[@]} -lt 1 ] + then + continue + fi + + case "${fmt}" in + "gz") + gunzip "${flist[@]}" + ;; + "xz") + unxz "${flist[@]}" + ;; + "zstd") + unzstd "${flist[@]}" + ;; + esac + done +} + find_kernel_binary() { local kernel_binary=${*} local kernel_binary_found= diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 486f0e6c..aaf108e4 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -1806,6 +1806,10 @@ append_firmware() { cp -rL --parents --target-directory="${TDIR}/lib/firmware" "${fwlist[@]}" 2>/dev/null \ || gen_die "Failed to copy firmware files to '${TDIR}/lib/firmware'!" popd &>/dev/null || gen_die "Failed to chdir!" + + pushd "${TDIR}/lib/firmware" &>/dev/null || gen_die "Failed to chdir to '${TDIR}/lib/firmware'!" + find_and_unpack xz zstd + popd &>/dev/null || gen_die "Failed to chdir!" fi cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" @@ -1940,6 +1944,10 @@ append_modules() { cp -ax --parents --target-directory "${modules_dstdir}" modules* 2>/dev/null \ || gen_die "Failed to copy '${modules_srcdir}/modules*' to '${modules_dstdir}'!" + pushd "${modules_dstdir}" &>/dev/null || gen_die "Failed to chdir to '${modules_dstdir}'!" + find_and_unpack gz xz zstd + popd &>/dev/null || gen_die "Failed to chdir!" + print_info 2 "$(get_indent 2)modules: Updating modules.dep ..." local depmod_cmd=( depmod -a -b "${TDIR}" ${KV} ) print_info 3 "COMMAND: ${depmod_cmd[*]}" 1 0 1 |