summaryrefslogtreecommitdiff
path: root/classes/mlinux-image.bbclass
blob: 3f49a949e1128addd0f57075fbbdec1f98de2a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
63
# redefine mkfs.jffs2 command and remove --faketime option so we get non-zero file times
# having file mod times of zero confuses cron
IMAGE_CMD_jffs2 = "mkfs.jffs2 --root=${IMAGE_ROOTFS} --output=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 ${EXTRA_IMAGECMD}"

# set specified root password in image using ROOT_PASSWORD_HASH
mlinux_set_root_password () {
    if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
        sed -i 's%^root:[^:]*:%root:${ROOT_PASSWORD_HASH}:%' ${IMAGE_ROOTFS}/etc/shadow
    elif [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
        sed -i 's%^root:[^:]*:%root:${ROOT_PASSWORD_HASH}:%' ${IMAGE_ROOTFS}/etc/passwd
    fi
}
ROOTFS_POSTPROCESS_COMMAND += "mlinux_set_root_password;"

# generate upgrade.bin files -- provides single file for upgrades
do_firmware () {
    cd ${DEPLOY_DIR_IMAGE}
    rm -f bstrap.bin* uboot.bin* uImage.bin* rootfs.jffs2* model

    cp at91bootstrap_pmecc_padded.bin bstrap.bin
    cp u-boot-${MACHINE}.bin uboot.bin
    cp uImage-${MACHINE}.bin uImage.bin
    cp ${IMAGE_BASENAME}-${MACHINE}.jffs2 rootfs.jffs2

    cat bstrap.bin | md5sum > bstrap.bin.md5
    cat uboot.bin | md5sum > uboot.bin.md5
    cat uImage.bin | md5sum > uImage.bin.md5
    cat rootfs.jffs2 | md5sum > rootfs.jffs2.md5

    echo "${MACHINE}" > model

    tar cvf ${IMAGE_BASENAME}-${MACHINE}-upgrade.bin uImage.bin* rootfs.jffs2* model
    tar cvf ${IMAGE_BASENAME}-${MACHINE}-upgrade-withboot.bin bstrap.bin* uboot.bin* uImage.bin* rootfs.jffs2* model
    rm -f bstrap.bin* uboot.bin* uImage.bin* rootfs.jffs2* model
}

addtask firmware after do_rootfs before do_build

# make links to images in TFTPBOOT_DIR for ease of development
do_tftpboot_links() {
    TFTPBOOT_CLEAN="oe_bootstrap.bin oe_bootstrap_pmecc_padded.bin \
                    oe_u-boot.bin oe_uImage.bin oe_rootfs.jffs2 oe_images oe_upgrade.bin oe_upgrade-withboot.bin"

    if [ -n "${TFTPBOOT_DIR}" ]; then
        install -d ${DEPLOY_DIR_IMAGE}

        for f in ${TFTPBOOT_CLEAN}; do
            rm -f ${TFTPBOOT_DIR}/$f
        done

        ln -nfs ${DEPLOY_DIR_IMAGE}/at91bootstrap.bin ${TFTPBOOT_DIR}/oe_bootstrap.bin
        if [ -f ${DEPLOY_DIR_IMAGE}/at91bootstrap_pmecc_padded.bin ]; then
            ln -nfs ${DEPLOY_DIR_IMAGE}/at91bootstrap_pmecc_padded.bin ${TFTPBOOT_DIR}/oe_bootstrap_pmecc_padded.bin
        fi
        ln -nfs ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.bin ${TFTPBOOT_DIR}/oe_u-boot.bin
        ln -nfs ${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin ${TFTPBOOT_DIR}/oe_uImage.bin
        ln -nfs ${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.jffs2 ${TFTPBOOT_DIR}/oe_rootfs.jffs2
        ln -nfs ${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}-upgrade.bin ${TFTPBOOT_DIR}/oe_upgrade.bin
        ln -nfs ${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}-upgrade-withboot.bin ${TFTPBOOT_DIR}/oe_upgrade-withboot.bin
        ln -nfs ${DEPLOY_DIR_IMAGE} ${TFTPBOOT_DIR}/oe_images
    fi
}
addtask tftpboot_links after do_firmware before do_build