aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/moon/files/get_deb_depends.py
blob: d510bcf46cc7b7f90f39f282a9e469f4aa26f71a (plain)
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
#!/usr/bin/env python3

import sys
import subprocess

pkts = []

for arg in sys.argv[1:]:
    proc = subprocess.Popen(["dpkg-deb",
                             "--info",
                             arg],
                            stdin=None,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    out = proc.stdout.read()
    err = proc.stderr.read()
    if err:
        print("An error occurred with {} ({})".format(arg, err))
        continue
    for line in out.splitlines():
        line = line.decode('utf-8')
        if " Depends:" in line:
            line = line.replace(" Depends:", "")
            for _dep in line.split(','):
                pkts.append(_dep.split()[0])

print(" ".join(pkts))