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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 72EBE1382C5 for ; Sat, 16 Jan 2021 10:12:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 831E9E0867; Sat, 16 Jan 2021 10:12:01 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6A215E0867 for ; Sat, 16 Jan 2021 10:12:01 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 63436340F66 for ; Sat, 16 Jan 2021 10:12:00 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AAC884A7 for ; Sat, 16 Jan 2021 10:11:57 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1610790788.9201c6c58e9a8b9dd184a4d2445b4144cf22df8f.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/dist-kernel-utils.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 9201c6c58e9a8b9dd184a4d2445b4144cf22df8f X-VCS-Branch: master Date: Sat, 16 Jan 2021 10:11:57 +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: 3b2375e8-6b2c-4a8b-a2cd-147785aef687 X-Archives-Hash: 4e7928b721cba96078746c9466d790cf commit: 9201c6c58e9a8b9dd184a4d2445b4144cf22df8f Author: Michał Górny gentoo org> AuthorDate: Wed Jan 13 14:15:54 2021 +0000 Commit: Michał Górny gentoo org> CommitDate: Sat Jan 16 09:53:08 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9201c6c5 dist-kernel-utils.eclass: Support dracut's uefi=yes option Support dracut's uefi=yes configuration option that creates a combined UEFI stub, kernel and initramfs in a single UEFI executable. If such an output is detected, install it in place of the actual kernel image and stub out the duplicate initrd to save space. Signed-off-by: Michał Górny gentoo.org> eclass/dist-kernel-utils.eclass | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index d65dc0924b4..9ab65b097b3 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -41,8 +41,20 @@ dist-kernel_build_initramfs() { local output=${1} local version=${2} + local rel_image_path=$(dist-kernel_get_image_path) + local image=${output%/*}/${rel_image_path##*/} + + local args=( + --force + # if uefi=yes is used, dracut needs to locate the kernel image + --kernel-image "${image}" + + # positional arguments + "${output}" "${version}" + ) + ebegin "Building initramfs via dracut" - dracut --force "${output}" "${version}" + dracut "${args[@]}" eend ${?} || die -n "Building initramfs failed" } @@ -85,6 +97,23 @@ dist-kernel_install_kernel() { local image=${2} local map=${3} + # if dracut is used in uefi=yes mode, initrd will actually + # be a combined kernel+initramfs UEFI executable. we can easily + # recognize it by PE magic (vs cpio for a regular initramfs) + local initrd=${image%/*}/initrd + local magic + [[ -s ${initrd} ]] && read -n 2 magic < "${initrd}" + if [[ ${magic} == MZ ]]; then + einfo "Combined UEFI kernel+initramfs executable found" + # install the combined executable in place of kernel + image=${initrd}.uefi + mv "${initrd}" "${image}" || die + # put an empty file in place of initrd. installing a duplicate + # file would waste disk space, and removing it entirely provokes + # kernel-install to regenerate it via dracut. + > "${initrd}" + fi + ebegin "Installing the kernel via installkernel" # note: .config is taken relatively to System.map; # initrd relatively to bzImage