diff options
Diffstat (limited to 'meta/classes-recipe/kernel.bbclass')
-rw-r--r-- | meta/classes-recipe/kernel.bbclass | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass index b084d6d69d..2d9943c8a0 100644 --- a/meta/classes-recipe/kernel.bbclass +++ b/meta/classes-recipe/kernel.bbclass | |||
@@ -12,7 +12,7 @@ KERNEL_PACKAGE_NAME ??= "kernel" | |||
12 | KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }" | 12 | KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }" |
13 | 13 | ||
14 | PROVIDES += "virtual/kernel" | 14 | PROVIDES += "virtual/kernel" |
15 | DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native bison-native" | 15 | DEPENDS += "virtual/cross-binutils virtual/cross-cc kmod-native bc-native bison-native" |
16 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lzo", "lzop-native", "", d)}" | 16 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lzo", "lzop-native", "", d)}" |
17 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lz4", "lz4-native", "", d)}" | 17 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lz4", "lz4-native", "", d)}" |
18 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.zst", "zstd-native", "", d)}" | 18 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.zst", "zstd-native", "", d)}" |
@@ -21,7 +21,10 @@ PACKAGE_WRITE_DEPS += "depmodwrapper-cross" | |||
21 | do_deploy[depends] += "depmodwrapper-cross:do_populate_sysroot gzip-native:do_populate_sysroot" | 21 | do_deploy[depends] += "depmodwrapper-cross:do_populate_sysroot gzip-native:do_populate_sysroot" |
22 | do_clean[depends] += "make-mod-scripts:do_clean" | 22 | do_clean[depends] += "make-mod-scripts:do_clean" |
23 | 23 | ||
24 | CVE_PRODUCT ?= "linux_kernel" | 24 | # CPE entries from NVD use linux_kernel, but the raw CVE entries from the kernel CNA have |
25 | # vendor: linux and product: linux. Note that multiple distributions use "linux" as a product | ||
26 | # name, so we need to fill vendor to avoid false positives | ||
27 | CVE_PRODUCT ?= "linux_kernel linux:linux" | ||
25 | 28 | ||
26 | S = "${STAGING_KERNEL_DIR}" | 29 | S = "${STAGING_KERNEL_DIR}" |
27 | B = "${WORKDIR}/build" | 30 | B = "${WORKDIR}/build" |
@@ -81,6 +84,10 @@ python __anonymous () { | |||
81 | types = (alttype + ' ' + types).strip() | 84 | types = (alttype + ' ' + types).strip() |
82 | d.setVar('KERNEL_IMAGETYPES', types) | 85 | d.setVar('KERNEL_IMAGETYPES', types) |
83 | 86 | ||
87 | # Since kernel-fitimage.bbclass got replaced by kernel-fit-image.bbclass | ||
88 | if "fitImage" in types: | ||
89 | bb.error("fitImage is no longer supported as a KERNEL_IMAGETYPE(S). FIT images are built by the linux-yocto-fitimage recipe.") | ||
90 | |||
84 | # KERNEL_IMAGETYPES may contain a mixture of image types supported directly | 91 | # KERNEL_IMAGETYPES may contain a mixture of image types supported directly |
85 | # by the kernel build system and types which are created by post-processing | 92 | # by the kernel build system and types which are created by post-processing |
86 | # the output of the kernel build system (e.g. compressing vmlinux -> | 93 | # the output of the kernel build system (e.g. compressing vmlinux -> |
@@ -115,7 +122,9 @@ python __anonymous () { | |||
115 | 122 | ||
116 | d.setVar('PKG:%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower)) | 123 | d.setVar('PKG:%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower)) |
117 | d.setVar('ALLOW_EMPTY:%s-image-%s' % (kname, typelower), '1') | 124 | d.setVar('ALLOW_EMPTY:%s-image-%s' % (kname, typelower), '1') |
118 | d.prependVar('pkg_postinst:%s-image-%s' % (kname,typelower), """set +e | 125 | |
126 | if d.getVar('KERNEL_IMAGETYPE_SYMLINK') == '1': | ||
127 | d.prependVar('pkg_postinst:%s-image-%s' % (kname,typelower), """set +e | ||
119 | if [ -n "$D" ]; then | 128 | if [ -n "$D" ]; then |
120 | ln -sf %s-${KERNEL_VERSION} $D/${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 | 129 | ln -sf %s-${KERNEL_VERSION} $D/${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 |
121 | else | 130 | else |
@@ -127,7 +136,7 @@ else | |||
127 | fi | 136 | fi |
128 | set -e | 137 | set -e |
129 | """ % (type, type, type, type, type, type, type)) | 138 | """ % (type, type, type, type, type, type, type)) |
130 | d.setVar('pkg_postrm:%s-image-%s' % (kname,typelower), """set +e | 139 | d.setVar('pkg_postrm:%s-image-%s' % (kname,typelower), """set +e |
131 | if [ -f "${KERNEL_IMAGEDEST}/%s" -o -L "${KERNEL_IMAGEDEST}/%s" ]; then | 140 | if [ -f "${KERNEL_IMAGEDEST}/%s" -o -L "${KERNEL_IMAGEDEST}/%s" ]; then |
132 | rm -f ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 | 141 | rm -f ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 |
133 | fi | 142 | fi |
@@ -141,7 +150,7 @@ set -e | |||
141 | # standalone for use by wic and other tools. | 150 | # standalone for use by wic and other tools. |
142 | if image: | 151 | if image: |
143 | if d.getVar('INITRAMFS_MULTICONFIG'): | 152 | if d.getVar('INITRAMFS_MULTICONFIG'): |
144 | d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' mc::${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete') | 153 | d.appendVarFlag('do_bundle_initramfs', 'mcdepends', ' mc:${BB_CURRENT_MC}:${INITRAMFS_MULTICONFIG}:${INITRAMFS_IMAGE}:do_image_complete') |
145 | else: | 154 | else: |
146 | d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') | 155 | d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') |
147 | if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): | 156 | if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')): |
@@ -222,15 +231,13 @@ KERNEL_DTBVENDORED ?= "0" | |||
222 | # | 231 | # |
223 | # configuration | 232 | # configuration |
224 | # | 233 | # |
225 | export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE") or "ttyS0"}" | ||
226 | |||
227 | KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}" | 234 | KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}" |
228 | 235 | ||
229 | # kernels are generally machine specific | 236 | # kernels are generally machine specific |
230 | PACKAGE_ARCH = "${MACHINE_ARCH}" | 237 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
231 | 238 | ||
232 | # U-Boot support | 239 | # U-Boot support |
233 | UBOOT_ENTRYPOINT ?= "20008000" | 240 | UBOOT_ENTRYPOINT ?= "0x20008000" |
234 | UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}" | 241 | UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}" |
235 | 242 | ||
236 | # Some Linux kernel configurations need additional parameters on the command line | 243 | # Some Linux kernel configurations need additional parameters on the command line |
@@ -463,7 +470,7 @@ kernel_do_install() { | |||
463 | rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build" | 470 | rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build" |
464 | rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source" | 471 | rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source" |
465 | # Remove empty module directories to prevent QA issues | 472 | # Remove empty module directories to prevent QA issues |
466 | find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete | 473 | [ -d "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" ] && find "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" -type d -empty -delete |
467 | else | 474 | else |
468 | bbnote "no modules to install" | 475 | bbnote "no modules to install" |
469 | fi | 476 | fi |
@@ -474,17 +481,10 @@ kernel_do_install() { | |||
474 | install -d ${D}/${KERNEL_IMAGEDEST} | 481 | install -d ${D}/${KERNEL_IMAGEDEST} |
475 | 482 | ||
476 | # | 483 | # |
477 | # When including an initramfs bundle inside a FIT image, the fitImage is created after the install task | 484 | # bundle_initramfs runs after do_install before do_deploy. do_deploy does what's needed therefore. |
478 | # by do_assemble_fitimage_initramfs. | ||
479 | # This happens after the generation of the initramfs bundle (done by do_bundle_initramfs). | ||
480 | # So, at the level of the install task we should not try to install the fitImage. fitImage is still not | ||
481 | # generated yet. | ||
482 | # After the generation of the fitImage, the deploy task copies the fitImage from the build directory to | ||
483 | # the deploy folder. | ||
484 | # | 485 | # |
485 | |||
486 | for imageType in ${KERNEL_IMAGETYPES} ; do | 486 | for imageType in ${KERNEL_IMAGETYPES} ; do |
487 | if [ $imageType != "fitImage" ] || [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ] ; then | 487 | if [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ] ; then |
488 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType ${D}/${KERNEL_IMAGEDEST}/$imageType-${KERNEL_VERSION} | 488 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType ${D}/${KERNEL_IMAGEDEST}/$imageType-${KERNEL_VERSION} |
489 | fi | 489 | fi |
490 | done | 490 | done |
@@ -658,7 +658,7 @@ KERNEL_LOCALVERSION ??= "" | |||
658 | # Note: This class saves the value of localversion to a file | 658 | # Note: This class saves the value of localversion to a file |
659 | # so other recipes like make-mod-scripts can restore it via the | 659 | # so other recipes like make-mod-scripts can restore it via the |
660 | # helper function get_kernellocalversion_file | 660 | # helper function get_kernellocalversion_file |
661 | export LOCALVERSION="${KERNEL_LOCALVERSION}" | 661 | export LOCALVERSION = "${KERNEL_LOCALVERSION}" |
662 | 662 | ||
663 | kernel_do_configure() { | 663 | kernel_do_configure() { |
664 | # fixes extra + in /lib/modules/2.6.37+ | 664 | # fixes extra + in /lib/modules/2.6.37+ |
@@ -679,25 +679,15 @@ kernel_do_configure() { | |||
679 | 679 | ||
680 | # Copy defconfig to .config if .config does not exist. This allows | 680 | # Copy defconfig to .config if .config does not exist. This allows |
681 | # recipes to manage the .config themselves in do_configure:prepend(). | 681 | # recipes to manage the .config themselves in do_configure:prepend(). |
682 | if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then | 682 | if [ -f "${UNPACKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then |
683 | cp "${WORKDIR}/defconfig" "${B}/.config" | 683 | cp "${UNPACKDIR}/defconfig" "${B}/.config" |
684 | fi | 684 | fi |
685 | 685 | ||
686 | ${KERNEL_CONFIG_COMMAND} | 686 | ${KERNEL_CONFIG_COMMAND} |
687 | } | 687 | } |
688 | 688 | ||
689 | do_savedefconfig() { | ||
690 | bbplain "Saving defconfig to:\n${B}/defconfig" | ||
691 | oe_runmake -C ${B} savedefconfig | ||
692 | } | ||
693 | do_savedefconfig[nostamp] = "1" | ||
694 | addtask savedefconfig after do_configure | ||
695 | |||
696 | inherit cml1 pkgconfig | 689 | inherit cml1 pkgconfig |
697 | 690 | ||
698 | # Need LD, HOSTLDFLAGS and more for config operations | ||
699 | KCONFIG_CONFIG_COMMAND:append = " ${EXTRA_OEMAKE}" | ||
700 | |||
701 | EXPORT_FUNCTIONS do_compile do_transform_kernel do_transform_bundled_initramfs do_install do_configure | 691 | EXPORT_FUNCTIONS do_compile do_transform_kernel do_transform_bundled_initramfs do_install do_configure |
702 | 692 | ||
703 | # kernel-base becomes kernel-${KERNEL_VERSION} | 693 | # kernel-base becomes kernel-${KERNEL_VERSION} |
@@ -715,9 +705,10 @@ RDEPENDS:${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base (= ${EXTENDPKGV}) | |||
715 | # not wanted in images as standard | 705 | # not wanted in images as standard |
716 | RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image (= ${EXTENDPKGV})" | 706 | RRECOMMENDS:${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image (= ${EXTENDPKGV})" |
717 | PKG:${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" | 707 | PKG:${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" |
708 | RPROVIDES:${KERNEL_PACKAGE_NAME}-image += "${KERNEL_PACKAGE_NAME}-image" | ||
718 | RDEPENDS:${KERNEL_PACKAGE_NAME}-image += "${@oe.utils.conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux (= ${EXTENDPKGV})', '', d)}" | 709 | RDEPENDS:${KERNEL_PACKAGE_NAME}-image += "${@oe.utils.conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux (= ${EXTENDPKGV})', '', d)}" |
719 | PKG:${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" | 710 | PKG:${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" |
720 | RPROVIDES:${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}" | 711 | RPROVIDES:${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION} ${KERNEL_PACKAGE_NAME}-base" |
721 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME} = "1" | 712 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME} = "1" |
722 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-base = "1" | 713 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-base = "1" |
723 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-image = "1" | 714 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-image = "1" |
@@ -851,9 +842,6 @@ kernel_do_deploy() { | |||
851 | 842 | ||
852 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then | 843 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then |
853 | for imageType in ${KERNEL_IMAGETYPES} ; do | 844 | for imageType in ${KERNEL_IMAGETYPES} ; do |
854 | if [ "$imageType" = "fitImage" ] ; then | ||
855 | continue | ||
856 | fi | ||
857 | initramfsBaseName=$imageType-${INITRAMFS_NAME} | 845 | initramfsBaseName=$imageType-${INITRAMFS_NAME} |
858 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfsBaseName${KERNEL_IMAGE_BIN_EXT} | 846 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfsBaseName${KERNEL_IMAGE_BIN_EXT} |
859 | if [ -n "${INITRAMFS_LINK_NAME}" ] ; then | 847 | if [ -n "${INITRAMFS_LINK_NAME}" ] ; then |