- Timestamp:
- 2005-12-08T16:15:20Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b00fdde
- Parents:
- ac0cb2a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/config.py
rac0cb2a r944b15c 231 231 f.close() 232 232 233 def check_condition(text, defaults): 234 result = True 235 conds = text.split('&') 233 def check_condition(text, defaults, asked_names): 234 seen_vars = [ x[0] for x in asked_names ] 235 ctype = 'cnf' 236 if ')|' in text or '|(' in text: 237 ctype = 'dnf' 238 239 if ctype == 'cnf': 240 conds = text.split('&') 241 else: 242 conds = text.split('|') 243 236 244 for cond in conds: 237 245 if cond.startswith('(') and cond.endswith(')'): 238 246 cond = cond[1:-1] 239 if not check_dnf(cond, defaults): 247 248 inside = check_inside(cond, defaults, ctype, seen_vars) 249 250 if ctype == 'cnf' and not inside: 240 251 return False 241 return True 242 243 def check_dnf(text, defaults): 252 if ctype == 'dnf' and inside: 253 return True 254 255 if ctype == 'cnf': 256 return True 257 return False 258 259 def check_inside(text, defaults, ctype, seen_vars): 244 260 """ 245 261 Check that the condition specified on input line is True … … 247 263 only CNF is supported 248 264 """ 249 conds = text.split('|') 265 if ctype == 'cnf': 266 conds = text.split('|') 267 else: 268 conds = text.split('&') 250 269 for cond in conds: 251 270 res = re.match(r'^(.*?)(!?=)(.*)$', cond) … … 255 274 oper = res.group(2) 256 275 condval = res.group(3) 276 if condname not in seen_vars: 277 raise RuntimeError("Variable %s not defined before being asked." %\ 278 condname) 257 279 if not defaults.has_key(condname): 258 280 raise RuntimeError("Condition var %s does not exist: %s" % \ 259 281 (condname,text)) 260 282 261 if oper=='=' and condval == defaults[condname]: 262 return True 263 if oper == '!=' and condval != defaults[condname]: 264 return True 265 return False 283 if ctype == 'cnf': 284 if oper == '=' and condval == defaults[condname]: 285 return True 286 if oper == '!=' and condval != defaults[condname]: 287 return True 288 else: 289 if oper== '=' and condval != defaults[condname]: 290 return False 291 if oper== '!=' and condval == defaults[condname]: 292 print 2 293 return False 294 if ctype=='cnf': 295 return False 296 return True 266 297 267 298 def parse_config(input, output, dlg, defaults={}, askonly=None): … … 305 336 raise RuntimeError('Invalid command: %s' % line) 306 337 if res.group(1): 307 if not check_condition(res.group(1), defaults): 338 if not check_condition(res.group(1), defaults, 339 asked_names): 308 340 continue 309 341 args = res.group(2).strip().split(' ') … … 335 367 336 368 if res.group(1): 337 if not check_condition(res.group(1), defaults): 369 if not check_condition(res.group(1), defaults, 370 asked_names): 338 371 if default is not None: 339 372 outf.write('#!# %s = %s\n' % (varname, default)) … … 366 399 raise RuntimeError("Bad line: %s" % line) 367 400 if res.group(1): 368 if not check_condition(res.group(1),defaults): 401 if not check_condition(res.group(1),defaults, 402 asked_names): 369 403 continue 370 404 choices.append((res.group(2), res.group(3))) … … 434 468 435 469 if not defmode and dlg.yesno('Rebuild kernel?') == 'y': 436 os.execlp('make','make','clean',' all')470 os.execlp('make','make','clean','build') 437 471 438 472 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.