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