summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/bootimg.bbclass71
-rw-r--r--meta/classes/syslinux.bbclass68
2 files changed, 76 insertions, 63 deletions
diff --git a/meta/classes/bootimg.bbclass b/meta/classes/bootimg.bbclass
index dbaa677600..0554ffa00a 100644
--- a/meta/classes/bootimg.bbclass
+++ b/meta/classes/bootimg.bbclass
@@ -17,36 +17,26 @@
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 20# External variables (also used by syslinux.bbclass)
21# ${INITRD} - indicates a filesystem image to use as an initrd (optional) 21# ${INITRD} - indicates a filesystem image to use as an initrd (optional)
22# ${NOISO} - skip building the ISO image if set to 1
22# ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional) 23# ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
23# ${AUTO_SYSLINUXCFG} - set this to 1 to enable creating an automatic config
24# ${LABELS} - a list of targets for the automatic config
25# ${APPEND} - an override list of append strings for each label
26# ${SYSLINUX_OPTS} - additional options to add to the syslinux file ';' delimited
27 24
28do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \ 25do_bootimg[depends] += "dosfstools-native:do_populate_sysroot \
29 syslinux:do_populate_sysroot \ 26 mtools-native:do_populate_sysroot \
30 syslinux-native:do_populate_sysroot \ 27 cdrtools-native:do_populate_sysroot"
31 mtools-native:do_populate_sysroot \
32 cdrtools-native:do_populate_sysroot"
33 28
34PACKAGES = " " 29PACKAGES = " "
35EXCLUDE_FROM_WORLD = "1" 30EXCLUDE_FROM_WORLD = "1"
36 31
37HDDDIR = "${S}/hdd/boot" 32HDDDIR = "${S}/hdd/boot"
38ISODIR = "${S}/cd/isolinux" 33ISODIR = "${S}/cd"
39 34
40BOOTIMG_VOLUME_ID ?= "boot" 35BOOTIMG_VOLUME_ID ?= "boot"
41BOOTIMG_EXTRA_SPACE ?= "512" 36BOOTIMG_EXTRA_SPACE ?= "512"
42 37
43# Get the build_syslinux_cfg() function from the syslinux class
44
45SYSLINUXCFG = "${HDDDIR}/syslinux.cfg"
46SYSLINUXMENU = "${HDDDIR}/menu"
47
48inherit syslinux 38inherit syslinux
49 39
50build_iso() { 40build_iso() {
51 # Only create an ISO if we have an INITRD and NOISO was not set 41 # Only create an ISO if we have an INITRD and NOISO was not set
52 if [ -z "${INITRD}" ] || [ ! -s "${INITRD}" ] || [ "${NOISO}" = "1" ]; then 42 if [ -z "${INITRD}" ] || [ ! -s "${INITRD}" ] || [ "${NOISO}" = "1" ]; then
@@ -56,31 +46,12 @@ build_iso() {
56 46
57 install -d ${ISODIR} 47 install -d ${ISODIR}
58 48
59 # Install the kernel 49 syslinux_iso_populate
60 install -m 0644 ${STAGING_DIR_HOST}/kernel/bzImage \
61 ${ISODIR}/vmlinuz
62
63 # Install the configuration files
64 cp ${HDDDIR}/syslinux.cfg ${ISODIR}/isolinux.cfg
65
66 if [ -f ${SYSLINUXMENU} ]; then
67 cp ${SYSLINUXMENU} ${ISODIR}
68 fi
69
70 install -m 0644 ${INITRD} ${ISODIR}/initrd
71
72 if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then
73 install -m 0644 ${ROOTFS} ${ISODIR}/rootfs.img
74 fi
75
76 # And install the syslinux stuff
77 cp ${STAGING_LIBDIR}/syslinux/isolinux.bin ${ISODIR}
78 50
79 mkisofs -V ${BOOTIMG_VOLUME_ID} \ 51 mkisofs -V ${BOOTIMG_VOLUME_ID} \
80 -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \ 52 -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.iso \
81 -b isolinux/isolinux.bin -c isolinux/boot.cat -r \ 53 -b ${ISO_BOOTIMG} -c ${ISO_BOOTCAT} -r \
82 -no-emul-boot -boot-load-size 4 -boot-info-table \ 54 ${MKISOFS_OPTIONS} ${ISODIR}
83 ${S}/cd/
84 55
85 cd ${DEPLOY_DIR_IMAGE} 56 cd ${DEPLOY_DIR_IMAGE}
86 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.iso 57 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.iso
@@ -91,34 +62,24 @@ build_hddimg() {
91 # Create an HDD image 62 # Create an HDD image
92 if [ "${NOHDD}" != "1" ] ; then 63 if [ "${NOHDD}" != "1" ] ; then
93 install -d ${HDDDIR} 64 install -d ${HDDDIR}
94 install -m 0644 ${STAGING_DIR_HOST}/kernel/bzImage \ 65 syslinux_hddimg_populate
95 ${HDDDIR}/vmlinuz
96
97 if [ -n "${INITRD}" ] && [ -s "${INITRD}" ]; then
98 install -m 0644 ${INITRD} ${HDDDIR}/initrd
99 fi
100
101 if [ -n "${ROOTFS}" ] && [ -s "${ROOTFS}" ]; then
102 install -m 0644 ${ROOTFS} ${HDDDIR}/rootfs.img
103 fi
104 66
105 install -m 444 ${STAGING_LIBDIR}/syslinux/ldlinux.sys ${HDDDIR}/ldlinux.sys 67 # Determine the block count for the final image
106
107 # Do a little math, bash style
108 BLOCKS=`du -bks ${HDDDIR} | cut -f 1` 68 BLOCKS=`du -bks ${HDDDIR} | cut -f 1`
109 SIZE=`expr $BLOCKS + ${BOOTIMG_EXTRA_SPACE}` 69 SIZE=`expr $BLOCKS + ${BOOTIMG_EXTRA_SPACE}`
110 70
111 mkdosfs -n ${BOOTIMG_VOLUME_ID} -d ${HDDDIR} \ 71 mkdosfs -n ${BOOTIMG_VOLUME_ID} -d ${HDDDIR} \
112 -C ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg $SIZE 72 -C ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg $SIZE
73
74 syslinux_hddimg_install
113 75
114 syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
115 chmod 644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg 76 chmod 644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
116 77
117 cd ${DEPLOY_DIR_IMAGE} 78 cd ${DEPLOY_DIR_IMAGE}
118 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hddimg 79 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hddimg
119 ln -s ${IMAGE_NAME}.hddimg ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hddimg 80 ln -s ${IMAGE_NAME}.hddimg ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.hddimg
120 fi 81 fi
121} 82}
122 83
123python do_bootimg() { 84python do_bootimg() {
124 bb.build.exec_func('build_syslinux_cfg', d) 85 bb.build.exec_func('build_syslinux_cfg', d)
diff --git a/meta/classes/syslinux.bbclass b/meta/classes/syslinux.bbclass
index 0cc6b851bc..6eb804b75c 100644
--- a/meta/classes/syslinux.bbclass
+++ b/meta/classes/syslinux.bbclass
@@ -2,7 +2,63 @@
2# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved 2# Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved
3# Released under the MIT license (see packages/COPYING) 3# Released under the MIT license (see packages/COPYING)
4 4
5# This creates a configuration file suitable for use with syslinux. 5# Provide syslinux specific functions for building bootable images.
6
7# External variables
8# ${INITRD} - indicates a filesystem image to use as an initrd (optional)
9# ${ROOTFS} - indicates a filesystem image to include as the root filesystem (optional)
10# ${AUTO_SYSLINUXMENU} - set this to 1 to enable creating an automatic menu
11# ${LABELS} - a list of targets for the automatic config
12# ${APPEND} - an override list of append strings for each label
13# ${SYSLINUX_OPTS} - additional options to add to the syslinux file ';' delimited
14
15do_bootimg[depends] += "syslinux:do_populate_sysroot \
16 syslinux-native:do_populate_sysroot"
17
18SYSLINUXCFG = "syslinux.cfg"
19SYSLINUXMENU = "menu"
20
21SYSLINUX_ISODIR = "${ISODIR}/isolinux"
22SYSLINUX_HDDDIR = "${HDDDIR}"
23ISO_BOOTIMG = "isolinux/isolinux.bin"
24ISO_BOOTCAT = "isolinux/boot.cat"
25MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table"
26
27syslinux_populate() {
28 DEST=$1
29 CFGNAME=$2
30
31 install -d ${DEST}
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
42 # Install the config files
43 install -m 0644 ${SYSLINUXCFG} ${DEST}/${CFGNAME}
44 if [ -f ${SYSLINUXMENU} ]; then
45 install -m 0644 ${SYSLINUXMENU} ${DEST}
46 fi
47}
48
49syslinux_iso_populate() {
50 syslinux_populate ${SYSLINUX_ISODIR} isolinux.cfg
51 install -m 0644 ${STAGING_LIBDIR}/syslinux/isolinux.bin ${SYSLINUX_ISODIR}
52}
53
54syslinux_hddimg_populate() {
55 syslinux_populate ${SYSLINUX_HDDDIR} syslinux.cfg
56 install -m 0444 ${STAGING_LIBDIR}/syslinux/ldlinux.sys ${SYSLINUX_HDDDIR}/ldlinux.sys
57}
58
59syslinux_hddimg_install() {
60 syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
61}
6 62
7python build_syslinux_menu () { 63python build_syslinux_menu () {
8 import copy 64 import copy
@@ -26,10 +82,8 @@ python build_syslinux_menu () {
26 if not cfile: 82 if not cfile:
27 raise bb.build.FuncFailed('Unable to read SYSLINUXMENU') 83 raise bb.build.FuncFailed('Unable to read SYSLINUXMENU')
28 84
29 bb.mkdirhier(os.path.dirname(cfile))
30
31 try: 85 try:
32 cfgfile = file(cfile, 'w') 86 cfgfile = file(cfile, 'w')
33 except OSError: 87 except OSError:
34 raise bb.build.funcFailed('Unable to open %s' % (cfile)) 88 raise bb.build.funcFailed('Unable to open %s' % (cfile))
35 89
@@ -85,10 +139,8 @@ python build_syslinux_cfg () {
85 if not cfile: 139 if not cfile:
86 raise bb.build.FuncFailed('Unable to read SYSLINUXCFG') 140 raise bb.build.FuncFailed('Unable to read SYSLINUXCFG')
87 141
88 bb.mkdirhier(os.path.dirname(cfile))
89
90 try: 142 try:
91 cfgfile = file(cfile, 'w') 143 cfgfile = file(cfile, 'w')
92 except OSError: 144 except OSError:
93 raise bb.build.funcFailed('Unable to open %s' % (cfile)) 145 raise bb.build.funcFailed('Unable to open %s' % (cfile))
94 146
@@ -103,7 +155,7 @@ python build_syslinux_cfg () {
103 if opts: 155 if opts:
104 for opt in opts.split(';'): 156 for opt in opts.split(';'):
105 cfgfile.write('%s\n' % opt) 157 cfgfile.write('%s\n' % opt)
106 158
107 cfgfile.write('ALLOWOPTIONS 1\n'); 159 cfgfile.write('ALLOWOPTIONS 1\n');
108 cfgfile.write('DEFAULT %s\n' % (labels.split()[0])) 160 cfgfile.write('DEFAULT %s\n' % (labels.split()[0]))
109 161