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) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 930C3158004 for ; Tue, 14 May 2024 11:59:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DE93BE29EE; Tue, 14 May 2024 11:59:38 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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 908D1E299F for ; Tue, 14 May 2024 11:59:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 050FE33D9AD; Tue, 14 May 2024 11:59:38 +0000 (UTC) X-Virus-Scanned: by amavisd-new using ClamAV at gentoo.org X-Spam-Flag: NO X-Spam-Score: -1.119 X-Spam-Level: X-Spam-Status: No, score=-1.119 tagged_above=-9999 required=3.5 tests=[AWL=0.000, BAYES_00=-1.9, KHOP_HELO_FCRDNS=0.001, SPF_HELO_FAIL=0.001, SPF_NEUTRAL=0.779] autolearn=no autolearn_force=no Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XNbVHPi1Fhn7; Tue, 14 May 2024 11:59:31 +0000 (UTC) Received: from andrew-gentoo-laptop.science.ru.nl (n036122.science.ru.nl [131.174.36.122]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 306FA335C03; Tue, 14 May 2024 11:59:31 +0000 (UTC) From: Andrew Ammerlaan To: gentoo-dev@lists.gentoo.org Cc: Andrew Ammerlaan Subject: [gentoo-dev] [PATCH 1/7] linux-mod-r1.eclass: add USE=initramfs Date: Tue, 14 May 2024 13:59:06 +0200 Message-ID: <20240514115924.29167-1-andrewammerlaan@gentoo.org> X-Mailer: git-send-email 2.45.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: b0ea9c05-722b-45c2-a03e-b16e47ce38c0 X-Archives-Hash: 9a38e7d8966db4265e8de03aa48553a4 Adds a new variable that adds the "initramfs" flag when set. This new flag controls whether or not the modules that were built should be included in the initramfs. If the modules should be included, then we also rebuild the initramfs/uki in post_install using installkernel. Bug: https://bugs.gentoo.org/923025 Bug: https://bugs.gentoo.org/928271 Signed-off-by: Andrew Ammerlaan --- eclass/linux-mod-r1.eclass | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass index 4b267aae4db1..d9651f962604 100644 --- a/eclass/linux-mod-r1.eclass +++ b/eclass/linux-mod-r1.eclass @@ -131,6 +131,15 @@ IDEPEND=" sys-apps/kmod[tools] " +if [[ ${MODULES_INITRAMFS_IUSE} ]]; then + IUSE+=" ${MODULES_INITRAMFS_IUSE}" + IDEPEND+=" + ${MODULES_INITRAMFS_IUSE#+}? ( + sys-kernel/installkernel + ) + " +fi + if [[ -n ${MODULES_OPTIONAL_IUSE} ]]; then : "${MODULES_OPTIONAL_IUSE#+}? ( | )" RDEPEND=${_/|/${RDEPEND}} DEPEND=${_/|/${DEPEND}} \ @@ -179,6 +188,22 @@ fi # # May want to look at KERNEL_CHOST before considering this. +# @ECLASS_VARIABLE: MODULES_INITRAMFS_IUSE +# @DEFAULT_UNSET +# @PRE_INHERIT +# @DESCRIPTION: +# If set, adds the specified USE flag. When this flag is enabled the +# installed kernel modules are registered for inclusion in the dracut +# initramfs. Additionally, if distribution kernels are used +# (USE="dist-kernel") then these kernels are re-installed. +# +# The typical recommended value is "initramfs" or "+initramfs" (global +# IUSE). +# +# If MODULES_INITRAMFS_IUSE is not set, or the specified flag is not +# enabled, then the installed kernel modules are omitted from the +# dracut initramfs. + # @ECLASS_VARIABLE: MODULES_SIGN_HASH # @USER_VARIABLE # @DEFAULT_UNSET @@ -471,6 +496,19 @@ linux-mod-r1_pkg_postinst() { dist-kernel_compressed_module_cleanup "${EROOT}/lib/modules/${KV_FULL}" _modules_update_depmod + if [[ -z ${ROOT} && ${MODULES_INITRAMFS_IUSE} ]] && + use dist-kernel && use ${MODULES_INITRAMFS_IUSE#+} + then + dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}" + fi + + if has_version virtual/dist-kernel && ! use dist-kernel; then + ewarn "virtual/dist-kernel is installed, but USE=\"dist-kernel\"" + ewarn "is not enabled for ${CATEGORY}/${PN}." + ewarn "It's recommended to globally enable the dist-kernel USE flag" + ewarn "to automatically trigger initramfs rebuilds on kernel updates" + fi + # post_process ensures modules were installed and that the eclass' USE # are likely not no-ops (unfortunately postinst itself may be missed) [[ -v _MODULES_GLOBAL[ran:post_process] ]] || @@ -550,6 +588,7 @@ modules_post_process() { # which can lead to unnecessarily increased size or stale modules) # _modules_process_depmod.d "${mods[@]#"${path}/"}" + _modules_process_dracut.conf.d "${mods[@]##*/}" _modules_process_strip "${mods[@]}" _modules_process_sign "${mods[@]}" _modules_sanity_modversion "${mods[@]}" # after strip/sign in case broke it @@ -904,6 +943,21 @@ _modules_process_depmod.d() { ) } +# @FUNCTION: _modules_process_dracut.conf.d +# @USAGE: ... +# @INTERNAL +# @DESCRIPTION: +# Create dracut.conf.d snippet defining if module should be included in the +# initramfs. +_modules_process_dracut.conf.d() { + ( + insinto /usr/lib/dracut/dracut.conf.d + [[ ${MODULES_INITRAMFS_IUSE} ]] && use ${MODULES_INITRAMFS_IUSE#+} && + : add || : omit + newins - 10-${PN}.conf <<<"${_}_drivers+=\" ${*%.ko} \"" + ) +} + # @FUNCTION: _modules_process_sign # @USAGE: ... # @INTERNAL -- 2.45.0