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