[Buildroot] [PATCH 3/3] graph-depends: split off get_rdepends from get_depends
Yann E. MORIN
yann.morin.1998 at free.fr
Sun Feb 5 21:14:34 UTC 2017
Thomas DS, All,
On 2017-02-03 21:57 +0100, Thomas De Schampheleire spake thusly:
> From: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
>
> The use of a 'rule' variable that can contain 'show-depends' or
> 'show-rdepends' is not logical if get_depends is considered as a reusable
> function from various scripts. The name of these rules are too much an
> implementation detail.
>
> Therefore, split the existing get_depends into two separate functions
> get_depends and get_rdepends, while keeping code duplication to a minimum.
>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
Regards,
Yann E. MORIN.
> ---
> support/scripts/graph-depends | 6 +++---
> support/scripts/pkgutil.py | 17 +++++++++++++----
> 2 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
> index 7aedcb5..fbd5917 100755
> --- a/support/scripts/graph-depends
> +++ b/support/scripts/graph-depends
> @@ -102,13 +102,13 @@ else:
> transitive = args.transitive
>
> if args.direct:
> - rule = "show-depends"
> + get_depends_func = pkgutil.get_depends
> arrow_dir = "forward"
> else:
> if mode == MODE_FULL:
> sys.stderr.write("--reverse needs a package\n")
> sys.exit(1)
> - rule = "show-rdepends"
> + get_depends_func = pkgutil.get_rdepends
> arrow_dir = "back"
>
> # Get the colours: we need exactly three colours,
> @@ -157,7 +157,7 @@ def get_all_depends(pkgs):
> if len(filtered_pkgs) == 0:
> return []
>
> - depends = pkgutil.get_depends(filtered_pkgs, rule)
> + depends = get_depends_func(filtered_pkgs)
>
> deps = set()
> for pkg in filtered_pkgs:
> diff --git a/support/scripts/pkgutil.py b/support/scripts/pkgutil.py
> index a911123..cd1bbd5 100644
> --- a/support/scripts/pkgutil.py
> +++ b/support/scripts/pkgutil.py
> @@ -27,10 +27,7 @@ def get_version(pkgs):
> version[pkg] = output[i]
> return version
>
> -# 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, rule):
> +def _get_depends(pkgs, rule):
> sys.stderr.write("Getting dependencies for %s\n" % pkgs)
> cmd = ["make", "-s", "--no-print-directory" ]
> for pkg in pkgs:
> @@ -53,3 +50,15 @@ def get_depends(pkgs, rule):
> 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')
> --
> 2.10.2
>
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
More information about the buildroot
mailing list