diff options
author | Yegor Yefremov <yegorslists@googlemail.com> | 2017-03-21 09:22:33 +0100 |
---|---|---|
committer | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2017-03-21 23:11:04 +0100 |
commit | 3b627c89dc8adf8c60efd773935bf66004e8433d (patch) | |
tree | 5b2341b380524bc068108b4f89c2e954f3ea734c /support/scripts/brpkgutil.py | |
parent | 00c21338655e29b10fa6e59d5abe389abaa4271d (diff) | |
download | buildroot-3b627c89dc8adf8c60efd773935bf66004e8433d.tar.gz buildroot-3b627c89dc8adf8c60efd773935bf66004e8433d.zip |
graph-depends: rename pkgutil.py to brpkgutil.py
pkgutil.py is also part of Python itself. Placing pkgutil.py as is
in a folder with other scripts that require original pkgutil will
break them. This is the case with scanpypi. So rename pkgutil.py
to brpkgutil.py to avoid naming collision.
Fixes: https://bugs.busybox.net/show_bug.cgi?id=9766
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support/scripts/brpkgutil.py')
-rw-r--r-- | support/scripts/brpkgutil.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/support/scripts/brpkgutil.py b/support/scripts/brpkgutil.py new file mode 100644 index 0000000000..a0e2352bad --- /dev/null +++ b/support/scripts/brpkgutil.py @@ -0,0 +1,62 @@ +# Copyright (C) 2010-2013 Thomas Petazzoni <thomas.petazzoni@free-electrons.com> + +import sys +import subprocess + +# Execute the "make <pkg>-show-version" command to get the version of a given +# list of packages, and return the version formatted as a Python dictionary. +def get_version(pkgs): + sys.stderr.write("Getting version for %s\n" % pkgs) + cmd = ["make", "-s", "--no-print-directory" ] + for pkg in pkgs: + cmd.append("%s-show-version" % pkg) + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) + output = p.communicate()[0] + if p.returncode != 0: + sys.stderr.write("Error getting version %s\n" % pkgs) + sys.exit(1) + output = output.split("\n") + if len(output) != len(pkgs) + 1: + sys.stderr.write("Error getting version\n") + sys.exit(1) + version = {} + for i in range(0, len(pkgs)): + pkg = pkgs[i] + version[pkg] = output[i] + return version + +def _get_depends(pkgs, rule): + sys.stderr.write("Getting dependencies for %s\n" % pkgs) + cmd = ["make", "-s", "--no-print-directory" ] + for pkg in pkgs: + cmd.append("%s-%s" % (pkg, rule)) + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) + output = p.communicate()[0] + if p.returncode != 0: + sys.stderr.write("Error getting dependencies %s\n" % pkgs) + sys.exit(1) + output = output.split("\n") + if len(output) != len(pkgs) + 1: + sys.stderr.write("Error getting dependencies\n") + sys.exit(1) + deps = {} + for i in range(0, len(pkgs)): + pkg = pkgs[i] + pkg_deps = output[i].split(" ") + if pkg_deps == ['']: + deps[pkg] = [] + else: + deps[pkg] = pkg_deps + return deps + +# Execute the "make <pkg>-show-depends" command to get the list of +# dependencies of a given list of packages, and return the list of +# dependencies formatted as a Python dictionary. +def get_depends(pkgs): + return _get_depends(pkgs, 'show-depends') + +# Execute the "make <pkg>-show-rdepends" command to get the list of +# reverse dependencies of a given list of packages, and return the +# list of dependencies formatted as a Python dictionary. +def get_rdepends(pkgs): + return _get_depends(pkgs, 'show-rdepends') |