From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 957D2158004 for ; Mon, 20 May 2024 12:59:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8FB9BE2A3F; Mon, 20 May 2024 12:59:15 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4FC6CE2A3E for ; Mon, 20 May 2024 12:59:15 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8791133BF29 for ; Mon, 20 May 2024 12:59:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1956C1AE5 for ; Mon, 20 May 2024 12:59:13 +0000 (UTC) From: "Ben Kohler" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ben Kohler" Message-ID: <1716209939.9d16c25da9935b1b0beb38357fe3c8b4ee2e236b.bkohler@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_funcs.sh gen_initramfs.sh X-VCS-Directories: / X-VCS-Committer: bkohler X-VCS-Committer-Name: Ben Kohler X-VCS-Revision: 9d16c25da9935b1b0beb38357fe3c8b4ee2e236b X-VCS-Branch: master Date: Mon, 20 May 2024 12:59:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 50904211-056d-4999-967f-d60278816594 X-Archives-Hash: 88e88cbd06394e3ad6b10b88649b6999 commit: 9d16c25da9935b1b0beb38357fe3c8b4ee2e236b Author: Dmitriy Baranov gmail com> AuthorDate: Tue Mar 5 20:28:49 2024 +0000 Commit: Ben Kohler gentoo org> CommitDate: Mon May 20 12:58:59 2024 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=9d16c25d gen_initramfs.sh: unpack compressed modules/firmwares to reduce image size Signed-off-by: Dmitriy Baranov gmail.com> Signed-off-by: Ben Kohler gentoo.org> gen_funcs.sh | 34 ++++++++++++++++++++++++++++++++++ gen_initramfs.sh | 8 ++++++++ 2 files changed, 42 insertions(+) diff --git a/gen_funcs.sh b/gen_funcs.sh index c31e15a..70a4969 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 486f0e6..aaf108e 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