[98376de] | 1 | #!/usr/bin/env python
|
---|
[44882c8] | 2 | #
|
---|
[5a55ae6] | 3 | # Copyright (c) 2006 Ondrej Palkovsky
|
---|
[9a0367f] | 4 | # Copyright (c) 2009 Martin Decky
|
---|
[44882c8] | 5 | # All rights reserved.
|
---|
| 6 | #
|
---|
| 7 | # Redistribution and use in source and binary forms, with or without
|
---|
| 8 | # modification, are permitted provided that the following conditions
|
---|
| 9 | # are met:
|
---|
| 10 | #
|
---|
| 11 | # - Redistributions of source code must retain the above copyright
|
---|
| 12 | # notice, this list of conditions and the following disclaimer.
|
---|
| 13 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | # documentation and/or other materials provided with the distribution.
|
---|
| 16 | # - The name of the author may not be used to endorse or promote products
|
---|
| 17 | # derived from this software without specific prior written permission.
|
---|
| 18 | #
|
---|
| 19 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 29 | #
|
---|
[98376de] | 30 | """
|
---|
[9a0367f] | 31 | HelenOS configuration system
|
---|
[98376de] | 32 | """
|
---|
| 33 | import sys
|
---|
| 34 | import os
|
---|
| 35 | import re
|
---|
[5a8fbcb9] | 36 | import time
|
---|
| 37 | import subprocess
|
---|
[27fb3d6] | 38 | import xtui
|
---|
[98376de] | 39 |
|
---|
[41f7564] | 40 | INPUT = sys.argv[1]
|
---|
[84266669] | 41 | MAKEFILE = 'Makefile.config'
|
---|
| 42 | MACROS = 'config.h'
|
---|
| 43 | DEFS = 'config.defs'
|
---|
[31fb9a0] | 44 | PRECONF = 'defaults'
|
---|
[98376de] | 45 |
|
---|
[9a0367f] | 46 | def read_defaults(fname, defaults):
|
---|
| 47 | "Read saved values from last configuration run"
|
---|
| 48 |
|
---|
[84266669] | 49 | inf = file(fname, 'r')
|
---|
[9a0367f] | 50 |
|
---|
| 51 | for line in inf:
|
---|
| 52 | res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line)
|
---|
| 53 | if (res):
|
---|
| 54 | defaults[res.group(1)] = res.group(2)
|
---|
| 55 |
|
---|
| 56 | inf.close()
|
---|
[98376de] | 57 |
|
---|
[9a0367f] | 58 | def check_condition(text, defaults, ask_names):
|
---|
[81c8d54] | 59 | "Check that the condition specified on input line is True (only CNF and DNF is supported)"
|
---|
[9a0367f] | 60 |
|
---|
| 61 | ctype = 'cnf'
|
---|
| 62 |
|
---|
| 63 | if ((')|' in text) or ('|(' in text)):
|
---|
| 64 | ctype = 'dnf'
|
---|
| 65 |
|
---|
| 66 | if (ctype == 'cnf'):
|
---|
| 67 | conds = text.split('&')
|
---|
| 68 | else:
|
---|
| 69 | conds = text.split('|')
|
---|
| 70 |
|
---|
| 71 | for cond in conds:
|
---|
| 72 | if (cond.startswith('(')) and (cond.endswith(')')):
|
---|
| 73 | cond = cond[1:-1]
|
---|
| 74 |
|
---|
| 75 | inside = check_inside(cond, defaults, ctype)
|
---|
| 76 |
|
---|
| 77 | if (ctype == 'cnf') and (not inside):
|
---|
| 78 | return False
|
---|
| 79 |
|
---|
| 80 | if (ctype == 'dnf') and (inside):
|
---|
| 81 | return True
|
---|
| 82 |
|
---|
| 83 | if (ctype == 'cnf'):
|
---|
| 84 | return True
|
---|
| 85 | return False
|
---|
[98376de] | 86 |
|
---|
[9a0367f] | 87 | def check_inside(text, defaults, ctype):
|
---|
[81c8d54] | 88 | "Check for condition"
|
---|
[9a0367f] | 89 |
|
---|
| 90 | if (ctype == 'cnf'):
|
---|
| 91 | conds = text.split('|')
|
---|
| 92 | else:
|
---|
| 93 | conds = text.split('&')
|
---|
| 94 |
|
---|
| 95 | for cond in conds:
|
---|
| 96 | res = re.match(r'^(.*?)(!?=)(.*)$', cond)
|
---|
| 97 | if (not res):
|
---|
| 98 | raise RuntimeError("Invalid condition: %s" % cond)
|
---|
| 99 |
|
---|
| 100 | condname = res.group(1)
|
---|
| 101 | oper = res.group(2)
|
---|
| 102 | condval = res.group(3)
|
---|
| 103 |
|
---|
| 104 | if (not defaults.has_key(condname)):
|
---|
| 105 | varval = ''
|
---|
| 106 | else:
|
---|
| 107 | varval = defaults[condname]
|
---|
[7aef7ee] | 108 | if (varval == '*'):
|
---|
| 109 | varval = 'y'
|
---|
[9a0367f] | 110 |
|
---|
| 111 | if (ctype == 'cnf'):
|
---|
| 112 | if (oper == '=') and (condval == varval):
|
---|
| 113 | return True
|
---|
| 114 |
|
---|
| 115 | if (oper == '!=') and (condval != varval):
|
---|
| 116 | return True
|
---|
| 117 | else:
|
---|
| 118 | if (oper == '=') and (condval != varval):
|
---|
| 119 | return False
|
---|
| 120 |
|
---|
| 121 | if (oper == '!=') and (condval == varval):
|
---|
| 122 | return False
|
---|
| 123 |
|
---|
| 124 | if (ctype == 'cnf'):
|
---|
| 125 | return False
|
---|
| 126 |
|
---|
| 127 | return True
|
---|
[98376de] | 128 |
|
---|
[9a0367f] | 129 | def parse_config(fname, ask_names):
|
---|
| 130 | "Parse configuration file"
|
---|
| 131 |
|
---|
| 132 | inf = file(fname, 'r')
|
---|
| 133 |
|
---|
| 134 | name = ''
|
---|
| 135 | choices = []
|
---|
| 136 |
|
---|
| 137 | for line in inf:
|
---|
| 138 |
|
---|
| 139 | if (line.startswith('!')):
|
---|
| 140 | # Ask a question
|
---|
| 141 | res = re.search(r'!\s*(?:\[(.*?)\])?\s*([^\s]+)\s*\((.*)\)\s*$', line)
|
---|
| 142 |
|
---|
| 143 | if (not res):
|
---|
| 144 | raise RuntimeError("Weird line: %s" % line)
|
---|
| 145 |
|
---|
| 146 | cond = res.group(1)
|
---|
| 147 | varname = res.group(2)
|
---|
| 148 | vartype = res.group(3)
|
---|
| 149 |
|
---|
| 150 | ask_names.append((varname, vartype, name, choices, cond))
|
---|
| 151 | name = ''
|
---|
| 152 | choices = []
|
---|
| 153 | continue
|
---|
| 154 |
|
---|
| 155 | if (line.startswith('@')):
|
---|
| 156 | # Add new line into the 'choices' array
|
---|
| 157 | res = re.match(r'@\s*(?:\[(.*?)\])?\s*"(.*?)"\s*(.*)$', line)
|
---|
| 158 |
|
---|
| 159 | if not res:
|
---|
| 160 | raise RuntimeError("Bad line: %s" % line)
|
---|
| 161 |
|
---|
| 162 | choices.append((res.group(2), res.group(3)))
|
---|
| 163 | continue
|
---|
| 164 |
|
---|
| 165 | if (line.startswith('%')):
|
---|
| 166 | # Name of the option
|
---|
| 167 | name = line[1:].strip()
|
---|
| 168 | continue
|
---|
| 169 |
|
---|
| 170 | if ((line.startswith('#')) or (line == '\n')):
|
---|
| 171 | # Comment or empty line
|
---|
| 172 | continue
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | raise RuntimeError("Unknown syntax: %s" % line)
|
---|
| 176 |
|
---|
| 177 | inf.close()
|
---|
[98376de] | 178 |
|
---|
[9a0367f] | 179 | def yes_no(default):
|
---|
| 180 | "Return '*' if yes, ' ' if no"
|
---|
| 181 |
|
---|
| 182 | if (default == 'y'):
|
---|
| 183 | return '*'
|
---|
| 184 |
|
---|
| 185 | return ' '
|
---|
[98376de] | 186 |
|
---|
[27fb3d6] | 187 | def subchoice(screen, name, choices, default):
|
---|
[9a0367f] | 188 | "Return choice of choices"
|
---|
| 189 |
|
---|
[27fb3d6] | 190 | maxkey = 0
|
---|
| 191 | for key, val in choices:
|
---|
| 192 | length = len(key)
|
---|
| 193 | if (length > maxkey):
|
---|
| 194 | maxkey = length
|
---|
[9a0367f] | 195 |
|
---|
| 196 | options = []
|
---|
[27fb3d6] | 197 | position = None
|
---|
| 198 | cnt = 0
|
---|
| 199 | for key, val in choices:
|
---|
| 200 | if ((default) and (key == default)):
|
---|
| 201 | position = cnt
|
---|
| 202 |
|
---|
| 203 | options.append(" %-*s %s " % (maxkey, key, val))
|
---|
| 204 | cnt += 1
|
---|
[9a0367f] | 205 |
|
---|
[27fb3d6] | 206 | (button, value) = xtui.choice_window(screen, name, 'Choose value', options, position)
|
---|
[9a0367f] | 207 |
|
---|
[27fb3d6] | 208 | if (button == 'cancel'):
|
---|
[9a0367f] | 209 | return None
|
---|
| 210 |
|
---|
[27fb3d6] | 211 | return choices[value][0]
|
---|
[98376de] | 212 |
|
---|
[9a0367f] | 213 | def check_choices(defaults, ask_names):
|
---|
| 214 | "Check whether all accessible variables have a default"
|
---|
| 215 |
|
---|
[27fb3d6] | 216 | for varname, vartype, name, choices, cond in ask_names:
|
---|
[9a0367f] | 217 | if ((cond) and (not check_condition(cond, defaults, ask_names))):
|
---|
| 218 | continue
|
---|
| 219 |
|
---|
| 220 | if (not defaults.has_key(varname)):
|
---|
| 221 | return False
|
---|
| 222 |
|
---|
| 223 | return True
|
---|
[98376de] | 224 |
|
---|
[84266669] | 225 | def create_output(mkname, mcname, dfname, defaults, ask_names):
|
---|
[9a0367f] | 226 | "Create output configuration"
|
---|
| 227 |
|
---|
[5a8fbcb9] | 228 | timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
---|
[fe12f9f4] | 229 |
|
---|
| 230 | sys.stderr.write("Fetching current revision identifier ... ")
|
---|
[5a8fbcb9] | 231 | version = subprocess.Popen(['bzr', 'version-info', '--custom', '--template={clean}:{revno}:{revision_id}'], stdout = subprocess.PIPE).communicate()[0].split(':')
|
---|
[fe12f9f4] | 232 | sys.stderr.write("OK\n")
|
---|
[5a8fbcb9] | 233 |
|
---|
| 234 | if (len(version) == 3):
|
---|
| 235 | revision = version[1]
|
---|
| 236 | if (version[0] != 1):
|
---|
| 237 | revision += 'M'
|
---|
| 238 | revision += ' (%s)' % version[2]
|
---|
| 239 | else:
|
---|
| 240 | revision = None
|
---|
[84266669] | 241 |
|
---|
| 242 | outmk = file(mkname, 'w')
|
---|
| 243 | outmc = file(mcname, 'w')
|
---|
| 244 | outdf = file(dfname, 'w')
|
---|
| 245 |
|
---|
| 246 | outmk.write('#########################################\n')
|
---|
| 247 | outmk.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
|
---|
| 248 | outmk.write('#########################################\n\n')
|
---|
[9a0367f] | 249 |
|
---|
[84266669] | 250 | outmc.write('/***************************************\n')
|
---|
| 251 | outmc.write(' * AUTO-GENERATED FILE, DO NOT EDIT!!! *\n')
|
---|
| 252 | outmc.write(' ***************************************/\n\n')
|
---|
| 253 |
|
---|
| 254 | outdf.write('#########################################\n')
|
---|
| 255 | outdf.write('## AUTO-GENERATED FILE, DO NOT EDIT!!! ##\n')
|
---|
| 256 | outdf.write('#########################################\n\n')
|
---|
| 257 | outdf.write('CONFIG_DEFS =')
|
---|
[9a0367f] | 258 |
|
---|
[27fb3d6] | 259 | for varname, vartype, name, choices, cond in ask_names:
|
---|
[9a0367f] | 260 | if ((cond) and (not check_condition(cond, defaults, ask_names))):
|
---|
| 261 | continue
|
---|
| 262 |
|
---|
| 263 | if (not defaults.has_key(varname)):
|
---|
| 264 | default = ''
|
---|
| 265 | else:
|
---|
| 266 | default = defaults[varname]
|
---|
[7aef7ee] | 267 | if (default == '*'):
|
---|
| 268 | default = 'y'
|
---|
[9a0367f] | 269 |
|
---|
[84266669] | 270 | outmk.write('# %s\n%s = %s\n\n' % (name, varname, default))
|
---|
| 271 |
|
---|
[04b29ca] | 272 | if ((vartype == "y") or (vartype == "n") or (vartype == "y/n") or (vartype == "n/y")):
|
---|
[84266669] | 273 | if (default == "y"):
|
---|
| 274 | outmc.write('/* %s */\n#define %s\n\n' % (name, varname))
|
---|
| 275 | outdf.write(' -D%s' % varname)
|
---|
| 276 | else:
|
---|
[06da55b] | 277 | outmc.write('/* %s */\n#define %s %s\n#define %s_%s\n\n' % (name, varname, default, varname, default))
|
---|
| 278 | outdf.write(' -D%s=%s -D%s_%s' % (varname, default, varname, default))
|
---|
[9a0367f] | 279 |
|
---|
[5a8fbcb9] | 280 | if (revision is not None):
|
---|
| 281 | outmk.write('REVISION = %s\n' % revision)
|
---|
| 282 | outmc.write('#define REVISION %s\n' % revision)
|
---|
| 283 | outdf.write(' "-DREVISION=%s"' % revision)
|
---|
[84266669] | 284 |
|
---|
[5a8fbcb9] | 285 | outmk.write('TIMESTAMP = %s\n' % timestamp)
|
---|
[84266669] | 286 | outmc.write('#define TIMESTAMP %s\n' % timestamp)
|
---|
[5a8fbcb9] | 287 | outdf.write(' "-DTIMESTAMP=%s"\n' % timestamp)
|
---|
[84266669] | 288 |
|
---|
| 289 | outmk.close()
|
---|
| 290 | outmc.close()
|
---|
| 291 | outdf.close()
|
---|
[98376de] | 292 |
|
---|
[31fb9a0] | 293 | def sorted_dir(root):
|
---|
| 294 | list = os.listdir(root)
|
---|
| 295 | list.sort()
|
---|
| 296 | return list
|
---|
| 297 |
|
---|
| 298 | def read_preconfigured(root, fname, screen, defaults):
|
---|
| 299 | options = []
|
---|
| 300 | opt2path = {}
|
---|
| 301 | cnt = 0
|
---|
| 302 |
|
---|
| 303 | # Look for profiles
|
---|
| 304 | for name in sorted_dir(root):
|
---|
| 305 | path = os.path.join(root, name)
|
---|
| 306 | canon = os.path.join(path, fname)
|
---|
| 307 |
|
---|
| 308 | if ((os.path.isdir(path)) and (os.path.exists(canon)) and (os.path.isfile(canon))):
|
---|
| 309 | subprofile = False
|
---|
| 310 |
|
---|
| 311 | # Look for subprofiles
|
---|
| 312 | for subname in sorted_dir(path):
|
---|
| 313 | subpath = os.path.join(path, subname)
|
---|
| 314 | subcanon = os.path.join(subpath, fname)
|
---|
| 315 |
|
---|
| 316 | if ((os.path.isdir(subpath)) and (os.path.exists(subcanon)) and (os.path.isfile(subcanon))):
|
---|
| 317 | subprofile = True
|
---|
| 318 | options.append("%s (%s)" % (name, subname))
|
---|
| 319 | opt2path[cnt] = (canon, subcanon)
|
---|
| 320 | cnt += 1
|
---|
| 321 |
|
---|
| 322 | if (not subprofile):
|
---|
| 323 | options.append(name)
|
---|
| 324 | opt2path[cnt] = (canon, None)
|
---|
| 325 | cnt += 1
|
---|
| 326 |
|
---|
| 327 | (button, value) = xtui.choice_window(screen, 'Load preconfigured defaults', 'Choose configuration profile', options, None)
|
---|
| 328 |
|
---|
| 329 | if (button == 'cancel'):
|
---|
| 330 | return None
|
---|
| 331 |
|
---|
| 332 | read_defaults(opt2path[value][0], defaults)
|
---|
| 333 | if (opt2path[value][1] != None):
|
---|
| 334 | read_defaults(opt2path[value][1], defaults)
|
---|
| 335 |
|
---|
[98376de] | 336 | def main():
|
---|
[9a0367f] | 337 | defaults = {}
|
---|
| 338 | ask_names = []
|
---|
| 339 |
|
---|
| 340 | # Parse configuration file
|
---|
| 341 | parse_config(INPUT, ask_names)
|
---|
| 342 |
|
---|
| 343 | # Read defaults from previous run
|
---|
[84266669] | 344 | if os.path.exists(MAKEFILE):
|
---|
| 345 | read_defaults(MAKEFILE, defaults)
|
---|
[9a0367f] | 346 |
|
---|
| 347 | # Default mode: only check defaults and regenerate configuration
|
---|
| 348 | if ((len(sys.argv) >= 3) and (sys.argv[2] == 'default')):
|
---|
| 349 | if (check_choices(defaults, ask_names)):
|
---|
[84266669] | 350 | create_output(MAKEFILE, MACROS, DEFS, defaults, ask_names)
|
---|
[9a0367f] | 351 | return 0
|
---|
| 352 |
|
---|
[48c3d50] | 353 | # Check mode: only check defaults
|
---|
| 354 | if ((len(sys.argv) >= 3) and (sys.argv[2] == 'check')):
|
---|
| 355 | if (check_choices(defaults, ask_names)):
|
---|
| 356 | return 0
|
---|
| 357 | return 1
|
---|
| 358 |
|
---|
[27fb3d6] | 359 | screen = xtui.screen_init()
|
---|
[9a0367f] | 360 | try:
|
---|
| 361 | selname = None
|
---|
[31fb9a0] | 362 | position = None
|
---|
[9a0367f] | 363 | while True:
|
---|
| 364 |
|
---|
[81c8d54] | 365 | # Cancel out all defaults which have to be deduced
|
---|
| 366 | for varname, vartype, name, choices, cond in ask_names:
|
---|
[7aef7ee] | 367 | if ((vartype == 'y') and (defaults.has_key(varname)) and (defaults[varname] == '*')):
|
---|
[81c8d54] | 368 | defaults[varname] = None
|
---|
| 369 |
|
---|
[9a0367f] | 370 | options = []
|
---|
| 371 | opt2row = {}
|
---|
[31fb9a0] | 372 | cnt = 1
|
---|
| 373 |
|
---|
| 374 | options.append(" --- Load preconfigured defaults ... ")
|
---|
| 375 |
|
---|
[27fb3d6] | 376 | for varname, vartype, name, choices, cond in ask_names:
|
---|
[9a0367f] | 377 |
|
---|
| 378 | if ((cond) and (not check_condition(cond, defaults, ask_names))):
|
---|
| 379 | continue
|
---|
| 380 |
|
---|
| 381 | if (varname == selname):
|
---|
| 382 | position = cnt
|
---|
| 383 |
|
---|
| 384 | if (not defaults.has_key(varname)):
|
---|
| 385 | default = None
|
---|
| 386 | else:
|
---|
| 387 | default = defaults[varname]
|
---|
| 388 |
|
---|
| 389 | if (vartype == 'choice'):
|
---|
| 390 | # Check if the default is an acceptable value
|
---|
| 391 | if ((default) and (not default in [choice[0] for choice in choices])):
|
---|
| 392 | default = None
|
---|
| 393 | defaults.pop(varname)
|
---|
| 394 |
|
---|
| 395 | # If there is just one option, use it
|
---|
| 396 | if (len(choices) == 1):
|
---|
[84266669] | 397 | defaults[varname] = choices[0][0]
|
---|
| 398 | continue
|
---|
[9a0367f] | 399 |
|
---|
[c79d50d] | 400 | if (default == None):
|
---|
| 401 | options.append("? %s --> " % name)
|
---|
| 402 | else:
|
---|
| 403 | options.append(" %s [%s] --> " % (name, default))
|
---|
[84266669] | 404 | elif (vartype == 'y'):
|
---|
[7aef7ee] | 405 | defaults[varname] = '*'
|
---|
[84266669] | 406 | continue
|
---|
[95b4838d] | 407 | elif (vartype == 'n'):
|
---|
| 408 | defaults[varname] = 'n'
|
---|
| 409 | continue
|
---|
[9a0367f] | 410 | elif (vartype == 'y/n'):
|
---|
| 411 | if (default == None):
|
---|
| 412 | default = 'y'
|
---|
| 413 | defaults[varname] = default
|
---|
[c79d50d] | 414 | options.append(" <%s> %s " % (yes_no(default), name))
|
---|
[9a0367f] | 415 | elif (vartype == 'n/y'):
|
---|
| 416 | if (default == None):
|
---|
| 417 | default = 'n'
|
---|
| 418 | defaults[varname] = default
|
---|
[c79d50d] | 419 | options.append(" <%s> %s " % (yes_no(default), name))
|
---|
[9a0367f] | 420 | else:
|
---|
| 421 | raise RuntimeError("Unknown variable type: %s" % vartype)
|
---|
| 422 |
|
---|
[27fb3d6] | 423 | opt2row[cnt] = (varname, vartype, name, choices)
|
---|
[9a0367f] | 424 |
|
---|
| 425 | cnt += 1
|
---|
| 426 |
|
---|
[31fb9a0] | 427 | if (position >= options):
|
---|
| 428 | position = None
|
---|
| 429 |
|
---|
[27fb3d6] | 430 | (button, value) = xtui.choice_window(screen, 'HelenOS configuration', 'Choose configuration option', options, position)
|
---|
[9a0367f] | 431 |
|
---|
[27fb3d6] | 432 | if (button == 'cancel'):
|
---|
[9a0367f] | 433 | return 'Configuration canceled'
|
---|
| 434 |
|
---|
[6346efd] | 435 | if (button == 'done'):
|
---|
| 436 | if (check_choices(defaults, ask_names)):
|
---|
| 437 | break
|
---|
| 438 | else:
|
---|
| 439 | xtui.error_dialog(screen, 'Error', 'Some options have still undefined values. These options are marked with the "?" sign.')
|
---|
| 440 | continue
|
---|
| 441 |
|
---|
[31fb9a0] | 442 | if (value == 0):
|
---|
| 443 | read_preconfigured(PRECONF, MAKEFILE, screen, defaults)
|
---|
| 444 | position = 1
|
---|
| 445 | continue
|
---|
| 446 |
|
---|
| 447 | position = None
|
---|
[27fb3d6] | 448 | if (not opt2row.has_key(value)):
|
---|
| 449 | raise RuntimeError("Error selecting value: %s" % value)
|
---|
| 450 |
|
---|
| 451 | (selname, seltype, name, choices) = opt2row[value]
|
---|
[9a0367f] | 452 |
|
---|
[27fb3d6] | 453 | if (not defaults.has_key(selname)):
|
---|
| 454 | default = None
|
---|
| 455 | else:
|
---|
| 456 | default = defaults[selname]
|
---|
[9a0367f] | 457 |
|
---|
| 458 | if (seltype == 'choice'):
|
---|
[27fb3d6] | 459 | defaults[selname] = subchoice(screen, name, choices, default)
|
---|
[9a0367f] | 460 | elif ((seltype == 'y/n') or (seltype == 'n/y')):
|
---|
| 461 | if (defaults[selname] == 'y'):
|
---|
| 462 | defaults[selname] = 'n'
|
---|
| 463 | else:
|
---|
| 464 | defaults[selname] = 'y'
|
---|
| 465 | finally:
|
---|
[27fb3d6] | 466 | xtui.screen_done(screen)
|
---|
[9a0367f] | 467 |
|
---|
[84266669] | 468 | create_output(MAKEFILE, MACROS, DEFS, defaults, ask_names)
|
---|
[9a0367f] | 469 | return 0
|
---|
[98376de] | 470 |
|
---|
| 471 | if __name__ == '__main__':
|
---|
[43a10c4] | 472 | sys.exit(main())
|
---|