nwl-image.bbclass: add fitimage generation support
This commit is contained in:
parent
0cd9abc5a8
commit
0d2952d9e0
|
|
@ -0,0 +1,85 @@
|
|||
# This class generate a fitimage
|
||||
# This class should ihnerited after the nwl-image class
|
||||
|
||||
# Configuration:
|
||||
# ==============================================================================
|
||||
|
||||
# Set the initramfs to the current image being build by default
|
||||
# This can be overriden if another image as to be included
|
||||
INITRAMFS_IMAGE ??= "${IMAGE_BASENAME}"
|
||||
INITRAMFS_IMAGE_NAME ??= "${INITRAMFS_IMAGE}-${MACHINE}"
|
||||
|
||||
# Glue for kernel-fitimage
|
||||
# ==============================================================================
|
||||
|
||||
kernel_do_deploy () {
|
||||
# The kernel-fitimage class appends the deployment to this task. We just have to provide the task.
|
||||
deployDir=${DEPLOY_DIR_IMAGE}
|
||||
}
|
||||
|
||||
inherit kernel-fitimage
|
||||
inherit kernel-arch
|
||||
|
||||
do_assemble_fitimage:prepend() {
|
||||
install -d ${S}/arch/${ARCH}/boot/
|
||||
install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${KERNEL_IMAGE_LINK_NAME}${KERNEL_IMAGE_BIN_EXT} ${S}/arch/${ARCH}/boot/vmlinuz.bin
|
||||
|
||||
for DTB in ${KERNEL_DEVICETREE}; do
|
||||
# We have to watch out for when the device-tree is located in its own subdirectory in the kernel sources.
|
||||
# DTB_SUBDIR will contain this directory.
|
||||
DTB_DEPLOY=`basename ${DTB}`
|
||||
DTB_SUBDIR=`dirname ${DTB}`
|
||||
install -d arch/${ARCH}/boot/${DTB_SUBDIR}
|
||||
install -m 0644 ${DEPLOY_DIR_IMAGE}/${DTB_DEPLOY} ${S}/arch/${ARCH}/boot/${DTB}
|
||||
done
|
||||
}
|
||||
|
||||
KERNEL_CLASSES = "kernel-fitimage"
|
||||
KERNEL_IMAGETYPES += "fitImage"
|
||||
|
||||
# We want the initramfs inside the fitimage as a separate part and not bundle
|
||||
# inside the kernel part
|
||||
INITRAMFS_IMAGE_BUNDLE = "0"
|
||||
|
||||
|
||||
do_image_fitimage() {
|
||||
kernel_do_deploy
|
||||
}
|
||||
|
||||
|
||||
addtask image_fitimage after do_image before do_image_complete
|
||||
addtask assemble_fitimage_initramfs after do_image before do_image_fitimage
|
||||
addtask assemble_fitimage after do_image before do_image_fitimage
|
||||
|
||||
do_assemble_fitimage_initramfs[depends] += "virtual/kernel:do_deploy virtual/${TARGET_PREFIX}binutils:do_populate_sysroot"
|
||||
do_assemble_fitimage[depends] += "virtual/kernel:do_deploy virtual/${TARGET_PREFIX}binutils:do_populate_sysroot"
|
||||
|
||||
|
||||
# a fitimage image can be embedded into a WIC image
|
||||
do_image_wic[recrdeptask] += "do_image_fitimage"
|
||||
|
||||
python __anonymous () {
|
||||
initramfs = d.getVar('INITRAMFS_IMAGE')
|
||||
image = d.getVar('IMAGE_BASENAME')
|
||||
|
||||
if image == initramfs:
|
||||
|
||||
# If the initramfs is the same as the image being build, we should
|
||||
# not depend on do_image_complete but on do_image_${FSTYPE_WITHOUT_EXT}
|
||||
fstype = d.getVar('IMAGE_FSTYPES').split('.')[0]
|
||||
d.appendVarFlag('do_assemble_fitimage_initramfs', 'recrdeptask', f' do_image_{fstype}')
|
||||
depends = d.getVarFlag('do_assemble_fitimage_initramfs', 'depends')
|
||||
depends = depends.replace(f'{initramfs}:do_image_complete', '')
|
||||
d.setVarFlag('do_assemble_fitimage_initramfs', 'depends', depends)
|
||||
|
||||
|
||||
# If the initramfs is the same as the image being build, it should
|
||||
# come from IMGDEPLOYDIR instead of DEPLOY_DIR_IMAGE
|
||||
# This is done by using an ugly monkey patching of the
|
||||
# fitimage_assemble function
|
||||
imgdeploydir = d.getVar('IMGDEPLOYDIR')
|
||||
deploy_dir_image = d.getVar('DEPLOY_DIR_IMAGE')
|
||||
task = d.getVar('fitimage_assemble')
|
||||
task = task.replace(f'initramfs_path="{deploy_dir_image}', f'initramfs_path="{imgdeploydir}')
|
||||
d.setVar('fitimage_assemble', task)
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
SUMMARY = "Create a fitimage with included kernel, dtb and ramdisk"
|
||||
MAINTAINER = "Lucien Müller <lucien.mueller@netmodule.com>"
|
||||
LICENSE = "CLOSED"
|
||||
|
||||
inherit kernel-fitimage
|
||||
inherit kernel-arch
|
||||
inherit deploy
|
||||
|
||||
|
||||
PACKAGE_ARCH = "${MACHINE_ARCH}"
|
||||
|
||||
KERNEL_CLASSES = "kernel-fitimage"
|
||||
KERNEL_IMAGETYPES += "fitImage"
|
||||
|
||||
addtask assemble_fitimage_initramfs before do_install after do_compile
|
||||
addtask do_deploy after assemble_fitimage_initramfs
|
||||
|
||||
do_configure[depends] += "virtual/kernel:do_deploy"
|
||||
do_bundle_initramfs[depends] += "${INITRAMFS_IMAGE}:do_image_complete"
|
||||
do_deploy[depends] += "${PN}:do_assemble_fitimage"
|
||||
|
||||
INITRAMFS_IMAGE = "nwl-ramdisk-minimal"
|
||||
INITRAMFS_IMAGE_NAME = "${INITRAMFS_IMAGE}-${MACHINE}"
|
||||
INITRAMFS_IMAGE_BUNDLE = "0"
|
||||
|
||||
do_configure:prepend () {
|
||||
install -d ${S}/arch/${ARCH}/boot/
|
||||
for DTB in ${KERNEL_DEVICETREE}; do
|
||||
# We have to watch out for when the device-tree is located in its own subdirectory in the kernel sources.
|
||||
# DTB_SUBDIR will contain this directory.
|
||||
DTB_DEPLOY=`basename ${DTB}`
|
||||
DTB_SUBDIR=`dirname ${DTB}`
|
||||
install -d arch/${ARCH}/boot/${DTB_SUBDIR}
|
||||
install -m 0644 ${DEPLOY_DIR_IMAGE}/${DTB_DEPLOY} arch/${ARCH}/boot/${DTB}
|
||||
done
|
||||
install -m 0644 ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${KERNEL_IMAGE_LINK_NAME}.bin arch/${ARCH}/boot/vmlinuz.bin
|
||||
}
|
||||
|
||||
kernel_do_deploy () {
|
||||
# The kernel-fitimage class appends the deployment to this task. We just have to provide the task.
|
||||
}
|
||||
|
||||
do_deploy () {
|
||||
deployDir=${DEPLOY_DIR_IMAGE}
|
||||
kernel_do_deploy
|
||||
}
|
||||
|
||||
|
|
@ -1,17 +1,18 @@
|
|||
SUMMARY = "A minimal ramdisk image."
|
||||
MAINTAINER = "Lucien Müller <lucien.mueller@netmodule.com>"
|
||||
|
||||
COREOS_IMAGE_GENERATE_INSTALLER = "0"
|
||||
COREOS_IMAGE_GENERATE_UKI = "0"
|
||||
COREOS_IMAGE_GENERATE_SWU = "0"
|
||||
|
||||
inherit nwl-image
|
||||
inherit nwl-image-fitimage
|
||||
|
||||
IMAGE_FSTYPES = "cpio.xz"
|
||||
|
||||
# Keep only the minimum packages
|
||||
NO_RECOMMENDATIONS = "1"
|
||||
|
||||
COREOS_IMAGE_GENERATE_INSTALLER = "0"
|
||||
COREOS_IMAGE_GENERATE_UKI = "0"
|
||||
COREOS_IMAGE_GENERATE_SWU = "0"
|
||||
|
||||
IMAGE_INSTALL:append = " \
|
||||
coreutils \
|
||||
ncurses-terminfo-base \
|
||||
|
|
|
|||
Loading…
Reference in New Issue