summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcin Juszkiewicz <hrw@openedhand.com>2007-06-08 08:38:43 +0000
committerMarcin Juszkiewicz <hrw@openedhand.com>2007-06-08 08:38:43 +0000
commit9ac61d29688d3ed86196e156a8a234113aaa51d1 (patch)
tree8e89eeabf5cf930d4b82c07af90537395f9165f5
parent8b66792be9766f1bf844319e93e8ba6ca60f93c5 (diff)
downloadpoky-9ac61d29688d3ed86196e156a8a234113aaa51d1.tar.gz
syslinux.bbclass: imported from OE (needed to generate booting CD)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1893 311d38ba-8fff-0310-9ca6-ca027cbcb966
-rw-r--r--meta/classes/syslinux.bbclass156
1 files changed, 156 insertions, 0 deletions
diff --git a/meta/classes/syslinux.bbclass b/meta/classes/syslinux.bbclass
new file mode 100644
index 0000000000..2f5b6c43d7
--- /dev/null
+++ b/meta/classes/syslinux.bbclass
@@ -0,0 +1,156 @@
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# This creates a configuration file suitable for use with syslinux.
6
7python build_syslinux_menu () {
8 import copy
9 import sys
10
11 workdir = bb.data.getVar('WORKDIR', d, 1)
12 if not workdir:
13 bb.error("WORKDIR is not defined")
14 return
15
16 labels = bb.data.getVar('LABELS', d, 1)
17 if not labels:
18 bb.debug(1, "LABELS not defined, nothing to do")
19 return
20
21 if labels == []:
22 bb.debug(1, "No labels, nothing to do")
23 return
24
25 cfile = bb.data.getVar('SYSLINUXMENU', d, 1)
26 if not cfile:
27 raise bb.build.FuncFailed('Unable to read SYSLINUXMENU')
28
29 bb.mkdirhier(os.path.dirname(cfile))
30
31 try:
32 cfgfile = file(cfile, 'w')
33 except OSError:
34 raise bb.build.funcFailed('Unable to open %s' % (cfile))
35
36 # Beep the speaker and Clear the screen
37 cfgfile.write('\x07\x0C')
38
39 # The title should be configurable
40 cfgfile.write('AMD Geode Linux Boot Menu\n')
41 cfgfile.write('The following targets are available on this image:\n')
42 cfgfile.write('\n')
43
44 for label in labels.split():
45 from copy import deepcopy
46 localdata = deepcopy(d)
47
48 overrides = bb.data.getVar('OVERRIDES', localdata)
49 if not overrides:
50 raise bb.build.FuncFailed('OVERRIDES not defined')
51 overrides = bb.data.expand(overrides, localdata)
52
53 bb.data.setVar('OVERRIDES', label + ':' + overrides, localdata)
54 bb.data.update_data(localdata)
55
56 usage = bb.data.getVar('USAGE', localdata, 1)
57 cfgfile.write(' \x0F\x30\x3E%16s\x0F\x30\x37: ' % (label))
58 cfgfile.write('%s\n' % (usage))
59
60 del localdata
61
62 cfgfile.write('\n')
63 cfgfile.close()
64}
65
66python build_syslinux_cfg () {
67 import copy
68 import sys
69
70 workdir = bb.data.getVar('WORKDIR', d, 1)
71 if not workdir:
72 bb.error("WORKDIR not defined, unable to package")
73 return
74
75 labels = bb.data.getVar('LABELS', d, 1)
76 if not labels:
77 bb.debug(1, "LABELS not defined, nothing to do")
78 return
79
80 if labels == []:
81 bb.debug(1, "No labels, nothing to do")
82 return
83
84 cfile = bb.data.getVar('SYSLINUXCFG', d, 1)
85 if not cfile:
86 raise bb.build.FuncFailed('Unable to read SYSLINUXCFG')
87
88 bb.mkdirhier(os.path.dirname(cfile))
89
90 try:
91 cfgfile = file(cfile, 'w')
92 except OSError:
93 raise bb.build.funcFailed('Unable to open %s' % (cfile))
94
95 # FIXME - the timeout should be settable
96 # And maybe the default too
97 # Definately the prompt
98
99 cfgfile.write('# Automatically created by OE\n')
100
101 opts = bb.data.getVar('SYSLINUX_OPTS', d, 1)
102
103 if opts:
104 for opt in opts.split(';'):
105 cfgfile.write('%s\n' % opt)
106
107 cfgfile.write('ALLOWOPTIONS 1\n');
108 cfgfile.write('DEFAULT %s\n' % (labels.split()[0]))
109
110 timeout = bb.data.getVar('SYSLINUX_TIMEOUT', d, 1)
111
112 if timeout:
113 cfgfile.write('TIMEOUT %s\n' % timeout)
114 else:
115 cfgfile.write('TIMEOUT 50\n')
116
117 cfgfile.write('PROMPT 1\n')
118
119 menu = bb.data.getVar('AUTO_SYSLINUXMENU', d, 1)
120
121 # This is ugly. My bad.
122
123 if menu:
124 bb.build.exec_func('build_syslinux_menu', d)
125 mfile = bb.data.getVar('SYSLINUXMENU', d, 1)
126 cfgfile.write('DISPLAY %s\n' % (mfile.split('/')[-1]) )
127
128 for label in labels.split():
129 from copy import deepcopy
130 localdata = deepcopy(d)
131
132 overrides = bb.data.getVar('OVERRIDES', localdata)
133 if not overrides:
134 raise bb.build.FuncFailed('OVERRIDES not defined')
135 overrides = bb.data.expand(overrides, localdata)
136
137 bb.data.setVar('OVERRIDES', label + ':' + overrides, localdata)
138 bb.data.update_data(localdata)
139
140 cfgfile.write('LABEL %s\nKERNEL vmlinuz\n' % (label))
141
142 append = bb.data.getVar('APPEND', localdata, 1)
143 initrd = bb.data.getVar('INITRD', localdata, 1)
144
145 if append:
146 cfgfile.write('APPEND ')
147
148 if initrd:
149 cfgfile.write('initrd=initrd ')
150
151 cfgfile.write('%s\n' % (append))
152
153 del localdata
154
155 cfgfile.close()
156}