diff options
Diffstat (limited to 'meta/classes/syslinux.bbclass')
| -rw-r--r-- | meta/classes/syslinux.bbclass | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/meta/classes/syslinux.bbclass b/meta/classes/syslinux.bbclass new file mode 100644 index 0000000000..8964d3ff5e --- /dev/null +++ b/meta/classes/syslinux.bbclass | |||
| @@ -0,0 +1,187 @@ | |||
| 1 | # syslinux.bbclass | ||
| 2 | # Copyright (C) 2004-2006, Advanced Micro Devices, Inc. All Rights Reserved | ||
| 3 | # Released under the MIT license (see packages/COPYING) | ||
| 4 | |||
| 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 | # ${SYSLINUX_SPLASH} - A background for the vga boot menu if using the boot menu | ||
| 15 | # ${SYSLINUX_DEFAULT_CONSOLE} - set to "console=ttyX" to change kernel boot default console | ||
| 16 | # ${SYSLINUX_SERIAL} - Set an alternate serial port or turn off serial with empty string | ||
| 17 | # ${SYSLINUX_SERIAL_TTY} - Set alternate console=tty... kernel boot argument | ||
| 18 | # ${SYSLINUX_KERNEL_ARGS} - Add additional kernel arguments | ||
| 19 | |||
| 20 | do_bootimg[depends] += "syslinux:do_populate_sysroot \ | ||
| 21 | syslinux-native:do_populate_sysroot" | ||
| 22 | |||
| 23 | SYSLINUXCFG = "${S}/syslinux.cfg" | ||
| 24 | |||
| 25 | ISOLINUXDIR = "/isolinux" | ||
| 26 | SYSLINUXDIR = "/" | ||
| 27 | # The kernel has an internal default console, which you can override with | ||
| 28 | # a console=...some_tty... | ||
| 29 | SYSLINUX_DEFAULT_CONSOLE ?= "" | ||
| 30 | SYSLINUX_SERIAL ?= "0 115200" | ||
| 31 | SYSLINUX_SERIAL_TTY ?= "console=ttyS0,115200" | ||
| 32 | ISO_BOOTIMG = "isolinux/isolinux.bin" | ||
| 33 | ISO_BOOTCAT = "isolinux/boot.cat" | ||
| 34 | MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table" | ||
| 35 | APPEND_prepend = " ${SYSLINUX_ROOT} " | ||
| 36 | |||
| 37 | syslinux_populate() { | ||
| 38 | DEST=$1 | ||
| 39 | BOOTDIR=$2 | ||
| 40 | CFGNAME=$3 | ||
| 41 | |||
| 42 | install -d ${DEST}${BOOTDIR} | ||
| 43 | |||
| 44 | # Install the config files | ||
| 45 | install -m 0644 ${SYSLINUXCFG} ${DEST}${BOOTDIR}/${CFGNAME} | ||
| 46 | if [ "${AUTO_SYSLINUXMENU}" = 1 ] ; then | ||
| 47 | install -m 0644 ${STAGING_DATADIR}/syslinux/vesamenu.c32 ${DEST}${BOOTDIR}/vesamenu.c32 | ||
| 48 | install -m 0444 ${STAGING_DATADIR}/syslinux/libcom32.c32 ${DEST}${BOOTDIR}/libcom32.c32 | ||
| 49 | install -m 0444 ${STAGING_DATADIR}/syslinux/libutil.c32 ${DEST}${BOOTDIR}/libutil.c32 | ||
| 50 | if [ "${SYSLINUX_SPLASH}" != "" ] ; then | ||
| 51 | install -m 0644 ${SYSLINUX_SPLASH} ${DEST}${BOOTDIR}/splash.lss | ||
| 52 | fi | ||
| 53 | fi | ||
| 54 | } | ||
| 55 | |||
| 56 | syslinux_iso_populate() { | ||
| 57 | iso_dir=$1 | ||
| 58 | syslinux_populate $iso_dir ${ISOLINUXDIR} isolinux.cfg | ||
| 59 | install -m 0644 ${STAGING_DATADIR}/syslinux/isolinux.bin $iso_dir${ISOLINUXDIR} | ||
| 60 | install -m 0644 ${STAGING_DATADIR}/syslinux/ldlinux.c32 $iso_dir${ISOLINUXDIR} | ||
| 61 | } | ||
| 62 | |||
| 63 | syslinux_hddimg_populate() { | ||
| 64 | hdd_dir=$1 | ||
| 65 | syslinux_populate $hdd_dir ${SYSLINUXDIR} syslinux.cfg | ||
| 66 | install -m 0444 ${STAGING_DATADIR}/syslinux/ldlinux.sys $hdd_dir${SYSLINUXDIR}/ldlinux.sys | ||
| 67 | } | ||
| 68 | |||
| 69 | syslinux_hddimg_install() { | ||
| 70 | syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg | ||
| 71 | } | ||
| 72 | |||
| 73 | syslinux_hdddirect_install() { | ||
| 74 | DEST=$1 | ||
| 75 | syslinux $DEST | ||
| 76 | } | ||
| 77 | |||
| 78 | python build_syslinux_cfg () { | ||
| 79 | import copy | ||
| 80 | import sys | ||
| 81 | |||
| 82 | workdir = d.getVar('WORKDIR', True) | ||
| 83 | if not workdir: | ||
| 84 | bb.error("WORKDIR not defined, unable to package") | ||
| 85 | return | ||
| 86 | |||
| 87 | labels = d.getVar('LABELS', True) | ||
| 88 | if not labels: | ||
| 89 | bb.debug(1, "LABELS not defined, nothing to do") | ||
| 90 | return | ||
| 91 | |||
| 92 | if labels == []: | ||
| 93 | bb.debug(1, "No labels, nothing to do") | ||
| 94 | return | ||
| 95 | |||
| 96 | cfile = d.getVar('SYSLINUXCFG', True) | ||
| 97 | if not cfile: | ||
| 98 | raise bb.build.FuncFailed('Unable to read SYSLINUXCFG') | ||
| 99 | |||
| 100 | try: | ||
| 101 | cfgfile = file(cfile, 'w') | ||
| 102 | except OSError: | ||
| 103 | raise bb.build.funcFailed('Unable to open %s' % (cfile)) | ||
| 104 | |||
| 105 | cfgfile.write('# Automatically created by OE\n') | ||
| 106 | |||
| 107 | opts = d.getVar('SYSLINUX_OPTS', True) | ||
| 108 | |||
| 109 | if opts: | ||
| 110 | for opt in opts.split(';'): | ||
| 111 | cfgfile.write('%s\n' % opt) | ||
| 112 | |||
| 113 | cfgfile.write('ALLOWOPTIONS 1\n'); | ||
| 114 | syslinux_default_console = d.getVar('SYSLINUX_DEFAULT_CONSOLE', True) | ||
| 115 | syslinux_serial_tty = d.getVar('SYSLINUX_SERIAL_TTY', True) | ||
| 116 | syslinux_serial = d.getVar('SYSLINUX_SERIAL', True) | ||
| 117 | if syslinux_serial: | ||
| 118 | cfgfile.write('SERIAL %s\n' % syslinux_serial) | ||
| 119 | |||
| 120 | menu = d.getVar('AUTO_SYSLINUXMENU', True) | ||
| 121 | |||
| 122 | if menu and syslinux_serial: | ||
| 123 | cfgfile.write('DEFAULT Graphics console %s\n' % (labels.split()[0])) | ||
| 124 | else: | ||
| 125 | cfgfile.write('DEFAULT %s\n' % (labels.split()[0])) | ||
| 126 | |||
| 127 | timeout = d.getVar('SYSLINUX_TIMEOUT', True) | ||
| 128 | |||
| 129 | if timeout: | ||
| 130 | cfgfile.write('TIMEOUT %s\n' % timeout) | ||
| 131 | else: | ||
| 132 | cfgfile.write('TIMEOUT 50\n') | ||
| 133 | |||
| 134 | prompt = d.getVar('SYSLINUX_PROMPT', True) | ||
| 135 | if prompt: | ||
| 136 | cfgfile.write('PROMPT %s\n' % prompt) | ||
| 137 | else: | ||
| 138 | cfgfile.write('PROMPT 1\n') | ||
| 139 | |||
| 140 | if menu: | ||
| 141 | cfgfile.write('ui vesamenu.c32\n') | ||
| 142 | cfgfile.write('menu title Select kernel options and boot kernel\n') | ||
| 143 | cfgfile.write('menu tabmsg Press [Tab] to edit, [Return] to select\n') | ||
| 144 | splash = d.getVar('SYSLINUX_SPLASH', True) | ||
| 145 | if splash: | ||
| 146 | cfgfile.write('menu background splash.lss\n') | ||
| 147 | |||
| 148 | for label in labels.split(): | ||
| 149 | localdata = bb.data.createCopy(d) | ||
| 150 | |||
| 151 | overrides = localdata.getVar('OVERRIDES', True) | ||
| 152 | if not overrides: | ||
| 153 | raise bb.build.FuncFailed('OVERRIDES not defined') | ||
| 154 | |||
| 155 | localdata.setVar('OVERRIDES', label + ':' + overrides) | ||
| 156 | bb.data.update_data(localdata) | ||
| 157 | |||
| 158 | btypes = [ [ "", syslinux_default_console ] ] | ||
| 159 | if menu and syslinux_serial: | ||
| 160 | btypes = [ [ "Graphics console ", syslinux_default_console ], | ||
| 161 | [ "Serial console ", syslinux_serial_tty ] ] | ||
| 162 | |||
| 163 | for btype in btypes: | ||
| 164 | cfgfile.write('LABEL %s%s\nKERNEL /vmlinuz\n' % (btype[0], label)) | ||
| 165 | |||
| 166 | exargs = d.getVar('SYSLINUX_KERNEL_ARGS', True) | ||
| 167 | if exargs: | ||
| 168 | btype[1] += " " + exargs | ||
| 169 | |||
| 170 | append = localdata.getVar('APPEND', True) | ||
| 171 | initrd = localdata.getVar('INITRD', True) | ||
| 172 | |||
| 173 | if append: | ||
| 174 | cfgfile.write('APPEND ') | ||
| 175 | |||
| 176 | if initrd: | ||
| 177 | cfgfile.write('initrd=/initrd ') | ||
| 178 | |||
| 179 | cfgfile.write('LABEL=%s '% (label)) | ||
| 180 | |||
| 181 | cfgfile.write('%s %s\n' % (append, btype[1])) | ||
| 182 | else: | ||
| 183 | cfgfile.write('APPEND %s\n' % btype[1]) | ||
| 184 | |||
| 185 | cfgfile.close() | ||
| 186 | } | ||
| 187 | build_syslinux_cfg[vardeps] += "APPEND" | ||
