1 # Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7 # Execute the "make <pkg>-show-version" command to get the version of a given
8 # list of packages, and return the version formatted as a Python dictionary.
10 sys.stderr.write("Getting version for %s\n" % pkgs)
11 cmd = ["make", "-s", "--no-print-directory"]
13 cmd.append("%s-show-version" % pkg)
14 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
15 output = p.communicate()[0]
17 sys.stderr.write("Error getting version %s\n" % pkgs)
19 output = output.split("\n")
20 if len(output) != len(pkgs) + 1:
21 sys.stderr.write("Error getting version\n")
24 for i in range(0, len(pkgs)):
26 version[pkg] = output[i]
30 def _get_depends(pkgs, rule):
31 sys.stderr.write("Getting dependencies for %s\n" % pkgs)
32 cmd = ["make", "-s", "--no-print-directory"]
34 cmd.append("%s-%s" % (pkg, rule))
35 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
36 output = p.communicate()[0]
38 sys.stderr.write("Error getting dependencies %s\n" % pkgs)
40 output = output.split("\n")
41 if len(output) != len(pkgs) + 1:
42 sys.stderr.write("Error getting dependencies\n")
45 for i in range(0, len(pkgs)):
47 pkg_deps = output[i].split(" ")
55 # Execute the "make <pkg>-show-depends" command to get the list of
56 # dependencies of a given list of packages, and return the list of
57 # dependencies formatted as a Python dictionary.
58 def get_depends(pkgs):
59 return _get_depends(pkgs, 'show-depends')
62 # Execute the "make <pkg>-show-rdepends" command to get the list of
63 # reverse dependencies of a given list of packages, and return the
64 # list of dependencies formatted as a Python dictionary.
65 def get_rdepends(pkgs):
66 return _get_depends(pkgs, 'show-rdepends')