diff options
| -rw-r--r-- | meta/classes/syslinux.bbclass | 128 |
1 files changed, 49 insertions, 79 deletions
diff --git a/meta/classes/syslinux.bbclass b/meta/classes/syslinux.bbclass index c4596bffce..0b90eab228 100644 --- a/meta/classes/syslinux.bbclass +++ b/meta/classes/syslinux.bbclass | |||
| @@ -11,15 +11,17 @@ | |||
| 11 | # ${LABELS} - a list of targets for the automatic config | 11 | # ${LABELS} - a list of targets for the automatic config |
| 12 | # ${APPEND} - an override list of append strings for each label | 12 | # ${APPEND} - an override list of append strings for each label |
| 13 | # ${SYSLINUX_OPTS} - additional options to add to the syslinux file ';' delimited | 13 | # ${SYSLINUX_OPTS} - additional options to add to the syslinux file ';' delimited |
| 14 | # ${SYSLINUX_SPLASH} - A background for the vga boot menu if using the boot menu | ||
| 15 | # ${SYSLINUX_SERIAL} - Set an alternate serial port or turn off serial with empty string | ||
| 14 | 16 | ||
| 15 | do_bootimg[depends] += "syslinux:do_populate_sysroot \ | 17 | do_bootimg[depends] += "syslinux:do_populate_sysroot \ |
| 16 | syslinux-native:do_populate_sysroot" | 18 | syslinux-native:do_populate_sysroot" |
| 17 | 19 | ||
| 18 | SYSLINUXCFG = "${S}/syslinux.cfg" | 20 | SYSLINUXCFG = "${S}/syslinux.cfg" |
| 19 | SYSLINUXMENU = "${S}/menu" | ||
| 20 | 21 | ||
| 21 | ISOLINUXDIR = "/isolinux" | 22 | ISOLINUXDIR = "/isolinux" |
| 22 | SYSLINUXDIR = "/" | 23 | SYSLINUXDIR = "/" |
| 24 | SYSLINUX_SERIAL ?= "0 115200" | ||
| 23 | ISO_BOOTIMG = "isolinux/isolinux.bin" | 25 | ISO_BOOTIMG = "isolinux/isolinux.bin" |
| 24 | ISO_BOOTCAT = "isolinux/boot.cat" | 26 | ISO_BOOTCAT = "isolinux/boot.cat" |
| 25 | MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table" | 27 | MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table" |
| @@ -34,82 +36,34 @@ syslinux_populate() { | |||
| 34 | 36 | ||
| 35 | # Install the config files | 37 | # Install the config files |
| 36 | install -m 0644 ${SYSLINUXCFG} ${DEST}${BOOTDIR}/${CFGNAME} | 38 | install -m 0644 ${SYSLINUXCFG} ${DEST}${BOOTDIR}/${CFGNAME} |
| 37 | if [ -f ${SYSLINUXMENU} ]; then | ||
| 38 | install -m 0644 ${SYSLINUXMENU} ${DEST}${BOOTDIR} | ||
| 39 | fi | ||
| 40 | } | 39 | } |
| 41 | 40 | ||
| 42 | syslinux_iso_populate() { | 41 | syslinux_iso_populate() { |
| 43 | syslinux_populate ${ISODIR} ${ISOLINUXDIR} isolinux.cfg | 42 | syslinux_populate ${ISODIR} ${ISOLINUXDIR} isolinux.cfg |
| 44 | install -m 0644 ${STAGING_LIBDIR}/syslinux/isolinux.bin ${ISODIR}${ISOLINUXDIR} | 43 | install -m 0644 ${STAGING_LIBDIR}/syslinux/isolinux.bin ${ISODIR}${ISOLINUXDIR} |
| 44 | if [ "${AUTO_SYSLINUXMENU}" = 1 ] ; then | ||
| 45 | install -m 0644 ${STAGING_LIBDIR}/syslinux/vesamenu.c32 ${ISODIR}${ISOLINUXDIR}/vesamenu.c32 | ||
| 46 | if [ "${SYSLINUX_SPLASH}" != "" ] ; then | ||
| 47 | install -m 0644 ${SYSLINUX_SPLASH} ${ISODIR}${ISOLINUXDIR}/splash.lss | ||
| 48 | fi | ||
| 49 | fi | ||
| 45 | } | 50 | } |
| 46 | 51 | ||
| 47 | syslinux_hddimg_populate() { | 52 | syslinux_hddimg_populate() { |
| 48 | syslinux_populate ${HDDDIR} ${SYSLINUXDIR} syslinux.cfg | 53 | syslinux_populate ${HDDDIR} ${SYSLINUXDIR} syslinux.cfg |
| 49 | install -m 0444 ${STAGING_LIBDIR}/syslinux/ldlinux.sys ${HDDDIR}${SYSLINUXDIR}/ldlinux.sys | 54 | install -m 0444 ${STAGING_LIBDIR}/syslinux/ldlinux.sys ${HDDDIR}${SYSLINUXDIR}/ldlinux.sys |
| 55 | if [ "${AUTO_SYSLINUXMENU}" = 1 ] ; then | ||
| 56 | install -m 0644 ${STAGING_LIBDIR}/syslinux/vesamenu.c32 ${HDDDIR}${SYSLINUXDIR}/vesamenu.c32 | ||
| 57 | if [ "${SYSLINUX_SPLASH}" != "" ] ; then | ||
| 58 | install -m 0644 ${SYSLINUX_SPLASH} ${HDDDIR}${SYSLINUXDIR}/splash.lss | ||
| 59 | fi | ||
| 60 | fi | ||
| 50 | } | 61 | } |
| 51 | 62 | ||
| 52 | syslinux_hddimg_install() { | 63 | syslinux_hddimg_install() { |
| 53 | syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg | 64 | syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg |
| 54 | } | 65 | } |
| 55 | 66 | ||
| 56 | python build_syslinux_menu () { | ||
| 57 | import copy | ||
| 58 | import sys | ||
| 59 | |||
| 60 | workdir = d.getVar('WORKDIR', True) | ||
| 61 | if not workdir: | ||
| 62 | bb.error("WORKDIR is not defined") | ||
| 63 | return | ||
| 64 | |||
| 65 | labels = d.getVar('LABELS', True) | ||
| 66 | if not labels: | ||
| 67 | bb.debug(1, "LABELS not defined, nothing to do") | ||
| 68 | return | ||
| 69 | |||
| 70 | if labels == []: | ||
| 71 | bb.debug(1, "No labels, nothing to do") | ||
| 72 | return | ||
| 73 | |||
| 74 | cfile = d.getVar('SYSLINUXMENU', True) | ||
| 75 | if not cfile: | ||
| 76 | raise bb.build.FuncFailed('Unable to read SYSLINUXMENU') | ||
| 77 | |||
| 78 | try: | ||
| 79 | cfgfile = file(cfile, 'w') | ||
| 80 | except OSError: | ||
| 81 | raise bb.build.funcFailed('Unable to open %s' % (cfile)) | ||
| 82 | |||
| 83 | # Beep the speaker and Clear the screen | ||
| 84 | cfgfile.write('\x07\x0C') | ||
| 85 | |||
| 86 | # The title should be configurable | ||
| 87 | cfgfile.write('Linux Boot Menu\n') | ||
| 88 | cfgfile.write('The following targets are available on this image:\n') | ||
| 89 | cfgfile.write('\n') | ||
| 90 | |||
| 91 | for label in labels.split(): | ||
| 92 | from copy import deepcopy | ||
| 93 | localdata = deepcopy(d) | ||
| 94 | |||
| 95 | overrides = localdata.getVar('OVERRIDES') | ||
| 96 | if not overrides: | ||
| 97 | raise bb.build.FuncFailed('OVERRIDES not defined') | ||
| 98 | overrides = localdata.expand(overrides) | ||
| 99 | |||
| 100 | localdata.setVar('OVERRIDES', label + ':' + overrides) | ||
| 101 | bb.data.update_data(localdata) | ||
| 102 | |||
| 103 | usage = localdata.getVar('USAGE', True) | ||
| 104 | cfgfile.write(' \x0F\x30\x3E%16s\x0F\x30\x37: ' % (label)) | ||
| 105 | cfgfile.write('%s\n' % (usage)) | ||
| 106 | |||
| 107 | del localdata | ||
| 108 | |||
| 109 | cfgfile.write('\n') | ||
| 110 | cfgfile.close() | ||
| 111 | } | ||
| 112 | |||
| 113 | python build_syslinux_cfg () { | 67 | python build_syslinux_cfg () { |
| 114 | import copy | 68 | import copy |
| 115 | import sys | 69 | import sys |
| @@ -146,7 +100,16 @@ python build_syslinux_cfg () { | |||
| 146 | cfgfile.write('%s\n' % opt) | 100 | cfgfile.write('%s\n' % opt) |
| 147 | 101 | ||
| 148 | cfgfile.write('ALLOWOPTIONS 1\n'); | 102 | cfgfile.write('ALLOWOPTIONS 1\n'); |
| 149 | cfgfile.write('DEFAULT %s\n' % (labels.split()[0])) | 103 | syslinux_serial = d.getVar('SYSLINUX_SERIAL', True) |
| 104 | if syslinux_serial: | ||
| 105 | cfgfile.write('SERIAL %s\n' % syslinux_serial) | ||
| 106 | |||
| 107 | menu = d.getVar('AUTO_SYSLINUXMENU', True) | ||
| 108 | |||
| 109 | if menu and syslinux_serial: | ||
| 110 | cfgfile.write('DEFAULT Graphics console %s\n' % (labels.split()[0])) | ||
| 111 | else: | ||
| 112 | cfgfile.write('DEFAULT %s\n' % (labels.split()[0])) | ||
| 150 | 113 | ||
| 151 | timeout = d.getVar('SYSLINUX_TIMEOUT', True) | 114 | timeout = d.getVar('SYSLINUX_TIMEOUT', True) |
| 152 | 115 | ||
| @@ -161,14 +124,13 @@ python build_syslinux_cfg () { | |||
| 161 | else: | 124 | else: |
| 162 | cfgfile.write('PROMPT 1\n') | 125 | cfgfile.write('PROMPT 1\n') |
| 163 | 126 | ||
| 164 | menu = d.getVar('AUTO_SYSLINUXMENU', True) | ||
| 165 | |||
| 166 | # This is ugly. My bad. | ||
| 167 | |||
| 168 | if menu: | 127 | if menu: |
| 169 | bb.build.exec_func('build_syslinux_menu', d) | 128 | cfgfile.write('ui vesamenu.c32\n') |
| 170 | mfile = d.getVar('SYSLINUXMENU', True) | 129 | cfgfile.write('menu title Select kernel options and boot kernel\n') |
| 171 | cfgfile.write('DISPLAY %s\n' % (mfile.split('/')[-1]) ) | 130 | cfgfile.write('menu tabmsg Press [Tab] to edit, [Return] to select\n') |
| 131 | splash = d.getVar('SYSLINUX_SPLASH', True) | ||
| 132 | if splash: | ||
| 133 | cfgfile.write('menu background splash.lss\n') | ||
| 172 | 134 | ||
| 173 | for label in labels.split(): | 135 | for label in labels.split(): |
| 174 | localdata = bb.data.createCopy(d) | 136 | localdata = bb.data.createCopy(d) |
| @@ -176,24 +138,32 @@ python build_syslinux_cfg () { | |||
| 176 | overrides = localdata.getVar('OVERRIDES', True) | 138 | overrides = localdata.getVar('OVERRIDES', True) |
| 177 | if not overrides: | 139 | if not overrides: |
| 178 | raise bb.build.FuncFailed('OVERRIDES not defined') | 140 | raise bb.build.FuncFailed('OVERRIDES not defined') |
| 179 | 141 | ||
| 180 | localdata.setVar('OVERRIDES', label + ':' + overrides) | 142 | localdata.setVar('OVERRIDES', label + ':' + overrides) |
| 181 | bb.data.update_data(localdata) | 143 | bb.data.update_data(localdata) |
| 182 | 144 | ||
| 183 | cfgfile.write('LABEL %s\nKERNEL /vmlinuz\n' % (label)) | 145 | btypes = [ [ "", "console=tty0" ] ] |
| 146 | if menu and syslinux_serial: | ||
| 147 | btypes = [ [ "Graphics console ", " console=tty0" ], | ||
| 148 | [ "Serial console ", " console=ttyS0,115200" ] ] | ||
| 149 | |||
| 150 | for btype in btypes: | ||
| 151 | cfgfile.write('LABEL %s%s\nKERNEL /vmlinuz\n' % (btype[0], label)) | ||
| 184 | 152 | ||
| 185 | append = localdata.getVar('APPEND', True) | 153 | append = localdata.getVar('APPEND', True) |
| 186 | initrd = localdata.getVar('INITRD', True) | 154 | initrd = localdata.getVar('INITRD', True) |
| 187 | 155 | ||
| 188 | if append: | 156 | if append: |
| 189 | cfgfile.write('APPEND ') | 157 | cfgfile.write('APPEND ') |
| 190 | 158 | ||
| 191 | if initrd: | 159 | if initrd: |
| 192 | cfgfile.write('initrd=/initrd ') | 160 | cfgfile.write('initrd=/initrd ') |
| 193 | 161 | ||
| 194 | cfgfile.write('LABEL=%s '% (label)) | 162 | cfgfile.write('LABEL=%s '% (label)) |
| 195 | 163 | ||
| 196 | cfgfile.write('%s\n' % (append)) | 164 | cfgfile.write('%s %s\n' % (append, btype[1])) |
| 165 | else: | ||
| 166 | cfgfile.write('APPEND %s\n' % btype[1]) | ||
| 197 | 167 | ||
| 198 | cfgfile.close() | 168 | cfgfile.close() |
| 199 | } | 169 | } |
