diff options
| author | Richard Purdie <rpurdie@linux.intel.com> | 2010-03-25 11:44:25 +0000 |
|---|---|---|
| committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-03-25 11:44:25 +0000 |
| commit | 027c1678789dd6d04243bec23a9a91975b4e4a70 (patch) | |
| tree | 17fb08ceea546b627c69d42625290667b27be6f0 /meta | |
| parent | f30bf93e14868e405999335d3db5af9e23a55425 (diff) | |
| download | poky-027c1678789dd6d04243bec23a9a91975b4e4a70.tar.gz | |
boot-directdisk.bbclass: Add direct disk image creation class
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/classes/boot-directdisk.bbclass | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass new file mode 100644 index 0000000000..f4abae991b --- /dev/null +++ b/meta/classes/boot-directdisk.bbclass | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | # boot-directdisk.bbclass | ||
| 2 | # (loosly based off bootimg.bbclass Copyright (C) 2004, Advanced Micro Devices, Inc.) | ||
| 3 | # | ||
| 4 | # Create an image which can be placed directly onto a harddisk using dd and then | ||
| 5 | # booted. | ||
| 6 | # | ||
| 7 | # This uses syslinux. extlinux would have been nice but required the ext2/3 | ||
| 8 | # partition to be mounted. grub requires to run itself as part of the install | ||
| 9 | # process. | ||
| 10 | # | ||
| 11 | # The end result is a 512 boot sector populated with an MBR and partition table | ||
| 12 | # followed by an msdos fat16 partition containing syslinux and a linux kernel | ||
| 13 | # completed by the ext2/3 rootfs. | ||
| 14 | # | ||
| 15 | # We have to push the msdos parition table size > 16MB so fat 16 is used as parted | ||
| 16 | # won't touch fat12 partitions. | ||
| 17 | |||
| 18 | # External variables needed | ||
| 19 | |||
| 20 | # ${ROOTFS} - the rootfs image to incorporate | ||
| 21 | |||
| 22 | do_bootdirectdisk[depends] += "dosfstools-native:do_populate_sysroot \ | ||
| 23 | syslinux:do_populate_sysroot \ | ||
| 24 | syslinux-installer-native:do_populate_sysroot" | ||
| 25 | |||
| 26 | PACKAGES = " " | ||
| 27 | EXCLUDE_FROM_WORLD = "1" | ||
| 28 | |||
| 29 | HDDDIR = "${S}/hdd/boot" | ||
| 30 | HDDIMG = "${S}/hdd.image" | ||
| 31 | |||
| 32 | BOOTDD_VOLUME_ID ?= "boot" | ||
| 33 | BOOTDD_EXTRA_SPACE ?= "16384" | ||
| 34 | |||
| 35 | # Get the build_syslinux_cfg() function from the syslinux class | ||
| 36 | |||
| 37 | AUTO_SYSLINUXCFG = "1" | ||
| 38 | LABELS = "boot" | ||
| 39 | APPEND = "root=/dev/sda2" | ||
| 40 | TIMEOUT = "10" | ||
| 41 | SYSLINUXCFG = "${HDDDIR}/syslinux.cfg" | ||
| 42 | SYSLINUXMENU = "${HDDDIR}/menu" | ||
| 43 | |||
| 44 | inherit syslinux | ||
| 45 | |||
| 46 | build_boot_dd() { | ||
| 47 | IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect | ||
| 48 | |||
| 49 | install -d ${HDDDIR} | ||
| 50 | install -m 0644 ${STAGING_DIR}/${MACHINE}${HOST_VENDOR}-${HOST_OS}/kernel/bzImage ${HDDDIR}/vmlinuz | ||
| 51 | install -m 444 ${STAGING_DATADIR}/syslinux/ldlinux.sys ${HDDDIR}/ldlinux.sys | ||
| 52 | |||
| 53 | BLOCKS=`du -bks ${HDDDIR} | cut -f 1` | ||
| 54 | SIZE=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}` | ||
| 55 | |||
| 56 | mkdosfs -n ${BOOTDD_VOLUME_ID} -d ${HDDDIR} -C ${HDDIMG} $SIZE | ||
| 57 | syslinux ${HDDIMG} | ||
| 58 | chmod 644 ${HDDIMG} | ||
| 59 | |||
| 60 | ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1` | ||
| 61 | TOTALSIZE=`expr $SIZE + $ROOTFSBLOCKS` | ||
| 62 | END1=`expr $SIZE \* 1024` | ||
| 63 | END2=`expr $END1 + 512` | ||
| 64 | END3=`expr \( $ROOTFSBLOCKS \* 1024 \) + $END1` | ||
| 65 | |||
| 66 | echo $ROOTFSBLOCKS $TOTALSIZE $END1 $END2 $END3 | ||
| 67 | rm -rf $IMAGE | ||
| 68 | dd if=/dev/zero of=$IMAGE bs=1024 seek=$TOTALSIZE count=1 | ||
| 69 | |||
| 70 | parted $IMAGE mklabel msdos | ||
| 71 | parted $IMAGE mkpart primary fat16 0 ${END1}B | ||
| 72 | parted $IMAGE unit B mkpart primary ext2 ${END2}B ${END3}B | ||
| 73 | parted $IMAGE set 1 boot on | ||
| 74 | parted $IMAGE print | ||
| 75 | |||
| 76 | OFFSET=`expr $END2 / 512` | ||
| 77 | dd if=/tmp/mbr.bin of=$IMAGE conv=notrunc | ||
| 78 | dd if=${HDDIMG} of=$IMAGE conv=notrunc seek=1 bs=512 | ||
| 79 | dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512 | ||
| 80 | |||
| 81 | cd ${DEPLOY_DIR_IMAGE} | ||
| 82 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect | ||
| 83 | ln -s ${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect | ||
| 84 | } | ||
| 85 | |||
| 86 | python do_bootdirectdisk() { | ||
| 87 | bb.build.exec_func('build_syslinux_cfg', d) | ||
| 88 | bb.build.exec_func('build_boot_dd', d) | ||
| 89 | } | ||
| 90 | |||
| 91 | addtask bootdirectdisk before do_build | ||
| 92 | do_bootdirectdisk[nostamp] = "1" | ||
