commit: 53161dfada35f9d5a766a74413341c69cde0a67a Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Sun Dec 29 03:57:58 2019 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Sun Dec 29 03:57:58 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=53161dfa
gen_initramfs.sh: create_initramfs(): Fix integrated initramfs creation - CONFIG_INITRAMFS_SOURCE value must be quoted. - CONFIG_INITRAMFS_COMPRESSION_* is only available in >=linux-4.10. - Use CONFIG_RD_* for <linux-4.10. But make sure that only option for selected compression type is set and every other type is disabled. Otherwise, last set compression type would be used all the time, see $KERNEL_DIR/usr/Makefile for details. - Add sanity check which checks for integrated initramfs. Bug: https://bugs.gentoo.org/703826 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> gen_initramfs.sh | 21 +++++++++++++++++++-- genkernel | 7 +++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 38c77d0..283e308 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -1890,7 +1890,8 @@ create_initramfs() { print_info 1 "$(get_indent 1)>> --integrated-initramfs is set; Setting CONFIG_INITRAMFS_* options ..." [ -f "${KCONFIG_MODIFIED_MARKER}" ] && rm "${KCONFIG_MODIFIED_MARKER}" - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_INITRAMFS_SOURCE" "${CPIO_ARCHIVE}.cpio" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_BLK_DEV_INITRD" "y" + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_INITRAMFS_SOURCE" "\"${CPIO_ARCHIVE}.cpio\"" kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_INITRAMFS_ROOT_UID" "0" kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_INITRAMFS_ROOT_GID" "0" @@ -1904,7 +1905,23 @@ create_initramfs() { KOPTION_VALUE=y fi - kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_INITRAMFS_COMPRESSION_${KNOWN_INITRAMFS_COMPRESSION_TYPE}" "${KOPTION_VALUE}" + if [ ${KV_NUMERIC} -ge 4010 ] + then + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_INITRAMFS_COMPRESSION_${KNOWN_INITRAMFS_COMPRESSION_TYPE}" "${KOPTION_VALUE}" + + if [[ "${KOPTION_VALUE}" == "y" && "${KNOWN_INITRAMFS_COMPRESSION_TYPE}" != "NONE" ]] + then + # Make sure that the kernel can decompress our initramfs + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_RD_${KNOWN_INITRAMFS_COMPRESSION_TYPE}" "${KOPTION_VALUE}" + fi + else + [[ "${KNOWN_INITRAMFS_COMPRESSION_TYPE}" == "NONE" ]] && continue + + # In <linux-4.10, to control used initramfs compression, we have to + # disable every supported compression type except compression type + # we want to use, (see $KERNEL_DIR/usr/Makefile). + kconfig_set_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_RD_${KNOWN_INITRAMFS_COMPRESSION_TYPE}" "${KOPTION_VALUE}" + fi done if [ -f "${KCONFIG_MODIFIED_MARKER}" ] diff --git a/genkernel b/genkernel index 93f670e..3d25634 100755 --- a/genkernel +++ b/genkernel @@ -364,6 +364,13 @@ if isTrue "${INTEGRATED_INITRAMFS}" then print_info 1 '' 1 0 + cfg_CONFIG_INITRAMFS_SOURCE=$(kconfig_get_opt "${KERNEL_OUTPUTDIR}/.config" "CONFIG_INITRAMFS_SOURCE") + if [[ "${cfg_CONFIG_INITRAMFS_SOURCE}" != "\"${CPIO_ARCHIVE}.cpio\"" ]] + then + gen_die "Sanity check failed: CONFIG_INITRAMFS_SOURCE is not set to '${CPIO_ARCHIVE}.cpio' in '${KERNEL_OUTPUTDIR}/.config'!" + fi + unset cfg_CONFIG_INITRAMFS_SOURCE + # We build the kernel a second time to include the initramfs compile_kernel fi
