Subversion Repositories HelenOS

Rev

Rev 4054 | Rev 4062 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4054 Rev 4058
Line 38... Line 38...
38
 
38
 
39
INPUT = sys.argv[1]
39
INPUT = sys.argv[1]
40
MAKEFILE = 'Makefile.config'
40
MAKEFILE = 'Makefile.config'
41
MACROS = 'config.h'
41
MACROS = 'config.h'
42
DEFS = 'config.defs'
42
DEFS = 'config.defs'
-
 
43
PRECONF = 'defaults'
43
 
44
 
44
def read_defaults(fname, defaults):
45
def read_defaults(fname, defaults):
45
    "Read saved values from last configuration run"
46
    "Read saved values from last configuration run"
46
   
47
   
47
    inf = file(fname, 'r')
48
    inf = file(fname, 'r')
Line 274... Line 275...
274
   
275
   
275
    outmk.close()
276
    outmk.close()
276
    outmc.close()
277
    outmc.close()
277
    outdf.close()
278
    outdf.close()
278
 
279
 
-
 
280
def sorted_dir(root):
-
 
281
    list = os.listdir(root)
-
 
282
    list.sort()
-
 
283
    return list
-
 
284
 
-
 
285
def read_preconfigured(root, fname, screen, defaults):
-
 
286
    options = []
-
 
287
    opt2path = {}
-
 
288
    cnt = 0
-
 
289
   
-
 
290
    # Look for profiles
-
 
291
    for name in sorted_dir(root):
-
 
292
        path = os.path.join(root, name)
-
 
293
        canon = os.path.join(path, fname)
-
 
294
       
-
 
295
        if ((os.path.isdir(path)) and (os.path.exists(canon)) and (os.path.isfile(canon))):
-
 
296
            subprofile = False
-
 
297
           
-
 
298
            # Look for subprofiles
-
 
299
            for subname in sorted_dir(path):
-
 
300
                subpath = os.path.join(path, subname)
-
 
301
                subcanon = os.path.join(subpath, fname)
-
 
302
               
-
 
303
                if ((os.path.isdir(subpath)) and (os.path.exists(subcanon)) and (os.path.isfile(subcanon))):
-
 
304
                    subprofile = True
-
 
305
                    options.append("%s (%s)" % (name, subname))
-
 
306
                    opt2path[cnt] = (canon, subcanon)
-
 
307
                    cnt += 1
-
 
308
           
-
 
309
            if (not subprofile):
-
 
310
                options.append(name)
-
 
311
                opt2path[cnt] = (canon, None)
-
 
312
                cnt += 1
-
 
313
   
-
 
314
    (button, value) = xtui.choice_window(screen, 'Load preconfigured defaults', 'Choose configuration profile', options, None)
-
 
315
   
-
 
316
    if (button == 'cancel'):
-
 
317
        return None
-
 
318
   
-
 
319
    read_defaults(opt2path[value][0], defaults)
-
 
320
    if (opt2path[value][1] != None):
-
 
321
        read_defaults(opt2path[value][1], defaults)
-
 
322
 
279
def main():
323
def main():
280
    defaults = {}
324
    defaults = {}
281
    ask_names = []
325
    ask_names = []
282
   
326
   
283
    # Parse configuration file
327
    # Parse configuration file
Line 300... Line 344...
300
        return 1
344
        return 1
301
   
345
   
302
    screen = xtui.screen_init()
346
    screen = xtui.screen_init()
303
    try:
347
    try:
304
        selname = None
348
        selname = None
-
 
349
        position = None
305
        while True:
350
        while True:
306
           
351
           
307
            # Cancel out all defaults which have to be deduced
352
            # Cancel out all defaults which have to be deduced
308
            for varname, vartype, name, choices, cond in ask_names:
353
            for varname, vartype, name, choices, cond in ask_names:
309
                if ((vartype == 'y') and (defaults.has_key(varname)) and (defaults[varname] == '*')):
354
                if ((vartype == 'y') and (defaults.has_key(varname)) and (defaults[varname] == '*')):
310
                    defaults[varname] = None
355
                    defaults[varname] = None
311
           
356
           
312
            options = []
357
            options = []
313
            opt2row = {}
358
            opt2row = {}
314
            position = None
359
            cnt = 1
315
            cnt = 0
360
           
-
 
361
            options.append("  --- Load preconfigured defaults ... ")
-
 
362
           
316
            for varname, vartype, name, choices, cond in ask_names:
363
            for varname, vartype, name, choices, cond in ask_names:
317
               
364
               
318
                if ((cond) and (not check_condition(cond, defaults, ask_names))):
365
                if ((cond) and (not check_condition(cond, defaults, ask_names))):
319
                    continue
366
                    continue
320
               
367
               
Line 359... Line 406...
359
               
406
               
360
                opt2row[cnt] = (varname, vartype, name, choices)
407
                opt2row[cnt] = (varname, vartype, name, choices)
361
               
408
               
362
                cnt += 1
409
                cnt += 1
363
           
410
           
-
 
411
            if (position >= options):
-
 
412
                position = None
-
 
413
           
364
            (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
414
            (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
365
           
415
           
366
            if (button == 'cancel'):
416
            if (button == 'cancel'):
367
                return 'Configuration canceled'
417
                return 'Configuration canceled'
368
           
418
           
-
 
419
            if (value == 0):
-
 
420
                read_preconfigured(PRECONF, MAKEFILE, screen, defaults)
-
 
421
                position = 1
-
 
422
                continue
-
 
423
           
-
 
424
            position = None
369
            if (not opt2row.has_key(value)):
425
            if (not opt2row.has_key(value)):
370
                raise RuntimeError("Error selecting value: %s" % value)
426
                raise RuntimeError("Error selecting value: %s" % value)
371
           
427
           
372
            (selname, seltype, name, choices) = opt2row[value]
428
            (selname, seltype, name, choices) = opt2row[value]
373
           
429