summaryrefslogtreecommitdiffstats
path: root/meta/classes/boot-directdisk.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/boot-directdisk.bbclass')
-rw-r--r--meta/classes/boot-directdisk.bbclass65
1 files changed, 55 insertions, 10 deletions
diff --git a/meta/classes/boot-directdisk.bbclass b/meta/classes/boot-directdisk.bbclass
index 8a55aae6a3..4b9d7bd128 100644
--- a/meta/classes/boot-directdisk.bbclass
+++ b/meta/classes/boot-directdisk.bbclass
@@ -31,6 +31,29 @@ EXCLUDE_FROM_WORLD = "1"
31BOOTDD_VOLUME_ID ?= "boot" 31BOOTDD_VOLUME_ID ?= "boot"
32BOOTDD_EXTRA_SPACE ?= "16384" 32BOOTDD_EXTRA_SPACE ?= "16384"
33 33
34EFI = "${@base_contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
35EFI_CLASS = "${@base_contains("MACHINE_FEATURES", "efi", "grub-efi", "", d)}"
36
37# Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
38# contain "efi". This way legacy is supported by default if neither is
39# specified, maintaining the original behavior.
40def pcbios(d):
41 pcbios = base_contains("MACHINE_FEATURES", "pcbios", "1", "0", d)
42 if pcbios == "0":
43 pcbios = base_contains("MACHINE_FEATURES", "efi", "0", "1", d)
44 return pcbios
45
46def pcbios_class(d):
47 if d.getVar("PCBIOS", True) == "1":
48 return "syslinux"
49 return ""
50
51PCBIOS = "${@pcbios(d)}"
52PCBIOS_CLASS = "${@pcbios_class(d)}"
53
54inherit ${PCBIOS_CLASS}
55inherit ${EFI_CLASS}
56
34# Get the build_syslinux_cfg() function from the syslinux class 57# Get the build_syslinux_cfg() function from the syslinux class
35 58
36AUTO_SYSLINUXCFG = "1" 59AUTO_SYSLINUXCFG = "1"
@@ -38,17 +61,32 @@ DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
38SYSLINUX_ROOT ?= "root=/dev/sda2" 61SYSLINUX_ROOT ?= "root=/dev/sda2"
39SYSLINUX_TIMEOUT ?= "10" 62SYSLINUX_TIMEOUT ?= "10"
40 63
41inherit syslinux 64populate() {
42 65 DEST=$1
66 install -d ${DEST}
67
68 # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use.
69 install -m 0644 ${STAGING_KERNEL_DIR}/bzImage ${DEST}/vmlinuz
70
71 if [ -n "${INITRD}" ] && [ -s "${INITRD}" ]; then
72 install -m 0644 ${INITRD} ${DEST}/initrd
73 fi
74
75}
76
43build_boot_dd() { 77build_boot_dd() {
44 HDDDIR="${S}/hdd/boot" 78 HDDDIR="${S}/hdd/boot"
45 HDDIMG="${S}/hdd.image" 79 HDDIMG="${S}/hdd.image"
46 IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect 80 IMAGE=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect
47 81
48 install -d $HDDDIR 82 populate ${HDDDIR}
49 install -m 0644 ${STAGING_KERNEL_DIR}/bzImage $HDDDIR/vmlinuz 83
50 install -m 0644 ${S}/syslinux.cfg $HDDDIR/syslinux.cfg 84 if [ "${PCBIOS}" = "1" ]; then
51 install -m 444 ${STAGING_DATADIR}/syslinux/ldlinux.sys $HDDDIR/ldlinux.sys 85 syslinux_hddimg_populate
86 fi
87 if [ "${EFI}" = "1" ]; then
88 grubefi_hddimg_populate
89 fi
52 90
53 BLOCKS=`du -bks $HDDDIR | cut -f 1` 91 BLOCKS=`du -bks $HDDDIR | cut -f 1`
54 BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}` 92 BLOCKS=`expr $BLOCKS + ${BOOTDD_EXTRA_SPACE}`
@@ -62,7 +100,9 @@ build_boot_dd() {
62 mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS 100 mkdosfs -n ${BOOTDD_VOLUME_ID} -S 512 -C $HDDIMG $BLOCKS
63 mcopy -i $HDDIMG -s $HDDDIR/* ::/ 101 mcopy -i $HDDIMG -s $HDDDIR/* ::/
64 102
65 syslinux $HDDIMG 103 if [ "${PCBIOS}" = "1" ]; then
104 syslinux_hdddirect_install $HDDIMG
105 fi
66 chmod 644 $HDDIMG 106 chmod 644 $HDDIMG
67 107
68 ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1` 108 ROOTFSBLOCKS=`du -Lbks ${ROOTFS} | cut -f 1`
@@ -85,9 +125,11 @@ build_boot_dd() {
85 dd of=$IMAGE bs=1 seek=440 conv=notrunc 125 dd of=$IMAGE bs=1 seek=440 conv=notrunc
86 126
87 OFFSET=`expr $END2 / 512` 127 OFFSET=`expr $END2 / 512`
88 dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc 128 if [ "${PCBIOS}" = "1" ]; then
129 dd if=${STAGING_DATADIR}/syslinux/mbr.bin of=$IMAGE conv=notrunc
130 fi
89 dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512 131 dd if=$HDDIMG of=$IMAGE conv=notrunc seek=1 bs=512
90 dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512 132 dd if=${ROOTFS} of=$IMAGE conv=notrunc seek=$OFFSET bs=512
91 133
92 cd ${DEPLOY_DIR_IMAGE} 134 cd ${DEPLOY_DIR_IMAGE}
93 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect 135 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hdddirect
@@ -96,7 +138,10 @@ build_boot_dd() {
96 138
97python do_bootdirectdisk() { 139python do_bootdirectdisk() {
98 validate_disk_signature(d) 140 validate_disk_signature(d)
99 bb.build.exec_func('build_syslinux_cfg', d) 141 if d.getVar("PCBIOS", True) == "1":
142 bb.build.exec_func('build_syslinux_cfg', d)
143 if d.getVar("EFI", True) == "1":
144 bb.build.exec_func('build_grub_cfg', d)
100 bb.build.exec_func('build_boot_dd', d) 145 bb.build.exec_func('build_boot_dd', d)
101} 146}
102 147