-
Notifications
You must be signed in to change notification settings - Fork 3
/
shlibvischeck-debian
executable file
·81 lines (67 loc) · 2.39 KB
/
shlibvischeck-debian
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python3
# The MIT License (MIT)
#
# Copyright 2018-2021 Yury Gribov
#
# Use of this source code is governed by MIT license that can be
# found in the LICENSE.txt file.
# Analyzes difference between public and binary interfaces in Debian packages.
import os
import os.path
import re
import argparse
import shlibvischeck.common.error as e
from shlibvischeck.analysis.debian import *
def is_bad_pkg(pkg):
return re.search('^(libreoffice|glibc)', pkg)
def main():
me = os.path.basename(__file__)
e.set_basename(me)
e.set_throw_on_error()
parser = argparse.ArgumentParser(description="Analyzes difference between public and binary interfaces in Debian packages.",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""\
Examples:
$ {0} libacl1
""".format(me))
parser.add_argument('--verbose', '-v',
help="Print diagnostic info.",
action='count', default=0)
parser.add_argument('--permissive', '-p',
help="Ignore dummy symbols introduced by ld (_edata, __bss_start, etc.) "
"and libgcc (_init, _fini).",
dest='permissive', action='store_true', default=False)
parser.add_argument('--no-permissive',
help="Disable --permissive (default).",
dest='permissive', action='store_false')
parser.add_argument('rest',
nargs=argparse.REMAINDER, default=[])
args = parser.parse_args()
total = fails = 0
failed_packages = []
processed_pkgs = set()
for pkg in args.rest:
src = get_pkg_attribute(pkg, 'Package', True, True)[0]
# TODO: handle errors
if src in processed_pkgs or is_bad_pkg(src):
continue
processed_pkgs.add(src)
total += 1
print("Processing package '%s'..." % pkg)
success = False
try:
if analyze_debian_package(pkg, args.permissive, args.verbose):
success = True
except Exception:
import traceback
traceback.print_exc()
finally:
if not success:
print("Failed to analyze package '%s'." % pkg)
fails += 1
failed_packages.append(src)
if fails > 0:
print("%d packages failed (out of %d): %s" % (fails, total,
' '.join(failed_packages)))
if __name__ == '__main__':
main()