xorg-release 6.1 KB

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