command.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. """
  2. BitBake 'Command' module
  3. Provide an interface to interact with the bitbake server through 'commands'
  4. """
  5. # Copyright (C) 2006-2007 Richard Purdie
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License version 2 as
  9. # published by the Free Software Foundation.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along
  17. # with this program; if not, write to the Free Software Foundation, Inc.,
  18. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. """
  20. The bitbake server takes 'commands' from its UI/commandline.
  21. Commands are either synchronous or asynchronous.
  22. Async commands return data to the client in the form of events.
  23. Sync commands must only return data through the function return value
  24. and must not trigger events, directly or indirectly.
  25. Commands are queued in a CommandQueue
  26. """
  27. from collections import OrderedDict, defaultdict
  28. import bb.event
  29. import bb.cooker
  30. import bb.remotedata
  31. class DataStoreConnectionHandle(object):
  32. def __init__(self, dsindex=0):
  33. self.dsindex = dsindex
  34. class CommandCompleted(bb.event.Event):
  35. pass
  36. class CommandExit(bb.event.Event):
  37. def __init__(self, exitcode):
  38. bb.event.Event.__init__(self)
  39. self.exitcode = int(exitcode)
  40. class CommandFailed(CommandExit):
  41. def __init__(self, message):
  42. self.error = message
  43. CommandExit.__init__(self, 1)
  44. def __str__(self):
  45. return "Command execution failed: %s" % self.error
  46. class CommandError(Exception):
  47. pass
  48. class Command:
  49. """
  50. A queue of asynchronous commands for bitbake
  51. """
  52. def __init__(self, cooker):
  53. self.cooker = cooker
  54. self.cmds_sync = CommandsSync()
  55. self.cmds_async = CommandsAsync()
  56. self.remotedatastores = bb.remotedata.RemoteDatastores(cooker)
  57. # FIXME Add lock for this
  58. self.currentAsyncCommand = None
  59. def runCommand(self, commandline, ro_only = False):
  60. command = commandline.pop(0)
  61. if hasattr(CommandsSync, command):
  62. # Can run synchronous commands straight away
  63. command_method = getattr(self.cmds_sync, command)
  64. if ro_only:
  65. if not hasattr(command_method, 'readonly') or False == getattr(command_method, 'readonly'):
  66. return None, "Not able to execute not readonly commands in readonly mode"
  67. try:
  68. if getattr(command_method, 'needconfig', False):
  69. self.cooker.updateCacheSync()
  70. result = command_method(self, commandline)
  71. except CommandError as exc:
  72. return None, exc.args[0]
  73. except (Exception, SystemExit):
  74. import traceback
  75. return None, traceback.format_exc()
  76. else:
  77. return result, None
  78. if self.currentAsyncCommand is not None:
  79. return None, "Busy (%s in progress)" % self.currentAsyncCommand[0]
  80. if command not in CommandsAsync.__dict__:
  81. return None, "No such command"
  82. self.currentAsyncCommand = (command, commandline)
  83. self.cooker.configuration.server_register_idlecallback(self.cooker.runCommands, self.cooker)
  84. return True, None
  85. def runAsyncCommand(self):
  86. try:
  87. if self.cooker.state in (bb.cooker.state.error, bb.cooker.state.shutdown, bb.cooker.state.forceshutdown):
  88. # updateCache will trigger a shutdown of the parser
  89. # and then raise BBHandledException triggering an exit
  90. self.cooker.updateCache()
  91. return False
  92. if self.currentAsyncCommand is not None:
  93. (command, options) = self.currentAsyncCommand
  94. commandmethod = getattr(CommandsAsync, command)
  95. needcache = getattr( commandmethod, "needcache" )
  96. if needcache and self.cooker.state != bb.cooker.state.running:
  97. self.cooker.updateCache()
  98. return True
  99. else:
  100. commandmethod(self.cmds_async, self, options)
  101. return False
  102. else:
  103. return False
  104. except KeyboardInterrupt as exc:
  105. self.finishAsyncCommand("Interrupted")
  106. return False
  107. except SystemExit as exc:
  108. arg = exc.args[0]
  109. if isinstance(arg, str):
  110. self.finishAsyncCommand(arg)
  111. else:
  112. self.finishAsyncCommand("Exited with %s" % arg)
  113. return False
  114. except Exception as exc:
  115. import traceback
  116. if isinstance(exc, bb.BBHandledException):
  117. self.finishAsyncCommand("")
  118. else:
  119. self.finishAsyncCommand(traceback.format_exc())
  120. return False
  121. def finishAsyncCommand(self, msg=None, code=None):
  122. if msg or msg == "":
  123. bb.event.fire(CommandFailed(msg), self.cooker.data)
  124. elif code:
  125. bb.event.fire(CommandExit(code), self.cooker.data)
  126. else:
  127. bb.event.fire(CommandCompleted(), self.cooker.data)
  128. self.currentAsyncCommand = None
  129. self.cooker.finishcommand()
  130. def split_mc_pn(pn):
  131. if pn.startswith("multiconfig:"):
  132. _, mc, pn = pn.split(":", 2)
  133. return (mc, pn)
  134. return ('', pn)
  135. class CommandsSync:
  136. """
  137. A class of synchronous commands
  138. These should run quickly so as not to hurt interactive performance.
  139. These must not influence any running synchronous command.
  140. """
  141. def stateShutdown(self, command, params):
  142. """
  143. Trigger cooker 'shutdown' mode
  144. """
  145. command.cooker.shutdown(False)
  146. def stateForceShutdown(self, command, params):
  147. """
  148. Stop the cooker
  149. """
  150. command.cooker.shutdown(True)
  151. def getAllKeysWithFlags(self, command, params):
  152. """
  153. Returns a dump of the global state. Call with
  154. variable flags to be retrieved as params.
  155. """
  156. flaglist = params[0]
  157. return command.cooker.getAllKeysWithFlags(flaglist)
  158. getAllKeysWithFlags.readonly = True
  159. def getVariable(self, command, params):
  160. """
  161. Read the value of a variable from data
  162. """
  163. varname = params[0]
  164. expand = True
  165. if len(params) > 1:
  166. expand = (params[1] == "True")
  167. return command.cooker.data.getVar(varname, expand)
  168. getVariable.readonly = True
  169. def setVariable(self, command, params):
  170. """
  171. Set the value of variable in data
  172. """
  173. varname = params[0]
  174. value = str(params[1])
  175. command.cooker.extraconfigdata[varname] = value
  176. command.cooker.data.setVar(varname, value)
  177. def getSetVariable(self, command, params):
  178. """
  179. Read the value of a variable from data and set it into the datastore
  180. which effectively expands and locks the value.
  181. """
  182. varname = params[0]
  183. result = self.getVariable(command, params)
  184. command.cooker.data.setVar(varname, result)
  185. return result
  186. def setConfig(self, command, params):
  187. """
  188. Set the value of variable in configuration
  189. """
  190. varname = params[0]
  191. value = str(params[1])
  192. setattr(command.cooker.configuration, varname, value)
  193. def enableDataTracking(self, command, params):
  194. """
  195. Enable history tracking for variables
  196. """
  197. command.cooker.enableDataTracking()
  198. def disableDataTracking(self, command, params):
  199. """
  200. Disable history tracking for variables
  201. """
  202. command.cooker.disableDataTracking()
  203. def setPrePostConfFiles(self, command, params):
  204. prefiles = params[0].split()
  205. postfiles = params[1].split()
  206. command.cooker.configuration.prefile = prefiles
  207. command.cooker.configuration.postfile = postfiles
  208. setPrePostConfFiles.needconfig = False
  209. def matchFile(self, command, params):
  210. fMatch = params[0]
  211. return command.cooker.matchFile(fMatch)
  212. matchFile.needconfig = False
  213. def getUIHandlerNum(self, command, params):
  214. return bb.event.get_uihandler()
  215. getUIHandlerNum.needconfig = False
  216. getUIHandlerNum.readonly = True
  217. def setEventMask(self, command, params):
  218. handlerNum = params[0]
  219. llevel = params[1]
  220. debug_domains = params[2]
  221. mask = params[3]
  222. return bb.event.set_UIHmask(handlerNum, llevel, debug_domains, mask)
  223. setEventMask.needconfig = False
  224. setEventMask.readonly = True
  225. def setFeatures(self, command, params):
  226. """
  227. Set the cooker features to include the passed list of features
  228. """
  229. features = params[0]
  230. command.cooker.setFeatures(features)
  231. setFeatures.needconfig = False
  232. # although we change the internal state of the cooker, this is transparent since
  233. # we always take and leave the cooker in state.initial
  234. setFeatures.readonly = True
  235. def updateConfig(self, command, params):
  236. options = params[0]
  237. environment = params[1]
  238. cmdline = params[2]
  239. command.cooker.updateConfigOpts(options, environment, cmdline)
  240. updateConfig.needconfig = False
  241. def parseConfiguration(self, command, params):
  242. """Instruct bitbake to parse its configuration
  243. NOTE: it is only necessary to call this if you aren't calling any normal action
  244. (otherwise parsing is taken care of automatically)
  245. """
  246. command.cooker.parseConfiguration()
  247. parseConfiguration.needconfig = False
  248. def getLayerPriorities(self, command, params):
  249. ret = []
  250. # regex objects cannot be marshalled by xmlrpc
  251. for collection, pattern, regex, pri in command.cooker.bbfile_config_priorities:
  252. ret.append((collection, pattern, regex.pattern, pri))
  253. return ret
  254. getLayerPriorities.readonly = True
  255. def getRecipes(self, command, params):
  256. try:
  257. mc = params[0]
  258. except IndexError:
  259. mc = ''
  260. return list(command.cooker.recipecaches[mc].pkg_pn.items())
  261. getRecipes.readonly = True
  262. def getRecipeDepends(self, command, params):
  263. try:
  264. mc = params[0]
  265. except IndexError:
  266. mc = ''
  267. return list(command.cooker.recipecaches[mc].deps.items())
  268. getRecipeDepends.readonly = True
  269. def getRecipeVersions(self, command, params):
  270. try:
  271. mc = params[0]
  272. except IndexError:
  273. mc = ''
  274. return command.cooker.recipecaches[mc].pkg_pepvpr
  275. getRecipeVersions.readonly = True
  276. def getRecipeProvides(self, command, params):
  277. try:
  278. mc = params[0]
  279. except IndexError:
  280. mc = ''
  281. return command.cooker.recipecaches[mc].fn_provides
  282. getRecipeProvides.readonly = True
  283. def getRecipePackages(self, command, params):
  284. try:
  285. mc = params[0]
  286. except IndexError:
  287. mc = ''
  288. return command.cooker.recipecaches[mc].packages
  289. getRecipePackages.readonly = True
  290. def getRecipePackagesDynamic(self, command, params):
  291. try:
  292. mc = params[0]
  293. except IndexError:
  294. mc = ''
  295. return command.cooker.recipecaches[mc].packages_dynamic
  296. getRecipePackagesDynamic.readonly = True
  297. def getRProviders(self, command, params):
  298. try:
  299. mc = params[0]
  300. except IndexError:
  301. mc = ''
  302. return command.cooker.recipecaches[mc].rproviders
  303. getRProviders.readonly = True
  304. def getRuntimeDepends(self, command, params):
  305. ret = []
  306. try:
  307. mc = params[0]
  308. except IndexError:
  309. mc = ''
  310. rundeps = command.cooker.recipecaches[mc].rundeps
  311. for key, value in rundeps.items():
  312. if isinstance(value, defaultdict):
  313. value = dict(value)
  314. ret.append((key, value))
  315. return ret
  316. getRuntimeDepends.readonly = True
  317. def getRuntimeRecommends(self, command, params):
  318. ret = []
  319. try:
  320. mc = params[0]
  321. except IndexError:
  322. mc = ''
  323. runrecs = command.cooker.recipecaches[mc].runrecs
  324. for key, value in runrecs.items():
  325. if isinstance(value, defaultdict):
  326. value = dict(value)
  327. ret.append((key, value))
  328. return ret
  329. getRuntimeRecommends.readonly = True
  330. def getRecipeInherits(self, command, params):
  331. try:
  332. mc = params[0]
  333. except IndexError:
  334. mc = ''
  335. return command.cooker.recipecaches[mc].inherits
  336. getRecipeInherits.readonly = True
  337. def getBbFilePriority(self, command, params):
  338. try:
  339. mc = params[0]
  340. except IndexError:
  341. mc = ''
  342. return command.cooker.recipecaches[mc].bbfile_priority
  343. getBbFilePriority.readonly = True
  344. def getDefaultPreference(self, command, params):
  345. try:
  346. mc = params[0]
  347. except IndexError:
  348. mc = ''
  349. return command.cooker.recipecaches[mc].pkg_dp
  350. getDefaultPreference.readonly = True
  351. def getSkippedRecipes(self, command, params):
  352. # Return list sorted by reverse priority order
  353. import bb.cache
  354. skipdict = OrderedDict(sorted(command.cooker.skiplist.items(),
  355. key=lambda x: (-command.cooker.collection.calc_bbfile_priority(bb.cache.virtualfn2realfn(x[0])[0]), x[0])))
  356. return list(skipdict.items())
  357. getSkippedRecipes.readonly = True
  358. def getOverlayedRecipes(self, command, params):
  359. return list(command.cooker.collection.overlayed.items())
  360. getOverlayedRecipes.readonly = True
  361. def getFileAppends(self, command, params):
  362. fn = params[0]
  363. return command.cooker.collection.get_file_appends(fn)
  364. getFileAppends.readonly = True
  365. def getAllAppends(self, command, params):
  366. return command.cooker.collection.bbappends
  367. getAllAppends.readonly = True
  368. def findProviders(self, command, params):
  369. return command.cooker.findProviders()
  370. findProviders.readonly = True
  371. def findBestProvider(self, command, params):
  372. (mc, pn) = split_mc_pn(params[0])
  373. return command.cooker.findBestProvider(pn, mc)
  374. findBestProvider.readonly = True
  375. def allProviders(self, command, params):
  376. try:
  377. mc = params[0]
  378. except IndexError:
  379. mc = ''
  380. return list(bb.providers.allProviders(command.cooker.recipecaches[mc]).items())
  381. allProviders.readonly = True
  382. def getRuntimeProviders(self, command, params):
  383. rprovide = params[0]
  384. try:
  385. mc = params[1]
  386. except IndexError:
  387. mc = ''
  388. all_p = bb.providers.getRuntimeProviders(command.cooker.recipecaches[mc], rprovide)
  389. if all_p:
  390. best = bb.providers.filterProvidersRunTime(all_p, rprovide,
  391. command.cooker.data,
  392. command.cooker.recipecaches[mc])[0][0]
  393. else:
  394. best = None
  395. return all_p, best
  396. getRuntimeProviders.readonly = True
  397. def dataStoreConnectorFindVar(self, command, params):
  398. dsindex = params[0]
  399. name = params[1]
  400. datastore = command.remotedatastores[dsindex]
  401. value, overridedata = datastore._findVar(name)
  402. if value:
  403. content = value.get('_content', None)
  404. if isinstance(content, bb.data_smart.DataSmart):
  405. # Value is a datastore (e.g. BB_ORIGENV) - need to handle this carefully
  406. idx = command.remotedatastores.check_store(content, True)
  407. return {'_content': DataStoreConnectionHandle(idx),
  408. '_connector_origtype': 'DataStoreConnectionHandle',
  409. '_connector_overrides': overridedata}
  410. elif isinstance(content, set):
  411. return {'_content': list(content),
  412. '_connector_origtype': 'set',
  413. '_connector_overrides': overridedata}
  414. else:
  415. value['_connector_overrides'] = overridedata
  416. else:
  417. value = {}
  418. value['_connector_overrides'] = overridedata
  419. return value
  420. dataStoreConnectorFindVar.readonly = True
  421. def dataStoreConnectorGetKeys(self, command, params):
  422. dsindex = params[0]
  423. datastore = command.remotedatastores[dsindex]
  424. return list(datastore.keys())
  425. dataStoreConnectorGetKeys.readonly = True
  426. def dataStoreConnectorGetVarHistory(self, command, params):
  427. dsindex = params[0]
  428. name = params[1]
  429. datastore = command.remotedatastores[dsindex]
  430. return datastore.varhistory.variable(name)
  431. dataStoreConnectorGetVarHistory.readonly = True
  432. def dataStoreConnectorExpandPythonRef(self, command, params):
  433. config_data_dict = params[0]
  434. varname = params[1]
  435. expr = params[2]
  436. config_data = command.remotedatastores.receive_datastore(config_data_dict)
  437. varparse = bb.data_smart.VariableParse(varname, config_data)
  438. return varparse.python_sub(expr)
  439. def dataStoreConnectorRelease(self, command, params):
  440. dsindex = params[0]
  441. if dsindex <= 0:
  442. raise CommandError('dataStoreConnectorRelease: invalid index %d' % dsindex)
  443. command.remotedatastores.release(dsindex)
  444. def dataStoreConnectorSetVarFlag(self, command, params):
  445. dsindex = params[0]
  446. name = params[1]
  447. flag = params[2]
  448. value = params[3]
  449. datastore = command.remotedatastores[dsindex]
  450. datastore.setVarFlag(name, flag, value)
  451. def dataStoreConnectorDelVar(self, command, params):
  452. dsindex = params[0]
  453. name = params[1]
  454. datastore = command.remotedatastores[dsindex]
  455. if len(params) > 2:
  456. flag = params[2]
  457. datastore.delVarFlag(name, flag)
  458. else:
  459. datastore.delVar(name)
  460. def dataStoreConnectorRenameVar(self, command, params):
  461. dsindex = params[0]
  462. name = params[1]
  463. newname = params[2]
  464. datastore = command.remotedatastores[dsindex]
  465. datastore.renameVar(name, newname)
  466. def parseRecipeFile(self, command, params):
  467. """
  468. Parse the specified recipe file (with or without bbappends)
  469. and return a datastore object representing the environment
  470. for the recipe.
  471. """
  472. fn = params[0]
  473. appends = params[1]
  474. appendlist = params[2]
  475. if len(params) > 3:
  476. config_data_dict = params[3]
  477. config_data = command.remotedatastores.receive_datastore(config_data_dict)
  478. else:
  479. config_data = None
  480. if appends:
  481. if appendlist is not None:
  482. appendfiles = appendlist
  483. else:
  484. appendfiles = command.cooker.collection.get_file_appends(fn)
  485. else:
  486. appendfiles = []
  487. # We are calling bb.cache locally here rather than on the server,
  488. # but that's OK because it doesn't actually need anything from
  489. # the server barring the global datastore (which we have a remote
  490. # version of)
  491. if config_data:
  492. # We have to use a different function here if we're passing in a datastore
  493. # NOTE: we took a copy above, so we don't do it here again
  494. envdata = bb.cache.parse_recipe(config_data, fn, appendfiles)['']
  495. else:
  496. # Use the standard path
  497. parser = bb.cache.NoCache(command.cooker.databuilder)
  498. envdata = parser.loadDataFull(fn, appendfiles)
  499. idx = command.remotedatastores.store(envdata)
  500. return DataStoreConnectionHandle(idx)
  501. parseRecipeFile.readonly = True
  502. class CommandsAsync:
  503. """
  504. A class of asynchronous commands
  505. These functions communicate via generated events.
  506. Any function that requires metadata parsing should be here.
  507. """
  508. def buildFile(self, command, params):
  509. """
  510. Build a single specified .bb file
  511. """
  512. bfile = params[0]
  513. task = params[1]
  514. if len(params) > 2:
  515. internal = params[2]
  516. else:
  517. internal = False
  518. if internal:
  519. command.cooker.buildFileInternal(bfile, task, fireevents=False, quietlog=True)
  520. else:
  521. command.cooker.buildFile(bfile, task)
  522. buildFile.needcache = False
  523. def buildTargets(self, command, params):
  524. """
  525. Build a set of targets
  526. """
  527. pkgs_to_build = params[0]
  528. task = params[1]
  529. command.cooker.buildTargets(pkgs_to_build, task)
  530. buildTargets.needcache = True
  531. def generateDepTreeEvent(self, command, params):
  532. """
  533. Generate an event containing the dependency information
  534. """
  535. pkgs_to_build = params[0]
  536. task = params[1]
  537. command.cooker.generateDepTreeEvent(pkgs_to_build, task)
  538. command.finishAsyncCommand()
  539. generateDepTreeEvent.needcache = True
  540. def generateDotGraph(self, command, params):
  541. """
  542. Dump dependency information to disk as .dot files
  543. """
  544. pkgs_to_build = params[0]
  545. task = params[1]
  546. command.cooker.generateDotGraphFiles(pkgs_to_build, task)
  547. command.finishAsyncCommand()
  548. generateDotGraph.needcache = True
  549. def generateTargetsTree(self, command, params):
  550. """
  551. Generate a tree of buildable targets.
  552. If klass is provided ensure all recipes that inherit the class are
  553. included in the package list.
  554. If pkg_list provided use that list (plus any extras brought in by
  555. klass) rather than generating a tree for all packages.
  556. """
  557. klass = params[0]
  558. pkg_list = params[1]
  559. command.cooker.generateTargetsTree(klass, pkg_list)
  560. command.finishAsyncCommand()
  561. generateTargetsTree.needcache = True
  562. def findConfigFiles(self, command, params):
  563. """
  564. Find config files which provide appropriate values
  565. for the passed configuration variable. i.e. MACHINE
  566. """
  567. varname = params[0]
  568. command.cooker.findConfigFiles(varname)
  569. command.finishAsyncCommand()
  570. findConfigFiles.needcache = False
  571. def findFilesMatchingInDir(self, command, params):
  572. """
  573. Find implementation files matching the specified pattern
  574. in the requested subdirectory of a BBPATH
  575. """
  576. pattern = params[0]
  577. directory = params[1]
  578. command.cooker.findFilesMatchingInDir(pattern, directory)
  579. command.finishAsyncCommand()
  580. findFilesMatchingInDir.needcache = False
  581. def findConfigFilePath(self, command, params):
  582. """
  583. Find the path of the requested configuration file
  584. """
  585. configfile = params[0]
  586. command.cooker.findConfigFilePath(configfile)
  587. command.finishAsyncCommand()
  588. findConfigFilePath.needcache = False
  589. def showVersions(self, command, params):
  590. """
  591. Show the currently selected versions
  592. """
  593. command.cooker.showVersions()
  594. command.finishAsyncCommand()
  595. showVersions.needcache = True
  596. def showEnvironmentTarget(self, command, params):
  597. """
  598. Print the environment of a target recipe
  599. (needs the cache to work out which recipe to use)
  600. """
  601. pkg = params[0]
  602. command.cooker.showEnvironment(None, pkg)
  603. command.finishAsyncCommand()
  604. showEnvironmentTarget.needcache = True
  605. def showEnvironment(self, command, params):
  606. """
  607. Print the standard environment
  608. or if specified the environment for a specified recipe
  609. """
  610. bfile = params[0]
  611. command.cooker.showEnvironment(bfile)
  612. command.finishAsyncCommand()
  613. showEnvironment.needcache = False
  614. def parseFiles(self, command, params):
  615. """
  616. Parse the .bb files
  617. """
  618. command.cooker.updateCache()
  619. command.finishAsyncCommand()
  620. parseFiles.needcache = True
  621. def compareRevisions(self, command, params):
  622. """
  623. Parse the .bb files
  624. """
  625. if bb.fetch.fetcher_compare_revisions(command.cooker.data):
  626. command.finishAsyncCommand(code=1)
  627. else:
  628. command.finishAsyncCommand()
  629. compareRevisions.needcache = True
  630. def triggerEvent(self, command, params):
  631. """
  632. Trigger a certain event
  633. """
  634. event = params[0]
  635. bb.event.fire(eval(event), command.cooker.data)
  636. command.currentAsyncCommand = None
  637. triggerEvent.needcache = False
  638. def resetCooker(self, command, params):
  639. """
  640. Reset the cooker to its initial state, thus forcing a reparse for
  641. any async command that has the needcache property set to True
  642. """
  643. command.cooker.reset()
  644. command.finishAsyncCommand()
  645. resetCooker.needcache = False
  646. def clientComplete(self, command, params):
  647. """
  648. Do the right thing when the controlling client exits
  649. """
  650. command.cooker.clientComplete()
  651. command.finishAsyncCommand()
  652. clientComplete.needcache = False