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.
12 from distutils
.version
import LooseVersion
14 # This can be customized
15 XORG_VERSION
= "X11R7.7"
17 # Key names in dictionaries
18 XORG_VERSION_KEY
= "xorg-version"
19 BR_VERSION_KEY
= "br-version"
20 BR_NAME_KEY
= "br-name"
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
30 # Get the list of tarballs of a X.org release, parse it, and return a
31 # dictionary of dictionaries, of the form:
33 # { <name_of_package> : { XORG_VERSION_KEY: <version_of_package> },
34 # <name_of_package2> : { XORG_VERSION_KEY: <version_of_package2> }}
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()
40 links
= b
.findAll("a")
42 r
= re
.compile("(.*)-([0-9\.]*).tar.bz2")
43 # We now have a list of all links.
45 href
= link
.get("href")
46 # Skip everything but tarballs
47 if not href
.endswith(".tar.bz2"):
49 # Separate the name and the version
50 groups
= r
.match(href
)
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
:
58 packages
[name
] = { XORG_VERSION_KEY
: version
}
61 # Files and directories in package/x11r7/ that should be ignored in
63 BUILDROOT_EXCEPTIONS
= [
64 "mcookie", # Code is directly in package directory
67 "xdriver_xf86-input-tslib", # From Pengutronix, not part of X.org releases
70 # Prefixes of directories in package/x11r7/ that must be stripped
71 # before trying to match Buildroot package names with X.org tarball
73 BUILDROOT_PREFIXES
= [
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:]
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
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():
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"))
111 if d
in BUILDROOT_EXCEPTIONS
:
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
121 # There is no X.org package with this name, so we add a
123 packages
[pkgname
] = { BR_VERSION_KEY
: version
,
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()
137 nothing_todo_pkgs
= 0
139 pkg
= packages
[pkgname
]
141 if pkg
.has_key(XORG_VERSION_KEY
) and not pkg
.has_key(BR_VERSION_KEY
):
142 xorg_version
= pkg
[XORG_VERSION_KEY
]
144 action
= "Add to Buildroot"
146 elif not pkg
.has_key(XORG_VERSION_KEY
) and pkg
.has_key(BR_VERSION_KEY
):
147 br_version
= pkg
[BR_VERSION_KEY
]
149 action
= "Remove from Buildroot"
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
]
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
162 br_version
= pkg
[BR_VERSION_KEY
]
163 xorg_version
= pkg
[XORG_VERSION_KEY
]
165 nothing_todo_pkgs
+= 1
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
)
176 packages
= get_xorg_release_pkgs()
177 packages
= get_buildroot_pkgs(packages
)
179 show_summary(packages
)