diff options
author | Darren Hart <dvhart@linux.intel.com> | 2012-02-01 16:15:04 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-02-08 00:50:22 +0000 |
commit | 67cfa7474449987f1f0c5232e19783ee79e3883d (patch) | |
tree | caa97626a856ea434a469c37e340d2ddc4b7499d /meta/classes | |
parent | 50a097be169f4eb0bfbef181c11bd4afe8ad127b (diff) | |
download | poky-67cfa7474449987f1f0c5232e19783ee79e3883d.tar.gz |
bootimg: Use the same OS files for each boot method
Fixes [YOCTO #1951]
The do_bootimg code can generate hybrid efi+pcbios images (syslinux and
grub-efi) to boot on platforms with both EFI and legacy BIOS options. The
current implementation copies the kernel, initrd, and rootfs twice,
unnecessarily bloating the image size. This is an especially egregious bug
on -sato images.
Update the classes to use a common install of the kernel, initrd, and rootfs to
the root of the boot media. Grub-efi, syslinux, and isolinux can all reference
this location explicitly with a leading slash.
Tested with an EFI+PCBIOS image in both EFI and PCBIOS boot modes on two
platforms. No ISO image testing was performed.
(From OE-Core rev: 5209016cf4c4c8f649e37dc8857b3fbcfe8dd8c8)
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/bootimg.bbclass | 31 | ||||
-rw-r--r-- | meta/classes/grub-efi.bbclass | 28 | ||||
-rw-r--r-- | meta/classes/syslinux.bbclass | 34 |
3 files changed, 46 insertions, 47 deletions
diff --git a/meta/classes/bootimg.bbclass b/meta/classes/bootimg.bbclass index a717600cf9..1d1a3d04af 100644 --- a/meta/classes/bootimg.bbclass +++ b/meta/classes/bootimg.bbclass | |||
@@ -8,13 +8,13 @@ | |||
8 | # End result is two things: | 8 | # End result is two things: |
9 | # | 9 | # |
10 | # 1. A .hddimg file which is an msdos filesystem containing syslinux, a kernel, | 10 | # 1. A .hddimg file which is an msdos filesystem containing syslinux, a kernel, |
11 | # an initrd and a rootfs image. These can be written to harddisks directly and | 11 | # an initrd and a rootfs image. These can be written to harddisks directly and |
12 | # also booted on USB flash disks (write them there with dd). | 12 | # also booted on USB flash disks (write them there with dd). |
13 | # | 13 | # |
14 | # 2. A CD .iso image | 14 | # 2. A CD .iso image |
15 | 15 | ||
16 | # Boot process is that the initrd will boot and process which label was selected | 16 | # Boot process is that the initrd will boot and process which label was selected |
17 | # in syslinux. Actions based on the label are then performed (e.g. installing to | 17 | # in syslinux. Actions based on the label are then performed (e.g. installing to |
18 | # an hdd) | 18 | # an hdd) |
19 | 19 | ||
20 | # External variables (also used by syslinux.bbclass) | 20 | # External variables (also used by syslinux.bbclass) |
@@ -29,8 +29,8 @@ do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \ | |||
29 | PACKAGES = " " | 29 | PACKAGES = " " |
30 | EXCLUDE_FROM_WORLD = "1" | 30 | EXCLUDE_FROM_WORLD = "1" |
31 | 31 | ||
32 | HDDDIR = "${S}/hdd/boot" | 32 | HDDDIR = "${S}/hddimg" |
33 | ISODIR = "${S}/cd" | 33 | ISODIR = "${S}/iso" |
34 | 34 | ||
35 | BOOTIMG_VOLUME_ID ?= "boot" | 35 | BOOTIMG_VOLUME_ID ?= "boot" |
36 | BOOTIMG_EXTRA_SPACE ?= "512" | 36 | BOOTIMG_EXTRA_SPACE ?= "512" |
@@ -58,6 +58,22 @@ PCBIOS_CLASS = ${@pcbios_class(d)} | |||
58 | inherit ${PCBIOS_CLASS} | 58 | inherit ${PCBIOS_CLASS} |
59 | inherit ${EFI_CLASS} | 59 | inherit ${EFI_CLASS} |
60 | 60 | ||
61 | populate() { | ||
62 | DEST=$1 | ||
63 | install -d ${DEST} | ||
64 | |||
65 | # Install bzImage, initrd, and rootfs.img in DEST for all loaders to use. | ||
66 | install -m 0644 ${STAGING_DIR_HOST}/kernel/bzImage ${DEST}/vmlinuz | ||
67 | |||
68 | if [ -n "${INITRD}" ] && [ -s "${INITRD}" ]; then | ||
69 | install -m 0644 ${INITRD} ${DEST}/initrd | ||
70 | fi | ||
71 | |||
72 | if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then | ||
73 | install -m 0644 ${ROOTFS} ${DEST}/rootfs.img | ||
74 | fi | ||
75 | |||
76 | } | ||
61 | 77 | ||
62 | build_iso() { | 78 | build_iso() { |
63 | # Only create an ISO if we have an INITRD and NOISO was not set | 79 | # Only create an ISO if we have an INITRD and NOISO was not set |
@@ -66,7 +82,7 @@ build_iso() { | |||
66 | return | 82 | return |
67 | fi | 83 | fi |
68 | 84 | ||
69 | install -d ${ISODIR} | 85 | populate ${ISODIR} |
70 | 86 | ||
71 | if [ "${PCBIOS}" = "1" ]; then | 87 | if [ "${PCBIOS}" = "1" ]; then |
72 | syslinux_iso_populate | 88 | syslinux_iso_populate |
@@ -95,7 +111,8 @@ build_iso() { | |||
95 | build_hddimg() { | 111 | build_hddimg() { |
96 | # Create an HDD image | 112 | # Create an HDD image |
97 | if [ "${NOHDD}" != "1" ] ; then | 113 | if [ "${NOHDD}" != "1" ] ; then |
98 | install -d ${HDDDIR} | 114 | populate ${HDDDIR} |
115 | |||
99 | if [ "${PCBIOS}" = "1" ]; then | 116 | if [ "${PCBIOS}" = "1" ]; then |
100 | syslinux_hddimg_populate | 117 | syslinux_hddimg_populate |
101 | fi | 118 | fi |
diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass index 762322b28e..1efb43b805 100644 --- a/meta/classes/grub-efi.bbclass +++ b/meta/classes/grub-efi.bbclass | |||
@@ -22,39 +22,29 @@ GRUB_TIMEOUT ?= "10" | |||
22 | GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" | 22 | GRUB_OPTS ?= "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1" |
23 | 23 | ||
24 | EFIDIR = "/EFI/BOOT" | 24 | EFIDIR = "/EFI/BOOT" |
25 | GRUB_HDDDIR = "${HDDDIR}${EFIDIR}" | ||
26 | GRUB_ISODIR = "${ISODIR}${EFIDIR}" | ||
27 | 25 | ||
28 | grubefi_populate() { | 26 | grubefi_populate() { |
27 | # DEST must be the root of the image so that EFIDIR is not | ||
28 | # nested under a top level directory. | ||
29 | DEST=$1 | 29 | DEST=$1 |
30 | 30 | ||
31 | install -d ${DEST} | 31 | install -d ${DEST}${EFIDIR} |
32 | |||
33 | install -m 0644 ${STAGING_DIR_HOST}/kernel/bzImage ${DEST}/vmlinuz | ||
34 | |||
35 | if [ -n "${INITRD}" ] && [ -s "${INITRD}" ]; then | ||
36 | install -m 0644 ${INITRD} ${DEST}/initrd | ||
37 | fi | ||
38 | |||
39 | if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then | ||
40 | install -m 0644 ${ROOTFS} ${DEST}/rootfs.img | ||
41 | fi | ||
42 | 32 | ||
43 | GRUB_IMAGE="bootia32.efi" | 33 | GRUB_IMAGE="bootia32.efi" |
44 | if [ "${TARGET_ARCH}" = "x86_64" ]; then | 34 | if [ "${TARGET_ARCH}" = "x86_64" ]; then |
45 | GRUB_IMAGE="bootx64.efi" | 35 | GRUB_IMAGE="bootx64.efi" |
46 | fi | 36 | fi |
47 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST} | 37 | install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR} |
48 | 38 | ||
49 | install -m 0644 ${GRUBCFG} ${DEST} | 39 | install -m 0644 ${GRUBCFG} ${DEST}${EFIDIR} |
50 | } | 40 | } |
51 | 41 | ||
52 | grubefi_iso_populate() { | 42 | grubefi_iso_populate() { |
53 | grubefi_populate ${GRUB_ISODIR} | 43 | grubefi_populate ${ISODIR} |
54 | } | 44 | } |
55 | 45 | ||
56 | grubefi_hddimg_populate() { | 46 | grubefi_hddimg_populate() { |
57 | grubefi_populate ${GRUB_HDDDIR} | 47 | grubefi_populate ${HDDDIR} |
58 | } | 48 | } |
59 | 49 | ||
60 | python build_grub_cfg() { | 50 | python build_grub_cfg() { |
@@ -109,7 +99,7 @@ python build_grub_cfg() { | |||
109 | bb.data.update_data(localdata) | 99 | bb.data.update_data(localdata) |
110 | 100 | ||
111 | cfgfile.write('\nmenuentry \'%s\'{\n' % (label)) | 101 | cfgfile.write('\nmenuentry \'%s\'{\n' % (label)) |
112 | cfgfile.write('linux ${EFIDIR}/vmlinuz LABEL=%s' % (label)) | 102 | cfgfile.write('linux /vmlinuz LABEL=%s' % (label)) |
113 | 103 | ||
114 | append = localdata.getVar('APPEND', True) | 104 | append = localdata.getVar('APPEND', True) |
115 | initrd = localdata.getVar('INITRD', True) | 105 | initrd = localdata.getVar('INITRD', True) |
@@ -119,7 +109,7 @@ python build_grub_cfg() { | |||
119 | cfgfile.write('\n') | 109 | cfgfile.write('\n') |
120 | 110 | ||
121 | if initrd: | 111 | if initrd: |
122 | cfgfile.write('initrd ${EFIDIR}/initrd') | 112 | cfgfile.write('initrd /initrd') |
123 | cfgfile.write('\n}\n') | 113 | cfgfile.write('\n}\n') |
124 | 114 | ||
125 | cfgfile.close() | 115 | cfgfile.close() |
diff --git a/meta/classes/syslinux.bbclass b/meta/classes/syslinux.bbclass index 91c4275747..1569074b21 100644 --- a/meta/classes/syslinux.bbclass +++ b/meta/classes/syslinux.bbclass | |||
@@ -18,42 +18,34 @@ do_bootimg[depends] += "syslinux:do_populate_sysroot \ | |||
18 | SYSLINUXCFG = "${S}/syslinux.cfg" | 18 | SYSLINUXCFG = "${S}/syslinux.cfg" |
19 | SYSLINUXMENU = "${S}/menu" | 19 | SYSLINUXMENU = "${S}/menu" |
20 | 20 | ||
21 | SYSLINUX_ISODIR = "${ISODIR}/isolinux" | 21 | ISOLINUXDIR = "/isolinux" |
22 | SYSLINUX_HDDDIR = "${HDDDIR}" | 22 | SYSLINUXDIR = "/" |
23 | ISO_BOOTIMG = "isolinux/isolinux.bin" | 23 | ISO_BOOTIMG = "isolinux/isolinux.bin" |
24 | ISO_BOOTCAT = "isolinux/boot.cat" | 24 | ISO_BOOTCAT = "isolinux/boot.cat" |
25 | MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table" | 25 | MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table" |
26 | 26 | ||
27 | syslinux_populate() { | 27 | syslinux_populate() { |
28 | DEST=$1 | 28 | DEST=$1 |
29 | CFGNAME=$2 | 29 | BOOTDIR=$2 |
30 | CFGNAME=$3 | ||
30 | 31 | ||
31 | install -d ${DEST} | 32 | install -d ${DEST}${BOOTDIR} |
32 | |||
33 | # Install the kernel, initrd, and rootfs | ||
34 | install -m 0644 ${STAGING_DIR_HOST}/kernel/bzImage ${DEST}/vmlinuz | ||
35 | if [ -n "${INITRD}" ] && [ -s "${INITRD}" ]; then | ||
36 | install -m 0644 ${INITRD} ${DEST}/initrd | ||
37 | fi | ||
38 | if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then | ||
39 | install -m 0644 ${ROOTFS} ${DEST}/rootfs.img | ||
40 | fi | ||
41 | 33 | ||
42 | # Install the config files | 34 | # Install the config files |
43 | install -m 0644 ${SYSLINUXCFG} ${DEST}/${CFGNAME} | 35 | install -m 0644 ${SYSLINUXCFG} ${DEST}${BOOTDIR}/${CFGNAME} |
44 | if [ -f ${SYSLINUXMENU} ]; then | 36 | if [ -f ${SYSLINUXMENU} ]; then |
45 | install -m 0644 ${SYSLINUXMENU} ${DEST} | 37 | install -m 0644 ${SYSLINUXMENU} ${DEST}${BOOTDIR} |
46 | fi | 38 | fi |
47 | } | 39 | } |
48 | 40 | ||
49 | syslinux_iso_populate() { | 41 | syslinux_iso_populate() { |
50 | syslinux_populate ${SYSLINUX_ISODIR} isolinux.cfg | 42 | syslinux_populate ${ISODIR} ${ISOLINUXDIR} isolinux.cfg |
51 | install -m 0644 ${STAGING_LIBDIR}/syslinux/isolinux.bin ${SYSLINUX_ISODIR} | 43 | install -m 0644 ${STAGING_LIBDIR}/syslinux/isolinux.bin ${ISODIR}${ISOLINUXDIR} |
52 | } | 44 | } |
53 | 45 | ||
54 | syslinux_hddimg_populate() { | 46 | syslinux_hddimg_populate() { |
55 | syslinux_populate ${SYSLINUX_HDDDIR} syslinux.cfg | 47 | syslinux_populate ${HDDDIR} ${SYSLINUXDIR} syslinux.cfg |
56 | install -m 0444 ${STAGING_LIBDIR}/syslinux/ldlinux.sys ${SYSLINUX_HDDDIR}/ldlinux.sys | 48 | install -m 0444 ${STAGING_LIBDIR}/syslinux/ldlinux.sys ${HDDDIR}${SYSLINUXDIR}/ldlinux.sys |
57 | } | 49 | } |
58 | 50 | ||
59 | syslinux_hddimg_install() { | 51 | syslinux_hddimg_install() { |
@@ -187,7 +179,7 @@ python build_syslinux_cfg () { | |||
187 | localdata.setVar('OVERRIDES', label + ':' + overrides) | 179 | localdata.setVar('OVERRIDES', label + ':' + overrides) |
188 | bb.data.update_data(localdata) | 180 | bb.data.update_data(localdata) |
189 | 181 | ||
190 | cfgfile.write('LABEL %s\nKERNEL vmlinuz\n' % (label)) | 182 | cfgfile.write('LABEL %s\nKERNEL /vmlinuz\n' % (label)) |
191 | 183 | ||
192 | append = localdata.getVar('APPEND', 1) | 184 | append = localdata.getVar('APPEND', 1) |
193 | initrd = localdata.getVar('INITRD', 1) | 185 | initrd = localdata.getVar('INITRD', 1) |
@@ -196,7 +188,7 @@ python build_syslinux_cfg () { | |||
196 | cfgfile.write('APPEND ') | 188 | cfgfile.write('APPEND ') |
197 | 189 | ||
198 | if initrd: | 190 | if initrd: |
199 | cfgfile.write('initrd=initrd ') | 191 | cfgfile.write('initrd=/initrd ') |
200 | 192 | ||
201 | cfgfile.write('LABEL=%s '% (label)) | 193 | cfgfile.write('LABEL=%s '% (label)) |
202 | 194 | ||