mkbootimg.bbclass 1.87 KB
Newer Older
1
#
2
# This class is used to create Android device compatible boot.img files with kernel and initrd using mkbootimg
3 4
#

5
MKBOOTIMG_ARGS ?= ""
6
KERNEL_OUTPUT ?= "${KERNEL_OUTPUT_DIR}/${KERNEL_IMAGETYPE}"
7

8
do_compile[depends] += "initramfs-android-image:do_image_complete"
9 10 11
DEPENDS += "mkbootimg-tools-native"

do_compile_append() {
12 13 14 15
    mkbootimg -o ${B}/boot.img \
              --kernel ${KERNEL_OUTPUT}  \
              --ramdisk ${DEPLOY_DIR_IMAGE}/initramfs-android-image-${MACHINE}.cpio.gz \
              ${MKBOOTIMG_ARGS}
16 17 18
}

do_deploy_append() {
19 20 21 22 23 24 25 26
    # We're probably interested only in zImage KERNEL_IMAGETYPE, but keep
    # the for loop for consistency with other bbclasses
    for type in ${KERNEL_IMAGETYPES} ; do
        base_name=${type}-${KERNEL_IMAGE_BASE_NAME}
        symlink_name=${type}-${KERNEL_IMAGE_SYMLINK_NAME}
        cp ${B}/boot.img ${DEPLOYDIR}/${base_name}.fastboot
        ln -sf ${base_name}.fastboot ${DEPLOYDIR}/${symlink_name}.fastboot
    done
27 28
}

29 30 31 32 33 34 35
# Update mechanism

do_install_append() {
    install -d ${D}/${KERNEL_IMAGEDEST}
    install -m 0644 ${B}/boot.img ${D}/${KERNEL_IMAGEDEST}
}

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
pkg_postinst_kernel-image_append () {
    if [ x"$D" = "x" ] ; then
        if [ ! -e /boot/boot.img ] ; then
            # if the boot image is not available here something went wrong and we don't
            # continue with anything that can be dangerous
            exit 1
        fi

        BOOT_PARTITION_NAMES="LNX boot KERNEL"
        for i in $BOOT_PARTITION_NAMES; do
            path=$(find /dev -name "*$i*"|grep disk| head -n 1)
            [ -n "$path" ] && break
        done

        if [ -z "$path" ] ; then
            echo "Boot partition does not exist!"
            exit 1
        fi

        echo "Flashing the new kernel /boot/boot.img to $path"
        dd if=/boot/boot.img of=$path
    else
        exit 1
    fi
}

FILES_kernel-image += "/${KERNEL_IMAGEDEST}/boot.img"