From: Yegor Yefremov Date: Tue, 21 Mar 2017 08:22:33 +0000 (+0100) Subject: graph-depends: rename pkgutil.py to brpkgutil.py X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3b627c89dc8adf8c60efd773935bf66004e8433d;p=buildroot.git 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 Signed-off-by: Thomas Petazzoni --- 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 + +import sys +import subprocess + +# Execute the "make -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 -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 -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') diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends index fbd5917053..b258c565b0 100755 --- a/support/scripts/graph-depends +++ b/support/scripts/graph-depends @@ -26,7 +26,7 @@ import subprocess import argparse from fnmatch import fnmatch -import pkgutil +import brpkgutil # Modes of operation: MODE_FULL = 1 # draw full dependency graph for all selected packages @@ -102,13 +102,13 @@ else: transitive = args.transitive if args.direct: - get_depends_func = pkgutil.get_depends + get_depends_func = brpkgutil.get_depends arrow_dir = "forward" else: if mode == MODE_FULL: sys.stderr.write("--reverse needs a package\n") sys.exit(1) - get_depends_func = pkgutil.get_rdepends + get_depends_func = brpkgutil.get_rdepends arrow_dir = "back" # Get the colours: we need exactly three colours, @@ -330,7 +330,7 @@ if check_only: sys.exit(0) dict_deps = remove_extra_deps(dict_deps) -dict_version = pkgutil.get_version([pkg for pkg in allpkgs +dict_version = brpkgutil.get_version([pkg for pkg in allpkgs if pkg != "all" and not pkg.startswith("root")]) # Print the attributes of a node: label and fill-color diff --git a/support/scripts/pkgutil.py b/support/scripts/pkgutil.py deleted file mode 100644 index a0e2352bad..0000000000 --- a/support/scripts/pkgutil.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2010-2013 Thomas Petazzoni - -import sys -import subprocess - -# Execute the "make -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 -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 -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')