Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit linux-kernel-base kernel-module-split |
| 2 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 3 | COMPATIBLE_HOST = ".*-linux" |
| 4 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5 | KERNEL_PACKAGE_NAME ??= "kernel" |
| 6 | KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }" |
| 7 | |
| 8 | PROVIDES += "${@ "virtual/kernel" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else "" }" |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 9 | DEPENDS += "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}gcc kmod-native bc-native bison-native" |
| 10 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lzo", "lzop-native", "", d)}" |
| 11 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.lz4", "lz4-native", "", d)}" |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 12 | DEPENDS += "${@bb.utils.contains("INITRAMFS_FSTYPES", "cpio.zst", "zstd-native", "", d)}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 13 | PACKAGE_WRITE_DEPS += "depmodwrapper-cross" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 14 | |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 15 | do_deploy[depends] += "depmodwrapper-cross:do_populate_sysroot gzip-native:do_populate_sysroot" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 16 | do_clean[depends] += "make-mod-scripts:do_clean" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | |
| 18 | CVE_PRODUCT ?= "linux_kernel" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | |
| 20 | S = "${STAGING_KERNEL_DIR}" |
| 21 | B = "${WORKDIR}/build" |
| 22 | KBUILD_OUTPUT = "${B}" |
| 23 | OE_TERMINAL_EXPORTS += "KBUILD_OUTPUT" |
| 24 | |
| 25 | # we include gcc above, we dont need virtual/libc |
| 26 | INHIBIT_DEFAULT_DEPS = "1" |
| 27 | |
| 28 | KERNEL_IMAGETYPE ?= "zImage" |
| 29 | INITRAMFS_IMAGE ?= "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 30 | INITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}-${MACHINE}', ''][d.getVar('INITRAMFS_IMAGE') == '']}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 31 | INITRAMFS_TASK ?= "" |
| 32 | INITRAMFS_IMAGE_BUNDLE ?= "" |
| 33 | |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 34 | # KERNEL_VERSION is extracted from source code. It is evaluated as |
| 35 | # None for the first parsing, since the code has not been fetched. |
| 36 | # After the code is fetched, it will be evaluated as real version |
| 37 | # number and cause kernel to be rebuilt. To avoid this, make |
| 38 | # KERNEL_VERSION_NAME and KERNEL_VERSION_PKG_NAME depend on |
| 39 | # LINUX_VERSION which is a constant. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 40 | KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION') or ""}" |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 41 | KERNEL_VERSION_NAME[vardepvalue] = "${LINUX_VERSION}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 42 | KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 43 | KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}" |
| 44 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | python __anonymous () { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 46 | pn = d.getVar("PN") |
| 47 | kpn = d.getVar("KERNEL_PACKAGE_NAME") |
| 48 | |
| 49 | # XXX Remove this after bug 11905 is resolved |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 50 | # FILES:${KERNEL_PACKAGE_NAME}-dev doesn't expand correctly |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 51 | if kpn == pn: |
| 52 | bb.warn("Some packages (E.g. *-dev) might be missing due to " |
| 53 | "bug 11905 (variable KERNEL_PACKAGE_NAME == PN)") |
| 54 | |
| 55 | # The default kernel recipe builds in a shared location defined by |
| 56 | # bitbake/distro confs: STAGING_KERNEL_DIR and STAGING_KERNEL_BUILDDIR. |
| 57 | # Set these variables to directories under ${WORKDIR} in alternate |
| 58 | # kernel recipes (I.e. where KERNEL_PACKAGE_NAME != kernel) so that they |
| 59 | # may build in parallel with the default kernel without clobbering. |
| 60 | if kpn != "kernel": |
| 61 | workdir = d.getVar("WORKDIR") |
| 62 | sourceDir = os.path.join(workdir, 'kernel-source') |
| 63 | artifactsDir = os.path.join(workdir, 'kernel-build-artifacts') |
| 64 | d.setVar("STAGING_KERNEL_DIR", sourceDir) |
| 65 | d.setVar("STAGING_KERNEL_BUILDDIR", artifactsDir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 67 | # Merge KERNEL_IMAGETYPE and KERNEL_ALT_IMAGETYPE into KERNEL_IMAGETYPES |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 68 | type = d.getVar('KERNEL_IMAGETYPE') or "" |
| 69 | alttype = d.getVar('KERNEL_ALT_IMAGETYPE') or "" |
| 70 | types = d.getVar('KERNEL_IMAGETYPES') or "" |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 71 | if type not in types.split(): |
| 72 | types = (type + ' ' + types).strip() |
| 73 | if alttype not in types.split(): |
| 74 | types = (alttype + ' ' + types).strip() |
| 75 | d.setVar('KERNEL_IMAGETYPES', types) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 76 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 77 | # KERNEL_IMAGETYPES may contain a mixture of image types supported directly |
| 78 | # by the kernel build system and types which are created by post-processing |
| 79 | # the output of the kernel build system (e.g. compressing vmlinux -> |
| 80 | # vmlinux.gz in kernel_do_compile()). |
| 81 | # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported |
| 82 | # directly by the kernel build system. |
| 83 | if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'): |
| 84 | typeformake = set() |
| 85 | for type in types.split(): |
| 86 | if type == 'vmlinux.gz': |
| 87 | type = 'vmlinux' |
| 88 | typeformake.add(type) |
| 89 | |
| 90 | d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', ' '.join(sorted(typeformake))) |
| 91 | |
| 92 | kname = d.getVar('KERNEL_PACKAGE_NAME') or "kernel" |
| 93 | imagedest = d.getVar('KERNEL_IMAGEDEST') |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 94 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 95 | for type in types.split(): |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 96 | if bb.data.inherits_class('nopackages', d): |
| 97 | continue |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 98 | typelower = type.lower() |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 99 | d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower)) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 100 | d.setVar('FILES:' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type) |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 101 | d.appendVar('RDEPENDS:%s-image' % kname, ' %s-image-%s (= ${EXTENDPKGV})' % (kname, typelower)) |
| 102 | splitmods = d.getVar("KERNEL_SPLIT_MODULES") |
| 103 | if splitmods != '1': |
| 104 | d.appendVar('RDEPENDS:%s-image' % kname, ' %s-modules (= ${EXTENDPKGV})' % kname) |
| 105 | d.appendVar('RDEPENDS:%s-image-%s' % (kname, typelower), ' %s-modules-${KERNEL_VERSION_PKG_NAME} (= ${EXTENDPKGV})' % kname) |
| 106 | d.setVar('PKG:%s-modules' % kname, '%s-modules-${KERNEL_VERSION_PKG_NAME}' % kname) |
| 107 | d.appendVar('RPROVIDES:%s-modules' % kname, '%s-modules-${KERNEL_VERSION_PKG_NAME}' % kname) |
| 108 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 109 | d.setVar('PKG:%s-image-%s' % (kname,typelower), '%s-image-%s-${KERNEL_VERSION_PKG_NAME}' % (kname, typelower)) |
| 110 | d.setVar('ALLOW_EMPTY:%s-image-%s' % (kname, typelower), '1') |
| 111 | d.setVar('pkg_postinst:%s-image-%s' % (kname,typelower), """set +e |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 112 | if [ -n "$D" ]; then |
| 113 | ln -sf %s-${KERNEL_VERSION} $D/${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 |
| 114 | else |
| 115 | ln -sf %s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 |
| 116 | if [ $? -ne 0 ]; then |
| 117 | echo "Filesystem on ${KERNEL_IMAGEDEST}/ doesn't support symlinks, falling back to copied image (%s)." |
| 118 | install -m 0644 ${KERNEL_IMAGEDEST}/%s-${KERNEL_VERSION} ${KERNEL_IMAGEDEST}/%s |
| 119 | fi |
| 120 | fi |
| 121 | set -e |
| 122 | """ % (type, type, type, type, type, type, type)) |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 123 | d.setVar('pkg_postrm:%s-image-%s' % (kname,typelower), """set +e |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 124 | if [ -f "${KERNEL_IMAGEDEST}/%s" -o -L "${KERNEL_IMAGEDEST}/%s" ]; then |
| 125 | rm -f ${KERNEL_IMAGEDEST}/%s > /dev/null 2>&1 |
| 126 | fi |
| 127 | set -e |
| 128 | """ % (type, type, type)) |
| 129 | |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 130 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 131 | image = d.getVar('INITRAMFS_IMAGE') |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 132 | # If the INTIRAMFS_IMAGE is set but the INITRAMFS_IMAGE_BUNDLE is set to 0, |
| 133 | # the do_bundle_initramfs does nothing, but the INITRAMFS_IMAGE is built |
| 134 | # standalone for use by wic and other tools. |
| 135 | if image: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 136 | d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 137 | |
| 138 | # NOTE: setting INITRAMFS_TASK is for backward compatibility |
| 139 | # The preferred method is to set INITRAMFS_IMAGE, because |
| 140 | # this INITRAMFS_TASK has circular dependency problems |
| 141 | # if the initramfs requires kernel modules |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 142 | image_task = d.getVar('INITRAMFS_TASK') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 143 | if image_task: |
| 144 | d.appendVarFlag('do_configure', 'depends', ' ${INITRAMFS_TASK}') |
| 145 | } |
| 146 | |
| 147 | # Here we pull in all various kernel image types which we support. |
| 148 | # |
| 149 | # In case you're wondering why kernel.bbclass inherits the other image |
| 150 | # types instead of the other way around, the reason for that is to |
| 151 | # maintain compatibility with various currently existing meta-layers. |
| 152 | # By pulling in the various kernel image types here, we retain the |
| 153 | # original behavior of kernel.bbclass, so no meta-layers should get |
| 154 | # broken. |
| 155 | # |
| 156 | # KERNEL_CLASSES by default pulls in kernel-uimage.bbclass, since this |
| 157 | # used to be the default behavior when only uImage was supported. This |
| 158 | # variable can be appended by users who implement support for new kernel |
| 159 | # image types. |
| 160 | |
| 161 | KERNEL_CLASSES ?= " kernel-uimage " |
| 162 | inherit ${KERNEL_CLASSES} |
| 163 | |
| 164 | # Old style kernels may set ${S} = ${WORKDIR}/git for example |
| 165 | # We need to move these over to STAGING_KERNEL_DIR. We can't just |
| 166 | # create the symlink in advance as the git fetcher can't cope with |
| 167 | # the symlink. |
| 168 | do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}" |
| 169 | do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 170 | python do_symlink_kernsrc () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 171 | s = d.getVar("S") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 172 | if s[-1] == '/': |
| 173 | # drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as directory name and fail |
| 174 | s=s[:-1] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 175 | kernsrc = d.getVar("STAGING_KERNEL_DIR") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | if s != kernsrc: |
| 177 | bb.utils.mkdirhier(kernsrc) |
| 178 | bb.utils.remove(kernsrc, recurse=True) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 179 | if d.getVar("EXTERNALSRC"): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 180 | # With EXTERNALSRC S will not be wiped so we can symlink to it |
| 181 | os.symlink(s, kernsrc) |
| 182 | else: |
| 183 | import shutil |
| 184 | shutil.move(s, kernsrc) |
| 185 | os.symlink(kernsrc, s) |
| 186 | } |
Andrew Geissler | c3d88e4 | 2020-10-02 09:45:00 -0500 | [diff] [blame] | 187 | # do_patch is normally ordered before do_configure, but |
| 188 | # externalsrc.bbclass deletes do_patch, breaking the dependency of |
| 189 | # do_configure on do_symlink_kernsrc. |
| 190 | addtask symlink_kernsrc before do_patch do_configure after do_unpack |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 191 | |
| 192 | inherit kernel-arch deploy |
| 193 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 194 | PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*" |
| 195 | PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-image-.*" |
| 196 | PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-firmware-.*" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | |
| 198 | export OS = "${TARGET_OS}" |
| 199 | export CROSS_COMPILE = "${TARGET_PREFIX}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 200 | export KBUILD_BUILD_VERSION = "1" |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 201 | export KBUILD_BUILD_USER ?= "oe-user" |
| 202 | export KBUILD_BUILD_HOST ?= "oe-host" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 203 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 204 | KERNEL_RELEASE ?= "${KERNEL_VERSION}" |
| 205 | |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 206 | # The directory where built kernel lies in the kernel tree |
| 207 | KERNEL_OUTPUT_DIR ?= "arch/${ARCH}/boot" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 208 | KERNEL_IMAGEDEST ?= "boot" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 209 | |
| 210 | # |
| 211 | # configuration |
| 212 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 213 | export CMDLINE_CONSOLE = "console=${@d.getVar("KERNEL_CONSOLE") or "ttyS0"}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 214 | |
| 215 | KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}" |
| 216 | |
| 217 | KERNEL_LOCALVERSION ?= "" |
| 218 | |
| 219 | # kernels are generally machine specific |
| 220 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 221 | |
| 222 | # U-Boot support |
| 223 | UBOOT_ENTRYPOINT ?= "20008000" |
| 224 | UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}" |
| 225 | |
| 226 | # Some Linux kernel configurations need additional parameters on the command line |
| 227 | KERNEL_EXTRA_ARGS ?= "" |
| 228 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame^] | 229 | EXTRA_OEMAKE = " HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"" |
| 230 | EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}"" |
Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 231 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 232 | KERNEL_ALT_IMAGETYPE ??= "" |
| 233 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 234 | copy_initramfs() { |
| 235 | echo "Copying initramfs into ./usr ..." |
| 236 | # In case the directory is not created yet from the first pass compile: |
| 237 | mkdir -p ${B}/usr |
| 238 | # Find and use the first initramfs image archive type we find |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 239 | rm -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 240 | for img in cpio cpio.gz cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst; do |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 241 | if [ -e "${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img" ]; then |
| 242 | cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 243 | case $img in |
| 244 | *gz) |
| 245 | echo "gzip decompressing image" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 246 | gunzip -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 247 | break |
| 248 | ;; |
| 249 | *lz4) |
| 250 | echo "lz4 decompressing image" |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 251 | lz4 -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 | break |
| 253 | ;; |
| 254 | *lzo) |
| 255 | echo "lzo decompressing image" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 256 | lzop -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 257 | break |
| 258 | ;; |
| 259 | *lzma) |
| 260 | echo "lzma decompressing image" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 261 | lzma -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 262 | break |
| 263 | ;; |
| 264 | *xz) |
| 265 | echo "xz decompressing image" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 266 | xz -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 267 | break |
| 268 | ;; |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 269 | *zst) |
| 270 | echo "zst decompressing image" |
| 271 | zstd -df ${B}/usr/${INITRAMFS_IMAGE_NAME}.$img |
| 272 | break |
| 273 | ;; |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 274 | esac |
Brad Bishop | f8caae3 | 2019-03-25 13:13:56 -0400 | [diff] [blame] | 275 | break |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 276 | fi |
| 277 | done |
Brad Bishop | f8caae3 | 2019-03-25 13:13:56 -0400 | [diff] [blame] | 278 | # Verify that the above loop found a initramfs, fail otherwise |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 279 | [ -f ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio ] && echo "Finished copy of initramfs into ./usr" || die "Could not find any ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE_NAME}.cpio{.gz|.lz4|.lzo|.lzma|.xz|.zst) for bundling; INITRAMFS_IMAGE_NAME might be wrong." |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 280 | } |
| 281 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 282 | do_bundle_initramfs () { |
| 283 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then |
| 284 | echo "Creating a kernel image with a bundled initramfs..." |
| 285 | copy_initramfs |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 286 | # Backing up kernel image relies on its type(regular file or symbolic link) |
| 287 | tmp_path="" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 288 | for imageType in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do |
| 289 | if [ -h ${KERNEL_OUTPUT_DIR}/$imageType ] ; then |
| 290 | linkpath=`readlink -n ${KERNEL_OUTPUT_DIR}/$imageType` |
| 291 | realpath=`readlink -fn ${KERNEL_OUTPUT_DIR}/$imageType` |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 292 | mv -f $realpath $realpath.bak |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 293 | tmp_path=$tmp_path" "$imageType"#"$linkpath"#"$realpath |
| 294 | elif [ -f ${KERNEL_OUTPUT_DIR}/$imageType ]; then |
| 295 | mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.bak |
| 296 | tmp_path=$tmp_path" "$imageType"##" |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 297 | fi |
| 298 | done |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 299 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 300 | kernel_do_compile |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 301 | # Restoring kernel image |
| 302 | for tp in $tmp_path ; do |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 303 | imageType=`echo $tp|cut -d "#" -f 1` |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 304 | linkpath=`echo $tp|cut -d "#" -f 2` |
| 305 | realpath=`echo $tp|cut -d "#" -f 3` |
| 306 | if [ -n "$realpath" ]; then |
| 307 | mv -f $realpath $realpath.initramfs |
| 308 | mv -f $realpath.bak $realpath |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 309 | ln -sf $linkpath.initramfs ${B}/${KERNEL_OUTPUT_DIR}/$imageType.initramfs |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 310 | else |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 311 | mv -f ${KERNEL_OUTPUT_DIR}/$imageType ${KERNEL_OUTPUT_DIR}/$imageType.initramfs |
| 312 | mv -f ${KERNEL_OUTPUT_DIR}/$imageType.bak ${KERNEL_OUTPUT_DIR}/$imageType |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 313 | fi |
| 314 | done |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 315 | fi |
| 316 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 317 | do_bundle_initramfs[dirs] = "${B}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 318 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 319 | python do_devshell:prepend () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 320 | os.environ["LDFLAGS"] = '' |
| 321 | } |
| 322 | |
| 323 | addtask bundle_initramfs after do_install before do_deploy |
| 324 | |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame^] | 325 | KERNEL_DEBUG_TIMESTAMPS ??= "0" |
| 326 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 327 | kernel_do_compile() { |
| 328 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame^] | 329 | if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 330 | # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not |
| 331 | # be set.... |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 332 | if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" = "0" ]; then |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 333 | # The source directory is not necessarily a git repository, so we |
| 334 | # specify the git-dir to ensure that git does not query a |
| 335 | # repository in any parent directory. |
| 336 | SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct 2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"` |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 337 | fi |
| 338 | |
| 339 | ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH` |
| 340 | export KBUILD_BUILD_TIMESTAMP="$ts" |
| 341 | export KCONFIG_NOTIMESTAMP=1 |
| 342 | bbnote "KBUILD_BUILD_TIMESTAMP: $ts" |
| 343 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 344 | # The $use_alternate_initrd is only set from |
| 345 | # do_bundle_initramfs() This variable is specifically for the |
| 346 | # case where we are making a second pass at the kernel |
| 347 | # compilation and we want to force the kernel build to use a |
| 348 | # different initramfs image. The way to do that in the kernel |
| 349 | # is to specify: |
| 350 | # make ...args... CONFIG_INITRAMFS_SOURCE=some_other_initramfs.cpio |
| 351 | if [ "$use_alternate_initrd" = "" ] && [ "${INITRAMFS_TASK}" != "" ] ; then |
| 352 | # The old style way of copying an prebuilt image and building it |
| 353 | # is turned on via INTIRAMFS_TASK != "" |
| 354 | copy_initramfs |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 355 | use_alternate_initrd=CONFIG_INITRAMFS_SOURCE=${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 356 | fi |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 357 | for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do |
Patrick Williams | 93c203f | 2021-10-06 16:15:23 -0500 | [diff] [blame] | 358 | oe_runmake ${typeformake} CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 359 | done |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 360 | # vmlinux.gz is not built by kernel |
| 361 | if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then |
| 362 | mkdir -p "${KERNEL_OUTPUT_DIR}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 363 | gzip -9cn < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 364 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | do_compile_kernelmodules() { |
| 368 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame^] | 369 | if [ "${KERNEL_DEBUG_TIMESTAMPS}" != "1" ]; then |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 370 | # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may not |
| 371 | # be set.... |
| 372 | if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" = "0" ]; then |
| 373 | # The source directory is not necessarily a git repository, so we |
| 374 | # specify the git-dir to ensure that git does not query a |
| 375 | # repository in any parent directory. |
| 376 | SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct 2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"` |
| 377 | fi |
| 378 | |
| 379 | ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH` |
| 380 | export KBUILD_BUILD_TIMESTAMP="$ts" |
| 381 | export KCONFIG_NOTIMESTAMP=1 |
| 382 | bbnote "KBUILD_BUILD_TIMESTAMP: $ts" |
| 383 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 384 | if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then |
Patrick Williams | 93c203f | 2021-10-06 16:15:23 -0500 | [diff] [blame] | 385 | oe_runmake -C ${B} ${PARALLEL_MAKE} modules CC="${KERNEL_CC}" LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 386 | |
| 387 | # Module.symvers gets updated during the |
| 388 | # building of the kernel modules. We need to |
| 389 | # update this in the shared workdir since some |
| 390 | # external kernel modules has a dependency on |
| 391 | # other kernel modules and will look at this |
| 392 | # file to do symbol lookups |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 393 | cp ${B}/Module.symvers ${STAGING_KERNEL_BUILDDIR}/ |
Andrew Geissler | 6ce62a2 | 2020-11-30 19:58:47 -0600 | [diff] [blame] | 394 | # 5.10+ kernels have module.lds that we need to copy for external module builds |
| 395 | if [ -e "${B}/scripts/module.lds" ]; then |
| 396 | install -Dm 0644 ${B}/scripts/module.lds ${STAGING_KERNEL_BUILDDIR}/scripts/module.lds |
| 397 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 398 | else |
| 399 | bbnote "no modules to compile" |
| 400 | fi |
| 401 | } |
| 402 | addtask compile_kernelmodules after do_compile before do_strip |
| 403 | |
| 404 | kernel_do_install() { |
| 405 | # |
| 406 | # First install the modules |
| 407 | # |
| 408 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE |
| 409 | if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 410 | oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${nonarch_base_libdir}/firmware modules_install |
| 411 | rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build" |
| 412 | rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 413 | # If the kernel/ directory is empty remove it to prevent QA issues |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 414 | rmdir --ignore-fail-on-non-empty "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 415 | else |
| 416 | bbnote "no modules to install" |
| 417 | fi |
| 418 | |
| 419 | # |
| 420 | # Install various kernel output (zImage, map file, config, module support files) |
| 421 | # |
| 422 | install -d ${D}/${KERNEL_IMAGEDEST} |
| 423 | install -d ${D}/boot |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 424 | |
| 425 | # |
| 426 | # When including an initramfs bundle inside a FIT image, the fitImage is created after the install task |
| 427 | # by do_assemble_fitimage_initramfs. |
| 428 | # This happens after the generation of the initramfs bundle (done by do_bundle_initramfs). |
| 429 | # So, at the level of the install task we should not try to install the fitImage. fitImage is still not |
| 430 | # generated yet. |
| 431 | # After the generation of the fitImage, the deploy task copies the fitImage from the build directory to |
| 432 | # the deploy folder. |
| 433 | # |
| 434 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 435 | for imageType in ${KERNEL_IMAGETYPES} ; do |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 436 | if [ $imageType != "fitImage" ] || [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ] ; then |
| 437 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType ${D}/${KERNEL_IMAGEDEST}/$imageType-${KERNEL_VERSION} |
| 438 | fi |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 439 | done |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 440 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 441 | install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} |
| 442 | install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} |
| 443 | install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} |
| 444 | [ -e Module.symvers ] && install -m 0644 Module.symvers ${D}/boot/Module.symvers-${KERNEL_VERSION} |
| 445 | install -d ${D}${sysconfdir}/modules-load.d |
| 446 | install -d ${D}${sysconfdir}/modprobe.d |
| 447 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 448 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 449 | # Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile |
| 450 | do_kernel_version_sanity_check() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 451 | if [ "x${KERNEL_VERSION_SANITY_SKIP}" = "x1" ]; then |
| 452 | exit 0 |
| 453 | fi |
| 454 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 455 | # The Makefile determines the kernel version shown at runtime |
| 456 | # Don't use KERNEL_VERSION because the headers it grabs the version from aren't generated until do_compile |
| 457 | VERSION=$(grep "^VERSION =" ${S}/Makefile | sed s/.*=\ *//) |
| 458 | PATCHLEVEL=$(grep "^PATCHLEVEL =" ${S}/Makefile | sed s/.*=\ *//) |
| 459 | SUBLEVEL=$(grep "^SUBLEVEL =" ${S}/Makefile | sed s/.*=\ *//) |
| 460 | EXTRAVERSION=$(grep "^EXTRAVERSION =" ${S}/Makefile | sed s/.*=\ *//) |
| 461 | |
| 462 | # Build a string for regex and a plain version string |
| 463 | reg="^${VERSION}\.${PATCHLEVEL}" |
| 464 | vers="${VERSION}.${PATCHLEVEL}" |
| 465 | if [ -n "${SUBLEVEL}" ]; then |
| 466 | # Ignoring a SUBLEVEL of zero is fine |
| 467 | if [ "${SUBLEVEL}" = "0" ]; then |
| 468 | reg="${reg}(\.${SUBLEVEL})?" |
| 469 | else |
| 470 | reg="${reg}\.${SUBLEVEL}" |
| 471 | vers="${vers}.${SUBLEVEL}" |
| 472 | fi |
| 473 | fi |
| 474 | vers="${vers}${EXTRAVERSION}" |
| 475 | reg="${reg}${EXTRAVERSION}" |
| 476 | |
| 477 | if [ -z `echo ${PV} | grep -E "${reg}"` ]; then |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 478 | bbfatal "Package Version (${PV}) does not match of kernel being built (${vers}). Please update the PV variable to match the kernel source or set KERNEL_VERSION_SANITY_SKIP=\"1\" in your recipe." |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 479 | fi |
| 480 | exit 0 |
| 481 | } |
| 482 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 483 | addtask shared_workdir after do_compile before do_compile_kernelmodules |
| 484 | addtask shared_workdir_setscene |
| 485 | |
| 486 | do_shared_workdir_setscene () { |
| 487 | exit 1 |
| 488 | } |
| 489 | |
| 490 | emit_depmod_pkgdata() { |
| 491 | # Stash data for depmod |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 492 | install -d ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/ |
| 493 | echo "${KERNEL_VERSION}" > ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/${KERNEL_PACKAGE_NAME}-abiversion |
| 494 | cp ${B}/System.map ${PKGDESTWORK}/${KERNEL_PACKAGE_NAME}-depmod/System.map-${KERNEL_VERSION} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 495 | } |
| 496 | |
| 497 | PACKAGEFUNCS += "emit_depmod_pkgdata" |
| 498 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 499 | do_shared_workdir[cleandirs] += " ${STAGING_KERNEL_BUILDDIR}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 500 | do_shared_workdir () { |
| 501 | cd ${B} |
| 502 | |
| 503 | kerneldir=${STAGING_KERNEL_BUILDDIR} |
| 504 | install -d $kerneldir |
| 505 | |
| 506 | # |
| 507 | # Store the kernel version in sysroots for module-base.bbclass |
| 508 | # |
| 509 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 510 | echo "${KERNEL_VERSION}" > $kerneldir/${KERNEL_PACKAGE_NAME}-abiversion |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 511 | |
| 512 | # Copy files required for module builds |
| 513 | cp System.map $kerneldir/System.map-${KERNEL_VERSION} |
Andrew Geissler | 475cb72 | 2020-07-10 16:00:51 -0500 | [diff] [blame] | 514 | [ -e Module.symvers ] && cp Module.symvers $kerneldir/ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 515 | cp .config $kerneldir/ |
| 516 | mkdir -p $kerneldir/include/config |
| 517 | cp include/config/kernel.release $kerneldir/include/config/kernel.release |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 518 | if [ -e certs/signing_key.x509 ]; then |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 519 | # The signing_key.* files are stored in the certs/ dir in |
| 520 | # newer Linux kernels |
| 521 | mkdir -p $kerneldir/certs |
| 522 | cp certs/signing_key.* $kerneldir/certs/ |
| 523 | elif [ -e signing_key.priv ]; then |
| 524 | cp signing_key.* $kerneldir/ |
| 525 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 526 | |
| 527 | # We can also copy over all the generated files and avoid special cases |
| 528 | # like version.h, but we've opted to keep this small until file creep starts |
| 529 | # to happen |
| 530 | if [ -e include/linux/version.h ]; then |
| 531 | mkdir -p $kerneldir/include/linux |
| 532 | cp include/linux/version.h $kerneldir/include/linux/version.h |
| 533 | fi |
| 534 | |
| 535 | # As of Linux kernel version 3.0.1, the clean target removes |
| 536 | # arch/powerpc/lib/crtsavres.o which is present in |
| 537 | # KBUILD_LDFLAGS_MODULE, making it required to build external modules. |
| 538 | if [ ${ARCH} = "powerpc" ]; then |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 539 | if [ -e arch/powerpc/lib/crtsavres.o ]; then |
| 540 | mkdir -p $kerneldir/arch/powerpc/lib/ |
| 541 | cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o |
| 542 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 543 | fi |
| 544 | |
| 545 | if [ -d include/generated ]; then |
| 546 | mkdir -p $kerneldir/include/generated/ |
| 547 | cp -fR include/generated/* $kerneldir/include/generated/ |
| 548 | fi |
| 549 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 550 | if [ -d arch/${ARCH}/include/generated ]; then |
| 551 | mkdir -p $kerneldir/arch/${ARCH}/include/generated/ |
| 552 | cp -fR arch/${ARCH}/include/generated/* $kerneldir/arch/${ARCH}/include/generated/ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 553 | fi |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 554 | |
| 555 | if (grep -q -i -e '^CONFIG_UNWINDER_ORC=y$' $kerneldir/.config); then |
| 556 | # With CONFIG_UNWINDER_ORC (the default in 4.14), objtool is required for |
| 557 | # out-of-tree modules to be able to generate object files. |
| 558 | if [ -x tools/objtool/objtool ]; then |
| 559 | mkdir -p ${kerneldir}/tools/objtool |
| 560 | cp tools/objtool/objtool ${kerneldir}/tools/objtool/ |
| 561 | fi |
| 562 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | # We don't need to stage anything, not the modules/firmware since those would clash with linux-firmware |
| 566 | sysroot_stage_all () { |
| 567 | : |
| 568 | } |
| 569 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 570 | KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} CC="${KERNEL_CC}" LD="${KERNEL_LD}" O=${B} olddefconfig || oe_runmake -C ${S} O=${B} CC="${KERNEL_CC}" LD="${KERNEL_LD}" oldnoconfig" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 571 | |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 572 | python check_oldest_kernel() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 573 | oldest_kernel = d.getVar('OLDEST_KERNEL') |
| 574 | kernel_version = d.getVar('KERNEL_VERSION') |
| 575 | tclibc = d.getVar('TCLIBC') |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 576 | if tclibc == 'glibc': |
| 577 | kernel_version = kernel_version.split('-', 1)[0] |
| 578 | if oldest_kernel and kernel_version: |
| 579 | if bb.utils.vercmp_string(kernel_version, oldest_kernel) < 0: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 580 | bb.warn('%s: OLDEST_KERNEL is "%s" but the version of the kernel you are building is "%s" - therefore %s as built may not be compatible with this kernel. Either set OLDEST_KERNEL to an older version, or build a newer kernel.' % (d.getVar('PN'), oldest_kernel, kernel_version, tclibc)) |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | check_oldest_kernel[vardepsexclude] += "OLDEST_KERNEL KERNEL_VERSION" |
| 584 | do_configure[prefuncs] += "check_oldest_kernel" |
| 585 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 586 | kernel_do_configure() { |
| 587 | # fixes extra + in /lib/modules/2.6.37+ |
| 588 | # $ scripts/setlocalversion . => + |
| 589 | # $ make kernelversion => 2.6.37 |
| 590 | # $ make kernelrelease => 2.6.37+ |
| 591 | touch ${B}/.scmversion ${S}/.scmversion |
| 592 | |
| 593 | if [ "${S}" != "${B}" ] && [ -f "${S}/.config" ] && [ ! -f "${B}/.config" ]; then |
| 594 | mv "${S}/.config" "${B}/.config" |
| 595 | fi |
| 596 | |
| 597 | # Copy defconfig to .config if .config does not exist. This allows |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 598 | # recipes to manage the .config themselves in do_configure:prepend(). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 599 | if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then |
| 600 | cp "${WORKDIR}/defconfig" "${B}/.config" |
| 601 | fi |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 602 | |
| 603 | ${KERNEL_CONFIG_COMMAND} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | do_savedefconfig() { |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 607 | bbplain "Saving defconfig to:\n${B}/defconfig" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 608 | oe_runmake -C ${B} savedefconfig |
| 609 | } |
| 610 | do_savedefconfig[nostamp] = "1" |
| 611 | addtask savedefconfig after do_configure |
| 612 | |
| 613 | inherit cml1 |
| 614 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 615 | KCONFIG_CONFIG_COMMAND:append = " LD='${KERNEL_LD}' HOSTLDFLAGS='${BUILD_LDFLAGS}'" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 616 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 617 | EXPORT_FUNCTIONS do_compile do_install do_configure |
| 618 | |
| 619 | # kernel-base becomes kernel-${KERNEL_VERSION} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 620 | # kernel-image becomes kernel-image-${KERNEL_VERSION} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 621 | PACKAGES = "${KERNEL_PACKAGE_NAME} ${KERNEL_PACKAGE_NAME}-base ${KERNEL_PACKAGE_NAME}-vmlinux ${KERNEL_PACKAGE_NAME}-image ${KERNEL_PACKAGE_NAME}-dev ${KERNEL_PACKAGE_NAME}-modules" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 622 | FILES:${PN} = "" |
| 623 | FILES:${KERNEL_PACKAGE_NAME}-base = "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.order ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/modules.builtin.modinfo" |
| 624 | FILES:${KERNEL_PACKAGE_NAME}-image = "" |
| 625 | FILES:${KERNEL_PACKAGE_NAME}-dev = "/boot/System.map* /boot/Module.symvers* /boot/config* ${KERNEL_SRC_PATH} ${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build" |
| 626 | FILES:${KERNEL_PACKAGE_NAME}-vmlinux = "/boot/vmlinux-${KERNEL_VERSION_NAME}" |
| 627 | FILES:${KERNEL_PACKAGE_NAME}-modules = "" |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 628 | RDEPENDS:${KERNEL_PACKAGE_NAME} = "${KERNEL_PACKAGE_NAME}-base (= ${EXTENDPKGV})" |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 629 | # Allow machines to override this dependency if kernel image files are |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 630 | # not wanted in images as standard |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 631 | RDEPENDS:${KERNEL_PACKAGE_NAME}-base ?= "${KERNEL_PACKAGE_NAME}-image (= ${EXTENDPKGV})" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 632 | PKG:${KERNEL_PACKAGE_NAME}-image = "${KERNEL_PACKAGE_NAME}-image-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 633 | RDEPENDS:${KERNEL_PACKAGE_NAME}-image += "${@oe.utils.conditional('KERNEL_IMAGETYPE', 'vmlinux', '${KERNEL_PACKAGE_NAME}-vmlinux (= ${EXTENDPKGV})', '', d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 634 | PKG:${KERNEL_PACKAGE_NAME}-base = "${KERNEL_PACKAGE_NAME}-${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}" |
| 635 | RPROVIDES:${KERNEL_PACKAGE_NAME}-base += "${KERNEL_PACKAGE_NAME}-${KERNEL_VERSION}" |
| 636 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME} = "1" |
| 637 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-base = "1" |
| 638 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-image = "1" |
| 639 | ALLOW_EMPTY:${KERNEL_PACKAGE_NAME}-modules = "1" |
| 640 | DESCRIPTION:${KERNEL_PACKAGE_NAME}-modules = "Kernel modules meta package" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 641 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 642 | pkg_postinst:${KERNEL_PACKAGE_NAME}-base () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 643 | if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then |
| 644 | mkdir -p $D/lib/modules/${KERNEL_VERSION} |
| 645 | fi |
| 646 | if [ -n "$D" ]; then |
| 647 | depmodwrapper -a -b $D ${KERNEL_VERSION} |
| 648 | else |
| 649 | depmod -a ${KERNEL_VERSION} |
| 650 | fi |
| 651 | } |
| 652 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 653 | PACKAGESPLITFUNCS:prepend = "split_kernel_packages " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 654 | |
| 655 | python split_kernel_packages () { |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 656 | do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex=r'^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | # Many scripts want to look in arch/$arch/boot for the bootable |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 660 | # image. This poses a problem for vmlinux and vmlinuz based |
| 661 | # booting. This task arranges to have vmlinux and vmlinuz appear |
| 662 | # in the normalized directory location. |
| 663 | do_kernel_link_images() { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 664 | if [ ! -d "${B}/arch/${ARCH}/boot" ]; then |
| 665 | mkdir ${B}/arch/${ARCH}/boot |
| 666 | fi |
| 667 | cd ${B}/arch/${ARCH}/boot |
| 668 | ln -sf ../../../vmlinux |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 669 | if [ -f ../../../vmlinuz ]; then |
| 670 | ln -sf ../../../vmlinuz |
| 671 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 672 | if [ -f ../../../vmlinuz.bin ]; then |
| 673 | ln -sf ../../../vmlinuz.bin |
| 674 | fi |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 675 | if [ -f ../../../vmlinux.64 ]; then |
| 676 | ln -sf ../../../vmlinux.64 |
| 677 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 678 | } |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 679 | addtask kernel_link_images after do_compile before do_strip |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 680 | |
| 681 | do_strip() { |
| 682 | if [ -n "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" ]; then |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 683 | if ! (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux"); then |
| 684 | bbwarn "image type(s) will not be stripped (not supported): ${KERNEL_IMAGETYPES}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 685 | return |
| 686 | fi |
| 687 | |
| 688 | cd ${B} |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 689 | headers=`"$CROSS_COMPILE"readelf -S ${KERNEL_OUTPUT_DIR}/vmlinux | \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 690 | grep "^ \{1,\}\[[0-9 ]\{1,\}\] [^ ]" | \ |
| 691 | sed "s/^ \{1,\}\[[0-9 ]\{1,\}\] //" | \ |
| 692 | gawk '{print $1}'` |
| 693 | |
| 694 | for str in ${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}; do { |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 695 | if ! (echo "$headers" | grep -q "^$str$"); then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 696 | bbwarn "Section not found: $str"; |
| 697 | fi |
| 698 | |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 699 | "$CROSS_COMPILE"strip -s -R $str ${KERNEL_OUTPUT_DIR}/vmlinux |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 700 | }; done |
| 701 | |
| 702 | bbnote "KERNEL_IMAGE_STRIP_EXTRA_SECTIONS is set, stripping sections:" \ |
| 703 | "${KERNEL_IMAGE_STRIP_EXTRA_SECTIONS}" |
| 704 | fi; |
| 705 | } |
| 706 | do_strip[dirs] = "${B}" |
| 707 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 708 | addtask strip before do_sizecheck after do_kernel_link_images |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 709 | |
| 710 | # Support checking the kernel size since some kernels need to reside in partitions |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 711 | # with a fixed length or there is a limit in transferring the kernel to memory. |
| 712 | # If more than one image type is enabled, warn on any that don't fit but only fail |
| 713 | # if none fit. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 714 | do_sizecheck() { |
| 715 | if [ ! -z "${KERNEL_IMAGE_MAXSIZE}" ]; then |
| 716 | invalid=`echo ${KERNEL_IMAGE_MAXSIZE} | sed 's/[0-9]//g'` |
| 717 | if [ -n "$invalid" ]; then |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 718 | die "Invalid KERNEL_IMAGE_MAXSIZE: ${KERNEL_IMAGE_MAXSIZE}, should be an integer (The unit is Kbytes)" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 719 | fi |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 720 | at_least_one_fits= |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 721 | for imageType in ${KERNEL_IMAGETYPES} ; do |
| 722 | size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$imageType | awk '{print $1}'` |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 723 | if [ $size -gt ${KERNEL_IMAGE_MAXSIZE} ]; then |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 724 | bbwarn "This kernel $imageType (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device." |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 725 | else |
| 726 | at_least_one_fits=y |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 727 | fi |
| 728 | done |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 729 | if [ -z "$at_least_one_fits" ]; then |
| 730 | die "All kernel images are too big for your device. Please reduce the size of the kernel by making more of it modular." |
| 731 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 732 | fi |
| 733 | } |
| 734 | do_sizecheck[dirs] = "${B}" |
| 735 | |
| 736 | addtask sizecheck before do_install after do_strip |
| 737 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 738 | inherit kernel-artifact-names |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 739 | |
| 740 | kernel_do_deploy() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 741 | deployDir="${DEPLOYDIR}" |
| 742 | if [ -n "${KERNEL_DEPLOYSUBDIR}" ]; then |
| 743 | deployDir="${DEPLOYDIR}/${KERNEL_DEPLOYSUBDIR}" |
| 744 | mkdir "$deployDir" |
| 745 | fi |
| 746 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 747 | for imageType in ${KERNEL_IMAGETYPES} ; do |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 748 | baseName=$imageType-${KERNEL_IMAGE_NAME} |
| 749 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType $deployDir/$baseName.bin |
| 750 | ln -sf $baseName.bin $deployDir/$imageType-${KERNEL_IMAGE_LINK_NAME}.bin |
| 751 | ln -sf $baseName.bin $deployDir/$imageType |
He Zhe | fe76b1e | 2016-05-25 04:47:16 -0400 | [diff] [blame] | 752 | done |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 753 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 754 | if [ ${MODULE_TARBALL_DEPLOY} = "1" ] && (grep -q -i -e '^CONFIG_MODULES=y$' .config); then |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 755 | mkdir -p ${D}${root_prefix}/lib |
Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 756 | if [ -n "${SOURCE_DATE_EPOCH}" ]; then |
| 757 | TAR_ARGS="--sort=name --clamp-mtime --mtime=@${SOURCE_DATE_EPOCH}" |
| 758 | else |
| 759 | TAR_ARGS="" |
| 760 | fi |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 761 | TAR_ARGS="$TAR_ARGS --owner=0 --group=0" |
Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 762 | tar $TAR_ARGS -cv -C ${D}${root_prefix} lib | gzip -9n > $deployDir/modules-${MODULE_TARBALL_NAME}.tgz |
| 763 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 764 | ln -sf modules-${MODULE_TARBALL_NAME}.tgz $deployDir/modules-${MODULE_TARBALL_LINK_NAME}.tgz |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 765 | fi |
| 766 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 767 | if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 768 | for imageType in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 769 | if [ "$imageType" = "fitImage" ] ; then |
| 770 | continue |
| 771 | fi |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 772 | initramfsBaseName=$imageType-${INITRAMFS_NAME} |
| 773 | install -m 0644 ${KERNEL_OUTPUT_DIR}/$imageType.initramfs $deployDir/$initramfsBaseName.bin |
| 774 | ln -sf $initramfsBaseName.bin $deployDir/$imageType-${INITRAMFS_LINK_NAME}.bin |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 775 | done |
| 776 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 777 | } |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 778 | |
| 779 | # We deploy to filenames that include PKGV and PKGR, read the saved data to |
| 780 | # ensure we get the right values for both |
| 781 | do_deploy[prefuncs] += "read_subpackage_metadata" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 782 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 783 | addtask deploy after do_populate_sysroot do_packagedata |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 784 | |
| 785 | EXPORT_FUNCTIONS do_deploy |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 786 | |
| 787 | # Add using Device Tree support |
| 788 | inherit kernel-devicetree |