9 sys
.stderr
.write("Set PYTHONPATH to bitbake/lib and restart.\n")
10 sys
.stderr
.write("The backtrace can be seen below.\n")
14 def strip_oe_version(oe_version
):
16 We need to strip the package epoch... and the PR to compare
17 it to the FreeBSD versions. Also FreeBSD seems to use _N as
18 PR so we might need to do more..
20 split
= oe_version
.split(':', 1)
23 split
= ver
.rsplit('-r', 1)
27 def compare_versions(oe
, freebsd_dict
, not_known
):
28 def handle_package(oe_name
, bsd_name
):
30 if oe_name
== bsd_name
:
31 print >> not_known
, "%s is not in OE" % oe_name
34 oe_version
= strip_oe_version(oe
[oe_name
])
35 for ver
in freebsd_dict
[bsd_name
]:
38 for (cmp, vers
) in ver
.versions
:
39 (bsd_ver
, bsd_pr
) = freebsd
.prepare_version(vers
)
40 cmp_res
= bb
.utils
.vercmp(('0', oe_version
, 'r0'), ('0', bsd_ver
, bsd_pr
))
64 str.append("%s %s %s %s" % (oe_name
, oe_version
, cmp, bsd_ver
))
66 print " && ".join(str), ver
.link
68 for package
in freebsd_dict
.keys():
69 # handle the various versions of OE packages
70 handle_package(package
, package
)
71 handle_package("%s-native" % package
, package
)
72 handle_package("%s-full-native" % package
, package
)
73 handle_package("%s-sdk" % package
, package
)
74 handle_package("%s-essential" % package
, package
)
75 handle_package("%s-cross" % package
, package
)
76 handle_package("%s-initial" % package
, package
)
77 handle_package("%s-trim" % package
, package
)
78 handle_package("%s-canadian" % package
, package
)
79 handle_package("%s-cross-sdk" % package
, package
)
81 def handle_options(args
):
83 parser
= optparse
.OptionParser(version
= "OE Audit version 0.1",
84 usage
= "%prog [options]")
85 parser
.add_option("-a", "--auditfile", help = "FreeBSD auditfile to use",
86 action
= "store", dest
= "freebsd_auditfile", default
= None)
87 parser
.add_option("-p", "--available", help = "Output of bitbake -s",
88 action
= "store", dest
= "oe_available", default
= None)
89 parser
.add_option("-b", "--buggy", help = "Write out unmaped packets",
90 action
= "store", dest
= "buggy", default
= "not_in_oe.bugs")
91 parser
.add_option("-f", "--fetch", help = "Fetch a new auditfile",
92 action
= "store_true", dest
= "fetch", default
= False)
94 options
, args
= parser
.parse_args(args
)
99 opts
= handle_options(sys
.argv
)
103 print "Fetching new auditfile with wget and unpacking to the local directory"
104 os
.system("(rm auditfile.tbz || true) && wget -c http://ports.freebsd.org/auditfile.tbz; tar xjf auditfile.tbz auditfile && rm auditfile.tbz")
106 if not opts
.oe_available
or not opts
.freebsd_auditfile
:
107 print "You need to specific -a and -p."
110 oe_packages
= oe
.read_available(opts
.oe_available
)
111 freebsd_vuln
= freebsd
.read_auditfile(opts
.freebsd_auditfile
)
112 buggy
= open(opts
.buggy
, "w+")
114 compare_versions(oe
=oe_packages
, freebsd_dict
=freebsd_vuln
, not_known
=buggy
)