xorg-release 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #!/usr/bin/env python
  2. # This script generates a report on the packaging status of X.org
  3. # releases in Buildroot. It does so by downloading the list of
  4. # tarballs that are part of a given X.org release, and compare that
  5. # with the packages that are available in Buildroot.
  6. import BeautifulSoup
  7. import re
  8. import os
  9. import urllib
  10. from distutils.version import LooseVersion
  11. # This can be customized
  12. XORG_VERSION = "X11R7.7"
  13. # Key names in dictionaries
  14. XORG_VERSION_KEY = "xorg-version"
  15. BR_VERSION_KEY = "br-version"
  16. BR_NAME_KEY = "br-name"
  17. # Packages part of X.org releases that we do not want to package in
  18. # Buildroot (old drivers for hardware unlikely to be used in embedded
  19. # contexts).
  20. XORG_EXCEPTIONS = [
  21. 'xf86-video-suncg6',
  22. 'xf86-video-sunffb',
  23. ]
  24. # Get the list of tarballs of a X.org release, parse it, and return a
  25. # dictionary of dictionaries, of the form:
  26. #
  27. # { <name_of_package> : { XORG_VERSION_KEY: <version_of_package> },
  28. # <name_of_package2> : { XORG_VERSION_KEY: <version_of_package2> }}
  29. #
  30. def get_xorg_release_pkgs():
  31. u = urllib.URLopener().open("http://www.x.org/releases/%s/src/everything/" % XORG_VERSION)
  32. b = BeautifulSoup.BeautifulSoup()
  33. b.feed(u.read())
  34. links = b.findAll("a")
  35. packages = {}
  36. r = re.compile("(.*)-([0-9\.]*).tar.bz2")
  37. # We now have a list of all links.
  38. for link in links:
  39. href = link.get("href")
  40. # Skip everything but tarballs
  41. if not href.endswith(".tar.bz2"):
  42. continue
  43. # Separate the name and the version
  44. groups = r.match(href)
  45. if not groups:
  46. continue
  47. name = groups.group(1)
  48. version = groups.group(2)
  49. # Skip packages we don't want to hear about
  50. if name in XORG_EXCEPTIONS:
  51. continue
  52. packages[name] = { XORG_VERSION_KEY : version }
  53. return packages
  54. # Files and directories in package/x11r7/ that should be ignored in
  55. # our processing.
  56. BUILDROOT_EXCEPTIONS = [
  57. "mcookie", # Code is directly in package directory
  58. "x11r7.mk",
  59. "Config.in",
  60. "xdriver_xf86-input-tslib", # From Pengutronix, not part of X.org releases
  61. ]
  62. # Prefixes of directories in package/x11r7/ that must be stripped
  63. # before trying to match Buildroot package names with X.org tarball
  64. # names.
  65. BUILDROOT_PREFIXES = [
  66. "xapp",
  67. "xdriver",
  68. "xfont",
  69. "xlib",
  70. "xserver",
  71. "xutil",
  72. "xproto",
  73. ]
  74. # From a Buildroot package name, try to see if a prefix should be
  75. # stripped from it. For example, passing "xapp_xlsfonts" as argument
  76. # to this function will return "xlsfonts".
  77. def buildroot_strip_prefix(dirname):
  78. for prefix in BUILDROOT_PREFIXES:
  79. if dirname.startswith(prefix + "_"):
  80. return dirname[len(prefix) + 1:]
  81. return dirname
  82. # From a Buildroot package name, parse its .mk file to find the
  83. # Buildroot version of the package by looking at the <foo>_VERSION
  84. # line.
  85. def buildroot_get_version(dirname):
  86. f = open(os.path.join("package", "x11r7", dirname, dirname + ".mk"))
  87. r = re.compile("^([A-Z0-9_]*)_VERSION = ([0-9\.]*)$")
  88. for l in f.readlines():
  89. m = r.match(l)
  90. if m:
  91. return m.group(2)
  92. return None
  93. # Augment the information of the X.org list of packages (given as
  94. # argument) by details about their packaging in Buildroot. Those
  95. # details are found by looking at the contents of package/x11r7/.
  96. def get_buildroot_pkgs(packages):
  97. dirs = os.listdir(os.path.join(os.getcwd(), "package", "x11r7"))
  98. for d in dirs:
  99. # Skip exceptions
  100. if d in BUILDROOT_EXCEPTIONS:
  101. continue
  102. pkgname = buildroot_strip_prefix(d)
  103. version = buildroot_get_version(d)
  104. if packages.has_key(pkgname):
  105. # There is a X.org package of the same name, so we just
  106. # add information to the existing dict entry.
  107. packages[pkgname]['br-version'] = version
  108. packages[pkgname]['br-name'] = d
  109. else:
  110. # There is no X.org package with this name, so we add a
  111. # new dict entry.
  112. packages[pkgname] = { BR_VERSION_KEY: version,
  113. BR_NAME_KEY : d }
  114. return packages
  115. def show_summary(packages):
  116. FORMAT_STRING = "%40s | %15s | %15s | %-30s"
  117. print FORMAT_STRING % ("Package name", "Vers in BR", "Vers in X.org", "Action")
  118. print FORMAT_STRING % ("-" * 40, "-" * 15, "-" * 15, "-" * 30)
  119. pkgs = packages.keys()
  120. pkgs.sort()
  121. total_pkgs = 0
  122. upgrade_pkgs = 0
  123. add_pkgs = 0
  124. remove_pkgs = 0
  125. nothing_todo_pkgs = 0
  126. for pkgname in pkgs:
  127. pkg = packages[pkgname]
  128. total_pkgs += 1
  129. if pkg.has_key(XORG_VERSION_KEY) and not pkg.has_key(BR_VERSION_KEY):
  130. xorg_version = pkg[XORG_VERSION_KEY]
  131. br_version = "N/A"
  132. action = "Add to Buildroot"
  133. add_pkgs += 1
  134. elif not pkg.has_key(XORG_VERSION_KEY) and pkg.has_key(BR_VERSION_KEY):
  135. br_version = pkg[BR_VERSION_KEY]
  136. xorg_version = "N/A"
  137. action = "Remove from Buildroot"
  138. remove_pkgs += 1
  139. elif LooseVersion(pkg[XORG_VERSION_KEY]) > LooseVersion(pkg[BR_VERSION_KEY]):
  140. br_version = pkg[BR_VERSION_KEY]
  141. xorg_version = pkg[XORG_VERSION_KEY]
  142. action = "Upgrade"
  143. upgrade_pkgs += 1
  144. elif LooseVersion(pkg[XORG_VERSION_KEY]) < LooseVersion(pkg[BR_VERSION_KEY]):
  145. br_version = pkg[BR_VERSION_KEY]
  146. xorg_version = pkg[XORG_VERSION_KEY]
  147. action = "More recent"
  148. nothing_todo_pkgs += 1
  149. else:
  150. br_version = pkg[BR_VERSION_KEY]
  151. xorg_version = pkg[XORG_VERSION_KEY]
  152. action = ""
  153. nothing_todo_pkgs += 1
  154. print FORMAT_STRING % (pkgname, br_version.center(15), xorg_version.center(15), action)
  155. print FORMAT_STRING % ("-" * 40, "-" * 15, "-" * 15, "-" * 30)
  156. STAT_FORMAT_STRING = "%40s : %3d"
  157. print STAT_FORMAT_STRING % ("Total number of packages", total_pkgs)
  158. print STAT_FORMAT_STRING % ("Packages to upgrade", upgrade_pkgs)
  159. print STAT_FORMAT_STRING % ("Packages to add", add_pkgs)
  160. print STAT_FORMAT_STRING % ("Packages to remove", remove_pkgs)
  161. print STAT_FORMAT_STRING % ("Packages with nothing to do", nothing_todo_pkgs)
  162. packages = get_xorg_release_pkgs()
  163. packages = get_buildroot_pkgs(packages)
  164. # print packages
  165. show_summary(packages)