From: Thomas De Schampheleire <patrickdepinguin@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 3/3] graph-depends: split off get_rdepends from get_depends
Date: Fri, 3 Feb 2017 21:57:45 +0100 [thread overview]
Message-ID: <20170203205745.14488-5-patrickdepinguin@gmail.com> (raw)
In-Reply-To: <20170203205745.14488-1-patrickdepinguin@gmail.com>
From: Thomas De Schampheleire <thomas.de_schampheleire@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@nokia.com>
---
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
next prev parent reply other threads:[~2017-02-03 20:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 20:57 [Buildroot] [PATCH 0/3] graph-depends: split off some functions to pkgutil.py Thomas De Schampheleire
2017-02-03 20:57 ` [Buildroot] [PATCH 1/3] graph-depends: avoid use of global var 'rule' in get_depends Thomas De Schampheleire
2017-02-05 14:20 ` Thomas Petazzoni
2017-02-05 20:37 ` Thomas De Schampheleire
2017-02-03 20:57 ` [Buildroot] [PATCH 1/1] support/scripts: split off get_version/get_depends into pkgutil.py Thomas De Schampheleire
2017-02-05 13:52 ` Thomas De Schampheleire
2017-02-03 20:57 ` [Buildroot] [PATCH 2/3] graph-depends: " Thomas De Schampheleire
2017-02-05 21:13 ` Yann E. MORIN
2017-02-05 21:27 ` Thomas De Schampheleire
2017-02-05 21:31 ` Yann E. MORIN
2017-02-06 12:49 ` Thomas Petazzoni
2018-11-07 18:07 ` Yann E. MORIN
2018-11-07 19:06 ` Thomas De Schampheleire
2018-11-07 19:39 ` Yann E. MORIN
2018-11-07 20:41 ` Thomas De Schampheleire
2018-11-07 21:06 ` Yann E. MORIN
2018-11-07 21:14 ` Thomas De Schampheleire
2018-11-07 22:26 ` Arnout Vandecappelle
2018-11-07 22:45 ` Yann E. MORIN
2018-11-08 8:01 ` Arnout Vandecappelle
2018-11-11 19:00 ` Yann E. MORIN
2017-02-03 20:57 ` Thomas De Schampheleire [this message]
2017-02-05 21:14 ` [Buildroot] [PATCH 3/3] graph-depends: split off get_rdepends from get_depends Yann E. MORIN
2017-02-06 12:50 ` Thomas Petazzoni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170203205745.14488-5-patrickdepinguin@gmail.com \
--to=patrickdepinguin@gmail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.