dump_cache.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env python
  2. # ex:ts=4:sw=4:sts=4:et
  3. # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
  4. #
  5. # Copyright (C) 2012 Wind River Systems, Inc.
  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. # This is used for dumping the bb_cache.dat, the output format is:
  21. # recipe_path PN PV PACKAGES
  22. #
  23. import os
  24. import sys
  25. import warnings
  26. # For importing bb.cache
  27. sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), '../lib'))
  28. from bb.cache import CoreRecipeInfo
  29. import pickle as pickle
  30. def main(argv=None):
  31. """
  32. Get the mapping for the target recipe.
  33. """
  34. if len(argv) != 1:
  35. print("Error, need one argument!", file=sys.stderr)
  36. return 2
  37. cachefile = argv[0]
  38. with open(cachefile, "rb") as cachefile:
  39. pickled = pickle.Unpickler(cachefile)
  40. while cachefile:
  41. try:
  42. key = pickled.load()
  43. val = pickled.load()
  44. except Exception:
  45. break
  46. if isinstance(val, CoreRecipeInfo) and (not val.skipped):
  47. pn = val.pn
  48. # Filter out the native recipes.
  49. if key.startswith('virtual:native:') or pn.endswith("-native"):
  50. continue
  51. # 1.0 is the default version for a no PV recipe.
  52. if "pv" in val.__dict__:
  53. pv = val.pv
  54. else:
  55. pv = "1.0"
  56. print("%s %s %s %s" % (key, pn, pv, ' '.join(val.packages)))
  57. if __name__ == "__main__":
  58. sys.exit(main(sys.argv[1:]))