-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathgetdeps.py
More file actions
executable file
·59 lines (50 loc) · 2.04 KB
/
getdeps.py
File metadata and controls
executable file
·59 lines (50 loc) · 2.04 KB
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
#!/usr/bin/env python3
from debian.deb822 import Deb822
import argparse
import os
## Parse arguments for the control file and desired dependency section.
parser = argparse.ArgumentParser(description='List package dependencies')
parser.add_argument('control', type=str, nargs='?',
help='Debian control file to parse')
parser.add_argument('-b', '--build', action='store_true',
help='List packages from the Build-Depends paragraph')
parser.add_argument('-r', '--runtime', action='store_true',
help='List packages from the Depends paragraph')
parser.add_argument('-a', '--all', action='store_true',
help='List all packages dependencies')
parser.add_argument('-n', '--no-qt', action='store_true',
help='Ignore Qt package dependencies')
args = parser.parse_args()
## If no control file was provided, assume control.qt6 from the source checkout.
if args.control is None:
linuxdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../linux/debian")
args.control = os.path.normpath(os.path.join(linuxdir, "control"))
## Figure out which paragraphs to dump.
if args.all:
args.build = True
args.runtime = True
## Default to the runtime dependencies if nothing else is set.
if not (args.build or args.runtime):
args.runtime = True
# Parse the control file to dump the package dependencies.
def dump(depends):
for dep in depends.split(','):
pkg = dep.split()[0]
if pkg.startswith('$'):
continue
if args.no_qt:
if pkg.startswith('qml6'):
continue
if pkg.startswith('qt6'):
continue
if pkg.startswith('libqt6'):
continue
if pkg.startswith('qmake'):
continue
print(pkg)
for p in Deb822.iter_paragraphs(open(args.control)):
for item in p.items():
if args.runtime and item[0] == 'Depends':
dump(item[1])
if args.build and item[0] == 'Build-Depends':
dump(item[1])