rpathsync / grubtobootman

Utility for converting GRUB configuration files to bootman.

commit 8: d74bac9c4dd0
parent 7: 32030ea36389
branch: default
Handle the "serial" option.
h...@zytor.com
2 years ago

Changed (Δ774 bytes):

raw changeset »

grubtobootman.py (33 lines added, 4 lines removed)

Up to file-list grubtobootman.py:

@@ -41,13 +41,38 @@ def is_other(title):
41
41
def shell_quote(str):
42
42
    nstr = ''
43
43
    for c in str[:]:
44
        if c == "\'" or c == "\!":
44
        if c == "\'" or c == '!':
45
45
            nstr = nstr + "\'\\" + c + "\'"
46
46
        else:
47
47
            nstr = nstr + c
48
48
    return "\'" + nstr + "\'"
49
49
50
50
#
51
# Deal with the Grub serial console option...
52
#
53
def handle_serial(str):
54
    unit = 0
55
    parity = 'n'
56
    word = 8
57
    stop = 1
58
    speed = 9600                # As good a default as any...
59
    for opt in str.split():
60
        try:
61
            if opt[0:7] == '--unit=':
62
                unit = int(opt[7:])
63
            elif opt[0:8] == '--speed=':
64
                speed = int(opt[8:])
65
            elif opt[0:9] == '--parity=':
66
                parity = opt[9]
67
            elif opt[0:7] == '--word=':
68
                word = int(opt[7:])
69
            elif opt[0:7] == '--stop=':
70
                stop = int(opt[7:])
71
        except ValueError:
72
            pass
73
    print 'serial %d %d%c%d%d' % (unit, speed, parity, word, stop)
74
75
#
51
76
# Emit kernel and xen options, as needed
52
77
# The fields are: [kparam, readonly, root, xenparam]
53
78
#
@@ -191,6 +216,12 @@ print ''
191
216
# global root (used by other parameters)
192
217
root = parameters['root']
193
218
219
# serial
220
try:
221
    handle_serial(parameters['serial'])
222
except KeyError:
223
    pass
224
194
225
# default
195
226
default = parameters['default']
196
227
if default == 'saved':
@@ -232,15 +263,13 @@ try:
232
263
except KeyError:
233
264
    pass
234
265
235
# XXX: deal with serial
236
237
266
#
238
267
# Set the kernel parameters to unknown.  This forces kernel
239
268
# parameters to be emitted.
240
269
#
241
270
# The fields are: [kparam, readonly, root, xenparam]
242
271
#
243
kparam = [None, -1, None, None]
272
kparam = ['', -1, None, '']
244
273
245
274
#
246
275
# Deal with titles