5 def read_available(filename):
7 Parses the output of bitbake -s
8 minus the first few lines
14 # str.split can not be used as we have multiple whitespace
15 first_space = line.find(" ")
16 package = line[0:first_space]
17 rest = line[first_space+1:]
18 pv = rest.strip().split(" ")[0]
20 packages[package] = pv
25 """Map a FreeBSD name to OE"""
27 "libpurple" : "pidgin",
31 "freeciv-gtk" : "freeciv",
34 "python23" : "python",
35 "python24" : "python",
36 "python25" : "python",
37 "python+ipv6" : "python",
38 "wget-devel" : "wget",
40 "freetype" : "freetype",
41 "qemu-devel" : "qemu",
43 "freeciv-gtk2": "freeciv",
47 "openvpn-devel" : "openvpn",
48 "mpeg123-esound" : "mpeg123",
49 "mpeg123-nas" : "mpeg123",
50 "cdrtools-cjk" : "cdrtools",
51 "apache+mod_ssl+mod_deflate" : "apache2",
52 "apache+mod_ssl*" : "apache2",
55 "{ja-,}bugzilla" : "bugzilla",
57 "mozilla+ipv6": "mozilla",
58 "mozilla-embeddded" : "mozilla",
60 "libsndfile" : "libsndfile1",
61 "sylpheed-gtk2": "sylpheed",
62 "cdrtools-devel": "cdrtools",
65 "ghostscript-gpl" : "gs",
66 "ghostscript-gnu-nox11" : "gs",
67 "ghostscript8" : "gs",
68 "ghostscript-afpl-nox11" : "gs",
69 "ghostscript-afpl" : "gs",
71 "mplayer-gtk" : "mplayer",
72 "xerces-c2" : "xerces-c",
75 "mplayer{,-gtk}{,-esound}" : "mplayer",
76 "proftpd-devel": "proftpd",
79 "php5-{cgi,cli}" : "php",
88 def is_not_in_oe(name):
89 """Method to reject packages not in OE"""
91 # packages that we will never have...
92 "linux-firefox", "fr-linux-netscape", "linux-netscape-{communicator,navigator}",
93 "linux_base", "ja-netscape7", "{ja,ko}-netscape-{communicator,navigator}-linux", "zhTW-linux-mozillafirebird", "ja-linux-mozillafirebird-gtk1", "el-linux-mozillafirebird", "mozilla-firebird", "netscape7",
94 "acroread4", "acroread7", "acroread5",
95 "linux-openmotif", "linux-flock", "linux-jdk", "linux-curl", "linux-png", "linux-firefox-devel",
97 # packages that we don't have now but maybe will have in
98 # the future and blacklisting them here might be a problem
99 "openoffice.org-2-devel", "openoffice.org-2", "it-openoffice", "ca-openoffice","sl-openoffice-SI", "ja-openoffice",
100 "drupal4", "drupal5", "drupal6", "drupal-pubcookie",
103 "kdenetwork", "ja-kdelibs", "kdegraphics", "kdepim", "kdebase4-runtime",
104 "xemacs-devel", "xemacs-devel-21.5", "xemacs-mule", "zh-xemacs", "zh-xemacs-mule",
105 "geeklog", "apach13-ssl", "nvidia-driver", "eGroupWare", "varnish", "heimdal",
106 "bugzilla", "agenda-snow-libs", "mozilla",
109 return name in not_in
113 Handles an entry like the one below:
114 vulnerability-test-port>=2000<2010.02.26|http://cvsweb.freebsd.org/ports/security/vulnerability-test-port/|Not vulnerable, just a test port (database: 2010-02-26)
116 def __init__(self, name, versions, link, kind):
118 self.versions = versions
122 def split_versions(self, input):
124 Split versions by <, >, >=, >=
129 # Try to determine <, >, >=, <=
130 # we will have to carry stuff on to find the
133 while i < len(input) - 1:
136 if c1 != '<' and c1 != '>' and c1 != '=':
140 # is a '=' coming behind it?
147 versions.append((next_type, input[last_pos:i]))
150 next_type = input[i:next]
155 versions.append((next_type, input[last_pos:len(input)]))
159 return "%s: %s" % (self.name, self.versions)
161 def create_infos(line):
162 split = line.split("|")
163 for i in range(0, len(split[0])):
165 if c != '<' and c != '=' and c != '>':
167 name = map_names(split[0][0:i])
168 versions = freebsd_info.split_versions(split[0][i:])
171 if is_not_in_oe(name):
172 print "Not in oe %s" % name
177 return [freebsd_info(name, versions, link, kind)]
179 def read_auditfile(filename):
181 Read an uncompressed audit file from freebsd
186 if line.startswith("#"):
189 infos = create_infos(line)
192 packages[info.name].append(info)
194 packages[info.name] = []
195 packages[info.name].append(info)
199 def strip_oe_version(oe_version):
201 We need to strip the package epoch... and the PR to compare
202 it to the FreeBSD versions. Also FreeBSD seems to use _N as
203 PR so we might need to do more..
205 split = oe_version.split(':', 1)
208 split = ver.rsplit('-r', 1)
212 def strip_bsd_version(bsd_version):
214 FreeBSD is adding ,1 for revisions.. remove that
216 split = bsd_version.rsplit(',', 1)
218 split = split.rsplit('_', 1)
221 def compare_versions(oe, freebsd, not_known):
222 def handle_package(oe_name, bsd_name):
223 if not oe_name in oe:
224 if oe_name == bsd_name:
225 print >> not_known, "%s is not in OE" % oe_name
228 oe_version = strip_oe_version(oe[oe_name])
229 for ver in freebsd[bsd_name]:
232 for (cmp, vers) in ver.versions:
233 bsd_ver = strip_bsd_version(vers)
234 cmp_res = bb.utils.vercmp(('0', oe_version, 'r0'), ('0', bsd_ver, 'r0'))
258 str.append("%s %s %s %s" % (oe_name, oe_version, cmp, bsd_ver))
260 print " && ".join(str), ver.link
262 for package in freebsd.keys():
263 # handle the various versions of OE packages
264 handle_package(package, package)
265 handle_package("%s-native" % package, package)
266 handle_package("%s-full-native" % package, package)
267 handle_package("%s-sdk" % package, package)
270 # read the input data
271 oe_packages = read_available("available")
272 freebsd_vuln = read_auditfile("auditfile")
273 buggy = open("not_in_oe.bugs", "w+")
275 compare_versions(oe=oe_packages, freebsd=freebsd_vuln, not_known=buggy)