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 3B315138334 for ; Tue, 26 Mar 2019 08:07:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4319EE089D; Tue, 26 Mar 2019 08:07:20 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 06855E089D for ; Tue, 26 Mar 2019 08:07:20 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 9848F335CFE for ; Tue, 26 Mar 2019 08:07:18 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8C2EA594 for ; Tue, 26 Mar 2019 08:07:14 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1553587523.fcf3076aef8396f394de82dd13b7a470753e2e97.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: / X-VCS-Repository: proj/genkernel X-VCS-Files: gen_configkernel.sh X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: fcf3076aef8396f394de82dd13b7a470753e2e97 X-VCS-Branch: master Date: Tue, 26 Mar 2019 08:07:14 +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: 1bbbd9b9-551f-4b18-a3ea-270c91434ab9 X-Archives-Hash: fa2be8134cc8ef116bd8be81370a3522 commit: fcf3076aef8396f394de82dd13b7a470753e2e97 Author: Thomas Deutschmann gentoo org> AuthorDate: Tue Mar 26 07:53:35 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Tue Mar 26 08:05:23 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=fcf3076a config_kernel(): add sanity check for required options Sometimes, genkernel modifies kernel config (.config), i.e. when parameter like "--lvm", "--hyperv" or "--virtio" are set. However, this can fail (for example if a required dependency is not set). To avoid problems like an unbootable system, we check for required options and error out if they are missing. Signed-off-by: Thomas Deutschmann gentoo.org> gen_configkernel.sh | 69 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/gen_configkernel.sh b/gen_configkernel.sh index 016d5b2..582d71f 100755 --- a/gen_configkernel.sh +++ b/gen_configkernel.sh @@ -124,6 +124,7 @@ config_kernel() { [ "$?" ] || gen_die "Error: ${add_config} failed!" fi + local -a required_kernel_options [ -f "${TEMP}/.kconfig_modified" ] && rm "${TEMP}/.kconfig_modified" # Force this on if we are using --genzimage @@ -140,10 +141,12 @@ config_kernel() { cfg_CONFIG_EXT4_FS=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_EXT4_FS") if isTrue "${cfg_CONFIG_EXT4_FS}" then - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_EXT4_USE_FOR_EXT2" "y" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_EXT4_USE_FOR_EXT2" "y" && + required_kernel_options+=(CONFIG_EXT4_USE_FOR_EXT2) else kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLOCK" "y" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_EXT2_FS" "y" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_EXT2_FS" "y" && + required_kernel_options+=(CONFIG_EXT2_FS) fi fi fi @@ -202,10 +205,12 @@ config_kernel() { esac kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLOCK" "y" kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_MD" "y" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLK_DEV_DM" "${cfg_CONFIG_BLK_DEV_DM}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLK_DEV_DM" "${cfg_CONFIG_BLK_DEV_DM}" && + required_kernel_options+=(CONFIG_BLK_DEV_DM) kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_DM_SNAPSHOT" "${cfg_CONFIG_DM_SNAPSHOT}" kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_DM_MIRROR" "${cfg_CONFIG_DM_MIRROR}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_FILE_LOCKING" "y" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_FILE_LOCKING" "y" && + required_kernel_options+=(CONFIG_FILE_LOCKING) fi # Make sure multipath modules are enabled in the kernel, if --multipath @@ -224,8 +229,10 @@ config_kernel() { esac kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLOCK" "y" kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_MD" "y" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLK_DEV_DM" "${cfg_CONFIG_BLK_DEV_DM}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_DM_MULTIPATH" "${cfg_CONFIG_DM_MULTIPATH}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLK_DEV_DM" "${cfg_CONFIG_BLK_DEV_DM}" && + required_kernel_options+=(CONFIG_BLK_DEV_DM) + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_DM_MULTIPATH" "${cfg_CONFIG_DM_MULTIPATH}" && + required_kernel_options+=(CONFIG_DM_MULTIPATH) fi # Make sure dmraid modules are enabled in the kernel, if --dmraid @@ -234,7 +241,8 @@ config_kernel() { print_info 1 "$(getIndent 1)>> Ensure that required kernel options for DMRAID support are set..." kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLOCK" "y" kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_MD" "y" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLK_DEV_DM" "${cfg_CONFIG_BLK_DEV_DM}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLK_DEV_DM" "${cfg_CONFIG_BLK_DEV_DM}" && + required_kernel_options+=(CONFIG_BLK_DEV_DM) fi # Make sure iSCSI modules are enabled in the kernel, if --iscsi @@ -267,9 +275,12 @@ config_kernel() { kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_SCSI" "${cfg_CONFIG_SCSI}" kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_SCSI_LOWLEVEL" "y" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_ISCSI_BOOT_SYSFS" "${cfg_CONFIG_ISCSI_BOOT_SYSFS}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_ISCSI_TCP" "${cfg_CONFIG_ISCSI_TCP}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_SCSI_ISCSI_ATTRS" "${cfg_CONFIG_SCSI_ISCSI_ATTRS}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_ISCSI_BOOT_SYSFS" "${cfg_CONFIG_ISCSI_BOOT_SYSFS}" && + required_kernel_options+=(CONFIG_ISCSI_BOOT_SYSFS) + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_ISCSI_TCP" "${cfg_CONFIG_ISCSI_TCP}" && + required_kernel_options+=(CONFIG_ISCSI_TCP) + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_SCSI_ISCSI_ATTRS" "${cfg_CONFIG_SCSI_ISCSI_ATTRS}" && + required_kernel_options+=(CONFIG_SCSI_ISCSI_ATTRS) fi # Make sure Hyper-V modules are enabled in the kernel, if --hyperv @@ -362,11 +373,15 @@ config_kernel() { *) cfg_CONFIG_HYPERV=${newcfg_setting} esac - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV" "${cfg_CONFIG_HYPERV}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV" "${cfg_CONFIG_HYPERV}" && + required_kernel_options+=(CONFIG_HYPERV) kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV_UTILS" "${cfg_CONFIG_HYPERV}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV_BALLOON" "${cfg_CONFIG_HYPERV}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV_STORAGE" "${cfg_CONFIG_HYPERV}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV_NET" "${cfg_CONFIG_HYPERV}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV_BALLOON" "${cfg_CONFIG_HYPERV}" && + required_kernel_options+=(CONFIG_HYPERV_BALLOON) + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV_STORAGE" "${cfg_CONFIG_HYPERV}" && + required_kernel_options+=(CONFIG_HYPERV_STORAGE) + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_HYPERV_NET" "${cfg_CONFIG_HYPERV}" && + required_kernel_options+=(CONFIG_HYPERV_NET) if [ $(($KV_MAJOR * 1000 + ${KV_MINOR})) -ge 4014 ] then @@ -493,11 +508,15 @@ config_kernel() { fi # VirtIO modules, activate in order! - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO" "${newvirtio_setting}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO" "${newvirtio_setting}" && + required_kernel_options+=(CONFIG_VIRTIO) kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO_MENU" "y" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_SCSI_VIRTIO" "${newvirtio_setting}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO_BLK" "${newvirtio_setting}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO_NET" "${newvirtio_setting}" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_SCSI_VIRTIO" "${newvirtio_setting}" && + required_kernel_options+=(CONFIG_SCSI_VIRTIO) + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO_BLK" "${newvirtio_setting}" && + required_kernel_options+=(CONFIG_VIRTIO_BLK) + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO_NET" "${newvirtio_setting}" && + required_kernel_options+=(CONFIG_VIRTIO_NET) kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_VIRTIO_PCI" "${newvirtio_setting}" if [ $(($KV_MAJOR * 1000 + ${KV_MINOR})) -ge 4011 ] @@ -556,6 +575,8 @@ config_kernel() { esac kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "$k" "${cfg}" done + + required_kernel_options+=(CONFIG_MICROCODE) fi if [ -f "${TEMP}/.kconfig_modified" ] @@ -571,4 +592,16 @@ config_kernel() { else print_info 2 "$(getIndent 1)>> genkernel did not need to add/modify any kernel options." fi + + print_info 2 "$(getIndent 1)>> checking for required kernel options..." + for required_kernel_option in "${required_kernel_options[@]}" + do + optval=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "${required_kernel_option}") + if [ -z "${optval}" ] + then + gen_die "something went wrong: Required kernel option '${required_kernel_option}' which genkernel tried to set is missing!" + else + print_info 2 "$(getIndent 2) - '${required_kernel_option}' is set to '${optval}'" + fi + done }