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

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

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

do_compile_append() {
    cd ${B}
    cp ${WORKDIR}/img_info .
    sed -i "s@%%KERNEL%%@${B}/${KERNEL_OUTPUT}@" img_info
14
    sed -i "s@%%KERNEL_SIZE%%@$(stat --printf="%s" ${B}/${KERNEL_OUTPUT})@" img_info
15
    sed -i "s@%%RAMDISK%%@${DEPLOY_DIR_IMAGE}/initramfs-android-image-${MACHINE}.cpio.gz@" img_info
16
    sed -i "s@%%RAMDISK_SIZE%%@$(stat --printf="%s" ${DEPLOY_DIR_IMAGE}/initramfs-android-image-${MACHINE}.cpio.gz)@" img_info
17
    mkboot . boot.img || { echo "mkboot failed"; exit 1; }
18 19 20
}

do_deploy_append() {
21 22 23 24 25 26 27 28
    # 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
29 30
}

31 32 33 34 35 36 37
# Update mechanism

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

38 39 40 41 42 43
pkg_postinst_ontarget_${KERNEL_PACKAGE_NAME}-image_append () {
    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
44

45 46 47 48 49
    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
50

51 52
    if [ -z "$path" ] ; then
        echo "Boot partition does not exist!"
53 54
        exit 1
    fi
55 56 57

    echo "Flashing the new kernel /boot/boot.img to $path"
    dd if=/boot/boot.img of=$path
58 59
}

60
FILES_${KERNEL_PACKAGE_NAME}-image += "/${KERNEL_IMAGEDEST}/boot.img"