opkg-query-helper.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env python
  2. # OpenEmbedded opkg query helper utility
  3. #
  4. # Written by: Paul Eggleton <paul.eggleton@linux.intel.com>
  5. #
  6. # Copyright 2012 Intel Corporation
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License version 2 as
  10. # published by the Free Software Foundation.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program; if not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. #
  21. #
  22. import sys
  23. import fileinput
  24. import re
  25. archmode = False
  26. filemode = False
  27. args = []
  28. for arg in sys.argv[1:]:
  29. if arg == '-a':
  30. archmode = True
  31. elif arg == '-f':
  32. filemode = True
  33. else:
  34. args.append(arg)
  35. # Regex for removing version specs after dependency items
  36. verregex = re.compile(' \([=<>]* [^ )]*\)')
  37. pkg = ""
  38. ver = ""
  39. for line in fileinput.input(args):
  40. line = line.rstrip()
  41. if ': ' in line:
  42. if line.startswith("Package:"):
  43. pkg = line.split(": ")[1]
  44. ver = ""
  45. else:
  46. if archmode:
  47. if line.startswith("Architecture:"):
  48. arch = line.split(": ")[1]
  49. print("%s %s" % (pkg,arch))
  50. elif filemode:
  51. if line.startswith("Version:"):
  52. ver = line.split(": ")[1]
  53. elif line.startswith("Architecture:"):
  54. arch = line.split(": ")[1]
  55. print("%s %s_%s_%s.ipk" % (pkg,pkg,ver,arch))
  56. else:
  57. if line.startswith("Depends:"):
  58. depval = line.split(": ")[1]
  59. deps = depval.split(", ")
  60. for dep in deps:
  61. dep = verregex.sub('', dep)
  62. print("%s|%s" % (pkg,dep))
  63. elif line.startswith("Recommends:"):
  64. recval = line.split(": ")[1]
  65. recs = recval.split(", ")
  66. for rec in recs:
  67. rec = verregex.sub('', rec)
  68. print("%s|%s [REC]" % (pkg, rec))