1 # Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
6 # Execute the "make <pkg>-show-version" command to get the version of a given
7 # list of packages, and return the version formatted as a Python dictionary.
9 sys
.stderr
.write("Getting version for %s\n" % pkgs
)
10 cmd
= ["make", "-s", "--no-print-directory" ]
12 cmd
.append("%s-show-version" % pkg
)
13 p
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
, universal_newlines
=True)
14 output
= p
.communicate()[0]
16 sys
.stderr
.write("Error getting version %s\n" % pkgs
)
18 output
= output
.split("\n")
19 if len(output
) != len(pkgs
) + 1:
20 sys
.stderr
.write("Error getting version\n")
23 for i
in range(0, len(pkgs
)):
25 version
[pkg
] = output
[i
]
28 def _get_depends(pkgs
, rule
):
29 sys
.stderr
.write("Getting dependencies for %s\n" % pkgs
)
30 cmd
= ["make", "-s", "--no-print-directory" ]
32 cmd
.append("%s-%s" % (pkg
, rule
))
33 p
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
, universal_newlines
=True)
34 output
= p
.communicate()[0]
36 sys
.stderr
.write("Error getting dependencies %s\n" % pkgs
)
38 output
= output
.split("\n")
39 if len(output
) != len(pkgs
) + 1:
40 sys
.stderr
.write("Error getting dependencies\n")
43 for i
in range(0, len(pkgs
)):
45 pkg_deps
= output
[i
].split(" ")
52 # Execute the "make <pkg>-show-depends" command to get the list of
53 # dependencies of a given list of packages, and return the list of
54 # dependencies formatted as a Python dictionary.
55 def get_depends(pkgs
):
56 return _get_depends(pkgs
, 'show-depends')
58 # Execute the "make <pkg>-show-rdepends" command to get the list of
59 # reverse dependencies of a given list of packages, and return the
60 # list of dependencies formatted as a Python dictionary.
61 def get_rdepends(pkgs
):
62 return _get_depends(pkgs
, 'show-rdepends')